[PATCH] D150635: [clangd] Implement end-definition-comment inlay hints

2023-05-24 Thread Qingyuan Zheng via Phabricator via cfe-commits
daiyousei-qz added inline comments.



Comment at: clang-tools-extra/clangd/InlayHints.cpp:578
+constexpr unsigned HintMinLineLimit = 2;
+constexpr unsigned HintMaxLengthLimit = 50;
+

nridge wrote:
> daiyousei-qz wrote:
> > sammccall wrote:
> > > We actually already have a configurable inlay hint length limit.
> > > It has the wrong name (`TypeNameLimit`) , but I think we should use it 
> > > anyway (and maybe try to fix the name later).
> > > 
> > > (I'm not sure making this configurable was a great idea, but given that 
> > > it exists, people will expect it to effectively limit the length of hints)
> > `TypeNameLimit` was introduced to limit the length of "DeducedTypes" only. 
> > I don't think using that number for all hints is a good idea because 
> > different hints appear in different contexts. For deduced type hint, it is 
> > displayed in the middle of the actual code, so it must be concise to not 
> > overwhelm the actual code. However, this hint is usually displayed at the 
> > end of an almost empty line. A much larger number of characters should be 
> > allowed.
> > 
> > (I'm not arguing here, but IMO such options are definitely helpful. Not 
> > everybody would fork llvm-project and build their own version of clangd 
> > binary. Without options to configure length of hints, people would disable 
> > "DeducedTypes" entirely if they cannot tolerate the default length limit, 
> > while this feature is definitely a cool thing to turn on. Personally, I 
> > actually think clangd has too little option compared to say rust-analyzer. 
> > But it's just my understanding)
> > For deduced type hint, it is displayed in the middle of the actual code, so 
> > it must be concise to not overwhelm the actual code. However, this hint is 
> > usually displayed at the end of an almost empty line. A much larger number 
> > of characters should be allowed.
> 
> Another consideration besides the location of the hint that is worth keeping 
> in mind, is what type of content is being printed.
> 
> Type names in C++ are composable in ways that identifiers are not (e.g. 
> `vector, allocator, 
> allocator>` etc.), such that there is a need to limit type 
> hints that doesn't really apply to say, parameter hints.
> 
> So, a question I have here is: can template argument lists appear in an 
> end-definition-comment hint?
> 
> For example, for:
> 
> ```
> template 
> struct S {
>   void foo();
> };
> 
> template 
> void S::foo() {
> }  // <--- HERE
> ```
> 
> is the hint at the indicated location `S::foo()`, or `S::foo()`? In the 
> latter case, we can imagine the hint getting long due to the type parameters, 
> and we may want to consider either limiting its length, or tweaking the code 
> to not print the type parameters.
Yes, currently this hint is only shown if the total length of hint label is 
less than 60 characters. I believe what we display should be exactly what is 
used to define the symbol. In your example,

```
template 
struct S {
  void foo();
};

template 
void S::foo() {
}  // S::foo
```
Basically, "[A]" and "[B]" is the same text (OFC excluding whitespaces).
```
void [A]() {
} // [B]
```
The hint won't be displayed if "[B]" is more than 60 characters.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150635

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


[PATCH] D145739: [-Wunsafe-buffer-usage] Group variables associated by pointer assignments

2023-05-24 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

In D145739#4370674 , @barannikov88 
wrote:

> Hi, just a heads-up, some bots seem to be unhappy with the test:
>
> https://lab.llvm.org/buildbot/#/builders/216/builds/21765
>
>   error: 'note' diagnostics expected but not seen: 
> File 
> Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\SemaCXX\warn-unsafe-buffer-usage-multi-decl-warnings.cpp
>  Line 169: {{^change type of 'q' to 'std::span' to preserve bounds 
> information, and change 'r' and 'p' to 'std::span' to propagate bounds 
> information between them$}}
>   error: 'note' diagnostics seen but not expected: 
> File 
> Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\SemaCXX\warn-unsafe-buffer-usage-multi-decl-warnings.cpp
>  Line 169: change type of 'q' to 'std::span' to preserve bounds information, 
> and change 'p' and 'r' to 'std::span' to propagate bounds information between 
> them
>   2 errors generated.

The test seems to randomly pass and fail on the bot. It seems that the order of 
'p' and 'r' in the output string may not be deterministic? Can you make the 
test more reliable or make it handle each situation (if appropriate)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145739

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


[PATCH] D150848: [clang-format] Respect ColumnLimit 0 lines breaks in inline asm

2023-05-24 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision.
owenpan added inline comments.



Comment at: clang/lib/Format/ContinuationIndenter.cpp:361
+(Style.BreakBeforeInlineASMColon == FormatStyle::BBIAS_OnlyMultiline &&
+ Style.ColumnLimit != 0 {
 return true;

FWIW.



Comment at: clang/unittests/Format/FormatTest.cpp:4622-4655
+  Style.BreakBeforeInlineASMColon = FormatStyle::BBIAS_OnlyMultiline;
+  verifyFormat("asm(\"xyz\" : \"=a\"(a), \"=d\"(b) : \"a\"(data));", Style);
+  EXPECT_EQ("asm(\"xyz\"\n"
+": \"=a\"(a), \"=d\"(b)\n"
+": \"a\"(data));",
+format("asm(\"xyz\"\n"
+   ": \"=a\"(a), \"=d\"(b)\n"

FWIW, it's easier to read IMO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150848

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


[PATCH] D151293: [clang][ExtractAPI] Refactor serializer to the CRTP

2023-05-24 Thread Erick Velez via Phabricator via cfe-commits
evelez7 updated this revision to Diff 525431.
evelez7 marked 8 inline comments as done.
evelez7 added a comment.

Address some review feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151293

Files:
  clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/CMakeLists.txt
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/ExtractAPI/Serialization/SerializerBase.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp

Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -38,14 +38,14 @@
 
 /// Helper function to inject a JSON object \p Obj into another object \p Paren
 /// at position \p Key.
-void serializeObject(Object , StringRef Key, std::optional Obj) {
+void visitObject(Object , StringRef Key, std::optional Obj) {
   if (Obj)
 Paren[Key] = std::move(*Obj);
 }
 
 /// Helper function to inject a JSON array \p Array into object \p Paren at
 /// position \p Key.
-void serializeArray(Object , StringRef Key, std::optional Array) {
+void visitArray(Object , StringRef Key, std::optional Array) {
   if (Array)
 Paren[Key] = std::move(*Array);
 }
@@ -66,7 +66,7 @@
 ///
 /// \returns \c std::nullopt if the version \p V is empty, or an \c Object
 /// containing the semantic version representation of \p V.
-std::optional serializeSemanticVersion(const VersionTuple ) {
+std::optional visitSemanticVersion(const VersionTuple ) {
   if (V.empty())
 return std::nullopt;
 
@@ -81,11 +81,11 @@
 ///
 /// The OS information in Symbol Graph contains the \c name of the OS, and an
 /// optional \c minimumVersion semantic version field.
-Object serializeOperatingSystem(const Triple ) {
+Object visitOperatingSystem(const Triple ) {
   Object OS;
   OS["name"] = T.getOSTypeName(T.getOS());
-  serializeObject(OS, "minimumVersion",
-  serializeSemanticVersion(T.getMinimumSupportedOSVersion()));
+  visitObject(OS, "minimumVersion",
+  visitSemanticVersion(T.getMinimumSupportedOSVersion()));
   return OS;
 }
 
@@ -93,16 +93,16 @@
 ///
 /// The platform object describes a target platform triple in corresponding
 /// three fields: \c architecture, \c vendor, and \c operatingSystem.
-Object serializePlatform(const Triple ) {
+Object visitPlatform(const Triple ) {
   Object Platform;
   Platform["architecture"] = T.getArchName();
   Platform["vendor"] = T.getVendorName();
-  Platform["operatingSystem"] = serializeOperatingSystem(T);
+  Platform["operatingSystem"] = visitOperatingSystem(T);
   return Platform;
 }
 
 /// Serialize a source position.
-Object serializeSourcePosition(const PresumedLoc ) {
+Object visitSourcePosition(const PresumedLoc ) {
   assert(Loc.isValid() && "invalid source position");
 
   Object SourcePosition;
@@ -117,10 +117,10 @@
 /// \param Loc The presumed location to serialize.
 /// \param IncludeFileURI If true, include the file path of \p Loc as a URI.
 /// Defaults to false.
-Object serializeSourceLocation(const PresumedLoc ,
-   bool IncludeFileURI = false) {
+Object visitSourceLocation(const PresumedLoc ,
+   bool IncludeFileURI = false) {
   Object SourceLocation;
-  serializeObject(SourceLocation, "position", serializeSourcePosition(Loc));
+  visitObject(SourceLocation, "position", visitSourcePosition(Loc));
 
   if (IncludeFileURI) {
 std::string FileURI = "file://";
@@ -133,11 +133,11 @@
 }
 
 /// Serialize a source range with begin and end locations.
-Object serializeSourceRange(const PresumedLoc ,
-const PresumedLoc ) {
+Object visitSourceRange(const PresumedLoc ,
+const PresumedLoc ) {
   Object SourceRange;
-  serializeObject(SourceRange, "start", serializeSourcePosition(BeginLoc));
-  serializeObject(SourceRange, "end", serializeSourcePosition(EndLoc));
+  visitObject(SourceRange, "start", visitSourcePosition(BeginLoc));
+  visitObject(SourceRange, "end", visitSourcePosition(EndLoc));
   return SourceRange;
 }
 
@@ -152,8 +152,7 @@
 ///
 /// \returns \c std::nullopt if the symbol has default availability attributes,
 /// or an \c Array containing the formatted availability information.
-std::optional
-serializeAvailability(const AvailabilitySet ) {
+std::optional visitAvailability(const AvailabilitySet ) {
   if (Availabilities.isDefault())
 return std::nullopt;
 
@@ -174,12 +173,12 @@
 if (AvailInfo.Unavailable)
   Availability["isUnconditionallyUnavailable"] = true;
 else {
-  serializeObject(Availability, "introducedVersion",
-  serializeSemanticVersion(AvailInfo.Introduced));
-  

[PATCH] D151393: [CodeGen] Make __clang_call_terminate have an unwind table entry

2023-05-24 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 525429.
smeenai added a comment.

Call SetLLVMFunctionAttributesForDefinition instead


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151393

Files:
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/clang-call-terminate.uwtable.cpp


Index: clang/test/CodeGenCXX/clang-call-terminate.uwtable.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/clang-call-terminate.uwtable.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fexceptions -fcxx-exceptions 
-emit-llvm -o - %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,NOUNWIND %s
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fexceptions -fcxx-exceptions 
-funwind-tables=1 -emit-llvm -o - %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,SYNCUNWIND %s
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fexceptions -fcxx-exceptions 
-funwind-tables=2 -emit-llvm -o - %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,ASYNCUNWIND %s
+
+void caller(void callback()) noexcept { callback(); }
+
+// CHECK: define {{.*}}void @__clang_call_terminate({{[^)]*}}) #[[#ATTRNUM:]]
+// CHECK: attributes #[[#ATTRNUM]] = {
+// NOUNWIND-NOT: uwtable
+// NOUNWIND-SAME: }
+// SYNCUNWIND-SAME: uwtable(sync)
+// ASYNCUNWIND-SAME: uwtable{{ }}
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -4689,6 +4689,7 @@
   cast(fnRef.getCallee()->stripPointerCasts());
   if (fn->empty()) {
 CGM.SetLLVMFunctionAttributes(GlobalDecl(), FI, fn, /*IsThunk=*/false);
+CGM.SetLLVMFunctionAttributesForDefinition(nullptr, fn);
 fn->setDoesNotThrow();
 fn->setDoesNotReturn();
 


Index: clang/test/CodeGenCXX/clang-call-terminate.uwtable.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/clang-call-terminate.uwtable.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fexceptions -fcxx-exceptions -emit-llvm -o - %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,NOUNWIND %s
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fexceptions -fcxx-exceptions -funwind-tables=1 -emit-llvm -o - %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,SYNCUNWIND %s
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fexceptions -fcxx-exceptions -funwind-tables=2 -emit-llvm -o - %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,ASYNCUNWIND %s
+
+void caller(void callback()) noexcept { callback(); }
+
+// CHECK: define {{.*}}void @__clang_call_terminate({{[^)]*}}) #[[#ATTRNUM:]]
+// CHECK: attributes #[[#ATTRNUM]] = {
+// NOUNWIND-NOT: uwtable
+// NOUNWIND-SAME: }
+// SYNCUNWIND-SAME: uwtable(sync)
+// ASYNCUNWIND-SAME: uwtable{{ }}
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -4689,6 +4689,7 @@
   cast(fnRef.getCallee()->stripPointerCasts());
   if (fn->empty()) {
 CGM.SetLLVMFunctionAttributes(GlobalDecl(), FI, fn, /*IsThunk=*/false);
+CGM.SetLLVMFunctionAttributesForDefinition(nullptr, fn);
 fn->setDoesNotThrow();
 fn->setDoesNotReturn();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151325: [analyzer] Differentiate lifetime extended temporaries

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

I generally support the idea of a CXXLifetimeExtendedObj region, definitely 
cleaner than a CXXTempObjectRegion with static lifetime.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151325

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


[PATCH] D151393: [CodeGen] Make __clang_call_terminate have an unwind table entry

2023-05-24 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4698
+if (CodeGenOpts.UnwindTables)
+  fn->setUWTableKind(llvm::UWTableKind(CodeGenOpts.UnwindTables));
+

We probably want to call SetLLVMFunctionAttributesForDefinition() here instead. 
 The end result isn't that much different, but it indicates the intent more 
clearly, and hopefully we avoid hitting similar issues in this code in the 
future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151393

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


[PATCH] D151397: [3/N][RISCV] Model vxrm in C intrinsics for RVV fixed-point instruction vaadd

2023-05-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/include/llvm/IR/IntrinsicsRISCV.td:1365
   defm vaaddu : RISCVSaturatingBinaryAAX;
-  defm vaadd : RISCVSaturatingBinaryAAX;
-  defm vaadd_rm : RISCVSaturatingBinaryAAXRoundingMode;
+  defm vaadd : RISCVSaturatingBinaryAAXRoundingMode;
   defm vasubu : RISCVSaturatingBinaryAAX;

craig.topper wrote:
> Why did the intrinsic change names?
Nevermind. I misread this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151397

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


[PATCH] D150635: [clangd] Implement end-definition-comment inlay hints

2023-05-24 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/InlayHints.cpp:578
+constexpr unsigned HintMinLineLimit = 2;
+constexpr unsigned HintMaxLengthLimit = 50;
+

daiyousei-qz wrote:
> sammccall wrote:
> > We actually already have a configurable inlay hint length limit.
> > It has the wrong name (`TypeNameLimit`) , but I think we should use it 
> > anyway (and maybe try to fix the name later).
> > 
> > (I'm not sure making this configurable was a great idea, but given that it 
> > exists, people will expect it to effectively limit the length of hints)
> `TypeNameLimit` was introduced to limit the length of "DeducedTypes" only. I 
> don't think using that number for all hints is a good idea because different 
> hints appear in different contexts. For deduced type hint, it is displayed in 
> the middle of the actual code, so it must be concise to not overwhelm the 
> actual code. However, this hint is usually displayed at the end of an almost 
> empty line. A much larger number of characters should be allowed.
> 
> (I'm not arguing here, but IMO such options are definitely helpful. Not 
> everybody would fork llvm-project and build their own version of clangd 
> binary. Without options to configure length of hints, people would disable 
> "DeducedTypes" entirely if they cannot tolerate the default length limit, 
> while this feature is definitely a cool thing to turn on. Personally, I 
> actually think clangd has too little option compared to say rust-analyzer. 
> But it's just my understanding)
> For deduced type hint, it is displayed in the middle of the actual code, so 
> it must be concise to not overwhelm the actual code. However, this hint is 
> usually displayed at the end of an almost empty line. A much larger number of 
> characters should be allowed.

Another consideration besides the location of the hint that is worth keeping in 
mind, is what type of content is being printed.

Type names in C++ are composable in ways that identifiers are not (e.g. 
`vector, allocator, 
allocator>` etc.), such that there is a need to limit type 
hints that doesn't really apply to say, parameter hints.

So, a question I have here is: can template argument lists appear in an 
end-definition-comment hint?

For example, for:

```
template 
struct S {
  void foo();
};

template 
void S::foo() {
}  // <--- HERE
```

is the hint at the indicated location `S::foo()`, or `S::foo()`? In the 
latter case, we can imagine the hint getting long due to the type parameters, 
and we may want to consider either limiting its length, or tweaking the code to 
not print the type parameters.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150635

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


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

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

Remove `Interpereter::getParser` + More clean up


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146809

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

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -29,6 +29,7 @@
 #include "gtest/gtest.h"
 
 using namespace clang;
+using namespace caas;
 
 #if defined(_AIX)
 #define CLANG_INTERPRETER_NO_SUPPORT_EXEC
@@ -46,10 +47,11 @@
   DiagnosticConsumer *Client = nullptr) {
   Args ClangArgs = {"-Xclang", "-emit-llvm-only"};
   ClangArgs.insert(ClangArgs.end(), ExtraArgs.begin(), ExtraArgs.end());
-  auto CI = cantFail(clang::IncrementalCompilerBuilder::create(ClangArgs));
+  auto CI =
+  cantFail(clang::caas::IncrementalCompilerBuilder::create(ClangArgs));
   if (Client)
 CI->getDiagnostics().setClient(Client, /*ShouldOwnClient=*/false);
-  return cantFail(clang::Interpreter::create(std::move(CI)));
+  return cantFail(clang::caas::Interpreter::create(std::move(CI)));
 }
 
 static size_t DeclsSize(TranslationUnitDecl *PTUDecl) {
Index: clang/unittests/Interpreter/IncrementalProcessingTest.cpp
===
--- clang/unittests/Interpreter/IncrementalProcessingTest.cpp
+++ clang/unittests/Interpreter/IncrementalProcessingTest.cpp
@@ -27,6 +27,7 @@
 
 using namespace llvm;
 using namespace clang;
+using namespace clang::caas;
 
 namespace {
 
@@ -55,7 +56,7 @@
   auto CI = llvm::cantFail(IncrementalCompilerBuilder::create(ClangArgv));
   auto Interp = llvm::cantFail(Interpreter::create(std::move(CI)));
 
-  std::array PTUs;
+  std::array PTUs;
 
   PTUs[0] = ::cantFail(Interp->Parse(TestProgram1));
   ASSERT_TRUE(PTUs[0]->TheModule);
Index: clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
===
--- clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -30,6 +30,7 @@
 #include "gtest/gtest.h"
 
 using namespace clang;
+using namespace clang::caas;
 
 namespace {
 using Args = std::vector;
@@ -38,10 +39,11 @@
   DiagnosticConsumer *Client = nullptr) {
   Args ClangArgs = {"-Xclang", "-emit-llvm-only"};
   ClangArgs.insert(ClangArgs.end(), ExtraArgs.begin(), ExtraArgs.end());
-  auto CI = cantFail(clang::IncrementalCompilerBuilder::create(ClangArgs));
+  auto CI =
+  cantFail(clang::caas::IncrementalCompilerBuilder::create(ClangArgs));
   if (Client)
 CI->getDiagnostics().setClient(Client, /*ShouldOwnClient=*/false);
-  return cantFail(clang::Interpreter::create(std::move(CI)));
+  return cantFail(clang::caas::Interpreter::create(std::move(CI)));
 }
 
 TEST(InterpreterTest, CatchException) {
Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -92,7 +92,8 @@
 
   // FIXME: Investigate if we could use runToolOnCodeWithArgs from tooling. It
   // can replace the boilerplate code for creation of the compiler instance.
-  auto CI = ExitOnErr(clang::IncrementalCompilerBuilder::create(ClangArgv));
+  auto CI =
+  ExitOnErr(clang::caas::IncrementalCompilerBuilder::create(ClangArgv));
 
   // Set an error handler, so that any LLVM backend diagnostics go through our
   // error handler.
@@ -102,7 +103,7 @@
   // Load any requested plugins.
   CI->LoadRequestedPlugins();
 
-  auto Interp = ExitOnErr(clang::Interpreter::create(std::move(CI)));
+  auto Interp = ExitOnErr(clang::caas::Interpreter::create(std::move(CI)));
   for (const std::string  : OptInputs) {
 if (auto Err = 

[PATCH] D151402: Address some review feedback

2023-05-24 Thread Erick Velez via Phabricator via cfe-commits
evelez7 created this revision.
Herald added a reviewer: ributzka.
Herald added a project: All.
evelez7 requested review of this revision.
Herald added a reviewer: dang.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Delete unnecessary includes, revert SymbolGraphSerializer hidden
namespace function names, move IgnoresList, Options to SGS

Depends on D151293 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151402

Files:
  clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp

Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -14,16 +14,11 @@
 #include "clang/ExtractAPI/Serialization/SymbolGraphSerializer.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Version.h"
-#include "clang/ExtractAPI/API.h"
-#include "clang/ExtractAPI/APIIgnoresList.h"
 #include "clang/ExtractAPI/DeclarationFragments.h"
-#include "clang/ExtractAPI/Serialization/SerializerBase.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
-#include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
-#include "llvm/Support/JSON.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/VersionTuple.h"
 #include 
@@ -38,14 +33,14 @@
 
 /// Helper function to inject a JSON object \p Obj into another object \p Paren
 /// at position \p Key.
-void visitObject(Object , StringRef Key, std::optional Obj) {
+void serializeObject(Object , StringRef Key, std::optional Obj) {
   if (Obj)
 Paren[Key] = std::move(*Obj);
 }
 
 /// Helper function to inject a JSON array \p Array into object \p Paren at
 /// position \p Key.
-void visitArray(Object , StringRef Key, std::optional Array) {
+void serializeArray(Object , StringRef Key, std::optional Array) {
   if (Array)
 Paren[Key] = std::move(*Array);
 }
@@ -66,7 +61,7 @@
 ///
 /// \returns \c std::nullopt if the version \p V is empty, or an \c Object
 /// containing the semantic version representation of \p V.
-std::optional visitSemanticVersion(const VersionTuple ) {
+std::optional serializeSemanticVersion(const VersionTuple ) {
   if (V.empty())
 return std::nullopt;
 
@@ -81,11 +76,11 @@
 ///
 /// The OS information in Symbol Graph contains the \c name of the OS, and an
 /// optional \c minimumVersion semantic version field.
-Object visitOperatingSystem(const Triple ) {
+Object serializeOperatingSystem(const Triple ) {
   Object OS;
   OS["name"] = T.getOSTypeName(T.getOS());
-  visitObject(OS, "minimumVersion",
-  visitSemanticVersion(T.getMinimumSupportedOSVersion()));
+  serializeObject(OS, "minimumVersion",
+  serializeSemanticVersion(T.getMinimumSupportedOSVersion()));
   return OS;
 }
 
@@ -93,16 +88,16 @@
 ///
 /// The platform object describes a target platform triple in corresponding
 /// three fields: \c architecture, \c vendor, and \c operatingSystem.
-Object visitPlatform(const Triple ) {
+Object serializePlatform(const Triple ) {
   Object Platform;
   Platform["architecture"] = T.getArchName();
   Platform["vendor"] = T.getVendorName();
-  Platform["operatingSystem"] = visitOperatingSystem(T);
+  Platform["operatingSystem"] = serializeOperatingSystem(T);
   return Platform;
 }
 
 /// Serialize a source position.
-Object visitSourcePosition(const PresumedLoc ) {
+Object serializeSourcePosition(const PresumedLoc ) {
   assert(Loc.isValid() && "invalid source position");
 
   Object SourcePosition;
@@ -117,10 +112,10 @@
 /// \param Loc The presumed location to serialize.
 /// \param IncludeFileURI If true, include the file path of \p Loc as a URI.
 /// Defaults to false.
-Object visitSourceLocation(const PresumedLoc ,
-   bool IncludeFileURI = false) {
+Object serializeSourceLocation(const PresumedLoc ,
+   bool IncludeFileURI = false) {
   Object SourceLocation;
-  visitObject(SourceLocation, "position", visitSourcePosition(Loc));
+  serializeObject(SourceLocation, "position", serializeSourcePosition(Loc));
 
   if (IncludeFileURI) {
 std::string FileURI = "file://";
@@ -133,11 +128,11 @@
 }
 
 /// Serialize a source range with begin and end locations.
-Object visitSourceRange(const PresumedLoc ,
-const PresumedLoc ) {
+Object serializeSourceRange(const PresumedLoc ,
+const PresumedLoc ) {
   Object SourceRange;
-  visitObject(SourceRange, "start", visitSourcePosition(BeginLoc));
-  visitObject(SourceRange, "end", visitSourcePosition(EndLoc));
+  serializeObject(SourceRange, "start", 

[PATCH] D148489: [clangd] Implement configs to stop clangd produce a certain semantic tokens

2023-05-24 Thread Qingyuan Zheng via Phabricator via cfe-commits
daiyousei-qz added a comment.

Sorry for the inactivity. I have replace the parameter with const ref. By the 
way, I also removed the existing `IncludeInactiveRegionTokens` flag and uses 
this filter instead. Please help review the change. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148489

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


[PATCH] D148489: [clangd] Implement configs to stop clangd produce a certain semantic tokens

2023-05-24 Thread Qingyuan Zheng via Phabricator via cfe-commits
daiyousei-qz updated this revision to Diff 525421.
daiyousei-qz added a comment.

- Address review comment and remove a unnecessary flag


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148489

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "Annotations.h"
+#include "Config.h"
 #include "Protocol.h"
 #include "SemanticHighlighting.h"
 #include "SourceCode.h"
@@ -1260,6 +1261,17 @@
   EXPECT_EQ(Toks[3].deltaStart, 2u);
   EXPECT_EQ(Toks[3].length, 3u);
 }
+
+TEST(SemanticHighlighting, WithHighlightingFilter) {
+  llvm::StringRef AnnotatedCode = R"cpp(
+int *$Variable[[x]] = new int;
+)cpp";
+  Config Cfg;
+  Cfg.SemanticTokens.DisabledKinds = {"Operator"};
+  Cfg.SemanticTokens.DisabledModifiers = {"Declaration", "Definition"};
+  WithContextValue WithCfg(Config::Key, std::move(Cfg));
+  checkHighlightings(AnnotatedCode, {}, ~ScopeModifierMask);
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -246,6 +246,23 @@
   EXPECT_EQ(Results[0].InlayHints.DeducedTypes, std::nullopt);
 }
 
+TEST(ParseYAML, SemanticTokens) {
+  CapturedDiags Diags;
+  Annotations YAML(R"yaml(
+SemanticTokens:
+  DisabledKinds: [ Operator, InactiveCode]
+  DisabledModifiers: Readonly
+  )yaml");
+  auto Results =
+  Fragment::parseYAML(YAML.code(), "config.yaml", Diags.callback());
+  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
+  ASSERT_EQ(Results.size(), 1u);
+  EXPECT_THAT(Results[0].SemanticTokens.DisabledKinds,
+  ElementsAre(val("Operator"), val("InactiveCode")));
+  EXPECT_THAT(Results[0].SemanticTokens.DisabledModifiers,
+  ElementsAre(val("Readonly")));
+}
+
 TEST(ParseYAML, IncludesIgnoreHeader) {
   CapturedDiags Diags;
   Annotations YAML(R"yaml(
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -61,6 +61,8 @@
 };
 
 llvm::raw_ostream <<(llvm::raw_ostream , HighlightingKind K);
+std::optional
+highlightingKindFromString(llvm::StringRef Name);
 
 enum class HighlightingModifier {
   Declaration,
@@ -88,6 +90,8 @@
 static_assert(static_cast(HighlightingModifier::LastModifier) < 32,
   "Increase width of modifiers bitfield!");
 llvm::raw_ostream <<(llvm::raw_ostream , HighlightingModifier K);
+std::optional
+highlightingModifierFromString(llvm::StringRef Name);
 
 // Contains all information needed for the highlighting a token.
 struct HighlightingToken {
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "SemanticHighlighting.h"
+#include "Config.h"
 #include "FindTarget.h"
 #include "HeuristicResolver.h"
 #include "ParsedAST.h"
@@ -354,13 +355,57 @@
   return Winner;
 }
 
+/// Filter to remove particular kinds of highlighting tokens and modifiers from
+/// the output.
+class HighlightingFilter {
+public:
+  HighlightingFilter() {
+for (auto  : ActiveKindLookup)
+  Active = true;
+
+ActiveModifiersMask = ~0;
+  }
+
+  void disableKind(HighlightingKind Kind) {
+ActiveKindLookup[static_cast(Kind)] = false;
+  }
+
+  void disableModifier(HighlightingModifier Modifier) {
+ActiveModifiersMask &= ~(1 << static_cast(Modifier));
+  }
+
+  bool isHighlightKindActive(HighlightingKind Kind) const {
+return ActiveKindLookup[static_cast(Kind)];
+  }
+
+  uint32_t maskModifiers(uint32_t Modifiers) const {
+return Modifiers & ActiveModifiersMask;
+  }
+
+  static HighlightingFilter fromCurrentConfig() {
+const Config  = Config::current();
+HighlightingFilter Filter;
+for (const auto  : C.SemanticTokens.DisabledKinds)
+  if 

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

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



Comment at: clang/lib/Interpreter/Interpreter.cpp:434
+
+llvm::Expected Interpreter::CompileDecl(Decl *D) {
+  assert(D && "The Decl being compiled can't be null");

aaron.ballman wrote:
> Any way to make this take a `const Decl *` instead?
`DeclGroupRef` in line 439 asks a non-const Decl*, should we use `const Decl*` 
and const cast it?



Comment at: clang/lib/Interpreter/Value.cpp:272
+
 void Value::print(llvm::raw_ostream ) const {
   assert(OpaqueType != nullptr && "Can't print default Value");

v.g.vassilev wrote:
> We should add some documentation for users how to write a pretty-printer for 
> a custom class.
> 
> We do not seem to support the multiple inheritance case where one of the base 
> classes has a pretty-printer and the other does not. See the explanation in 
> Cling. It is okay to not have it at the moment but we should include a FIXME 
> here saying that we do not yet support it.
Where should I put the doc? Value.cpp is the implementation and it's unlikely 
for regular users to read it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146809

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


[PATCH] D151397: [3/N][RISCV] Model vxrm in C intrinsics for RVV fixed-point instruction vaadd

2023-05-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:2131
+}
+
 

Extra blank line



Comment at: 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaadd.c:16
 //
-vint8mf8_t test_vaadd_vv_i8mf8(vint8mf8_t op1, vint8mf8_t op2, size_t vl) {
-  return __riscv_vaadd_vv_i8mf8(op1, op2, vl);
+vint8mf8_t test_vaadd_vv_i8mf8(vint8mf8_t op1, vint8mf8_t op2, unsigned int 
vxrm, size_t vl) {
+  return __riscv_vaadd_vv_i8mf8(op1, op2, VXRM_RNU, vl);

The vxrm argument is unused



Comment at: llvm/include/llvm/IR/IntrinsicsRISCV.td:1365
   defm vaaddu : RISCVSaturatingBinaryAAX;
-  defm vaadd : RISCVSaturatingBinaryAAX;
-  defm vaadd_rm : RISCVSaturatingBinaryAAXRoundingMode;
+  defm vaadd : RISCVSaturatingBinaryAAXRoundingMode;
   defm vasubu : RISCVSaturatingBinaryAAX;

Why did the intrinsic change names?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151397

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


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

2023-05-24 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 525420.
junaire marked 15 inline comments as done.
junaire added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146809

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

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -29,6 +29,7 @@
 #include "gtest/gtest.h"
 
 using namespace clang;
+using namespace caas;
 
 #if defined(_AIX)
 #define CLANG_INTERPRETER_NO_SUPPORT_EXEC
@@ -46,10 +47,11 @@
   DiagnosticConsumer *Client = nullptr) {
   Args ClangArgs = {"-Xclang", "-emit-llvm-only"};
   ClangArgs.insert(ClangArgs.end(), ExtraArgs.begin(), ExtraArgs.end());
-  auto CI = cantFail(clang::IncrementalCompilerBuilder::create(ClangArgs));
+  auto CI =
+  cantFail(clang::caas::IncrementalCompilerBuilder::create(ClangArgs));
   if (Client)
 CI->getDiagnostics().setClient(Client, /*ShouldOwnClient=*/false);
-  return cantFail(clang::Interpreter::create(std::move(CI)));
+  return cantFail(clang::caas::Interpreter::create(std::move(CI)));
 }
 
 static size_t DeclsSize(TranslationUnitDecl *PTUDecl) {
Index: clang/unittests/Interpreter/IncrementalProcessingTest.cpp
===
--- clang/unittests/Interpreter/IncrementalProcessingTest.cpp
+++ clang/unittests/Interpreter/IncrementalProcessingTest.cpp
@@ -27,6 +27,7 @@
 
 using namespace llvm;
 using namespace clang;
+using namespace clang::caas;
 
 namespace {
 
@@ -55,7 +56,7 @@
   auto CI = llvm::cantFail(IncrementalCompilerBuilder::create(ClangArgv));
   auto Interp = llvm::cantFail(Interpreter::create(std::move(CI)));
 
-  std::array PTUs;
+  std::array PTUs;
 
   PTUs[0] = ::cantFail(Interp->Parse(TestProgram1));
   ASSERT_TRUE(PTUs[0]->TheModule);
Index: clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
===
--- clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -30,6 +30,7 @@
 #include "gtest/gtest.h"
 
 using namespace clang;
+using namespace clang::caas;
 
 namespace {
 using Args = std::vector;
@@ -38,10 +39,11 @@
   DiagnosticConsumer *Client = nullptr) {
   Args ClangArgs = {"-Xclang", "-emit-llvm-only"};
   ClangArgs.insert(ClangArgs.end(), ExtraArgs.begin(), ExtraArgs.end());
-  auto CI = cantFail(clang::IncrementalCompilerBuilder::create(ClangArgs));
+  auto CI =
+  cantFail(clang::caas::IncrementalCompilerBuilder::create(ClangArgs));
   if (Client)
 CI->getDiagnostics().setClient(Client, /*ShouldOwnClient=*/false);
-  return cantFail(clang::Interpreter::create(std::move(CI)));
+  return cantFail(clang::caas::Interpreter::create(std::move(CI)));
 }
 
 TEST(InterpreterTest, CatchException) {
Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -92,7 +92,8 @@
 
   // FIXME: Investigate if we could use runToolOnCodeWithArgs from tooling. It
   // can replace the boilerplate code for creation of the compiler instance.
-  auto CI = ExitOnErr(clang::IncrementalCompilerBuilder::create(ClangArgv));
+  auto CI =
+  ExitOnErr(clang::caas::IncrementalCompilerBuilder::create(ClangArgv));
 
   // Set an error handler, so that any LLVM backend diagnostics go through our
   // error handler.
@@ -102,7 +103,7 @@
   // Load any requested plugins.
   CI->LoadRequestedPlugins();
 
-  auto Interp = ExitOnErr(clang::Interpreter::create(std::move(CI)));
+  auto Interp = ExitOnErr(clang::caas::Interpreter::create(std::move(CI)));
   for (const std::string  : OptInputs) {
 if (auto Err = 

[PATCH] D145739: [-Wunsafe-buffer-usage] Group variables associated by pointer assignments

2023-05-24 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

Hi, just a heads-up, some bots seem to be unhappy with the test:

https://lab.llvm.org/buildbot/#/builders/216/builds/21765

  error: 'note' diagnostics expected but not seen: 
File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\SemaCXX\warn-unsafe-buffer-usage-multi-decl-warnings.cpp
 Line 169: {{^change type of 'q' to 'std::span' to preserve bounds information, 
and change 'r' and 'p' to 'std::span' to propagate bounds information between 
them$}}
  error: 'note' diagnostics seen but not expected: 
File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\SemaCXX\warn-unsafe-buffer-usage-multi-decl-warnings.cpp
 Line 169: change type of 'q' to 'std::span' to preserve bounds information, 
and change 'p' and 'r' to 'std::span' to propagate bounds information between 
them
  2 errors generated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145739

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


[PATCH] D143675: Discussion: Darwin Sanitizers Stable ABI

2023-05-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.

LGTM.




Comment at: compiler-rt/docs/ASanABI.rst:15
+
+...
+void __asan_load1(uptr p) { __asan_abi_loadn(p, 1, true); }

Delete `...`. Sample content implies that this is a code fragment and does not 
contain everything, so `...` is redundant.



Comment at: compiler-rt/docs/ASanABI.rst:22
+
+The shim library is only used when -fsanitize-stable-abi is specified in the 
Clang driver and the emitted instrumentation favors runtime calls over inline 
expansion.
+

Quote all compiler driver options with double backsticks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143675

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


[PATCH] D127647: [clang][lex] NFCI: Use FileEntryRef in ModuleMap::{load,lookup}ModuleMap()

2023-05-24 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.
Herald added a subscriber: ributzka.

TODO: Try rebasing this on top of D151398 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127647

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


[PATCH] D150635: [clangd] Implement end-definition-comment inlay hints

2023-05-24 Thread Qingyuan Zheng via Phabricator via cfe-commits
daiyousei-qz added a comment.

Addressed review comments except for those we don't have an agreement yet.




Comment at: clang-tools-extra/clangd/InlayHints.cpp:578
+constexpr unsigned HintMinLineLimit = 2;
+constexpr unsigned HintMaxLengthLimit = 50;
+

sammccall wrote:
> We actually already have a configurable inlay hint length limit.
> It has the wrong name (`TypeNameLimit`) , but I think we should use it anyway 
> (and maybe try to fix the name later).
> 
> (I'm not sure making this configurable was a great idea, but given that it 
> exists, people will expect it to effectively limit the length of hints)
`TypeNameLimit` was introduced to limit the length of "DeducedTypes" only. I 
don't think using that number for all hints is a good idea because different 
hints appear in different contexts. For deduced type hint, it is displayed in 
the middle of the actual code, so it must be concise to not overwhelm the 
actual code. However, this hint is usually displayed at the end of an almost 
empty line. A much larger number of characters should be allowed.

(I'm not arguing here, but IMO such options are definitely helpful. Not 
everybody would fork llvm-project and build their own version of clangd binary. 
Without options to configure length of hints, people would disable 
"DeducedTypes" entirely if they cannot tolerate the default length limit, while 
this feature is definitely a cool thing to turn on. Personally, I actually 
think clangd has too little option compared to say rust-analyzer. But it's just 
my understanding)



Comment at: clang-tools-extra/clangd/InlayHints.cpp:597
+auto BlockBeginLine =
+SM.getSpellingLineNumber(BraceRange.getBegin(), );
+if (Invalid)

sammccall wrote:
> this should be getFileLoc(BraceRange.getBegin()), I think?
Thanks for pointing out! As per comments below, calling `getLineNumber` instead 
of `getSpellingLineNumber` in the latest version.



Comment at: clang-tools-extra/clangd/InlayHints.cpp:783
+// Note this range doesn't include the trailing ';' in type definitions.
+// So we have to add SkippedChars to the end character.
+SourceRange R = D.getSourceRange();

sammccall wrote:
> daiyousei-qz wrote:
> > sammccall wrote:
> > > This is too much arithmetic and fiddly coupling between this function and 
> > > shouldHintEndDefinitionComment.
> > > 
> > > Among other things, it allows for confusion between unicode characters 
> > > (UTF-32), clang bytes (UTF-8), and LSP characters (usually UTF-16). And 
> > > we do have a bug here: shouldHintEndDefinition provides SkippedChars in 
> > > clang bytes, but you add it to end.character below which is in LSP 
> > > characters.
> > > 
> > > ---
> > > 
> > > Let's redesign a little... 
> > > 
> > > We have a `}` on some line. We want to compute a sensible part of that 
> > > line to attach to.
> > > A suitable range may not exist, in which case we're going to omit the 
> > > hint.
> > > 
> > > - The line consists of text we don't care about , the `}`, and then some 
> > > mix of whitespace, "trivial" punctuation, and "nontrivial" chars.
> > > - the range should always start at the `}`, since that's what we're 
> > > really hinting
> > > - to get the hint in the right place, the range should end after the 
> > > trivial chars, but before any trailing whitespace
> > > - if there are any nontrivial chars, there's no suitable range
> > > 
> > > so something like:
> > > 
> > > ```
> > > optional findBraceTargetRange(SourceLocation CloseBrace) {
> > >   auto [File, Offset] = SM.getDecomposedLoc(SM.getFileLoc(CloseBrace));
> > >   if (File != MainFileID) return std::nullopt;
> > >   StringRef RestOfLine = 
> > > MainFileBuf.substr(Offset).split('\n').first.rtrim();
> > >   if (!RestOfLine.consume_front("{")) return;
> > >   if (StringRef::npos != Punctuation.find_first_of(" ,;")) return 
> > > std::nullopt;
> > >   return {offsetToPosition(MainFileBuf, Offset), 
> > > offsetToPosition(MainFileBuf, Result.bytes_end() - 
> > > MainFileBuf.bytes_end()};
> > > }
> > > ```
> > > 
> > > and then call from addEndDefinitionComment, the result is LSPRange 
> > > already.
> > Done, also moved min-line and max-length logic to this function. Btw, I 
> > think we should avoid `offsetToPosition` as much as possible. It is a large 
> > overhead considering inlay hints are recomputed throughout the entire file 
> > for each edit. I frequently work with source code that's nearly 1MB large 
> > (Yes, I don't think we should have source file this large, but it is what 
> > it is).
> > also moved min-line and max-length logic to this function
> 
> I'd prefer you to move them back. As specified, that function is otherwise 
> strictly about examining the textual source code around the closing brace. 
> Now it's muddled: it also looks at the opening brace, and does lookups into 
> line tables.
> 
> You seem to be aiming to optimize 

[PATCH] D150635: [clangd] Implement end-definition-comment inlay hints

2023-05-24 Thread Qingyuan Zheng via Phabricator via cfe-commits
daiyousei-qz updated this revision to Diff 525418.
daiyousei-qz marked 9 inline comments as done.
daiyousei-qz added a comment.

- Move computeBlockEndHintRange
- Correct label length limit logic
- Correct line number computation for '{'
- Address other review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150635

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -77,6 +77,7 @@
   C.InlayHints.Parameters = false;
   C.InlayHints.DeducedTypes = false;
   C.InlayHints.Designators = false;
+  C.InlayHints.BlockEnd = false;
   return C;
 }
 
@@ -122,6 +123,15 @@
   assertHints(InlayHintKind::Designator, AnnotatedSource, Expected...);
 }
 
+template 
+void assertBlockEndHints(llvm::StringRef AnnotatedSource,
+ ExpectedHints... Expected) {
+  Config Cfg;
+  Cfg.InlayHints.BlockEnd = true;
+  WithContextValue WithCfg(Config::Key, std::move(Cfg));
+  assertHints(InlayHintKind::BlockEnd, AnnotatedSource, Expected...);
+}
+
 TEST(ParameterHints, Smoke) {
   assertParameterHints(R"cpp(
 void foo(int param);
@@ -1550,6 +1560,194 @@
   ExpectedHint{"a: ", "param1"}, ExpectedHint{"b: ", "param2"},
   ExpectedHint{"c: ", "param3"});
 }
+
+TEST(BlockEndHints, Functions) {
+  assertBlockEndHints(R"cpp(
+int foo() {
+  return 41;
+$foo[[}]]
+
+template 
+int bar() { 
+  // No hint for lambda for now
+  auto f = []() { 
+return X; 
+  };
+  return f(); 
+$bar[[}]]
+
+// No hint because this isn't a definition
+int buz();
+
+struct S{};
+bool operator==(S, S) {
+  return true;
+$opEqual[[}]]
+  )cpp",
+  ExpectedHint{" // foo", "foo"},
+  ExpectedHint{" // bar", "bar"},
+  ExpectedHint{" // operator==", "opEqual"});
+}
+
+TEST(BlockEndHints, Methods) {
+  assertBlockEndHints(R"cpp(
+struct Test {
+  // No hint because there's no function body
+  Test() = default;
+  
+  ~Test() {
+  $dtor[[}]]
+
+  void method1() {
+  $method1[[}]]
+
+  // No hint because this isn't a definition
+  void method2();
+
+  template 
+  void method3() {
+  $method3[[}]]
+
+  // No hint because this isn't a definition
+  template 
+  void method4();
+
+  Test operator+(int) const {
+return *this;
+  $opIdentity[[}]]
+
+  operator bool() const {
+return true;
+  $opBool[[}]]
+
+  // No hint because there's no function body
+  operator int() const = delete;
+} x;
+
+void Test::method2() {
+$method2[[}]]
+
+template 
+void Test::method4() {
+$method4[[}]]
+  )cpp",
+  ExpectedHint{" // ~Test", "dtor"},
+  ExpectedHint{" // method1", "method1"},
+  ExpectedHint{" // method3", "method3"},
+  ExpectedHint{" // operator+", "opIdentity"},
+  ExpectedHint{" // operator bool", "opBool"},
+  ExpectedHint{" // Test::method2", "method2"},
+  ExpectedHint{" // Test::method4", "method4"});
+}
+
+TEST(BlockEndHints, Namespaces) {
+  assertBlockEndHints(
+  R"cpp(
+namespace {
+  void foo();
+$anon[[}]]
+
+namespace ns {
+  void bar();
+$ns[[}]]
+  )cpp",
+  ExpectedHint{" // namespace", "anon"},
+  ExpectedHint{" // namespace ns", "ns"});
+}
+
+TEST(BlockEndHints, Types) {
+  assertBlockEndHints(
+  R"cpp(
+struct S {
+$S[[};]]
+
+class C {
+$C[[};]]
+
+union U {
+$U[[};]]
+
+enum E1 {
+$E1[[};]]
+
+enum class E2 {
+$E2[[};]]
+  )cpp",
+  ExpectedHint{" // struct S", "S"}, ExpectedHint{" // class C", "C"},
+  ExpectedHint{" // union U", "U"}, ExpectedHint{" // enum E1", "E1"},
+  ExpectedHint{" // enum class E2", "E2"});
+}
+
+TEST(BlockEndHints, TrailingSemicolon) {
+  assertBlockEndHints(R"cpp(
+// The hint is placed after the trailing ';'
+struct S1 {
+$S1[[}  ;]]   
+
+// The hint is always placed in the same line with the closing '}'.
+// So in this case where ';' is missing, it is attached to '}'.
+struct S2 {
+$S2[[}]]
+
+;
+
+// No hint because only one trailing ';' is allowed
+struct S3 {
+};;
+
+// No hint because trailing ';' is only allowed for 

[PATCH] D151194: [clang][dataflow] Add support for return values of reference type.

2023-05-24 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added inline comments.



Comment at: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h:196
+  void popCall(const CallExpr *Call, const Environment );
+  void popCall(const CXXConstructExpr *Call, const Environment );
 

I know that Obj-C is a non-goal, but it might worth a comment to support 
`ObjCMessageExpr` just in case someone wants to work on this. 

Btw, this is one of my biggest pet peeves about the Clang AST. We should have a 
common abstraction for all the callables, instead of having to bifurcate many 
of the APIs. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151194

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


[PATCH] D151201: [clang][dataflow] Fix a crash in `getLogicOperatorSubExprValue()`.

2023-05-24 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp:5064
+bool target() {
+  return true || false || false || false;
+}

Should we also test that the value of the expression is `true` in the analysis 
state?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151201

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


[PATCH] D151183: [clang][dataflow] Add a `ControlFlowContext::build()` overload taking a `FunctionDecl`.

2023-05-24 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added inline comments.
This revision is now accepted and ready to land.
Herald added a subscriber: rnkovacs.



Comment at: clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h:39
+
   /// Builds a ControlFlowContext from an AST node. `D` is the function in 
which
   /// `S` resides. `D.isTemplated()` must be false.

I was wondering if there is a plan to make the framework work for 
non-functions, like global initializers. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151183

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


[PATCH] D151397: [3/N][RISCV] Model vxrm in C intrinsics for RVV fixed-point instruction vaadd

2023-05-24 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 525413.
eopXD added a comment.

Bump CI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151397

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vaadd.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/vaadd.ll

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


[PATCH] D151398: [clang] Make `FileEntryRef::getDir()` return the as-requested `DirectoryEntryRef`

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

For redirected file entries, `FileEntryRef::getDir()` returns the parent 
directory entry of the target file entry. This differs from 
`FileEntry::getDir()` that always returns the parent directory that was last 
used to look up that file.

After switching from `FileEntry` to `FileEntryRef` for umbrella headers in 
D142113 , this discrepancy became observable 
and caused Clang to emit incorrect diagnostics.

This patch changes Clang so that it always associates `FileEntryRef` with the 
parent directory that was used to look it up. This brings its behavior closer 
to `FileEntry`, but without the hacky mutation.

This also ensures that 
`llvm::sys::path::parent_path(FileRef->getNameAsRequested()) == 
FileRef->getDir()->getName()`. Previously, `FileRef->getDir()` would fall 
underneath the redirecting VFS into the world of on-disk paths.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151398

Files:
  clang/include/clang/Basic/FileEntry.h
  clang/lib/Basic/FileManager.cpp
  clang/test/Modules/vfs-umbrella-same-dir.m
  clang/unittests/Basic/FileEntryTest.cpp
  clang/unittests/Basic/FileManagerTest.cpp

Index: clang/unittests/Basic/FileManagerTest.cpp
===
--- clang/unittests/Basic/FileManagerTest.cpp
+++ clang/unittests/Basic/FileManagerTest.cpp
@@ -310,6 +310,26 @@
   EXPECT_EQ(>getFileEntry(), >getFileEntry());
 }
 
+TEST_F(FileManagerTest, getFileRefReturnsCorrectDirNameForDifferentStatPath) {
+  // Inject files with the same inode into distinct directories (name & inode).
+  auto StatCache = std::make_unique();
+  StatCache->InjectDirectory("dir1", 40);
+  StatCache->InjectDirectory("dir2", 41);
+  StatCache->InjectFile("dir1/f.cpp", 42);
+  StatCache->InjectFile("dir2/f.cpp", 42, "dir1/f.cpp");
+
+  manager.setStatCache(std::move(StatCache));
+  auto Dir1F = manager.getFileRef("dir1/f.cpp");
+  auto Dir2F = manager.getFileRef("dir2/f.cpp");
+
+  ASSERT_FALSE(!Dir1F);
+  ASSERT_FALSE(!Dir2F);
+  EXPECT_EQ("dir1", Dir1F->getDir().getName());
+  EXPECT_EQ("dir2", Dir2F->getDir().getName());
+  EXPECT_EQ("dir1/f.cpp", Dir1F->getNameAsRequested());
+  EXPECT_EQ("dir2/f.cpp", Dir2F->getNameAsRequested());
+}
+
 // getFile() returns the same FileEntry for virtual files that have
 // corresponding real files that are aliases.
 TEST_F(FileManagerTest, getFileReturnsSameFileEntryForAliasedVirtualFiles) {
Index: clang/unittests/Basic/FileEntryTest.cpp
===
--- clang/unittests/Basic/FileEntryTest.cpp
+++ clang/unittests/Basic/FileEntryTest.cpp
@@ -9,6 +9,7 @@
 #include "clang/Basic/FileEntry.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/Support/Path.h"
 #include "gtest/gtest.h"
 
 using namespace llvm;
@@ -51,11 +52,14 @@
  .first);
   }
   FileEntryRef addFileRedirect(StringRef Name, FileEntryRef Base) {
+auto Dir = addDirectory(llvm::sys::path::parent_path(Name));
+
 return FileEntryRef(
 *Files
  .insert({Name, FileEntryRef::MapValue(
 const_cast(
-Base.getMapEntry()))})
+Base.getMapEntry()),
+Dir)})
  .first);
   }
 };
Index: clang/test/Modules/vfs-umbrella-same-dir.m
===
--- /dev/null
+++ clang/test/Modules/vfs-umbrella-same-dir.m
@@ -0,0 +1,53 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+//--- sources/FW/Private.h
+#include 
+//--- sources/FW/PrivateUnmapped.h
+#include 
+//--- sources/FW/Public.h
+#include 
+//--- frameworks/FW.framework/Headers/PublicPresent.h
+// empty
+//--- frameworks/FW.framework/Modules/module.modulemap
+framework module FW { umbrella header "Public.h" }
+//--- frameworks/FW.framework/Modules/module.private.modulemap
+framework module FW_Private { umbrella header "Private.h" }
+//--- vfs.json.in
+{
+  "case-sensitive": "false",
+  "version": 0,
+  "roots": [
+{
+  "contents": [
+{
+  "external-contents": "DIR/sources/FW/Public.h",
+  "name": "Public.h",
+  "type": "file"
+}
+  ],
+  "name": "DIR/frameworks/FW.framework/Headers",
+  "type": "directory"
+},
+{
+  "contents": [
+{
+  "external-contents": "DIR/sources/FW/Private.h",
+  "name": "Private.h",
+  "type": "file"
+}
+  ],
+  "name": "DIR/frameworks/FW.framework/PrivateHeaders",
+  "type": "directory"
+}
+  ]
+}
+
+//--- tu.m
+#import 
+// expected-no-diagnostics

[PATCH] D151281: [NFC][CLANG] Fix issue with dereference null return value found by Coverity

2023-05-24 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGad571e0d84b3: [NFC][CLANG] Fix issue with dereference null 
return value found by Coverity (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151281

Files:
  clang/lib/Sema/SemaDeclCXX.cpp


Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -7517,7 +7517,7 @@
 }
   }
 
-  const FunctionProtoType *Type = MD->getType()->getAs();
+  const FunctionProtoType *Type = MD->getType()->castAs();
 
   bool CanHaveConstParam = false;
   if (CSM == CXXCopyConstructor)


Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -7517,7 +7517,7 @@
 }
   }
 
-  const FunctionProtoType *Type = MD->getType()->getAs();
+  const FunctionProtoType *Type = MD->getType()->castAs();
 
   bool CanHaveConstParam = false;
   if (CSM == CXXCopyConstructor)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ad571e0 - [NFC][CLANG] Fix issue with dereference null return value found by Coverity

2023-05-24 Thread via cfe-commits

Author: Manna, Soumi
Date: 2023-05-24T19:17:03-07:00
New Revision: ad571e0d84b30f73fa36d6694c66d5b0fb896f97

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

LOG: [NFC][CLANG] Fix issue with dereference null return value found by Coverity

Reported by Static Analyzer Tool, Coverity:

Inside "SemaDeclCXX.cpp" file, in 
clang::Sema::CheckExplicitlyDefaultedSpecialMember(clang::CXXMethodDecl *, 
clang::Sema::CXXSpecialMember, clang::SourceLocation): Return value of function 
which returns null is dereferenced without checking.

  //returned_null: getAs returns nullptr (checked 117 out of 143 times).
  // var_assigned: Assigning: Type = nullptr return value from getAs.
  const FunctionProtoType *Type = MD->getType()->getAs();

  //Dereference null return value (NULL_RETURNS)
  //dereference: Dereferencing a pointer that might be nullptr Type when 
calling getReturnType.
  ReturnType = Type->getReturnType();

  //Dereference null return value (NULL_RETURNS)
  //dereference: Dereferencing a pointer that might be nullptr Type when 
calling getParamType.
  QualType ArgType = ExpectedParams ? Type->getParamType(0) : QualType();

This patch uses castAs instead of getAs which will assert if the type doesn't 
match.

Reviewed By: erichkeane

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

Added: 


Modified: 
clang/lib/Sema/SemaDeclCXX.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index cbe4229b05d0..65122c04c4b3 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -7517,7 +7517,7 @@ bool 
Sema::CheckExplicitlyDefaultedSpecialMember(CXXMethodDecl *MD,
 }
   }
 
-  const FunctionProtoType *Type = MD->getType()->getAs();
+  const FunctionProtoType *Type = MD->getType()->castAs();
 
   bool CanHaveConstParam = false;
   if (CSM == CXXCopyConstructor)



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


[PATCH] D151397: [3/N][RISCV] Model vxrm in C intrinsics for RVV fixed-point instruction vaadd

2023-05-24 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
hiraditya, arichardson.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead, MaskRay.
Herald added projects: clang, LLVM.

This commit consists of change in both clang front-end and RISC-
back-end.

In the front-end, this commit adds an additional operand to the C
intrinsics of `vaadd` that models the control of the rounding mode.

In the back-end, this commit replaces the existing `int.riscv.vaadd.*`
with `int.riscv.vaadd.rm.*` that was introduced in the previous patch
with the extra operand that models the control of the rounding mode
(`vxrm`) for RVV fixed-point intrinsics.

Note: The first 3 commit of the patch-set shows the intent to model the
rounding mode for fixed-point intrinsics by applying change to `vaadd`.
The proceeding patch will apply the change to the rest of the other
fixed-point instructions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151397

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vaadd.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/vaadd.ll

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


[PATCH] D151393: [CodeGen] Make __clang_call_terminate have an unwind table entry

2023-05-24 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
smeenai added reviewers: efriedma, jyknight, rnk, MaskRay.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
smeenai requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This enables debuggers to step past that frame on architectures that
don't use DWARF unwinding (such as armv7) even without debug info. The
problem should theoretically be architecture-agnostic, but according to
https://discourse.llvm.org/t/51633/2 it gets masked on architectures
that use DWARF unwind info.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151393

Files:
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/clang-call-terminate.uwtable.cpp


Index: clang/test/CodeGenCXX/clang-call-terminate.uwtable.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/clang-call-terminate.uwtable.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fexceptions -fcxx-exceptions 
-emit-llvm -o - %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,NOUNWIND %s
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fexceptions -fcxx-exceptions 
-funwind-tables=1 -emit-llvm -o - %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,SYNCUNWIND %s
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fexceptions -fcxx-exceptions 
-funwind-tables=2 -emit-llvm -o - %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,ASYNCUNWIND %s
+
+void caller(void callback()) noexcept { callback(); }
+
+// CHECK: define {{.*}}void @__clang_call_terminate({{[^)]*}}) #[[#ATTRNUM:]]
+// CHECK: attributes #[[#ATTRNUM]] = {
+// NOUNWIND-NOT: uwtable
+// NOUNWIND-SAME: }
+// SYNCUNWIND-SAME: uwtable(sync)
+// ASYNCUNWIND-SAME: uwtable{{ }}
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -4692,6 +4692,11 @@
 fn->setDoesNotThrow();
 fn->setDoesNotReturn();
 
+// Ensure stack traces can progress past this frame (e.g. for debuggers).
+const CodeGenOptions  = CGM.getCodeGenOpts();
+if (CodeGenOpts.UnwindTables)
+  fn->setUWTableKind(llvm::UWTableKind(CodeGenOpts.UnwindTables));
+
 // What we really want is to massively penalize inlining without
 // forbidding it completely.  The difference between that and
 // 'noinline' is negligible.


Index: clang/test/CodeGenCXX/clang-call-terminate.uwtable.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/clang-call-terminate.uwtable.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fexceptions -fcxx-exceptions -emit-llvm -o - %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,NOUNWIND %s
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fexceptions -fcxx-exceptions -funwind-tables=1 -emit-llvm -o - %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,SYNCUNWIND %s
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fexceptions -fcxx-exceptions -funwind-tables=2 -emit-llvm -o - %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,ASYNCUNWIND %s
+
+void caller(void callback()) noexcept { callback(); }
+
+// CHECK: define {{.*}}void @__clang_call_terminate({{[^)]*}}) #[[#ATTRNUM:]]
+// CHECK: attributes #[[#ATTRNUM]] = {
+// NOUNWIND-NOT: uwtable
+// NOUNWIND-SAME: }
+// SYNCUNWIND-SAME: uwtable(sync)
+// ASYNCUNWIND-SAME: uwtable{{ }}
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -4692,6 +4692,11 @@
 fn->setDoesNotThrow();
 fn->setDoesNotReturn();
 
+// Ensure stack traces can progress past this frame (e.g. for debuggers).
+const CodeGenOptions  = CGM.getCodeGenOpts();
+if (CodeGenOpts.UnwindTables)
+  fn->setUWTableKind(llvm::UWTableKind(CodeGenOpts.UnwindTables));
+
 // What we really want is to massively penalize inlining without
 // forbidding it completely.  The difference between that and
 // 'noinline' is negligible.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139267: Supporting tbaa.struct metadata generation for bitfields

2023-05-24 Thread Timo Stripf via Phabricator via cfe-commits
strimo378 updated this revision to Diff 525387.
strimo378 added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

- Updated a test case
- Supporting correct output for -new-struct-path-tbaa
- Added a paragraph to LangRef.rst (see 
https://discourse.llvm.org/t/rfc-clearify-tbaa-struct-requirements-within-language-reference/70835
 )


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

https://reviews.llvm.org/D139267

Files:
  clang/lib/CodeGen/CodeGenTBAA.cpp
  clang/lib/CodeGen/CodeGenTBAA.h
  clang/test/CodeGen/tbaa-struct.cpp
  llvm/docs/LangRef.rst

Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -6406,6 +6406,11 @@
 4 byte gap between the two fields. This gap represents padding which
 does not carry useful data and need not be preserved.
 
+The order of the fields is unspecified. The byte range
+[offset, offset + size) of two fields must not overlap. The size
+of one field might be greater than the size of its TBAA tag (e.g. in
+case of arrays) or might be smaller (e.g. in case of bitfields).
+
 '``noalias``' and '``alias.scope``' Metadata
 
 
Index: clang/test/CodeGen/tbaa-struct.cpp
===
--- clang/test/CodeGen/tbaa-struct.cpp
+++ clang/test/CodeGen/tbaa-struct.cpp
@@ -102,6 +102,32 @@
   *a1 = *a2;
 }
 
+struct E {
+  int : 8;
+  int a1 : 8;
+  int : 8;
+  int a2 : 8;
+  
+  int b1 : 9;
+  int : (32-9-9);
+  int b2 : 9;
+
+  int c1 : 15;
+  int c2 : 1;
+  int c3 : 1;
+  int : (32-15-1-1);
+  
+  char dummy[4];
+};
+
+void copy8(E *e1, E *e2) {
+// CHECK-LABEL: _Z5copy8P1ES0_
+// CHECK: call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %{{.*}}, ptr noundef nonnull align 4 dereferenceable(16) %{{.*}}, i64 16, i1 false)
+// CHECK-OLD-SAME: !tbaa.struct [[TS6:!.*]]
+// CHECK-NEW-SAME: !tbaa [[TAG_E:![0-9]*]]
+  *e1 = *e2;
+}
+
 // CHECK-OLD: [[TS]] = !{i64 0, i64 2, !{{.*}}, i64 4, i64 4, !{{.*}}, i64 8, i64 1, !{{.*}}, i64 12, i64 4, !{{.*}}}
 // CHECK-OLD: [[CHAR:!.*]] = !{!"omnipotent char", !{{.*}}}
 // CHECK-OLD: [[TAG_INT:!.*]] = !{[[INT:!.*]], [[INT]], i64 0}
@@ -113,6 +139,7 @@
 // CHECK-OLD: [[TS3]] = !{i64 0, i64 8, !{{.*}}, i64 0, i64 2, !{{.*}}, i64 4, i64 8, !{{.*}}}
 // CHECK-OLD: [[TS4]] = !{i64 0, i64 1, [[TAG_CHAR]], i64 1, i64 1, [[TAG_CHAR]], i64 2, i64 1, [[TAG_CHAR]]}
 // CHECK-OLD: [[TS5]] = !{i64 0, i64 1, [[TAG_CHAR]], i64 4, i64 1, [[TAG_CHAR]], i64 5, i64 1, [[TAG_CHAR]]}
+// CHECK-OLD: [[TS6]] = !{i64 1, i64 1, [[TAG_INT]], i64 3, i64 1, [[TAG_INT]], i64 4, i64 2, [[TAG_INT]], i64 6, i64 2, [[TAG_INT]], i64 8, i64 2, [[TAG_INT]], i64 10, i64 1, [[TAG_INT]], i64 12, i64 4, [[TAG_CHAR]]}
 
 // CHECK-NEW-DAG: [[TYPE_char:!.*]] = !{{{.*}}, i64 1, !"omnipotent char"}
 // CHECK-NEW-DAG: [[TAG_char]] = !{[[TYPE_char]], [[TYPE_char]], i64 0, i64 0}
@@ -127,3 +154,5 @@
 // CHECK-NEW-DAG: [[TAG_C]] = !{[[TYPE_C]], [[TYPE_C]], i64 0, i64 3}
 // CHECK-NEW-DAG: [[TYPE_D:!.*]] = !{[[TYPE_char]], i64 6, !"_ZTS1D", [[TYPE_char]], i64 0, i64 1, [[TYPE_char]], i64 4, i64 1, [[TYPE_char]], i64 5, i64 1}
 // CHECK-NEW-DAG: [[TAG_D]] = !{[[TYPE_D]], [[TYPE_D]], i64 0, i64 6}
+// CHECK-NEW-DAG: [[TYPE_E:!.*]] = !{[[TYPE_char]], i64 16, !"_ZTS1E", [[TYPE_int]], i64 1, i64 1, [[TYPE_int]], i64 3, i64 1, [[TYPE_int]], i64 4, i64 2, [[TYPE_int]], i64 6, i64 2, [[TYPE_int]], i64 8, i64 2, [[TYPE_int]], i64 9, i64 1, [[TYPE_int]], i64 10, i64 1, [[TYPE_char]], i64 12, i64 4}
+// CHECK-NEW-DAG: [[TAG_E]] = !{[[TYPE_E]], [[TYPE_E]], i64 0, i64 16}
Index: clang/lib/CodeGen/CodeGenTBAA.h
===
--- clang/lib/CodeGen/CodeGenTBAA.h
+++ clang/lib/CodeGen/CodeGenTBAA.h
@@ -146,6 +146,12 @@
   /// considered to be equivalent to it.
   llvm::MDNode *getChar();
 
+  /// AddCollectedField - Add one collected field to Fields vector
+  void
+  AddCollectedField(SmallVectorImpl ,
+uint64_t Offset, uint64_t Size, QualType QTy, bool MayAlias,
+bool FuseOverlapping);
+
   /// CollectFields - Collect information about the fields of a type for
   /// !tbaa.struct metadata formation. Return false for an unsupported type.
   bool CollectFields(uint64_t BaseOffset,
Index: clang/lib/CodeGen/CodeGenTBAA.cpp
===
--- clang/lib/CodeGen/CodeGenTBAA.cpp
+++ clang/lib/CodeGen/CodeGenTBAA.cpp
@@ -272,13 +272,44 @@
 Size);
 }
 
+void CodeGenTBAA::AddCollectedField(
+SmallVectorImpl , uint64_t Offset,
+uint64_t Size, QualType QTy, bool MayAlias, bool FuseOverlapping) {
+
+  // Fuse fields that overlap in their byte position (e.g. caused by bitfields)
+  if (FuseOverlapping && !Fields.empty() && Fields.back().Offset <= Offset &&
+  Offset < 

[PATCH] D151280: [NFC][CLANG] Fix static code analyzer concerns

2023-05-24 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 525388.
Manna added a comment.

Thank you @erichkeane for reviews! I have updated assert message.


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

https://reviews.llvm.org/D151280

Files:
  clang/lib/CodeGen/CGExprConstant.cpp


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1340,6 +1340,7 @@
 std::string Str;
 CGM.getContext().getObjCEncodingForType(E->getEncodedType(), Str);
 const ConstantArrayType *CAT = CGM.getContext().getAsConstantArrayType(T);
+assert(CAT && "String data not of constant array type!");
 
 // Resize the string to the right size, adding zeros at the end, or
 // truncating as needed.


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1340,6 +1340,7 @@
 std::string Str;
 CGM.getContext().getObjCEncodingForType(E->getEncodedType(), Str);
 const ConstantArrayType *CAT = CGM.getContext().getAsConstantArrayType(T);
+assert(CAT && "String data not of constant array type!");
 
 // Resize the string to the right size, adding zeros at the end, or
 // truncating as needed.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76096: [clang] allow const structs to be constant expressions in initializer lists

2023-05-24 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> It makes sense to me that const int foo[] = [ ...massive list...]; would take 
> long to validate the entire initializer as all constant expressions

The expensive part we're currently avoiding by bailing out of the constant 
evaluator (the code D76169  removes) is 
actually constructing an APValue; constructing APValues for large arrays and 
structs is disproportionately expensive compared to just walking the 
corresponding AST.




Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1013
+  if (V->hasInit())
+return Visit(V->getInit(), V->getType());
+return nullptr;

nickdesaulniers wrote:
> efriedma wrote:
> > rsmith wrote:
> > > efriedma wrote:
> > > > rsmith wrote:
> > > > > nickdesaulniers wrote:
> > > > > > efriedma wrote:
> > > > > > > You need to be more careful here; we can call ConstExprEmitter 
> > > > > > > for arbitrary expressions.
> > > > > > "Be more careful" how?
> > > > > Here are some specific cases in which you need to be more careful 
> > > > > because the code as-is would do the wrong thing:
> > > > > 
> > > > >  * when emitting a global's initializer in C++, where the value of 
> > > > > the object denoted by the DeclRefExpr could have changed between its 
> > > > > initialization and the expression we're currently emitting 
> > > > >  * when emitting anything other than a global initializer in C, where 
> > > > > the value of a global could have changed after its emission
> > > > >  * when emitting a reference to a non-global declaration in C (local 
> > > > > variables might change between initialization and use)
> > > > > 
> > > > > We would need to restrict this to the cases where the variable's 
> > > > > value cannot possibly have changed between initialization and use.
> > > > > 
> > > > > In C, that's (mostly) the case for a static storage variable 
> > > > > referenced from the initializer of a static storage variable, for a 
> > > > > thread storage variable referenced from the initializer of a static 
> > > > > storage variable, or for a thread storage variable referenced from 
> > > > > the initializer of a thread storage variable. Even then, this isn't 
> > > > > strictly correct in the presence of DSOs, but I think it should be 
> > > > > correct if the two variables are defined in the same translation unit.
> > > > > 
> > > > > In C++, that's (mostly) the case when the variable is `const` or 
> > > > > `constexpr` and has no mutable subobjects. (There's still the case 
> > > > > where the reference happens outside the lifetime of the object -- for 
> > > > > the most part we can handwave that away by saying it must be UB, but 
> > > > > that's not true in general in the period of construction and period 
> > > > > of destruction.)
> > > > > 
> > > > > In both cases, the optimization is (arguably) still wrong if there 
> > > > > are any volatile subobjects.
> > > > And this is why I don't want to duplicate the logic. :)
> > > > 
> > > > I'd rather not make different assumptions for C and C++; instead, I'd 
> > > > prefer to just use the intersection that's safe in both.  I'm concerned 
> > > > that we could come up with weird results for mixed C and C++ code, 
> > > > otherwise.  Also, it's easier to define the C++ rules because we can 
> > > > base them on the constexpr rules in the standard.
> > > I agree we probably want the same outcome as D76169 provides, if either 
> > > the performance is acceptable or we can find a way to avoid the 
> > > performance cost for the cases we already accept. Perhaps we could get 
> > > that outcome by ensuring that we try the CGExprConstant fast-path (at 
> > > least in C compilations, maybe in general) before we consider the 
> > > complete-but-slow evaluation strategy in ExprConstant?
> > I like the idea of guarding constant evaluation with a "fast path" that 
> > doesn't actually compute the APValues in simple cases.  We can just 
> > implement the simple stuff, and fall back to the full logic for complicated 
> > stuff.
> > 
> > My one concern is that we could go to a bunch of effort to emit a variable 
> > on the fast path, then fall off the fast path later because "return a[0];" 
> > tries to constant-fold a big array "a".
> > the CGExprConstant fast-path
> 
> Sorry, what is "the CGExprConstant fast-path"?
The "fast-path" would be the existing code in ConstExprEmitter.   The idea is 
to make the constant evaluator the primary source of truth in both C and C++, 
along the lines of D76169, but keep some code around in CGExprConstant to go 
directly from the AST to LLVM IR in cases where we don't really need the full 
power of the constant evaluator.

So take the following steps:
- Change 
ConstantEmitter::tryEmitPrivate/ConstantEmitter::tryEmitPrivateForVarInit to 
try ConstExprEmitter first, instead of falling back to ConstExprEmitter.
- Fix any bugs that come out of that.
- Change the constant evaluator to handle 

[PATCH] D151235: [Clang] Switch from TransformExpr to TransformInitializer in places we need to revert initializer to it syntactic form for Sema

2023-05-24 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik marked 2 inline comments as done.
shafik added inline comments.



Comment at: clang/test/CodeGenCXX/gh62818.cpp:1
+// RUN: %clang_cc1 -no-opaque-pointers -std=c++17 -emit-llvm -triple 
x86_64-linux-gnu -o - %s | FileCheck %s
+

Fznamznon wrote:
> Why no opaque pointers? AFAIK since LLVM 17 typed pointers are not supported.
I had copied it from another test and missed that aspect. It seems like a bunch 
of tests in that dir use this argument.


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

https://reviews.llvm.org/D151235

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


[PATCH] D151235: [Clang] Switch from TransformExpr to TransformInitializer in places we need to revert initializer to it syntactic form for Sema

2023-05-24 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik updated this revision to Diff 525385.
shafik added a comment.

- Update test


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

https://reviews.llvm.org/D151235

Files:
  clang/lib/Sema/TreeTransform.h
  clang/test/Analysis/missing-bind-temporary.cpp
  clang/test/CodeGenCXX/gh62818.cpp

Index: clang/test/CodeGenCXX/gh62818.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/gh62818.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++17 -emit-llvm -triple x86_64-linux-gnu -o - %s | FileCheck %s
+
+void doSomething();
+
+struct A {
+  A() {};
+  ~A() noexcept {
+doSomething();
+  }
+
+  A & operator=(A a) & noexcept {
+return *this;
+  }
+};
+
+template
+struct B {
+  void test() {a = {};}
+  // CHECK: define linkonce_odr void @_ZN1BIiE4testEv
+  // CHECK: call void @_ZN1AC1Ev(ptr noundef nonnull align 1 dereferenceable(1)
+  // CHECK: [[CALL:%.*]] = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNR1AaSES_
+  // CHECK: call void @_ZN1AD2Ev(ptr noundef nonnull align 1 dereferenceable(1)
+
+  A a;
+};
+
+void client(B ) {f.test();}
Index: clang/test/Analysis/missing-bind-temporary.cpp
===
--- clang/test/Analysis/missing-bind-temporary.cpp
+++ clang/test/Analysis/missing-bind-temporary.cpp
@@ -7,8 +7,6 @@
 int global;
 
 namespace variant_0 {
-// This variant of the code works correctly. Function foo() is not a template
-// function. Note that there are two destructors within foo().
 
 class A {
 public:
@@ -46,9 +44,6 @@
 } // end namespace variant_0
 
 namespace variant_1 {
-// Suddenly, if we turn foo() into a template, we are missing a
-// CXXBindTemporaryExpr in the AST, and therefore we're missing a
-// temporary destructor in the CFG.
 
 class A {
 public:
@@ -59,8 +54,6 @@
   A a;
 };
 
-// FIXME: Find the construction context for {} and enforce the temporary
-// destructor.
 // CHECK: template<> void foo(int)
 // CHECK:   [B1]
 // CHECK-NEXT:1:  (CXXConstructExpr, [B1.2], B)
@@ -68,10 +61,12 @@
 // CHECK-NEXT:3: operator=
 // CHECK-NEXT:4: [B1.3] (ImplicitCastExpr, FunctionToPointerDecay, B &(*)(B &&) noexcept)
 // CHECK-NEXT:5: i
-// CHECK-NEXT:6: {} (CXXConstructExpr, B)
-// CHECK-NEXT:7: [B1.6]
-// CHECK-NEXT:8: [B1.5] = [B1.7] (OperatorCall)
-// CHECK-NEXT:9: [B1.2].~B() (Implicit destructor)
+// CHECK-NEXT:6: {} (CXXConstructExpr, [B1.7], [B1.8], B)
+// CHECK-NEXT:7: [B1.6] (BindTemporary)
+// CHECK-NEXT:8: [B1.7]
+// CHECK-NEXT:9: [B1.5] = [B1.8] (OperatorCall)
+// CHECK-NEXT:10: ~B() (Temporary object destructor)
+// CHECK-NEXT:11: [B1.2].~B() (Implicit destructor)
 template  void foo(T) {
   B i;
   i = {};
@@ -80,8 +75,7 @@
 void bar() {
   global = 0;
   foo(1);
-  // FIXME: Should be TRUE, i.e. we should call (and inline) two destructors.
-  clang_analyzer_eval(global == 2); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(global == 2); // expected-warning{{TRUE [debug.ExprInspection]}}
 }
 
 } // end namespace variant_1
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -11402,7 +11402,8 @@
   if (LHS.isInvalid())
 return ExprError();
 
-  ExprResult RHS = getDerived().TransformExpr(E->getRHS());
+  ExprResult RHS =
+  getDerived().TransformInitializer(E->getRHS(), /*NotCopyInit=*/false);
   if (RHS.isInvalid())
 return ExprError();
 
@@ -11950,7 +11951,8 @@
 
   ExprResult Second;
   if (E->getNumArgs() == 2) {
-Second = getDerived().TransformExpr(E->getArg(1));
+Second =
+getDerived().TransformInitializer(E->getArg(1), /*NotCopyInit=*/false);
 if (Second.isInvalid())
   return ExprError();
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151281: [NFC][CLANG] Fix issue with dereference null return value found by Coverity

2023-05-24 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

Thank you @erichkeane for reviews!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151281

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


[PATCH] D150499: [AST] Initialized data after TypeSourceInfo

2023-05-24 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150499

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


[PATCH] D150504: [AST] Construct Capture objects before use

2023-05-24 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8826cd57825d: [AST] Construct Capture objects before use 
(authored by vitalybuka).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150504

Files:
  clang/include/clang/AST/Stmt.h
  clang/lib/AST/Stmt.cpp


Index: clang/lib/AST/Stmt.cpp
===
--- clang/lib/AST/Stmt.cpp
+++ clang/lib/AST/Stmt.cpp
@@ -1345,6 +1345,11 @@
   : Stmt(CapturedStmtClass, Empty), NumCaptures(NumCaptures),
 CapDeclAndKind(nullptr, CR_Default) {
   getStoredStmts()[NumCaptures] = nullptr;
+
+  // Construct default capture objects.
+  Capture *Buffer = getStoredCaptures();
+  for (unsigned I = 0, N = NumCaptures; I != N; ++I)
+new (Buffer++) Capture();
 }
 
 CapturedStmt *CapturedStmt::Create(const ASTContext , Stmt *S,
Index: clang/include/clang/AST/Stmt.h
===
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -3587,8 +3587,11 @@
 llvm::PointerIntPair VarAndKind;
 SourceLocation Loc;
 
+Capture() = default;
+
   public:
 friend class ASTStmtReader;
+friend class CapturedStmt;
 
 /// Create a new capture.
 ///


Index: clang/lib/AST/Stmt.cpp
===
--- clang/lib/AST/Stmt.cpp
+++ clang/lib/AST/Stmt.cpp
@@ -1345,6 +1345,11 @@
   : Stmt(CapturedStmtClass, Empty), NumCaptures(NumCaptures),
 CapDeclAndKind(nullptr, CR_Default) {
   getStoredStmts()[NumCaptures] = nullptr;
+
+  // Construct default capture objects.
+  Capture *Buffer = getStoredCaptures();
+  for (unsigned I = 0, N = NumCaptures; I != N; ++I)
+new (Buffer++) Capture();
 }
 
 CapturedStmt *CapturedStmt::Create(const ASTContext , Stmt *S,
Index: clang/include/clang/AST/Stmt.h
===
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -3587,8 +3587,11 @@
 llvm::PointerIntPair VarAndKind;
 SourceLocation Loc;
 
+Capture() = default;
+
   public:
 friend class ASTStmtReader;
+friend class CapturedStmt;
 
 /// Create a new capture.
 ///
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8826cd5 - [AST] Construct Capture objects before use

2023-05-24 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2023-05-24T17:09:45-07:00
New Revision: 8826cd57825d829121ad7fb73fab0a6cf30f29f6

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

LOG: [AST] Construct Capture objects before use

Msan reports https://reviews.llvm.org/P8308
The reason is if PointerIntPair is not properly
constructed, setPointer uses Info::updatePointer
on uninitialized value.

Reviewed By: #clang, rsmith

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

Added: 


Modified: 
clang/include/clang/AST/Stmt.h
clang/lib/AST/Stmt.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index e466aa1755daf..7e72e44f178a9 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -3587,8 +3587,11 @@ class CapturedStmt : public Stmt {
 llvm::PointerIntPair VarAndKind;
 SourceLocation Loc;
 
+Capture() = default;
+
   public:
 friend class ASTStmtReader;
+friend class CapturedStmt;
 
 /// Create a new capture.
 ///

diff  --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp
index 8744bba6c6d9d..c31fb48a2addf 100644
--- a/clang/lib/AST/Stmt.cpp
+++ b/clang/lib/AST/Stmt.cpp
@@ -1345,6 +1345,11 @@ CapturedStmt::CapturedStmt(EmptyShell Empty, unsigned 
NumCaptures)
   : Stmt(CapturedStmtClass, Empty), NumCaptures(NumCaptures),
 CapDeclAndKind(nullptr, CR_Default) {
   getStoredStmts()[NumCaptures] = nullptr;
+
+  // Construct default capture objects.
+  Capture *Buffer = getStoredCaptures();
+  for (unsigned I = 0, N = NumCaptures; I != N; ++I)
+new (Buffer++) Capture();
 }
 
 CapturedStmt *CapturedStmt::Create(const ASTContext , Stmt *S,



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


[PATCH] D151388: [HWASan] use hwasan linker for Android 14+

2023-05-24 Thread Florian Mayer via Phabricator via cfe-commits
fmayer created this revision.
Herald added a subscriber: danielkiss.
Herald added a project: All.
fmayer requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

This will allow to compile binaries that use hwasan to run on a
non-HWASan system image.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151388

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/linux-ld.c


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1259,6 +1259,22 @@
 // CHECK-ANDROID-32: "-dynamic-linker" "/system/bin/linker"
 // CHECK-ANDROID-64: "-dynamic-linker" "/system/bin/linker64"
 //
+// Test that Android 14 and newer use linker_hwasan64 for hwasan builds
+// RUN: %clang -### %s -no-pie 2>&1 \
+// RUN: -fsanitize=hwaddress \
+// RUN: --target=x86_64-linux-android33 \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-OLD %s
+// RUN: %clang -### %s -no-pie 2>&1 \
+// RUN: -fsanitize=hwaddress \
+// RUN: --target=x86_64-linux-android34 \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-NEW %s
+// CHECK-ANDROID-OLD: "-dynamic-linker" "/system/bin/linker64"
+// CHECK-ANDROID-NEW: "-dynamic-linker" "/system/bin/linker_hwasan64"
+//
 // Test that -pthread does not add -lpthread on Android.
 // RUN: %clang -### %s -no-pie 2>&1 \
 // RUN: --target=arm-linux-androideabi -pthread \
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -426,9 +426,17 @@
 
   const Distro Distro(getDriver().getVFS(), Triple);
 
-  if (Triple.isAndroid())
+  if (Triple.isAndroid()) {
+if (getSanitizerArgs(Args).needsHwasanRt() &&
+!Triple.isAndroidVersionLT(34) && Triple.isArch64Bit()) {
+  // On Android 14 and newer, there is a special linker_hwasan64 that
+  // allows to run HWASan binaries on non-HWASan system images. This
+  // is also available on HWASan system images, so we can just always
+  // use that instead.
+  return "/system/bin/linker_hwasan64";
+}
 return Triple.isArch64Bit() ? "/system/bin/linker64" : 
"/system/bin/linker";
-
+  }
   if (Triple.isMusl()) {
 std::string ArchName;
 bool IsArm = false;


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1259,6 +1259,22 @@
 // CHECK-ANDROID-32: "-dynamic-linker" "/system/bin/linker"
 // CHECK-ANDROID-64: "-dynamic-linker" "/system/bin/linker64"
 //
+// Test that Android 14 and newer use linker_hwasan64 for hwasan builds
+// RUN: %clang -### %s -no-pie 2>&1 \
+// RUN: -fsanitize=hwaddress \
+// RUN: --target=x86_64-linux-android33 \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-OLD %s
+// RUN: %clang -### %s -no-pie 2>&1 \
+// RUN: -fsanitize=hwaddress \
+// RUN: --target=x86_64-linux-android34 \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-NEW %s
+// CHECK-ANDROID-OLD: "-dynamic-linker" "/system/bin/linker64"
+// CHECK-ANDROID-NEW: "-dynamic-linker" "/system/bin/linker_hwasan64"
+//
 // Test that -pthread does not add -lpthread on Android.
 // RUN: %clang -### %s -no-pie 2>&1 \
 // RUN: --target=arm-linux-androideabi -pthread \
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -426,9 +426,17 @@
 
   const Distro Distro(getDriver().getVFS(), Triple);
 
-  if (Triple.isAndroid())
+  if (Triple.isAndroid()) {
+if (getSanitizerArgs(Args).needsHwasanRt() &&
+!Triple.isAndroidVersionLT(34) && Triple.isArch64Bit()) {
+  // On Android 14 and newer, there is a special linker_hwasan64 that
+  // allows to run HWASan binaries on non-HWASan system images. This
+  // is also available on HWASan system images, so we can just always
+  // use that instead.
+  return "/system/bin/linker_hwasan64";
+}
 return Triple.isArch64Bit() ? "/system/bin/linker64" : "/system/bin/linker";
-
+  }
   if (Triple.isMusl()) {
 std::string ArchName;
 bool IsArm = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145739: [-Wunsafe-buffer-usage] Group variables associated by pointer assignments

2023-05-24 Thread Rashmi Mudduluru 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 rGee6b08e99375: [-Wunsafe-buffer-usage] Group variables 
associated by pointer assignments (authored by t-rasmud).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D145739?vs=523596=525364#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145739

Files:
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-multi-decl-fixits-test.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-multi-decl-uuc-fixits.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-multi-decl-uuc.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-multi-decl-warnings.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-multi-decl-warnings.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-multi-decl-warnings.cpp
@@ -0,0 +1,347 @@
+// RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -fsafe-buffer-usage-suggestions -verify %s
+
+namespace std {
+  class type_info { };
+}
+
+void local_assign_both_span() {
+  int tmp;
+  int* p = new int[10]; // expected-warning{{'p' is an unsafe pointer used for buffer access}} expected-note-re^change type of 'p' to 'std::span' to preserve bounds information, and change 'q' to 'std::span' to propagate bounds information between them$
+  tmp = p[4];  // expected-note{{used in buffer access here}}
+
+  int* q = new int[10];  // expected-warning{{'q' is an unsafe pointer used for buffer access}} expected-note-re^change type of 'q' to 'std::span' to preserve bounds information, and change 'p' to 'std::span' to propagate bounds information between them$
+  tmp = q[4];  // expected-note{{used in buffer access here}}
+
+  q = p;
+}
+
+void local_assign_rhs_span() {
+  int tmp;
+  int* p = new int[10];
+  int* q = new int[10];  // expected-warning{{'q' is an unsafe pointer used for buffer access}} expected-note-re^change type of 'q' to 'std::span' to preserve bounds information$
+  tmp = q[4];  // expected-note{{used in buffer access here}}
+  p = q;
+}
+
+void local_assign_no_span() {
+  int tmp;
+  int* p = new int[10];
+  int* q = new int[10];
+  p = q;
+}
+
+void local_assign_lhs_span() {
+  int tmp;
+  int* p = new int[10];  // expected-warning{{'p' is an unsafe pointer used for buffer access}} expected-note-re^change type of 'p' to 'std::span' to preserve bounds information, and change 'q' to 'std::span' to propagate bounds information between them$
+  tmp = p[4];  // expected-note{{used in buffer access here}}
+  int* q = new int[10];
+
+  p = q;
+}
+
+
+// FIXME: Support initializations at declarations.
+void lhs_span_multi_assign() {
+  int *a = new int[2];
+  int *b = a;
+  int *c = b;
+  int *d = c;  // expected-warning{{'d' is an unsafe pointer used for buffer access}} expected-note-re^change type of 'd' to 'std::span' to preserve bounds information$
+  int tmp = d[2];  // expected-note{{used in buffer access here}}
+}
+
+void rhs_span() {
+  int *x = new int[3];
+  int *y;  // expected-warning{{'y' is an unsafe pointer used for buffer access}} expected-note-re^change type of 'y' to 'std::span' to preserve bounds information$
+  y[5] = 10;  // expected-note{{used in buffer access here}}
+
+  x = y;
+}
+
+void rhs_span1() {
+  int *q = new int[12];
+  int *p = q;  // expected-warning{{'p' is an unsafe pointer used for buffer access}} expected-note-re^change type of 'p' to 'std::span' to preserve bounds information$
+  p[5] = 10;  // expected-note{{used in buffer access here}}
+  int *r = q;  // expected-warning{{'r' is an unsafe pointer used for buffer access}} expected-note-re^change type of 'r' to 'std::span' to preserve bounds information$
+  r[10] = 5;  // expected-note{{used in buffer access here}}
+}
+
+void rhs_span2() {
+  int *q = new int[6];
+  int *p = q;  // expected-warning{{'p' is an unsafe pointer used for buffer access}} expected-note-re^change type of 'p' to 'std::span' to preserve bounds information$
+  p[5] = 10;  // expected-note{{used in buffer access here}}
+  int *r = q;
+}
+
+void test_grouping() {
+  int *z = new int[8];
+  int tmp;
+  int *y = new int[10];  // expected-warning{{'y' is an unsafe pointer used for buffer access}} expected-note-re^change type of 'y' to 'std::span' to preserve bounds information$
+  tmp = y[5]; // expected-note{{used in buffer access here}}
+
+  int *x = new int[10];
+  x = y;
+
+  int *w = z;
+}
+
+void test_grouping1() {
+  int 

[clang] ee6b08e - [-Wunsafe-buffer-usage] Group variables associated by pointer assignments

2023-05-24 Thread Rashmi Mudduluru via cfe-commits

Author: Rashmi Mudduluru
Date: 2023-05-24T16:20:55-07:00
New Revision: ee6b08e99375fc48d1e5848704a66c2e8e57eb3b

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

LOG: [-Wunsafe-buffer-usage] Group variables associated by pointer assignments

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

Added: 
clang/test/SemaCXX/warn-unsafe-buffer-usage-multi-decl-fixits-test.cpp
clang/test/SemaCXX/warn-unsafe-buffer-usage-multi-decl-uuc-fixits.cpp
clang/test/SemaCXX/warn-unsafe-buffer-usage-multi-decl-uuc.cpp
clang/test/SemaCXX/warn-unsafe-buffer-usage-multi-decl-warnings.cpp

Modified: 
clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Analysis/UnsafeBufferUsage.cpp
clang/lib/Sema/AnalysisBasedWarnings.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h 
b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
index 10635e8f3a29f..617bc7c77c565 100644
--- a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
+++ b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
@@ -19,6 +19,8 @@
 
 namespace clang {
 
+using DefMapTy = llvm::DenseMap>;
+
 /// The interface that lets the caller handle unsafe buffer usage analysis
 /// results by overriding this class's handle... methods.
 class UnsafeBufferUsageHandler {
@@ -34,9 +36,12 @@ class UnsafeBufferUsageHandler {
   virtual void handleUnsafeOperation(const Stmt *Operation,
  bool IsRelatedToDecl) = 0;
 
-  /// Invoked when a fix is suggested against a variable.
-  virtual void handleFixableVariable(const VarDecl *Variable,
- FixItList &) = 0;
+  /// Invoked when a fix is suggested against a variable. This function groups
+  /// all variables that must be fixed together (i.e their types must be 
changed to the
+  /// same target type to prevent type mismatches) into a single fixit.
+  virtual void handleUnsafeVariableGroup(const VarDecl *Variable,
+ const DefMapTy ,
+ FixItList &) = 0;
 
   /// Returns a reference to the `Preprocessor`:
   virtual bool isSafeBufferOptOut(const SourceLocation ) const = 0;

diff  --git 
a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def 
b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
index a112b6d105025..57d9dcc5bdcb7 100644
--- a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
+++ b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
@@ -36,6 +36,7 @@ FIXABLE_GADGET(PointerDereference)
 FIXABLE_GADGET(UPCAddressofArraySubscript) // '[any]' in an Unspecified 
Pointer Context
 FIXABLE_GADGET(UPCStandalonePointer)
 FIXABLE_GADGET(UPCPreIncrement)// '++Ptr' in an Unspecified 
Pointer Context
+FIXABLE_GADGET(PointerAssignment)
 
 #undef FIXABLE_GADGET
 #undef WARNING_GADGET

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index f203ac6c2a84e..a777d43f1468f 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11822,8 +11822,8 @@ def warn_unsafe_buffer_operation : Warning<
   InGroup, DefaultIgnore;
 def note_unsafe_buffer_operation : Note<
   "used%select{| in pointer arithmetic| in buffer access}0 here">;
-def note_unsafe_buffer_variable_fixit : Note<
-  "change type of '%0' to '%select{std::span|std::array|std::span::iterator}1' 
to preserve bounds information">;
+def note_unsafe_buffer_variable_fixit_group : Note<
+  "change type of %0 to '%select{std::span|std::array|std::span::iterator}1' 
to preserve bounds information%select{|, and change %2 to 
'%select{std::span|std::array|std::span::iterator}1' to propagate bounds 
information between them}3">;
 def note_safe_buffer_usage_suggestions_disabled : Note<
   "pass -fsafe-buffer-usage-suggestions to receive code hardening 
suggestions">;
 def err_loongarch_builtin_requires_la32 : Error<

diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 87e3ec90dbf2f..c9cc4ccbfb5d5 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace llvm;
 using namespace clang;
@@ -256,6 +257,29 @@ isInUnspecifiedPointerContext(internal::Matcher 
InnerMatcher) {
   // FIXME: any more cases? (UPC excludes the RHS of an assignment.  For now we
   // don't have to check that.)
 }
+
+// Returns a matcher that matches any expression 

[PATCH] D76096: [clang] allow const structs to be constant expressions in initializer lists

2023-05-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

So, @rsmith are you ok with a patch like https://reviews.llvm.org/D76169 that 
removes those fixmes?

It makes sense to me that `const int foo[] = [ ...massive list...];` would take 
long to validate the entire initializer as all constant expressions, but I'm 
simply trying to allow:

  const int foo[] = [ ...massive list...];
  int bar = foo[0];




Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1013
+  if (V->hasInit())
+return Visit(V->getInit(), V->getType());
+return nullptr;

efriedma wrote:
> rsmith wrote:
> > efriedma wrote:
> > > rsmith wrote:
> > > > nickdesaulniers wrote:
> > > > > efriedma wrote:
> > > > > > You need to be more careful here; we can call ConstExprEmitter for 
> > > > > > arbitrary expressions.
> > > > > "Be more careful" how?
> > > > Here are some specific cases in which you need to be more careful 
> > > > because the code as-is would do the wrong thing:
> > > > 
> > > >  * when emitting a global's initializer in C++, where the value of the 
> > > > object denoted by the DeclRefExpr could have changed between its 
> > > > initialization and the expression we're currently emitting 
> > > >  * when emitting anything other than a global initializer in C, where 
> > > > the value of a global could have changed after its emission
> > > >  * when emitting a reference to a non-global declaration in C (local 
> > > > variables might change between initialization and use)
> > > > 
> > > > We would need to restrict this to the cases where the variable's value 
> > > > cannot possibly have changed between initialization and use.
> > > > 
> > > > In C, that's (mostly) the case for a static storage variable referenced 
> > > > from the initializer of a static storage variable, for a thread storage 
> > > > variable referenced from the initializer of a static storage variable, 
> > > > or for a thread storage variable referenced from the initializer of a 
> > > > thread storage variable. Even then, this isn't strictly correct in the 
> > > > presence of DSOs, but I think it should be correct if the two variables 
> > > > are defined in the same translation unit.
> > > > 
> > > > In C++, that's (mostly) the case when the variable is `const` or 
> > > > `constexpr` and has no mutable subobjects. (There's still the case 
> > > > where the reference happens outside the lifetime of the object -- for 
> > > > the most part we can handwave that away by saying it must be UB, but 
> > > > that's not true in general in the period of construction and period of 
> > > > destruction.)
> > > > 
> > > > In both cases, the optimization is (arguably) still wrong if there are 
> > > > any volatile subobjects.
> > > And this is why I don't want to duplicate the logic. :)
> > > 
> > > I'd rather not make different assumptions for C and C++; instead, I'd 
> > > prefer to just use the intersection that's safe in both.  I'm concerned 
> > > that we could come up with weird results for mixed C and C++ code, 
> > > otherwise.  Also, it's easier to define the C++ rules because we can base 
> > > them on the constexpr rules in the standard.
> > I agree we probably want the same outcome as D76169 provides, if either the 
> > performance is acceptable or we can find a way to avoid the performance 
> > cost for the cases we already accept. Perhaps we could get that outcome by 
> > ensuring that we try the CGExprConstant fast-path (at least in C 
> > compilations, maybe in general) before we consider the complete-but-slow 
> > evaluation strategy in ExprConstant?
> I like the idea of guarding constant evaluation with a "fast path" that 
> doesn't actually compute the APValues in simple cases.  We can just implement 
> the simple stuff, and fall back to the full logic for complicated stuff.
> 
> My one concern is that we could go to a bunch of effort to emit a variable on 
> the fast path, then fall off the fast path later because "return a[0];" tries 
> to constant-fold a big array "a".
> the CGExprConstant fast-path

Sorry, what is "the CGExprConstant fast-path"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76096

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


[PATCH] D151383: [clang-tidy] Check for specific return types on all functions

2023-05-24 Thread NagaChaitanya Vellanki via Phabricator via cfe-commits
chaitanyav updated this revision to Diff 525359.
chaitanyav added a comment.

Reuse diag code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151383

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


Index: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -156,6 +156,15 @@
   auto UnusedInRangeForStmt = cxxForRangeStmt(hasBody(MatchedCallExpr));
   auto UnusedInCaseStmt = switchCase(forEach(MatchedCallExpr));
 
+  Finder->addMatcher(
+  callExpr(callee(functionDecl(anyOf(
+   hasReturnTypeLoc(loc(asString("std::error_code"))),
+   hasReturnTypeLoc(loc(asString("std::expected"))),
+   
hasReturnTypeLoc(loc(asString("boost::system::error_code"))),
+   hasReturnTypeLoc(loc(asString("abseil::Status")))
+  .bind("return-types"),
+  this);
+
   Finder->addMatcher(
   stmt(anyOf(UnusedInCompoundStmt, UnusedInIfStmt, UnusedInWhileStmt,
  UnusedInDoStmt, UnusedInForStmt, UnusedInRangeForStmt,
@@ -164,13 +173,17 @@
 }
 
 void UnusedReturnValueCheck::check(const MatchFinder::MatchResult ) {
-  if (const auto *Matched = Result.Nodes.getNodeAs("match")) {
-diag(Matched->getBeginLoc(),
- "the value returned by this function should be used")
-<< Matched->getSourceRange();
-diag(Matched->getBeginLoc(),
- "cast the expression to void to silence this warning",
- DiagnosticIDs::Note);
+  const char *callExprBindingNames[] = {"return-types", "match"};
+  for (const char *callExprBindingName : callExprBindingNames) {
+if (const auto *Matched =
+Result.Nodes.getNodeAs(callExprBindingName)) {
+  diag(Matched->getBeginLoc(),
+   "the value returned by this function should be used")
+  << Matched->getSourceRange();
+  diag(Matched->getBeginLoc(),
+   "cast the expression to void to silence this warning",
+   DiagnosticIDs::Note);
+};
   }
 }
 


Index: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -156,6 +156,15 @@
   auto UnusedInRangeForStmt = cxxForRangeStmt(hasBody(MatchedCallExpr));
   auto UnusedInCaseStmt = switchCase(forEach(MatchedCallExpr));
 
+  Finder->addMatcher(
+  callExpr(callee(functionDecl(anyOf(
+   hasReturnTypeLoc(loc(asString("std::error_code"))),
+   hasReturnTypeLoc(loc(asString("std::expected"))),
+   hasReturnTypeLoc(loc(asString("boost::system::error_code"))),
+   hasReturnTypeLoc(loc(asString("abseil::Status")))
+  .bind("return-types"),
+  this);
+
   Finder->addMatcher(
   stmt(anyOf(UnusedInCompoundStmt, UnusedInIfStmt, UnusedInWhileStmt,
  UnusedInDoStmt, UnusedInForStmt, UnusedInRangeForStmt,
@@ -164,13 +173,17 @@
 }
 
 void UnusedReturnValueCheck::check(const MatchFinder::MatchResult ) {
-  if (const auto *Matched = Result.Nodes.getNodeAs("match")) {
-diag(Matched->getBeginLoc(),
- "the value returned by this function should be used")
-<< Matched->getSourceRange();
-diag(Matched->getBeginLoc(),
- "cast the expression to void to silence this warning",
- DiagnosticIDs::Note);
+  const char *callExprBindingNames[] = {"return-types", "match"};
+  for (const char *callExprBindingName : callExprBindingNames) {
+if (const auto *Matched =
+Result.Nodes.getNodeAs(callExprBindingName)) {
+  diag(Matched->getBeginLoc(),
+   "the value returned by this function should be used")
+  << Matched->getSourceRange();
+  diag(Matched->getBeginLoc(),
+   "cast the expression to void to silence this warning",
+   DiagnosticIDs::Note);
+};
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151383: [clang-tidy] Check for specific return types on all functions

2023-05-24 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please extend test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151383

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


[PATCH] D151383: Check for specific return types on all functions

2023-05-24 Thread NagaChaitanya Vellanki via Phabricator via cfe-commits
chaitanyav added a comment.

@royjacobson Please list other types that must be included here. The tests are 
coming...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151383

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


[PATCH] D151383: Check for specific return types on all functions

2023-05-24 Thread NagaChaitanya Vellanki via Phabricator via cfe-commits
chaitanyav created this revision.
chaitanyav added a reviewer: royjacobson.
Herald added subscribers: PiotrZSL, carlosgalvezp.
Herald added a reviewer: njames93.
Herald added a project: All.
chaitanyav requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Extend the check to all functions with return types like

  std::error_code, std::expected, boost::system::error_code, abseil::Status...
  
  Resolves issue https://github.com/llvm/llvm-project/issues/62884


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151383

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


Index: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -156,6 +156,15 @@
   auto UnusedInRangeForStmt = cxxForRangeStmt(hasBody(MatchedCallExpr));
   auto UnusedInCaseStmt = switchCase(forEach(MatchedCallExpr));
 
+  Finder->addMatcher(
+  callExpr(callee(functionDecl(anyOf(
+   hasReturnTypeLoc(loc(asString("std::error_code"))),
+   hasReturnTypeLoc(loc(asString("std::expected"))),
+   
hasReturnTypeLoc(loc(asString("boost::system::error_code"))),
+   hasReturnTypeLoc(loc(asString("abseil::Status")))
+  .bind("return-types"),
+  this);
+
   Finder->addMatcher(
   stmt(anyOf(UnusedInCompoundStmt, UnusedInIfStmt, UnusedInWhileStmt,
  UnusedInDoStmt, UnusedInForStmt, UnusedInRangeForStmt,
@@ -164,6 +173,16 @@
 }
 
 void UnusedReturnValueCheck::check(const MatchFinder::MatchResult ) {
+
+  if (const auto *Matched = Result.Nodes.getNodeAs("return-types")) {
+diag(Matched->getBeginLoc(),
+ "the value returned by this function should be used")
+<< Matched->getSourceRange();
+diag(Matched->getBeginLoc(),
+ "cast the expression to void to silence this warning",
+ DiagnosticIDs::Note);
+  };
+
   if (const auto *Matched = Result.Nodes.getNodeAs("match")) {
 diag(Matched->getBeginLoc(),
  "the value returned by this function should be used")


Index: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -156,6 +156,15 @@
   auto UnusedInRangeForStmt = cxxForRangeStmt(hasBody(MatchedCallExpr));
   auto UnusedInCaseStmt = switchCase(forEach(MatchedCallExpr));
 
+  Finder->addMatcher(
+  callExpr(callee(functionDecl(anyOf(
+   hasReturnTypeLoc(loc(asString("std::error_code"))),
+   hasReturnTypeLoc(loc(asString("std::expected"))),
+   hasReturnTypeLoc(loc(asString("boost::system::error_code"))),
+   hasReturnTypeLoc(loc(asString("abseil::Status")))
+  .bind("return-types"),
+  this);
+
   Finder->addMatcher(
   stmt(anyOf(UnusedInCompoundStmt, UnusedInIfStmt, UnusedInWhileStmt,
  UnusedInDoStmt, UnusedInForStmt, UnusedInRangeForStmt,
@@ -164,6 +173,16 @@
 }
 
 void UnusedReturnValueCheck::check(const MatchFinder::MatchResult ) {
+
+  if (const auto *Matched = Result.Nodes.getNodeAs("return-types")) {
+diag(Matched->getBeginLoc(),
+ "the value returned by this function should be used")
+<< Matched->getSourceRange();
+diag(Matched->getBeginLoc(),
+ "cast the expression to void to silence this warning",
+ DiagnosticIDs::Note);
+  };
+
   if (const auto *Matched = Result.Nodes.getNodeAs("match")) {
 diag(Matched->getBeginLoc(),
  "the value returned by this function should be used")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150803: [WebAssembly] Add a new `wasm_async` clang attribute for marking async functions.

2023-05-24 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:1984
+   TargetSpecificAttr {
+  let Spellings = [Clang<"wasm_async">];
+  let Documentation = [WebAssemblyAsyncDocs];

brendandahl wrote:
> sbc100 wrote:
> > Should we call this em_async or emscripten_async since this is an 
> > emscripten-specific attribute?
> I wouldn't say this is emscripten specific. You could use this with 
> clang+binaryen without emscripten.
Maybe we can at least say that its web-specific?  Would it make any sense for 
non-web platforms?

If you are using clang + binaryen + web its hard to imagine a non-emscripten 
triple being used.. but maybe?



Comment at: lld/test/wasm/async.ll:18
+call void @bar()
+ret void
+}

For lld tests I've been trying for a while now to move away from `.ll` and just 
use `.s` format. 

The only reason we have any `.ll` files at all in this directory is because for 
a long time we didn't have a working `.s` format.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp:561
+void WebAssemblyAsmPrinter::EmitAsync(Module ) {
+  SmallVector EmittedAsyncs;
+

Perhaps call this `AsyncFuncs` or `AsyncFuncNames`?



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp:567
+  EmittedAsyncs.push_back(Sym);
+}
+  }

No need for curlys around one-liners in llvm



Comment at: llvm/test/MC/WebAssembly/async.s:20
+# CHECK-OBJ-NEXT:Index:   0
+# CHECK-OBJ-NEXT:Offset:  0x0
+# CHECK-OBJ-NEXT: Name:async

Indentation look wrong here.. `Index`, `Offset` and `Name` should align with 
`Type` I think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150803

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


[PATCH] D150803: [WebAssembly] Add a new `wasm_async` clang attribute for marking async functions.

2023-05-24 Thread Brendan Dahl via Phabricator via cfe-commits
brendandahl added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:1984
+   TargetSpecificAttr {
+  let Spellings = [Clang<"wasm_async">];
+  let Documentation = [WebAssemblyAsyncDocs];

sbc100 wrote:
> Should we call this em_async or emscripten_async since this is an 
> emscripten-specific attribute?
I wouldn't say this is emscripten specific. You could use this with 
clang+binaryen without emscripten.



Comment at: llvm/lib/MC/MCExpr.cpp:530
+  .Case("tpoff_lo", VK_VE_TPOFF_LO32)
+  .Default(VK_Invalid);
 }

sbc100 wrote:
> Was this whole block indented?  Maybe limit this to just a single line change?
This was changed by `git-clang-format HEAD~1` . I can revert though and only 
change that line.



Comment at: llvm/test/MC/WebAssembly/async.s:10-11
+
+.section.custom_section.async,"",@
+.int32  foo@FUNCINDEX
+

aheejin wrote:
> The intention looks little weird.. Is that what `llc` emits? 
Yeah, I wasn't really sure how to format, but that's what llc was doing. Open 
to changing it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150803

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


[PATCH] D150803: [WebAssembly] Add a new `wasm_async` clang attribute for marking async functions.

2023-05-24 Thread Brendan Dahl via Phabricator via cfe-commits
brendandahl updated this revision to Diff 525348.
brendandahl marked 5 inline comments as done.
brendandahl added a comment.

Review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150803

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/WebAssembly/wasm-async.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  lld/test/wasm/async.ll
  lld/test/wasm/merge-async-section.ll
  lld/wasm/InputChunks.cpp
  lld/wasm/InputFiles.cpp
  llvm/include/llvm/BinaryFormat/WasmRelocs.def
  llvm/include/llvm/MC/MCExpr.h
  llvm/lib/MC/MCExpr.cpp
  llvm/lib/MC/WasmObjectWriter.cpp
  llvm/lib/Object/WasmObjectFile.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h
  llvm/test/CodeGen/WebAssembly/async.ll
  llvm/test/MC/WebAssembly/async.s

Index: llvm/test/MC/WebAssembly/async.s
===
--- /dev/null
+++ llvm/test/MC/WebAssembly/async.s
@@ -0,0 +1,21 @@
+# RUN: llvm-mc -triple=wasm32-unknown-unknown < %s | FileCheck %s
+# Check that it also comiled to object for format.
+# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -o - < %s | obj2yaml | FileCheck -check-prefix=CHECK-OBJ %s
+
+foo:
+.globl foo
+.functype foo () -> ()
+end_function
+
+.section.custom_section.async,"",@
+.int32  foo@FUNCINDEX
+
+# CHECK:   .section .custom_section.async,"",@
+# CHECK-NEXT: .int32  foo@FUNCINDEX
+
+# CHECK-OBJ:- Type:CUSTOM
+# CHECK-OBJ-NEXT: Relocations:
+# CHECK-OBJ-NEXT:- Type:R_WASM_FUNCTION_INDEX_I32
+# CHECK-OBJ-NEXT:Index:   0
+# CHECK-OBJ-NEXT:Offset:  0x0
+# CHECK-OBJ-NEXT: Name:async
Index: llvm/test/CodeGen/WebAssembly/async.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/async.ll
@@ -0,0 +1,17 @@
+; RUN: llc < %s -asm-verbose=false -wasm-keep-registers | FileCheck %s
+
+target triple = "wasm32-unknown-unknown"
+
+define void @test0() #0 {
+  ret void
+}
+
+define void @test1() #0 {
+  ret void
+}
+
+attributes #0 = { "wasm-async" }
+
+; CHECK:  .section.custom_section.async,"",@
+; CHECK-NEXT: .int32  test0@FUNCINDEX
+; CHECK-NEXT: .int32  test1@FUNCINDEX
Index: llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h
===
--- llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h
+++ llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h
@@ -66,6 +66,7 @@
   void emitEndOfAsmFile(Module ) override;
   void EmitProducerInfo(Module );
   void EmitTargetFeatures(Module );
+  void EmitAsync(Module );
   void emitSymbolType(const MCSymbolWasm *Sym);
   void emitGlobalVariable(const GlobalVariable *GV) override;
   void emitJumpTableInfo() override;
Index: llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -438,6 +438,7 @@
 
   EmitProducerInfo(M);
   EmitTargetFeatures(M);
+  EmitAsync(M);
 }
 
 void WebAssemblyAsmPrinter::EmitProducerInfo(Module ) {
@@ -556,6 +557,33 @@
   OutStreamer->popSection();
 }
 
+void WebAssemblyAsmPrinter::EmitAsync(Module ) {
+  SmallVector EmittedAsyncs;
+
+  for (const auto  : M) {
+auto *Sym = cast(getSymbol());
+if (F.hasFnAttribute("wasm-async")) {
+  EmittedAsyncs.push_back(Sym);
+}
+  }
+  if (EmittedAsyncs.size() == 0)
+return;
+
+  MCSectionWasm *AsyncSection = OutContext.getWasmSection(
+  ".custom_section.async", SectionKind::getMetadata());
+  OutStreamer->pushSection();
+  OutStreamer->switchSection(AsyncSection);
+
+  for (auto  : EmittedAsyncs) {
+OutStreamer->emitValue(
+MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_WASM_FUNCINDEX,
+OutContext),
+4);
+  }
+
+  OutStreamer->popSection();
+}
+
 void WebAssemblyAsmPrinter::emitConstantPool() {
   emitDecls(*MMI->getModule());
   assert(MF->getConstantPool()->getConstants().empty() &&
Index: llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
===
--- llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
+++ llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
@@ -91,6 +91,8 @@
   return wasm::R_WASM_TYPE_INDEX_LEB;
 case MCSymbolRefExpr::VK_None:
   break;
+case MCSymbolRefExpr::VK_WASM_FUNCINDEX:
+  return wasm::R_WASM_FUNCTION_INDEX_I32;
 

[PATCH] D145265: [Pipeline] Remove GlobalCleanupPM

2023-05-24 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea accepted this revision.
asbirlea added a comment.
This revision is now accepted and ready to land.

This went through a few rounds of testing on our internal benchmarks and it's 
at a point where there are no meaningful run-time regressions observed, but the 
compile-time improvements remain and are significant enough to move fwd with 
the change.
Approving to move things forward. If folks do encounter regressions from this 
change before or after landing, please flag them here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145265

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


[PATCH] D151362: [CUDA] Add CUDA wrappers over clang builtins for sm_90.

2023-05-24 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
Herald added subscribers: mattd, bixia, yaxunl.
Herald added a project: All.
tra updated this revision to Diff 525338.
tra added a comment.
tra updated this revision to Diff 525340.
tra published this revision for review.
tra added a reviewer: jlebar.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Added vectorized fp32 atomic add.


tra added a comment.

clang-format changes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151362

Files:
  clang/lib/Headers/__clang_cuda_intrinsics.h

Index: clang/lib/Headers/__clang_cuda_intrinsics.h
===
--- clang/lib/Headers/__clang_cuda_intrinsics.h
+++ clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -577,6 +577,133 @@
 }
 #endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 800
 
+#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 900
+__device__ inline unsigned __isCtaShared(const void *ptr) {
+  return __isShared(ptr);
+}
+
+__device__ inline unsigned __isClusterShared(const void *__ptr) {
+  return __nvvm_isspacep_shared_cluster(__ptr);
+}
+
+__device__ inline void *__cluster_map_shared_rank(const void *__ptr,
+  unsigned __rank) {
+  return __nvvm_mapa((void *)__ptr, __rank);
+}
+
+__device__ inline unsigned __cluster_query_shared_rank(const void *__ptr) {
+  return __nvvm_getctarank((void *)__ptr);
+}
+
+__device__ inline uint2
+__cluster_map_shared_multicast(const void *__ptr,
+   unsigned int __cluster_cta_mask) {
+  return make_uint2((unsigned)__cvta_generic_to_shared(__ptr),
+__cluster_cta_mask);
+}
+
+__device__ inline unsigned __clusterDimIsSpecified() {
+  return __nvvm_is_explicit_cluster();
+}
+
+__device__ inline dim3 __clusterDim() {
+  return {__nvvm_read_ptx_sreg_cluster_nctaid_x(),
+  __nvvm_read_ptx_sreg_cluster_nctaid_y(),
+  __nvvm_read_ptx_sreg_cluster_nctaid_z()};
+}
+
+__device__ inline dim3 __clusterRelativeBlockIdx() {
+  return {__nvvm_read_ptx_sreg_cluster_ctaid_x(),
+  __nvvm_read_ptx_sreg_cluster_ctaid_y(),
+  __nvvm_read_ptx_sreg_cluster_ctaid_z()};
+}
+
+__device__ inline dim3 __clusterGridDimInClusters() {
+  return {__nvvm_read_ptx_sreg_nclusterid_x(),
+  __nvvm_read_ptx_sreg_nclusterid_y(),
+  __nvvm_read_ptx_sreg_nclusterid_z()};
+}
+
+__device__ inline dim3 __clusterIdx() {
+  return {__nvvm_read_ptx_sreg_clusterid_x(),
+  __nvvm_read_ptx_sreg_clusterid_y(),
+  __nvvm_read_ptx_sreg_clusterid_z()};
+}
+
+__device__ inline unsigned __clusterRelativeBlockRank() {
+  return __nvvm_read_ptx_sreg_cluster_ctarank();
+}
+
+__device__ inline unsigned __clusterSizeInBlocks() {
+  return __nvvm_read_ptx_sreg_cluster_nctarank();
+}
+
+__device__ inline void __cluster_barrier_arrive() {
+  __nvvm_barrier_cluster_arrive();
+}
+
+__device__ inline void __cluster_barrier_arrive_relaxed() {
+  __nvvm_barrier_cluster_arrive_relaxed();
+}
+
+__device__ inline void __cluster_barrier_wait() {
+  __nvvm_barrier_cluster_wait();
+}
+
+__device__ inline void __threadfence_cluster() { __nvvm_fence_sc_cluster(); }
+
+__device__ inline float2 atomicAdd(float2 *__ptr, float2 __val) {
+  float2 __ret;
+  __asm__("atom.add.v2.f32 {%0, %1}, [%2], {%3, %4};"
+  : "=f"(__ret.x), "=f"(__ret.y)
+  : "l"(__ptr), "f"(__val.x), "f"(__val.y));
+  return __ret;
+}
+
+__device__ inline float2 atomicAdd_block(float2 *__ptr, float2 __val) {
+  float2 __ret;
+  __asm__("atom.cta.add.v2.f32 {%0, %1}, [%2], {%3, %4};"
+  : "=f"(__ret.x), "=f"(__ret.y)
+  : "l"(__ptr), "f"(__val.x), "f"(__val.y));
+  return __ret;
+}
+
+__device__ inline float2 atomicAdd_system(float2 *__ptr, float2 __val) {
+  float2 __ret;
+  __asm__("atom.sys.add.v2.f32 {%0, %1}, [%2], {%3, %4};"
+  : "=f"(__ret.x), "=f"(__ret.y)
+  : "l"(__ptr), "f"(__val.x), "f"(__val.y));
+  return __ret;
+}
+
+__device__ inline float4 atomicAdd(float4 *__ptr, float4 __val) {
+  float4 __ret;
+  __asm__("atom.add.v4.f32 {%0, %1, %2, %3}, [%4], {%5, %6, %7, %8};"
+  : "=f"(__ret.x), "=f"(__ret.y), "=f"(__ret.z), "=f"(__ret.w)
+  : "l"(__ptr), "f"(__val.x), "f"(__val.y), "f"(__val.z), "f"(__val.w));
+  return __ret;
+}
+
+__device__ inline float4 atomicAdd_block(float4 *__ptr, float4 __val) {
+  float4 __ret;
+  __asm__(
+  "atom.cta.add.v4.f32 {%0, %1, %2, %3}, [%4], {%5, %6, %7, %8};"
+  : "=f"(__ret.x), "=f"(__ret.y), "=f"(__ret.z), "=f"(__ret.w)
+  : "l"(__ptr), "f"(__val.x), "f"(__val.y), "f"(__val.z), "f"(__val.w));
+  return __ret;
+}
+
+__device__ inline float4 atomicAdd_system(float4 *__ptr, float4 __val) {
+  float4 __ret;
+  __asm__(
+  "atom.sys.add.v4.f32 {%0, %1, %2, %3}, [%4], {%5, %6, %7, %8};"
+  : "=f"(__ret.x), "=f"(__ret.y), "=f"(__ret.z), "=f"(__ret.w)
+  : "l"(__ptr), "f"(__val.x), 

[PATCH] D150843: [clang][Diagnostics] Refactor printableTextForNextCharacter

2023-05-24 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

Give some time for @tahonermann to have an opportunity to review again, but 
otherwise this looks good to me. Thanks!




Comment at: clang/lib/Frontend/TextDiagnostic.cpp:124-128
+  if (CharSize == 1 && llvm::isLegalUTF8Sequence(Begin, End) &&
+  llvm::sys::locale::isPrint(*Begin)) {
+++(*I);
+return std::make_pair(SmallString<16>(Begin, End), true);
+  }

tbaeder wrote:
> tbaeder wrote:
> > cor3ntin wrote:
> > > tbaeder wrote:
> > > > cor3ntin wrote:
> > > > > this could be simplified : the common case for ascii could be just 
> > > > > looking at `isPrint(*Begin);` (which implies  CharSize == 1 and  
> > > > > llvm::isLegalUTF8Sequence(Begin, End))
> > > > > So you could do it before computing CharSize
> > > > This is not true in my testing fwiw.
> > > ```
> > > const unsigned char *Begin = SourceLine.bytes_begin() + *I;
> > > 
> > >   // Fast path for the common ASCII case.
> > >   if (*Begin < 0x80 && llvm::sys::locale::isPrint(*Begin)) {
> > > ++(*I);
> > > return std::make_pair(SmallString<16>(Begin, Begin + 1), true);
> > >   }
> > > ```
> > > seems to work fine locally. Note that I'm not sure `*Begin` is always 
> > > valid - it seems to be, but we might want an assert to check that 
> > > SourceLine is not empty. 
> > This function is only ever called in a `while (I < SourceLine.size())` 
> > loop. I've thought about refactoring this into a helper struct that keeps 
> > the index separate from the calling function to simplify callers.
> Oh also, there are two asserts at the beginning of the function to ensure `I` 
> is valid.
you are right, if, `SourceLine` is empty, that first asset would always fire


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

https://reviews.llvm.org/D150843

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


[PATCH] D151365: [Sema] cast to CXXRecordDecl correctly when diag a default comparison method

2023-05-24 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 updated this revision to Diff 525333.
HerrCai0907 added a comment.

change solution


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151365

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/SemaCXX/cxx20-default-compare.cpp


Index: clang/test/SemaCXX/cxx20-default-compare.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx20-default-compare.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -std=c++23 -verify -Wfloat-equal
+
+struct Foo {
+  float val;
+  bool operator==(const Foo &) const;
+  friend bool operator==(const Foo &, const Foo &);
+  friend bool operator==(Foo, Foo );
+};
+
+// Declare the defaulted comparison function as a member function.
+bool Foo::operator==(const Foo &) const = default; // expected-warning 
{{comparing floating point with == or != is unsafe}} expected-note {{in 
defaulted equality comparison operator for 'Foo' first required here}}
+
+// Declare the defaulted comparison function as a non-member function.
+bool operator==(const Foo &, const Foo &) = default;  // expected-warning 
{{comparing floating point with == or != is unsafe}} expected-note {{in 
defaulted equality comparison operator for 'Foo' first required here}}
+
+// Declare the defaulted comparison function as a non-member function. 
Arguments are passed by value.
+bool operator==(Foo, Foo) = default;  // expected-warning {{comparing floating 
point with == or != is unsafe}} expected-note {{in defaulted equality 
comparison operator for 'Foo' first required here}}
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -961,11 +961,13 @@
 << MD->isExplicitlyDefaulted() << DFK.asSpecialMember()
 << Context.getTagDeclType(MD->getParent());
   } else if (DFK.isComparison()) {
+QualType RecordType = FD->getParamDecl(0)
+  ->getType()
+  .getNonReferenceType();
 Diags.Report(Active->PointOfInstantiation,
  diag::note_comparison_synthesized_at)
 << (int)DFK.asComparison()
-<< Context.getTagDeclType(
-   cast(FD->getLexicalDeclContext()));
+<< Context.getRecordType(RecordType->getAsRecordDecl());
   }
   break;
 }
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -439,6 +439,9 @@
   (`#62789 `_).
 - Fix a crash when instantiating a non-type template argument in a dependent 
scope.
   (`#62533 `_).
+- Fix crash when diagnosing default comparison method.
+  (`#62791 `_) and
+  (`#62102 `_).
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/cxx20-default-compare.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx20-default-compare.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -std=c++23 -verify -Wfloat-equal
+
+struct Foo {
+  float val;
+  bool operator==(const Foo &) const;
+  friend bool operator==(const Foo &, const Foo &);
+  friend bool operator==(Foo, Foo );
+};
+
+// Declare the defaulted comparison function as a member function.
+bool Foo::operator==(const Foo &) const = default; // expected-warning {{comparing floating point with == or != is unsafe}} expected-note {{in defaulted equality comparison operator for 'Foo' first required here}}
+
+// Declare the defaulted comparison function as a non-member function.
+bool operator==(const Foo &, const Foo &) = default;  // expected-warning {{comparing floating point with == or != is unsafe}} expected-note {{in defaulted equality comparison operator for 'Foo' first required here}}
+
+// Declare the defaulted comparison function as a non-member function. Arguments are passed by value.
+bool operator==(Foo, Foo) = default;  // expected-warning {{comparing floating point with == or != is unsafe}} expected-note {{in defaulted equality comparison operator for 'Foo' first required here}}
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -961,11 +961,13 @@
 << MD->isExplicitlyDefaulted() << DFK.asSpecialMember()
 << Context.getTagDeclType(MD->getParent());
   } else if (DFK.isComparison()) {
+QualType RecordType = 

[PATCH] D151308: -fsanitize=function: fix alignment fault on Arm targets.

2023-05-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.

LGTM.




Comment at: clang/test/CodeGen/ubsan-function.cpp:4
 // RUN: %clang_cc1 -triple aarch64_be-linux-gnu -emit-llvm -o - %s 
-fsanitize=function -fno-sanitize-recover=all | FileCheck %s
+// RUN: %clang_cc1 -triple arm-none-eabi -emit-llvm -o - %s 
-fsanitize=function -fno-sanitize-recover=all | FileCheck %s 
--check-prefixes=CHECK,ARM
 

Consider using `--check-prefixes=CHECK,64` for 64-bit targets and 
`--check-prefixes=CHECK,ARM` (or `,32`) for the `// CHECK: call void 
@__ubsan_handle_function_type_mismatch_abort(ptr @[[#]], {{i64|i32}} %[[#]]) 
#[[#]], !nosanitize` line below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151308

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


[PATCH] D151308: -fsanitize=function: fix alignment fault on Arm targets.

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

In D151308#4367704 , @peter.smith 
wrote:

> This looks good to me. Will be worth waiting for a day to give the US time 
> zone time to leave any comments.

Thanks!

> I note that this is also broken in -fsanitize=kcfi [*] 
> (https://reviews.llvm.org/D135411) although fixing that is a separate patch. 
> Would you be able to raise a github issue to cover that?

`-fsanitize=kcfi` only supports aarch64 and x86-64 now. riscv64 is on the plan.

  % fclang -fsanitize=kcfi --traget=armv7-linux-gnueabi -c a.c
  clang: error: unsupported option '--traget=armv7-linux-gnueabi'




Comment at: clang/lib/CodeGen/CGExpr.cpp:5381
+llvm::Value *Mask = llvm::ConstantInt::get(IntPtrTy, ~1);
+llvm::Value *AlignedCalleeAddress =
+Builder.CreateAnd(CalleeAddress, Mask);

For chained operations, it may be cleaner to remove some used-once variables.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151308

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


[PATCH] D151373: [libclang] Expose arguments of clang::annotate{_type}

2023-05-24 Thread Fridtjof Mund via Phabricator via cfe-commits
fridtjof created this revision.
fridtjof added a reviewer: aaron.ballman.
Herald added a subscriber: arphaman.
Herald added a project: All.
fridtjof requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This enables easy consumption of arbitrary data added
to these annotations in addition to the annotation category,
which was already exposed.

I mostly just copied all the bits and pieces that seemed to do similar stuff, 
which seems to work.

I tested this locally with a very small C++ program to try and dump arguments 
for clang::annotate, which works.
Adding annotate_type to my test source code does not even expose the annotation 
itself however (I've attached it to parameter and variable types to no 
success), which seems like an unrelated bug (it should work for all Decls!).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151373

Files:
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CursorVisitor.h

Index: clang/tools/libclang/CursorVisitor.h
===
--- clang/tools/libclang/CursorVisitor.h
+++ clang/tools/libclang/CursorVisitor.h
@@ -276,7 +276,9 @@
   bool IsInRegionOfInterest(CXCursor C);
   bool RunVisitorWorkList(VisitorWorkList );
   void EnqueueWorkList(VisitorWorkList , const Stmt *S);
+  void EnqueueWorkList(VisitorWorkList , const Attr *A);
   LLVM_ATTRIBUTE_NOINLINE bool Visit(const Stmt *S);
+  LLVM_ATTRIBUTE_NOINLINE bool Visit(const Attr *A);
 
 private:
   std::optional handleDeclForVisitation(const Decl *D);
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -22,6 +22,7 @@
 #include "CursorVisitor.h"
 #include "clang-c/FatalErrorHandler.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/AttrVisitor.h"
 #include "clang/AST/DeclObjCCommon.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/OpenMPClause.h"
@@ -523,6 +524,13 @@
 return false;
   }
 
+  if (clang_isAttribute(Cursor.kind)) {
+if (const Attr *A = getCursorAttr(Cursor))
+  return Visit(A);
+
+return false;
+  }
+
   if (clang_isTranslationUnit(Cursor.kind)) {
 CXTranslationUnit TU = getCursorTU(Cursor);
 ASTUnit *CXXUnit = cxtu::getASTUnit(TU);
@@ -2085,7 +2093,8 @@
 (SourceLocation::UIntTy)(uintptr_t)data[1]);
   }
 };
-class EnqueueVisitor : public ConstStmtVisitor {
+class EnqueueVisitor : public ConstStmtVisitor,
+   public ConstAttrVisitor {
   friend class OMPClauseEnqueue;
   VisitorWorkList 
   CXCursor Parent;
@@ -2227,6 +2236,10 @@
   void VisitOMPTargetTeamsDistributeSimdDirective(
   const OMPTargetTeamsDistributeSimdDirective *D);
 
+  // Attributes
+  void VisitAnnotateAttr(const AnnotateAttr *A);
+  void VisitAnnotateTypeAttr(const AnnotateTypeAttr *A);
+
 private:
   void AddDeclarationNameInfo(const Stmt *S);
   void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc Qualifier);
@@ -2238,6 +2251,8 @@
   void AddTypeLoc(TypeSourceInfo *TI);
   void EnqueueChildren(const Stmt *S);
   void EnqueueChildren(const OMPClause *S);
+  void EnqueueChildren(const AnnotateAttr *A);
+  void EnqueueChildren(const AnnotateTypeAttr *A);
 };
 } // namespace
 
@@ -2727,6 +2742,31 @@
   VisitorWorkList::iterator I = WL.begin() + size, E = WL.end();
   std::reverse(I, E);
 }
+// TODO these two methods are exactly the same. Can this be expressed better?
+void EnqueueVisitor::EnqueueChildren(const AnnotateAttr *A) {
+  unsigned size = WL.size();
+  for (const Expr *Arg : A->args()) {
+VisitStmt(Arg);
+  }
+  if (size == WL.size())
+return;
+  // Now reverse the entries we just added.  This will match the DFS
+  // ordering performed by the worklist.
+  VisitorWorkList::iterator I = WL.begin() + size, E = WL.end();
+  std::reverse(I, E);
+}
+void EnqueueVisitor::EnqueueChildren(const AnnotateTypeAttr *A) {
+  unsigned size = WL.size();
+  for (const Expr *Arg : A->args()) {
+AddStmt(Arg);
+  }
+  if (size == WL.size())
+return;
+  // Now reverse the entries we just added.  This will match the DFS
+  // ordering performed by the worklist.
+  VisitorWorkList::iterator I = WL.begin() + size, E = WL.end();
+  std::reverse(I, E);
+}
 void EnqueueVisitor::VisitAddrLabelExpr(const AddrLabelExpr *E) {
   WL.push_back(LabelRefVisit(E->getLabel(), E->getLabelLoc(), Parent));
 }
@@ -2999,7 +3039,7 @@
   // If the opaque value has a source expression, just transparently
   // visit that.  This is useful for (e.g.) pseudo-object expressions.
   if (Expr *SourceExpr = E->getSourceExpr())
-return Visit(SourceExpr);
+return ConstStmtVisitor::Visit(SourceExpr);
 }
 void EnqueueVisitor::VisitLambdaExpr(const LambdaExpr *E) {
   AddStmt(E->getBody());
@@ -3019,7 +3059,7 @@
 }
 void EnqueueVisitor::VisitPseudoObjectExpr(const PseudoObjectExpr *E) {
   // Treat the expression like its syntactic form.
-  

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

2023-05-24 Thread Sedenion via Phabricator via cfe-commits
Sedeniono added a comment.

Heh, ok, so I wasn't that naive then to not run the tests of everything :-)

I had a look at the issue. The ClangRenameTests first do some replacements, and 
then call formatAndApplyReplacements() 

 with them, which also formats the lines containing the replacements. With my 
patch, calling `clang-format.exe -style=llvm --lines=13:13` on the following 
file (line 13 is the `OldAlias old_alias;`)

  #include "header.h"
  
  namespace x { class Old {}; }
  namespace ns {
  #define REF(alias) alias alias_var;
  
  #define ALIAS(old) \
using old##Alias = x::old; \
REF(old##Alias);
  
  ALIAS(Old);
  
  OldAlias old_alias;
  }

triggers the assert in adjustToUnmodifiedLine() 
.
 This is what happens in the `RenameAliasTest.AliasesInMacros` test.

The issue originates already from the line `#define REF(alias) alias 
alias_var;`: These are two `AnnotatedLine` instances at first, namely `#define 
REF(alias)` with `AnnotatedLine::Level` set to 0 and `alias alias_var;` with 
`AnnotatedLine::Level` equals to 1. They get joined eventually. Since my patch 
sets `A.Level = B.Level;` in `join()`, the joined line gets level 1. But the 
`LevelIndentTracker` is still in level 0 (i.e. `IndentForLevel` contains only 1 
element).

It is kind of the same problem why I added the `if (!Line.InPPDirective)` check 
in `nextLine()` in the patch: I think, if both AnnotatedLines are PP 
directives, then `join()` should not step "into" or "out of" levels. 
PP-directives are kind-of "temporary insertions". So, replacing in `join()` the 
`A.Level = B.Level;` from my patch with

  assert(A.InPPDirective == B.InPPDirective);
  if (!A.InPPDirective && !B.InPPDirective)
A.Level = B.Level;

seems to fix the problem. At least all Google tests (including the 
ClangRenameTests) pass that didn't fail without the patch. Any opinions on that 
idea?

I have to think some more about the levels and what it means regarding 
`join()`. I also need to get the clang-tidy test to run locally and also add 
the above example as a formatter test (if possible in a reduced form). Most 
likely I won't be able to do this until next week, sorry. :-/

To create a new fix, do I understand the guide 
 correctly that I 
basically execute `arc diff --verbatim` and mention `Depends on D151047` 
somewhere in the message? Will it then appear here automatically?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151047

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


[PATCH] D151162: Add -Wpacked-non-pod to -Wall

2023-05-24 Thread Zenong Zhang via Phabricator via cfe-commits
SlaterLatiao added a comment.

In D151162#4369584 , @aaron.ballman 
wrote:

> Please be sure to add a release note for the change, and it'd probably be 
> good to have a test case that shows this triggers under `-Wall` (the modified 
> test case explicitly names the diagnostic).

Thank you, Aaron. I'll add the test case. Should this change go under 
`Improvements to Clang’s diagnostics` in the release note?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151162

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


[PATCH] D150221: Add option -fkeep-static-variables to emit all static variables

2023-05-24 Thread Zheng Qian via Phabricator via cfe-commits
qianzhen added a comment.

Gentle ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150221

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


[PATCH] D151162: Add -Wpacked-non-pod to -Wall

2023-05-24 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/test/CodeGenCXX/warn-padded-packed.cpp:5
+// RUN: %clang_cc1 -triple=x86_64-none-none -Wpacked-non-pod -verify=top %s 
-emit-llvm-only
+// RUN: %clang_cc1 -triple=x86_64-none-none -Wpacked-non-pod 
-fclang-abi-compat=15 %s -emit-llvm-only
+

SlaterLatiao wrote:
> denik wrote:
> > Probably we don't need this one. But I'm not sure if there is any impact of 
> > the abi on`packed-non-pod`. According to the original test it checks only 
> > `-Wpacked` `packed attribute is unnecessary` warning.
> I added this line to make sure all the `packed attribute is unnecessary` 
> warnings in the existing test of  `-Wpacked` are not reported by  
> `-Wpacked-non-pod`. Yeah if the abi doesn't have any impact on 
> `-Wpacked-non-pod` this test is unnecessary. 
the old ABI shouldn't emit the `-Wpacked-non-pod` warning since the warning 
isn't correct in the old ABI - where packed is applied to non-pod equally as 
pod.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151162

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


[PATCH] D151344: Reland "[CMake] Bumps minimum version to 3.20.0.

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

I haven't tested this patch, but it looks like it contains everything that 
unbreaks our builds.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151344

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


[PATCH] D151365: [Sema] cast to CXXRecordDecl correctly when diag a default comparison method

2023-05-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D151365#4369650 , @HerrCai0907 
wrote:

> In D151365#4369605 , @erichkeane 
> wrote:
>
>> As Richard says, we should just be taking the first parameter type and using 
>> that instead (obviously de-qualified and removing reference if necessary).
>
> But we still can find the correct RecordDecl by `redecls`.

That ends up being an absurdly larger amount of work, and in the case of a 
'friend' declaration can result in the wrong answer, correct?  Consider 
something like:

  struct Foo;
  
  struct Bar {
  friend bool operator==(const Foo&, const Foo&);
  };
  
  struct Foo {
  friend bool operator==(const Foo&, const Foo&);
  };
  
  bool operator==(const Foo&, const Foo&) = default;

or even:

  struct Foo {
  bool operator==(const Foo&) const;
  };
  
  struct Bar {
  friend bool Foo::operator==(const Foo&) const;
  };
  
  
  bool operator==(Foo, Foo) = default;

In the 1st one, the lexical context could be 'Bar'.  Searching 'redecls' will 
end up with the 'first one first', so at least the 2nd example isn't as 
problematic, but I'm sure someone more clever than I could come up with a case 
where that could be declared in a different order.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151365

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


[PATCH] D151365: [Sema] cast to CXXRecordDecl correctly when diag a default comparison method

2023-05-24 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 added a comment.

In D151365#4369605 , @erichkeane 
wrote:

> As Richard says, we should just be taking the first parameter type and using 
> that instead (obviously de-qualified and removing reference if necessary).

But we still can find the correctly RecordDecl by `redecls`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151365

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


[PATCH] D151363: [NVPTX, CUDA] barrier intrinsics and builtins for sm_90

2023-05-24 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 525309.
tra added a comment.

whitespace fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151363

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenCUDA/builtins-sm90.cu
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/test/CodeGen/NVPTX/intrinsics-sm90.ll

Index: llvm/test/CodeGen/NVPTX/intrinsics-sm90.ll
===
--- llvm/test/CodeGen/NVPTX/intrinsics-sm90.ll
+++ llvm/test/CodeGen/NVPTX/intrinsics-sm90.ll
@@ -1,5 +1,5 @@
-; RUN: llc < %s -march=nvptx64 -mcpu=sm_90 -mattr=+ptx78| FileCheck --check-prefixes=CHECK %s
-; RUN: %if ptxas-11.8 %{ llc < %s -march=nvptx64 -mcpu=sm_90 -mattr=+ptx78| %ptxas-verify -arch=sm_90 %}
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_90 -mattr=+ptx80| FileCheck --check-prefixes=CHECK %s
+; RUN: %if ptxas-11.8 %{ llc < %s -march=nvptx64 -mcpu=sm_90 -mattr=+ptx80| %ptxas-verify -arch=sm_90 %}
 
 ; CHECK-LABEL: test_isspacep
 define i1 @test_isspacep_shared_cluster(ptr %p) {
@@ -120,6 +120,19 @@
 ret i1 %x
 }
 
+; CHECK-LABEL: test_barrier_cluster(
+define void @test_barrier_cluster() {
+; CHECK: barrier.cluster.arrive;
+   call void @llvm.nvvm.barrier.cluster.arrive()
+; CHECK: barrier.cluster.arrive.relaxed;
+   call void @llvm.nvvm.barrier.cluster.arrive.relaxed()
+; CHECK: barrier.cluster.wait;
+   call void @llvm.nvvm.barrier.cluster.wait()
+; CHECK: fence.sc.cluster
+   call void @llvm.nvvm.fence.sc.cluster()
+   ret void
+}
+
 
 declare i1 @llvm.nvvm.isspacep.shared.cluster(ptr %p);
 declare ptr @llvm.nvvm.mapa(ptr %p, i32 %r);
@@ -137,3 +150,7 @@
 declare i32 @llvm.nvvm.read.ptx.sreg.cluster.ctarank()
 declare i32 @llvm.nvvm.read.ptx.sreg.cluster.nctarank()
 declare i1 @llvm.nvvm.is_explicit_cluster()
+declare void @llvm.nvvm.barrier.cluster.arrive()
+declare void @llvm.nvvm.barrier.cluster.arrive.relaxed()
+declare void @llvm.nvvm.barrier.cluster.wait()
+declare void @llvm.nvvm.fence.sc.cluster()
Index: llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
===
--- llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
+++ llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
@@ -132,6 +132,18 @@
  "barrier.sync \t$id, $cnt;",
  [(int_nvvm_barrier_sync_cnt imm:$id, imm:$cnt)]>,
 Requires<[hasPTX<60>, hasSM<30>]>;
+class INT_BARRIER_CLUSTER Preds = [hasPTX<78>, hasSM<90>]>:
+NVPTXInst<(outs), (ins), "barrier.cluster."# variant #";", [(Intr)]>,
+Requires;
+
+def barrier_cluster_arrive:
+INT_BARRIER_CLUSTER<"arrive", int_nvvm_barrier_cluster_arrive>;
+def barrier_cluster_arrive_relaxed:
+INT_BARRIER_CLUSTER<"arrive.relaxed",
+int_nvvm_barrier_cluster_arrive_relaxed, [hasPTX<80>, hasSM<90>]>;
+def barrier_cluster_wait:
+INT_BARRIER_CLUSTER<"wait", int_nvvm_barrier_cluster_wait>;
 
 class SHFL_INSTR
@@ -303,6 +315,9 @@
 def INT_MEMBAR_GL  : MEMBAR<"membar.gl;",  int_nvvm_membar_gl>;
 def INT_MEMBAR_SYS : MEMBAR<"membar.sys;", int_nvvm_membar_sys>;
 
+def INT_FENCE_SC_CLUSTER:
+   MEMBAR<"fence.sc.cluster;", int_nvvm_fence_sc_cluster>,
+   Requires<[hasPTX<78>, hasSM<90>]>;
 
 //---
 // Async Copy Functions
Index: llvm/include/llvm/IR/IntrinsicsNVVM.td
===
--- llvm/include/llvm/IR/IntrinsicsNVVM.td
+++ llvm/include/llvm/IR/IntrinsicsNVVM.td
@@ -1358,6 +1358,14 @@
   Intrinsic<[], [llvm_i32_ty, llvm_i32_ty], [IntrConvergent, IntrNoCallback]>,
   ClangBuiltin<"__nvvm_barrier_sync_cnt">;
 
+  // barrier.cluster.[wait, arrive, arrive.relaxed]
+  def int_nvvm_barrier_cluster_arrive :
+  Intrinsic<[], [], [IntrConvergent, IntrNoCallback]>;
+  def int_nvvm_barrier_cluster_arrive_relaxed :
+  Intrinsic<[], [], [IntrConvergent, IntrNoCallback]>;
+  def int_nvvm_barrier_cluster_wait :
+  Intrinsic<[], [], [IntrConvergent, IntrNoCallback]>;
+
   // Membar
   def int_nvvm_membar_cta : ClangBuiltin<"__nvvm_membar_cta">,
   Intrinsic<[], [], [IntrNoCallback]>;
@@ -1365,6 +1373,8 @@
   Intrinsic<[], [], [IntrNoCallback]>;
   def int_nvvm_membar_sys : ClangBuiltin<"__nvvm_membar_sys">,
   Intrinsic<[], [], [IntrNoCallback]>;
+  def int_nvvm_fence_sc_cluster:
+  Intrinsic<[], [], [IntrNoCallback]>;
 
 // Async Copy
 def int_nvvm_cp_async_mbarrier_arrive :
Index: clang/test/CodeGenCUDA/builtins-sm90.cu
===
--- clang/test/CodeGenCUDA/builtins-sm90.cu
+++ clang/test/CodeGenCUDA/builtins-sm90.cu
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 "-triple" "nvptx64-nvidia-cuda" "-target-feature" "+ptx78" "-target-cpu" "sm_90" -emit-llvm -fcuda-is-device -o - %s | FileCheck %s
+// RUN: %clang_cc1 

[PATCH] D151365: [Sema] cast to CXXRecordDecl correctly when diag a default comparison method

2023-05-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

As Richard says, we should just be taking the first parameter type and using 
that instead (obviously de-qualified and removing reference if necessary).




Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:964
   } else if (DFK.isComparison()) {
-Diags.Report(Active->PointOfInstantiation,
- diag::note_comparison_synthesized_at)
-<< (int)DFK.asComparison()
-<< Context.getTagDeclType(
-   cast(FD->getLexicalDeclContext()));
+CXXRecordDecl *RD = nullptr;
+for (Decl *D : FD->redecls()) {

According to the comment on the related bug:

```
This code predates P2085R0, prior to which a comparison function could only be 
defaulted lexically within the class. Given that we can't use the 
lexically-enclosing class any more, we can instead look at the (first) 
parameter type to determine which class's comparison is being defaulted.
...
since the lexical context isn't the right thing for us to be looking at any more
...
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151365

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


[PATCH] D151363: [NVPTX, CUDA] barrier intrinsics and builtins for sm_90

2023-05-24 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
Herald added subscribers: mattd, gchakrabarti, asavonic, bixia, hiraditya, 
yaxunl.
Herald added a project: All.
tra updated this revision to Diff 525307.
tra added a comment.
tra published this revision for review.
tra added a reviewer: jlebar.
Herald added subscribers: llvm-commits, cfe-commits, jdoerfert, jholewinski.
Herald added projects: clang, LLVM.

Re-enabled .relaxed test, now that ptx80 is available.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151363

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenCUDA/builtins-sm90.cu
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/test/CodeGen/NVPTX/intrinsics-sm90.ll

Index: llvm/test/CodeGen/NVPTX/intrinsics-sm90.ll
===
--- llvm/test/CodeGen/NVPTX/intrinsics-sm90.ll
+++ llvm/test/CodeGen/NVPTX/intrinsics-sm90.ll
@@ -1,5 +1,5 @@
-; RUN: llc < %s -march=nvptx64 -mcpu=sm_90 -mattr=+ptx78| FileCheck --check-prefixes=CHECK %s
-; RUN: %if ptxas-11.8 %{ llc < %s -march=nvptx64 -mcpu=sm_90 -mattr=+ptx78| %ptxas-verify -arch=sm_90 %}
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_90 -mattr=+ptx80| FileCheck --check-prefixes=CHECK %s
+; RUN: %if ptxas-11.8 %{ llc < %s -march=nvptx64 -mcpu=sm_90 -mattr=+ptx80| %ptxas-verify -arch=sm_90 %}
 
 ; CHECK-LABEL: test_isspacep
 define i1 @test_isspacep_shared_cluster(ptr %p) {
@@ -120,6 +120,19 @@
 ret i1 %x
 }
 
+; CHECK-LABEL: test_barrier_cluster(
+define void @test_barrier_cluster() {
+; CHECK: barrier.cluster.arrive;
+   call void @llvm.nvvm.barrier.cluster.arrive()
+; CHECK: barrier.cluster.arrive.relaxed;
+   call void @llvm.nvvm.barrier.cluster.arrive.relaxed()
+; CHECK: barrier.cluster.wait;
+   call void @llvm.nvvm.barrier.cluster.wait()
+; CHECK: fence.sc.cluster
+   call void @llvm.nvvm.fence.sc.cluster()
+   ret void
+}
+
 
 declare i1 @llvm.nvvm.isspacep.shared.cluster(ptr %p);
 declare ptr @llvm.nvvm.mapa(ptr %p, i32 %r);
@@ -137,3 +150,7 @@
 declare i32 @llvm.nvvm.read.ptx.sreg.cluster.ctarank()
 declare i32 @llvm.nvvm.read.ptx.sreg.cluster.nctarank()
 declare i1 @llvm.nvvm.is_explicit_cluster()
+declare void @llvm.nvvm.barrier.cluster.arrive()
+declare void @llvm.nvvm.barrier.cluster.arrive.relaxed()
+declare void @llvm.nvvm.barrier.cluster.wait()
+declare void @llvm.nvvm.fence.sc.cluster()
Index: llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
===
--- llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
+++ llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
@@ -132,6 +132,18 @@
  "barrier.sync \t$id, $cnt;",
  [(int_nvvm_barrier_sync_cnt imm:$id, imm:$cnt)]>,
 Requires<[hasPTX<60>, hasSM<30>]>;
+class INT_BARRIER_CLUSTER Preds = [hasPTX<78>, hasSM<90>]>:
+NVPTXInst<(outs), (ins), "barrier.cluster."# variant #";", [(Intr)]>,
+Requires;
+
+def barrier_cluster_arrive:
+INT_BARRIER_CLUSTER<"arrive", int_nvvm_barrier_cluster_arrive>;
+def barrier_cluster_arrive_relaxed:
+INT_BARRIER_CLUSTER<"arrive.relaxed",
+int_nvvm_barrier_cluster_arrive_relaxed, [hasPTX<80>, hasSM<90>]>;
+def barrier_cluster_wait:
+INT_BARRIER_CLUSTER<"wait", int_nvvm_barrier_cluster_wait>;
 
 class SHFL_INSTR
@@ -303,6 +315,9 @@
 def INT_MEMBAR_GL  : MEMBAR<"membar.gl;",  int_nvvm_membar_gl>;
 def INT_MEMBAR_SYS : MEMBAR<"membar.sys;", int_nvvm_membar_sys>;
 
+def INT_FENCE_SC_CLUSTER:
+   MEMBAR<"fence.sc.cluster;", int_nvvm_fence_sc_cluster>,
+   Requires<[hasPTX<78>, hasSM<90>]>;
 
 //---
 // Async Copy Functions
Index: llvm/include/llvm/IR/IntrinsicsNVVM.td
===
--- llvm/include/llvm/IR/IntrinsicsNVVM.td
+++ llvm/include/llvm/IR/IntrinsicsNVVM.td
@@ -1358,6 +1358,14 @@
   Intrinsic<[], [llvm_i32_ty, llvm_i32_ty], [IntrConvergent, IntrNoCallback]>,
   ClangBuiltin<"__nvvm_barrier_sync_cnt">;
 
+  // barrier.cluster.[wait, arrive, arrive.relaxed]
+  def int_nvvm_barrier_cluster_arrive :
+  Intrinsic<[], [], [IntrConvergent, IntrNoCallback]>;
+  def int_nvvm_barrier_cluster_arrive_relaxed :
+  Intrinsic<[], [], [IntrConvergent, IntrNoCallback]>;
+  def int_nvvm_barrier_cluster_wait :
+  Intrinsic<[], [], [IntrConvergent, IntrNoCallback]>;
+
   // Membar
   def int_nvvm_membar_cta : ClangBuiltin<"__nvvm_membar_cta">,
   Intrinsic<[], [], [IntrNoCallback]>;
@@ -1365,6 +1373,8 @@
   Intrinsic<[], [], [IntrNoCallback]>;
   def int_nvvm_membar_sys : ClangBuiltin<"__nvvm_membar_sys">,
   Intrinsic<[], [], [IntrNoCallback]>;
+  def int_nvvm_fence_sc_cluster:
+  Intrinsic<[], [], [IntrNoCallback]>;
 
 // Async Copy
 def int_nvvm_cp_async_mbarrier_arrive :
Index: clang/test/CodeGenCUDA/builtins-sm90.cu

[PATCH] D151365: [Sema] cast to CXXRecoradDecl correctly when diag a default comparison method

2023-05-24 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

Comments here are relavant: https://github.com/llvm/llvm-project/issues/62102


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151365

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


[PATCH] D151356: [OpenMP] Fix transformed loop's var privacy

2023-05-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151356

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


[PATCH] D151162: Add -Wpacked-non-pod to -Wall

2023-05-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Please be sure to add a release note for the change, and it'd probably be good 
to have a test case that shows this triggers under `-Wall` (the modified test 
case explicitly names the diagnostic).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151162

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


[PATCH] D149677: [clang][TypePrinter] Add option to skip over elaborated types

2023-05-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D149677#4365031 , @sammccall wrote:

> In D149677#4356863 , @aaron.ballman 
> wrote:
>
>> I'm not seeing how the changes you've got here interact with 
>> `isScopeVisible()`; However, I also note that the only use of 
>> `isScopeVisible()` in tree is in clangd, so also adding @sammccall to see if 
>> they're hitting issues there or not.
>
> I don't think I can offer much experience one way or the other.
> clangd's original use of this extension point was in printing deduced types 
> (replace `auto` with a concrete type) so usually there was no sugar on the 
> types.
> In other cases we're e.g. generating function signatures, and happy with 
> *either* type-as-written-somewhere-in-the-code *or* 
> type-relative-to-enclosing-namespace, as long as we're not producing some 
> long qualified form that nobody would ever write.
>
>> We typically don't add new printing policies in tree without some need for 
>> them in the project itself (otherwise this becomes a maintenance problem), 
>> and I'm not certain I see a strong need for this to live in Clang
>
> The maintenance concern makes sense ("why do we have this, and can do we 
> still need it" needs to be an answerable question).
>
> But this paints out-of-tree users into a corner: the designs clang has chosen 
> here only really allow extension in two places:
>
> - customize the printing, but this can *only* be done in TypePrinter (or 
> reimplement the whole thing)
> - replace the sugar on the types before printing, but TreeTransform is 
> private, and any other solution requires tightly coupling with the full set 
> of types Clang supports
>
> I think if we want clang to be a generally-useful representation of the 
> source code then we need to make concessions to out-of-tree use-cases either 
> directly or via extensibility.

My primary concern with making those concessions is that there's no real metric 
for reviewers to use to determine whether a change is reasonable or not; anyone 
can argue "but I need this" and the above two points still hold them back. My 
secondary concern is that this will lead to `TypePrinter` being used for 
purposes which it was not designed to be used. This was an implementation 
detail class for getting a string-ified form of a `QualType` primarily for 
printing diagnostics. But it's morphing into a utility class to handle 
arbitrary type printing. We see the same sort of things with declaration 
printing, as well. That suggests to me that we need to change this class (and 
probably the decl printer too) to be more user-extensible for these out-of-tree 
needs. But it's a pretty heavy lift to expect @li.zhe.hua to do that work just 
because they're the latest person with a custom need, so I'm not certain of the 
best way forward.

That said, I'm not strongly opposed to the changes in this patch, so perhaps we 
should move forward with this and hope that kicks the can down the road long 
enough for someone to propose/implement a more extensible approach.




Comment at: clang/include/clang/AST/PrettyPrinter.h:143-145
+  /// Ignore qualifiers as specified by elaborated type sugar, instead letting
+  /// the underlying type handle printing the qualifiers.
+  unsigned IgnoreElaboratedQualifiers : 1;

li.zhe.hua wrote:
> aaron.ballman wrote:
> > The name is somewhat confusing to me, because tag names are also 
> > elaborations and those are handled by `SuppressTagKeyword` -- so what is 
> > the interaction between those when the user specifies true for 
> > `IgnoreElaboratedQualifiers` and false for `SuppressTagKeyword`?
> Ah, I hadn't considered tag names. Let me see...
> 
> I tried this out with the template specialization test case I added. If I have
> 
> ```
> using Alias = struct a::S;
> ```
> 
> then printing the aliased type of `Alias` with true for 
> `IgnoreElaboratedQualifiers` and false for `SuppressTagKeyword` gives 
> `"S"`. (I'm guessing that printing the template 
> specialization with `SuppressTagKeyword` disabled is weird or unexpected?) So 
> it would seem that `SuppressTagKeyword` still functions, as long as the 
> desugared type supports it?
> 
> Back to the topic of names, it seems like "qualifiers" is not sufficient, as 
> it also ignores elaborated tag keywords. Perhaps `IgnoreElaboration`?
> 
> ---
> Note: I initially had the name as `IgnoreElaboratedTypes`, but there was also 
> the [[ 
> https://github.com/llvm/llvm-project/blob/1b05e74982242da81d257f660302585cee691f3b/clang/lib/AST/TypePrinter.cpp#L1559-L1568
>  | tag definition printing logic ]] that I didn't fully understand, so I 
> thought just saying "qualifiers" would be more correct.
I think `IgnoreElaboration` has roughly the same problem of "which do I use and 
how do these operate in combination?" I was trying to convince myself that 
perhaps using a single field with an enumeration of named 

[PATCH] D151365: [Sema] cast to CXXRecoradDecl correctly when diag a default comparison method

2023-05-24 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 created this revision.
Herald added a project: All.
HerrCai0907 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixed: https://github.com/llvm/llvm-project/issues/62791
in c++20, default comparison is supported. `getLexicalDeclContext` maybe cannot
get the `CXXRecord` if default comparison defined out of `CXXRecord`.
This patch want to visit all the declaration of error function and find the
correct `CXXRecord`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151365

Files:
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/SemaCXX/cxx20-default-compare.cpp


Index: clang/test/SemaCXX/cxx20-default-compare.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx20-default-compare.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -std=c++23 -verify -Wfloat-equal
+
+struct Foo {
+  float val;
+  bool operator==(const Foo &) const;
+  friend bool operator==(const Foo &, const Foo &);
+  friend bool operator==(Foo, Foo );
+};
+
+// Declare the defaulted comparison function as a member function.
+bool Foo::operator==(const Foo &) const = default; // expected-warning 
{{comparing floating point with == or != is unsafe}} expected-note {{in 
defaulted equality comparison operator for 'Foo' first required here}}
+
+// Declare the defaulted comparison function as a non-member function.
+bool operator==(const Foo &, const Foo &) = default;  // expected-warning 
{{comparing floating point with == or != is unsafe}} expected-note {{in 
defaulted equality comparison operator for 'Foo' first required here}}
+
+// Declare the defaulted comparison function as a non-member function. 
Arguments are passed by value.
+bool operator==(Foo, Foo) = default;  // expected-warning {{comparing floating 
point with == or != is unsafe}} expected-note {{in defaulted equality 
comparison operator for 'Foo' first required here}}
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -961,11 +961,17 @@
 << MD->isExplicitlyDefaulted() << DFK.asSpecialMember()
 << Context.getTagDeclType(MD->getParent());
   } else if (DFK.isComparison()) {
-Diags.Report(Active->PointOfInstantiation,
- diag::note_comparison_synthesized_at)
-<< (int)DFK.asComparison()
-<< Context.getTagDeclType(
-   cast(FD->getLexicalDeclContext()));
+CXXRecordDecl *RD = nullptr;
+for (Decl *D : FD->redecls()) {
+  RD = dyn_cast(D->getLexicalDeclContext());
+  if (RD)
+break;
+}
+if (RD)
+  Diags.Report(Active->PointOfInstantiation,
+  diag::note_comparison_synthesized_at)
+  << (int)DFK.asComparison()
+  << Context.getTagDeclType(RD);
   }
   break;
 }


Index: clang/test/SemaCXX/cxx20-default-compare.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx20-default-compare.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -std=c++23 -verify -Wfloat-equal
+
+struct Foo {
+  float val;
+  bool operator==(const Foo &) const;
+  friend bool operator==(const Foo &, const Foo &);
+  friend bool operator==(Foo, Foo );
+};
+
+// Declare the defaulted comparison function as a member function.
+bool Foo::operator==(const Foo &) const = default; // expected-warning {{comparing floating point with == or != is unsafe}} expected-note {{in defaulted equality comparison operator for 'Foo' first required here}}
+
+// Declare the defaulted comparison function as a non-member function.
+bool operator==(const Foo &, const Foo &) = default;  // expected-warning {{comparing floating point with == or != is unsafe}} expected-note {{in defaulted equality comparison operator for 'Foo' first required here}}
+
+// Declare the defaulted comparison function as a non-member function. Arguments are passed by value.
+bool operator==(Foo, Foo) = default;  // expected-warning {{comparing floating point with == or != is unsafe}} expected-note {{in defaulted equality comparison operator for 'Foo' first required here}}
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -961,11 +961,17 @@
 << MD->isExplicitlyDefaulted() << DFK.asSpecialMember()
 << Context.getTagDeclType(MD->getParent());
   } else if (DFK.isComparison()) {
-Diags.Report(Active->PointOfInstantiation,
- diag::note_comparison_synthesized_at)
-<< (int)DFK.asComparison()
-<< Context.getTagDeclType(
-   

[PATCH] D150996: LLVM_FALLTHROUGH => [[fallthrough]]. NFC

2023-05-24 Thread Craig Topper via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6006d43e2d7d: LLVM_FALLTHROUGH = [[fallthrough]]. NFC 
(authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150996

Files:
  clang/lib/AST/TemplateBase.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Sema/SemaChecking.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  llvm/lib/Analysis/MemoryLocation.cpp
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/ProfileData/InstrProf.cpp
  llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
  llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCRegisterInfo.h
  llvm/lib/Target/SPIRV/SPIRVISelLowering.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8487,7 +8487,7 @@
   Ops[1] = SafeRHS;
   return new VPWidenRecipe(*I, make_range(Ops.begin(), Ops.end()));
 }
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   }
   case Instruction::Add:
   case Instruction::And:
Index: llvm/lib/Target/SPIRV/SPIRVISelLowering.cpp
===
--- llvm/lib/Target/SPIRV/SPIRVISelLowering.cpp
+++ llvm/lib/Target/SPIRV/SPIRVISelLowering.cpp
@@ -55,7 +55,7 @@
   switch (Intrinsic) {
   case Intrinsic::spv_load:
 AlignIdx = 2;
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   case Intrinsic::spv_store: {
 if (I.getNumOperands() >= AlignIdx + 1) {
   auto *AlignOp = cast(I.getOperand(AlignIdx));
Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.h
===
--- llvm/lib/Target/PowerPC/PPCRegisterInfo.h
+++ llvm/lib/Target/PowerPC/PPCRegisterInfo.h
@@ -183,7 +183,7 @@
   case 'f':
 if (RegName[1] == 'p')
   return RegName + 2;
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   case 'r':
   case 'v':
 if (RegName[1] == 's') {
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -10686,7 +10686,7 @@
   RetOps.push_back(Extract);
   return DAG.getMergeValues(RetOps, dl);
 }
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   }
   case Intrinsic::ppc_vsx_disassemble_pair: {
 int NumVecs = 2;
Index: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
+++ llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
@@ -3994,7 +3994,7 @@
   if (SRLConst && SRLConst->getSExtValue() == 16)
 return false;
 }
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   case ISD::ROTL:
   case ISD::SHL:
   case ISD::AND:
Index: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
===
--- llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
+++ llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
@@ -2529,7 +2529,7 @@
   return 2 * LT.first;
 if (!Ty->getScalarType()->isFP128Ty())
   return LT.first;
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   case ISD::FMUL:
   case ISD::FDIV:
 // These nodes are marked as 'custom' just to lower them to SVE.
Index: llvm/lib/ProfileData/InstrProf.cpp
===
--- llvm/lib/ProfileData/InstrProf.cpp
+++ llvm/lib/ProfileData/InstrProf.cpp
@@ -1385,7 +1385,7 @@
   case 10ull:
 H.TemporalProfTracesOffset =
 read(Buffer, offsetOf(::TemporalProfTracesOffset));
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   case 9ull:
 H.BinaryIdOffset = read(Buffer, offsetOf(::BinaryIdOffset));
 [[fallthrough]];
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -2420,7 +2420,7 @@
   case OMPScheduleType::BaseRuntimeSimd:
 assert(!ChunkSize &&
"schedule type does not support user-defined chunk sizes");
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   case OMPScheduleType::BaseDynamicChunked:
   case OMPScheduleType::BaseGuidedChunked:
   case OMPScheduleType::BaseGuidedIterativeChunked:
Index: llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp
===
--- llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp
+++ 

[clang] 6006d43 - LLVM_FALLTHROUGH => [[fallthrough]]. NFC

2023-05-24 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2023-05-24T12:40:10-07:00
New Revision: 6006d43e2d7dda56844f1c3867baa981cfefb8ea

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

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

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/lib/AST/TemplateBase.cpp
clang/lib/Basic/SourceManager.cpp
clang/lib/Sema/SemaChecking.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
llvm/lib/Analysis/MemoryLocation.cpp
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/lib/ProfileData/InstrProf.cpp
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/PowerPC/PPCRegisterInfo.h
llvm/lib/Target/SPIRV/SPIRVISelLowering.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Removed: 




diff  --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp
index c21e9c861875..c46b3e3d0c50 100644
--- a/clang/lib/AST/TemplateBase.cpp
+++ b/clang/lib/AST/TemplateBase.cpp
@@ -327,7 +327,7 @@ void TemplateArgument::Profile(llvm::FoldingSetNodeID ,
 
   case TemplateExpansion:
 ID.AddInteger(TemplateArg.NumExpansions);
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   case Template:
 ID.AddPointer(TemplateArg.Name);
 break;

diff  --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index f4ddae17f578..6fa802a33a50 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -1312,7 +1312,7 @@ LineOffsetMapping 
LineOffsetMapping::get(llvm::MemoryBufferRef Buffer,
 if (*Buf == '\n') {
   ++Buf;
 }
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   case '\n':
 LineOffsets.push_back(Buf - Start);
   };

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 6c2cbc60a81d..c02f4f5a5269 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3792,7 +3792,7 @@ bool Sema::CheckLoongArchBuiltinFunctionCall(const 
TargetInfo ,
   return Diag(TheCall->getBeginLoc(),
   diag::err_loongarch_builtin_requires_la64)
  << TheCall->getSourceRange();
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   case LoongArch::BI__builtin_loongarch_cacop_w: {
 if (BuiltinID == LoongArch::BI__builtin_loongarch_cacop_w &&
 !TI.hasFeature("32bit"))

diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 8d8af21e1994..7b74129f848e 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -511,14 +511,14 @@ ClangExpressionParser::ClangExpressionParser(
 break;
   case lldb::eLanguageTypeC_plus_plus_20:
 lang_opts.CPlusPlus20 = true;
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   case lldb::eLanguageTypeC_plus_plus_17:
 // FIXME: add a separate case for CPlusPlus14. Currently folded into C++17
 // because C++14 is the default standard for Clang but enabling CPlusPlus14
 // expression evaluatino doesn't pass the test-suite cleanly.
 lang_opts.CPlusPlus14 = true;
 lang_opts.CPlusPlus17 = true;
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   case lldb::eLanguageTypeC_plus_plus:
   case lldb::eLanguageTypeC_plus_plus_11:
   case lldb::eLanguageTypeC_plus_plus_14:

diff  --git a/llvm/lib/Analysis/MemoryLocation.cpp 
b/llvm/lib/Analysis/MemoryLocation.cpp
index e839f9e0dfb2..0404b32be848 100644
--- a/llvm/lib/Analysis/MemoryLocation.cpp
+++ b/llvm/lib/Analysis/MemoryLocation.cpp
@@ -257,7 +257,7 @@ MemoryLocation MemoryLocation::getForArgument(const 
CallBase *Call,
 
 case LibFunc_memset_chk:
   assert(ArgIdx == 0 && "Invalid argument index for memset_chk");
-  LLVM_FALLTHROUGH;
+  [[fallthrough]];
 case LibFunc_memcpy_chk: {
   assert((ArgIdx == 0 || ArgIdx == 1) &&
  "Invalid argument index for memcpy_chk");

diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp 
b/llvm/lib/Analysis/ScalarEvolution.cpp
index 2ad787053f83..a700eaedd6c7 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -15325,7 +15325,7 @@ const SCEV *ScalarEvolution::applyLoopGuards(const SCEV 
*Expr, const Loop *L) {
 if (RHS->getType()->isPointerTy())
   return;
 RHS = getUMaxExpr(RHS, One);
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   case 

[PATCH] D150913: [Clang][BFloat16] Upgrade __bf16 to arithmetic type, change mangling, and extend excess precision support.

2023-05-24 Thread M. Zeeshan Siddiqui via Phabricator via cfe-commits
codemzs updated this revision to Diff 525298.
codemzs marked 5 inline comments as done.
codemzs retitled this revision from "[Clang][Bfloat16] Upgrade __bf16 to 
arithmetic type, change mangling, and extend excess precision support." to 
"[Clang][BFloat16] Upgrade __bf16 to arithmetic type, change mangling, and 
extend excess precision support.".
codemzs set the repository for this revision to rG LLVM Github Monorepo.
codemzs added a comment.

Incorporates suggestions provided by @rjmccall, @pengfei, and @zahiraam.

@rjmccall, your thorough restructuring of the floating-point types 
documentation is highly appreciated. Thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150913

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/FPOptions.def
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/lib/AST/Type.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CodeGen/X86/avx512bf16-error.c
  clang/test/CodeGen/X86/bfloat-mangle.cpp
  clang/test/CodeGen/X86/bfloat16.cpp
  clang/test/CodeGen/X86/fexcess-precision-bfloat16.c
  clang/test/CodeGenCUDA/amdgpu-bf16.cu
  clang/test/CodeGenCUDA/bf16.cu
  clang/test/Driver/fexcess-precision.c
  clang/test/Sema/arm-bf16-forbidden-ops.c
  clang/test/Sema/arm-bf16-forbidden-ops.cpp
  clang/test/Sema/arm-bfloat.cpp
  clang/test/SemaCUDA/amdgpu-bf16.cu
  clang/test/SemaCUDA/bf16.cu

Index: clang/test/SemaCUDA/bf16.cu
===
--- clang/test/SemaCUDA/bf16.cu
+++ clang/test/SemaCUDA/bf16.cu
@@ -2,32 +2,32 @@
 // REQUIRES: x86-registered-target
 
 // RUN: %clang_cc1 "-triple" "x86_64-unknown-linux-gnu" "-aux-triple" "nvptx64-nvidia-cuda" \
-// RUN:"-target-cpu" "x86-64" -fsyntax-only -verify=scalar %s
+// RUN:"-target-cpu" "x86-64" -fsyntax-only -verify=scalar -Wno-unused %s
 // RUN: %clang_cc1 "-aux-triple" "x86_64-unknown-linux-gnu" "-triple" "nvptx64-nvidia-cuda" \
-// RUN:-fcuda-is-device "-aux-target-cpu" "x86-64" -fsyntax-only -verify=scalar %s
+// RUN:-fcuda-is-device "-aux-target-cpu" "x86-64" -fsyntax-only -verify=scalar -Wno-unused %s
 
 #include "Inputs/cuda.h"
 
 __device__ void test(bool b, __bf16 *out, __bf16 in) {
   __bf16 bf16 = in; // No error on using the type itself.
 
-  bf16 + bf16; // scalar-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
-  bf16 - bf16; // scalar-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
-  bf16 * bf16; // scalar-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
-  bf16 / bf16; // scalar-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+  bf16 + bf16;
+  bf16 - bf16;
+  bf16 * bf16;
+  bf16 / bf16;
 
   __fp16 fp16;
 
-  bf16 + fp16; // scalar-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
-  fp16 + bf16; // scalar-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
-  bf16 - fp16; // scalar-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
-  fp16 - bf16; // scalar-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
-  bf16 * fp16; // scalar-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
-  fp16 * bf16; // scalar-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
-  bf16 / fp16; // scalar-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
-  fp16 / bf16; // scalar-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 + fp16;
+  fp16 + bf16;
+  bf16 - fp16;
+  fp16 - bf16;
+  bf16 * fp16;
+  fp16 * bf16;
+  bf16 / fp16;
+  fp16 / bf16;
   bf16 = fp16; // scalar-error {{assigning to '__bf16' from incompatible type '__fp16'}}
   fp16 = bf16; // scalar-error {{assigning to '__fp16' from incompatible type '__bf16'}}
-  bf16 + (b ? fp16 : bf16); // scalar-error {{incompatible operand types ('__fp16' and '__bf16')}}
+  bf16 + (b ? fp16 : bf16);
   *out = bf16;
 }
Index: clang/test/SemaCUDA/amdgpu-bf16.cu
===
--- clang/test/SemaCUDA/amdgpu-bf16.cu
+++ clang/test/SemaCUDA/amdgpu-bf16.cu
@@ -1,13 +1,8 @@
 // REQUIRES: amdgpu-registered-target
 // REQUIRES: x86-registered-target
 
-// RUN: %clang_cc1 "-triple" "x86_64-unknown-linux-gnu" "-aux-triple" "amdgcn-amd-amdhsa"\
-// RUN:"-target-cpu" "x86-64" -fsyntax-only -verify=amdgcn %s
-// RUN: %clang_cc1 

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

2023-05-24 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D151047#4369503 , @MyDeveloperDay 
wrote:

> I think we need to extract the context of the test from RenameTests to ensure 
> we have it covered here. I don't personally normally run the entire LLVM 
> suite.

Dito, and I didn't know (or would have thought about) that clang-tidy uses 
clang-format code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151047

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


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

2023-05-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I think we need to extract the context of the test from RenameTests to ensure 
we have it covered here. I don't personally normally run the entire LLVM suite.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151047

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


[PATCH] D151361: [CUDA] bump supported CUDA version to 12.1/11.8

2023-05-24 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
Herald added subscribers: mattd, gchakrabarti, asavonic, bixia, hiraditya, 
yaxunl.
Herald added a project: All.
tra published this revision for review.
tra added a reviewer: jlebar.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay, jholewinski.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151361

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/include/clang/Basic/Cuda.h
  clang/lib/Basic/Cuda.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  llvm/lib/Target/NVPTX/NVPTX.td

Index: llvm/lib/Target/NVPTX/NVPTX.td
===
--- llvm/lib/Target/NVPTX/NVPTX.td
+++ llvm/lib/Target/NVPTX/NVPTX.td
@@ -24,89 +24,22 @@
 //   TableGen in NVPTXGenSubtarget.inc.
 //===--===//
 
-// SM Versions
-def SM20 : SubtargetFeature<"sm_20", "SmVersion", "20",
-"Target SM 2.0">;
-def SM21 : SubtargetFeature<"sm_21", "SmVersion", "21",
-"Target SM 2.1">;
-def SM30 : SubtargetFeature<"sm_30", "SmVersion", "30",
-"Target SM 3.0">;
-def SM32 : SubtargetFeature<"sm_32", "SmVersion", "32",
-"Target SM 3.2">;
-def SM35 : SubtargetFeature<"sm_35", "SmVersion", "35",
-"Target SM 3.5">;
-def SM37 : SubtargetFeature<"sm_37", "SmVersion", "37",
-"Target SM 3.7">;
-def SM50 : SubtargetFeature<"sm_50", "SmVersion", "50",
-"Target SM 5.0">;
-def SM52 : SubtargetFeature<"sm_52", "SmVersion", "52",
-"Target SM 5.2">;
-def SM53 : SubtargetFeature<"sm_53", "SmVersion", "53",
-"Target SM 5.3">;
-def SM60 : SubtargetFeature<"sm_60", "SmVersion", "60",
- "Target SM 6.0">;
-def SM61 : SubtargetFeature<"sm_61", "SmVersion", "61",
- "Target SM 6.1">;
-def SM62 : SubtargetFeature<"sm_62", "SmVersion", "62",
- "Target SM 6.2">;
-def SM70 : SubtargetFeature<"sm_70", "SmVersion", "70",
- "Target SM 7.0">;
-def SM72 : SubtargetFeature<"sm_72", "SmVersion", "72",
- "Target SM 7.2">;
-def SM75 : SubtargetFeature<"sm_75", "SmVersion", "75",
- "Target SM 7.5">;
-def SM80 : SubtargetFeature<"sm_80", "SmVersion", "80",
- "Target SM 8.0">;
-def SM86 : SubtargetFeature<"sm_86", "SmVersion", "86",
- "Target SM 8.6">;
-def SM87 : SubtargetFeature<"sm_87", "SmVersion", "87",
- "Target SM 8.7">;
-def SM89 : SubtargetFeature<"sm_89", "SmVersion", "89",
- "Target SM 8.9">;
-def SM90 : SubtargetFeature<"sm_90", "SmVersion", "90",
- "Target SM 9.0">;
+class FeatureSM:
+   SubtargetFeature<"sm_"# version, "SmVersion",
+"" # version,
+"Target SM " # version>;
+class FeaturePTX:
+   SubtargetFeature<"ptx"# version, "PTXVersion",
+"" # version,
+"Use PTX version " # version>;
 
-// PTX Versions
-def PTX32 : SubtargetFeature<"ptx32", "PTXVersion", "32",
- "Use PTX version 3.2">;
-def PTX40 : SubtargetFeature<"ptx40", "PTXVersion", "40",
- "Use PTX version 4.0">;
-def PTX41 : SubtargetFeature<"ptx41", "PTXVersion", "41",
- "Use PTX version 4.1">;
-def PTX42 : SubtargetFeature<"ptx42", "PTXVersion", "42",
- "Use PTX version 4.2">;
-def PTX43 : SubtargetFeature<"ptx43", "PTXVersion", "43",
- "Use PTX version 4.3">;
-def PTX50 : SubtargetFeature<"ptx50", "PTXVersion", "50",
- "Use PTX version 5.0">;
-def PTX60 : SubtargetFeature<"ptx60", "PTXVersion", "60",
- "Use PTX version 6.0">;
-def PTX61 : SubtargetFeature<"ptx61", "PTXVersion", "61",
- "Use PTX version 6.1">;
-def PTX63 : SubtargetFeature<"ptx63", "PTXVersion", "63",
- "Use PTX version 6.3">;
-def PTX64 : SubtargetFeature<"ptx64", "PTXVersion", "64",
- "Use PTX version 6.4">;
-def PTX65 : SubtargetFeature<"ptx65", "PTXVersion", "65",
- "Use PTX version 6.5">;
-def PTX70 : SubtargetFeature<"ptx70", "PTXVersion", "70",
- "Use PTX version 7.0">;
-def PTX71 : SubtargetFeature<"ptx71", "PTXVersion", "71",
- "Use PTX version 7.1">;
-def PTX72 : SubtargetFeature<"ptx72", "PTXVersion", "72",
- "Use PTX version 7.2">;
-def PTX73 : SubtargetFeature<"ptx73", 

[PATCH] D151076: [IRGen] Handle infinite cycles in findDominatingStoreToReturnValue.

2023-05-24 Thread Florian Hahn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf0687b47a0ce: [IRGen] Handle infinite cycles in 
findDominatingStoreToReturnValue. (authored by fhahn).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151076

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/dominating-store-infinite-cycle.c


Index: clang/test/CodeGen/dominating-store-infinite-cycle.c
===
--- /dev/null
+++ clang/test/CodeGen/dominating-store-infinite-cycle.c
@@ -0,0 +1,33 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | 
FileCheck %s
+
+// Test for PR62830 where there are 2 infinite cycles using goto. Make sure
+// clang codegen doesn't hang.
+int a;
+
+// CHECK-LABEL: define dso_local i32 @main
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[RETVAL:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 0, ptr [[RETVAL]], align 4
+// CHECK-NEXT:br label [[L1:%.*]]
+// CHECK:   L1:
+// CHECK-NEXT:br label [[L1]]
+// CHECK:   L2:
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr @a, align 4
+// CHECK-NEXT:[[TOBOOL:%.*]] = icmp ne i32 [[TMP0]], 0
+// CHECK-NEXT:br i1 [[TOBOOL]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
+// CHECK:   if.then:
+// CHECK-NEXT:br label [[L2:%.*]]
+// CHECK:   if.end:
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[RETVAL]], align 4
+// CHECK-NEXT:ret i32 [[TMP1]]
+//
+int main() {
+L1:
+  goto L1;
+
+L2:
+  if (!a)
+goto L2;
+}
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3461,8 +3461,9 @@
   // single-predecessors chain from the current insertion point.
   llvm::BasicBlock *StoreBB = store->getParent();
   llvm::BasicBlock *IP = CGF.Builder.GetInsertBlock();
+  llvm::SmallPtrSet SeenBBs;
   while (IP != StoreBB) {
-if (!(IP = IP->getSinglePredecessor()))
+if (!SeenBBs.insert(IP).second || !(IP = IP->getSinglePredecessor()))
   return nullptr;
   }
 


Index: clang/test/CodeGen/dominating-store-infinite-cycle.c
===
--- /dev/null
+++ clang/test/CodeGen/dominating-store-infinite-cycle.c
@@ -0,0 +1,33 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck %s
+
+// Test for PR62830 where there are 2 infinite cycles using goto. Make sure
+// clang codegen doesn't hang.
+int a;
+
+// CHECK-LABEL: define dso_local i32 @main
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[RETVAL:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 0, ptr [[RETVAL]], align 4
+// CHECK-NEXT:br label [[L1:%.*]]
+// CHECK:   L1:
+// CHECK-NEXT:br label [[L1]]
+// CHECK:   L2:
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr @a, align 4
+// CHECK-NEXT:[[TOBOOL:%.*]] = icmp ne i32 [[TMP0]], 0
+// CHECK-NEXT:br i1 [[TOBOOL]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
+// CHECK:   if.then:
+// CHECK-NEXT:br label [[L2:%.*]]
+// CHECK:   if.end:
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[RETVAL]], align 4
+// CHECK-NEXT:ret i32 [[TMP1]]
+//
+int main() {
+L1:
+  goto L1;
+
+L2:
+  if (!a)
+goto L2;
+}
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -3461,8 +3461,9 @@
   // single-predecessors chain from the current insertion point.
   llvm::BasicBlock *StoreBB = store->getParent();
   llvm::BasicBlock *IP = CGF.Builder.GetInsertBlock();
+  llvm::SmallPtrSet SeenBBs;
   while (IP != StoreBB) {
-if (!(IP = IP->getSinglePredecessor()))
+if (!SeenBBs.insert(IP).second || !(IP = IP->getSinglePredecessor()))
   return nullptr;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f0687b4 - [IRGen] Handle infinite cycles in findDominatingStoreToReturnValue.

2023-05-24 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2023-05-24T20:16:42+01:00
New Revision: f0687b47a0ce82da07127fee4fe6af801df54ca6

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

LOG: [IRGen] Handle infinite cycles in findDominatingStoreToReturnValue.

If there is an infinite cycle in the IR, the loop will never exit. Keep
track of visited basic blocks in a set and return nullptr if a block is
visited again.

Fixes #62830.

Reviewed By: rjmccall

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

Added: 
clang/test/CodeGen/dominating-store-infinite-cycle.c

Modified: 
clang/lib/CodeGen/CGCall.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 6a1d549c53a2..ec28c1db207a 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3461,8 +3461,9 @@ static llvm::StoreInst 
*findDominatingStoreToReturnValue(CodeGenFunction ) {
   // single-predecessors chain from the current insertion point.
   llvm::BasicBlock *StoreBB = store->getParent();
   llvm::BasicBlock *IP = CGF.Builder.GetInsertBlock();
+  llvm::SmallPtrSet SeenBBs;
   while (IP != StoreBB) {
-if (!(IP = IP->getSinglePredecessor()))
+if (!SeenBBs.insert(IP).second || !(IP = IP->getSinglePredecessor()))
   return nullptr;
   }
 

diff  --git a/clang/test/CodeGen/dominating-store-infinite-cycle.c 
b/clang/test/CodeGen/dominating-store-infinite-cycle.c
new file mode 100644
index ..cedd9be0b090
--- /dev/null
+++ b/clang/test/CodeGen/dominating-store-infinite-cycle.c
@@ -0,0 +1,33 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | 
FileCheck %s
+
+// Test for PR62830 where there are 2 infinite cycles using goto. Make sure
+// clang codegen doesn't hang.
+int a;
+
+// CHECK-LABEL: define dso_local i32 @main
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[RETVAL:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 0, ptr [[RETVAL]], align 4
+// CHECK-NEXT:br label [[L1:%.*]]
+// CHECK:   L1:
+// CHECK-NEXT:br label [[L1]]
+// CHECK:   L2:
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr @a, align 4
+// CHECK-NEXT:[[TOBOOL:%.*]] = icmp ne i32 [[TMP0]], 0
+// CHECK-NEXT:br i1 [[TOBOOL]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
+// CHECK:   if.then:
+// CHECK-NEXT:br label [[L2:%.*]]
+// CHECK:   if.end:
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[RETVAL]], align 4
+// CHECK-NEXT:ret i32 [[TMP1]]
+//
+int main() {
+L1:
+  goto L1;
+
+L2:
+  if (!a)
+goto L2;
+}



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


[PATCH] D151359: [CUDA] Relax restrictions on variadics in host-side compilation.

2023-05-24 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
Herald added subscribers: mattd, bixia, yaxunl.
Herald added a project: All.
tra published this revision for review.
tra added a reviewer: jlebar.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

D150718  allows variadics during GPU 
compilation, but we also need to do it for
the host compilation as well, as it will see the same code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151359

Files:
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4677,6 +4677,13 @@
   CmdArgs.push_back(Args.MakeArgString(
   Twine("-target-sdk-version=") +
   CudaVersionToString(CTC->CudaInstallation.version(;
+// Unsized function arguments used for variadics were introduced in
+// CUDA-9.0. We still do not support generating code that actually uses
+// variadic arguments yet, but we do need to allow parsing them as
+// recent CUDA headers rely on that.
+// https://github.com/llvm/llvm-project/issues/58410
+if (CTC->CudaInstallation.version() >= CudaVersion::CUDA_90)
+  CmdArgs.push_back("-fcuda-allow-variadic-functions");
   }
 }
 CmdArgs.push_back("-aux-triple");


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4677,6 +4677,13 @@
   CmdArgs.push_back(Args.MakeArgString(
   Twine("-target-sdk-version=") +
   CudaVersionToString(CTC->CudaInstallation.version(;
+// Unsized function arguments used for variadics were introduced in
+// CUDA-9.0. We still do not support generating code that actually uses
+// variadic arguments yet, but we do need to allow parsing them as
+// recent CUDA headers rely on that.
+// https://github.com/llvm/llvm-project/issues/58410
+if (CTC->CudaInstallation.version() >= CudaVersion::CUDA_90)
+  CmdArgs.push_back("-fcuda-allow-variadic-functions");
   }
 }
 CmdArgs.push_back("-aux-triple");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150996: LLVM_FALLTHROUGH => [[fallthrough]]. NFC

2023-05-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150996

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


[PATCH] D151145: Add disabled unittest reproducing TextProto formatting issue.

2023-05-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

We don't normally land broken tests, even if they are disabled, its better for 
us if we get a fix at the same time ;-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151145

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


[PATCH] D151162: Add -Wpacked-non-pod to -Wall

2023-05-24 Thread Zenong Zhang via Phabricator via cfe-commits
SlaterLatiao added inline comments.



Comment at: clang/test/CodeGenCXX/warn-padded-packed.cpp:5
+// RUN: %clang_cc1 -triple=x86_64-none-none -Wpacked-non-pod -verify=top %s 
-emit-llvm-only
+// RUN: %clang_cc1 -triple=x86_64-none-none -Wpacked-non-pod 
-fclang-abi-compat=15 %s -emit-llvm-only
+

denik wrote:
> Probably we don't need this one. But I'm not sure if there is any impact of 
> the abi on`packed-non-pod`. According to the original test it checks only 
> `-Wpacked` `packed attribute is unnecessary` warning.
I added this line to make sure all the `packed attribute is unnecessary` 
warnings in the existing test of  `-Wpacked` are not reported by  
`-Wpacked-non-pod`. Yeah if the abi doesn't have any impact on 
`-Wpacked-non-pod` this test is unnecessary. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151162

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


[PATCH] D151243: [CUDA] Fix wrappers for sm_80 functions

2023-05-24 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG29cb080c363d: [CUDA] Fix wrappers for sm_80 functions 
(authored by tra).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151243

Files:
  clang/lib/Headers/__clang_cuda_intrinsics.h

Index: clang/lib/Headers/__clang_cuda_intrinsics.h
===
--- clang/lib/Headers/__clang_cuda_intrinsics.h
+++ clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -512,70 +512,63 @@
 __device__ inline cuuint32_t __nvvm_get_smem_pointer(void *__ptr) {
   return __nv_cvta_generic_to_shared_impl(__ptr);
 }
+} // extern "C"
 
 #if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 800
-__device__ inline unsigned __reduce_add_sync_unsigned_impl(unsigned __mask,
-   unsigned __value) {
-  return __nvvm_redux_sync_add(__mask, __value);
-}
-__device__ inline int __reduce_add_sync_signed_impl(unsigned __mask,
-int __value) {
+__device__ inline unsigned __reduce_add_sync(unsigned __mask,
+ unsigned __value) {
   return __nvvm_redux_sync_add(__mask, __value);
 }
-__device__ inline unsigned __reduce_min_sync_unsigned_impl(unsigned __mask,
-   unsigned __value) {
+__device__ inline unsigned __reduce_min_sync(unsigned __mask,
+ unsigned __value) {
   return __nvvm_redux_sync_umin(__mask, __value);
 }
-__device__ inline unsigned __reduce_max_sync_unsigned_impl(unsigned __mask,
-   unsigned __value) {
+__device__ inline unsigned __reduce_max_sync(unsigned __mask,
+ unsigned __value) {
   return __nvvm_redux_sync_umax(__mask, __value);
 }
-__device__ inline int __reduce_min_sync_signed_impl(unsigned __mask,
-int __value) {
+__device__ inline int __reduce_min_sync(unsigned __mask, int __value) {
   return __nvvm_redux_sync_min(__mask, __value);
 }
-__device__ inline int __reduce_max_sync_signed_impl(unsigned __mask,
-int __value) {
+__device__ inline int __reduce_max_sync(unsigned __mask, int __value) {
   return __nvvm_redux_sync_max(__mask, __value);
 }
-__device__ inline unsigned __reduce_or_sync_unsigned_impl(unsigned __mask,
-  unsigned __value) {
+__device__ inline unsigned __reduce_or_sync(unsigned __mask, unsigned __value) {
   return __nvvm_redux_sync_or(__mask, __value);
 }
-__device__ inline unsigned __reduce_and_sync_unsigned_impl(unsigned __mask,
-   unsigned __value) {
+__device__ inline unsigned __reduce_and_sync(unsigned __mask,
+ unsigned __value) {
   return __nvvm_redux_sync_and(__mask, __value);
 }
-__device__ inline unsigned __reduce_xor_sync_unsigned_impl(unsigned __mask,
-   unsigned __value) {
+__device__ inline unsigned __reduce_xor_sync(unsigned __mask,
+ unsigned __value) {
   return __nvvm_redux_sync_xor(__mask, __value);
 }
 
-__device__ inline void
-__nv_memcpy_async_shared_global_4_impl(void *__dst, const void *__src,
-   unsigned __src_size) {
+__device__ inline void __nv_memcpy_async_shared_global_4(void *__dst,
+ const void *__src,
+ unsigned __src_size) {
   __nvvm_cp_async_ca_shared_global_4(
   (void __attribute__((address_space(3))) *)__dst,
   (const void __attribute__((address_space(1))) *)__src, __src_size);
 }
-__device__ inline void
-__nv_memcpy_async_shared_global_8_impl(void *__dst, const void *__src,
-   unsigned __src_size) {
+__device__ inline void __nv_memcpy_async_shared_global_8(void *__dst,
+ const void *__src,
+ unsigned __src_size) {
   __nvvm_cp_async_ca_shared_global_8(
   (void __attribute__((address_space(3))) *)__dst,
   (const void __attribute__((address_space(1))) *)__src, __src_size);
 }
-__device__ inline void
-__nv_memcpy_async_shared_global_16_impl(void *__dst, const void *__src,
-unsigned __src_size) {
+__device__ inline void __nv_memcpy_async_shared_global_16(void *__dst,
+  const void *__src,
+  

[clang] 29cb080 - [CUDA] Fix wrappers for sm_80 functions

2023-05-24 Thread Artem Belevich via cfe-commits

Author: Artem Belevich
Date: 2023-05-24T11:48:39-07:00
New Revision: 29cb080c363d655ab1179a5564f1a82460e49a06

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

LOG: [CUDA] Fix wrappers for sm_80 functions

Previous implementation provided wrappers for the internal implementations used
by CUDA headers. However, clang does not include those, so we need to provide
the public functions instead.

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

Added: 


Modified: 
clang/lib/Headers/__clang_cuda_intrinsics.h

Removed: 




diff  --git a/clang/lib/Headers/__clang_cuda_intrinsics.h 
b/clang/lib/Headers/__clang_cuda_intrinsics.h
index d085bf6536efc..43ed3d77a101e 100644
--- a/clang/lib/Headers/__clang_cuda_intrinsics.h
+++ b/clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -512,70 +512,63 @@ __device__ inline void 
*__nv_cvta_local_to_generic_impl(size_t __ptr) {
 __device__ inline cuuint32_t __nvvm_get_smem_pointer(void *__ptr) {
   return __nv_cvta_generic_to_shared_impl(__ptr);
 }
+} // extern "C"
 
 #if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 800
-__device__ inline unsigned __reduce_add_sync_unsigned_impl(unsigned __mask,
-   unsigned __value) {
-  return __nvvm_redux_sync_add(__mask, __value);
-}
-__device__ inline int __reduce_add_sync_signed_impl(unsigned __mask,
-int __value) {
+__device__ inline unsigned __reduce_add_sync(unsigned __mask,
+ unsigned __value) {
   return __nvvm_redux_sync_add(__mask, __value);
 }
-__device__ inline unsigned __reduce_min_sync_unsigned_impl(unsigned __mask,
-   unsigned __value) {
+__device__ inline unsigned __reduce_min_sync(unsigned __mask,
+ unsigned __value) {
   return __nvvm_redux_sync_umin(__mask, __value);
 }
-__device__ inline unsigned __reduce_max_sync_unsigned_impl(unsigned __mask,
-   unsigned __value) {
+__device__ inline unsigned __reduce_max_sync(unsigned __mask,
+ unsigned __value) {
   return __nvvm_redux_sync_umax(__mask, __value);
 }
-__device__ inline int __reduce_min_sync_signed_impl(unsigned __mask,
-int __value) {
+__device__ inline int __reduce_min_sync(unsigned __mask, int __value) {
   return __nvvm_redux_sync_min(__mask, __value);
 }
-__device__ inline int __reduce_max_sync_signed_impl(unsigned __mask,
-int __value) {
+__device__ inline int __reduce_max_sync(unsigned __mask, int __value) {
   return __nvvm_redux_sync_max(__mask, __value);
 }
-__device__ inline unsigned __reduce_or_sync_unsigned_impl(unsigned __mask,
-  unsigned __value) {
+__device__ inline unsigned __reduce_or_sync(unsigned __mask, unsigned __value) 
{
   return __nvvm_redux_sync_or(__mask, __value);
 }
-__device__ inline unsigned __reduce_and_sync_unsigned_impl(unsigned __mask,
-   unsigned __value) {
+__device__ inline unsigned __reduce_and_sync(unsigned __mask,
+ unsigned __value) {
   return __nvvm_redux_sync_and(__mask, __value);
 }
-__device__ inline unsigned __reduce_xor_sync_unsigned_impl(unsigned __mask,
-   unsigned __value) {
+__device__ inline unsigned __reduce_xor_sync(unsigned __mask,
+ unsigned __value) {
   return __nvvm_redux_sync_xor(__mask, __value);
 }
 
-__device__ inline void
-__nv_memcpy_async_shared_global_4_impl(void *__dst, const void *__src,
-   unsigned __src_size) {
+__device__ inline void __nv_memcpy_async_shared_global_4(void *__dst,
+ const void *__src,
+ unsigned __src_size) {
   __nvvm_cp_async_ca_shared_global_4(
   (void __attribute__((address_space(3))) *)__dst,
   (const void __attribute__((address_space(1))) *)__src, __src_size);
 }
-__device__ inline void
-__nv_memcpy_async_shared_global_8_impl(void *__dst, const void *__src,
-   unsigned __src_size) {
+__device__ inline void __nv_memcpy_async_shared_global_8(void *__dst,
+ const void *__src,
+ unsigned __src_size) {
   __nvvm_cp_async_ca_shared_global_8(
 

[PATCH] D151298: [clang][LoongArch] Fix the calling convention for empty struct in C++ mode

2023-05-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

As far as I'm concerned as editor of the Itanium ABI, the ABI treatment of 
trivial-for-the-purposes-of-calls classes is purely a psABI matter, and the 
Itanium ABI's wording around empty classes is merely a suggestion if the psABI 
doesn't have more specific rules (because empty structs are normally invalid in 
C).  Do what you think is best for your ABI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151298

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


[PATCH] D151076: [IRGen] Handle infinite cycles in findDominatingStoreToReturnValue.

2023-05-24 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.

Nice catch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151076

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


[PATCH] D148700: [clang] Add support for “regular” keyword attributes

2023-05-24 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! Thank you for your patience while we worked through the design details. 
:-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148700

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


[PATCH] D151162: Add -Wpacked-non-pod to -Wall

2023-05-24 Thread Zenong Zhang via Phabricator via cfe-commits
SlaterLatiao updated this revision to Diff 525280.
SlaterLatiao added a comment.

- Removed the -triple flag from warn-padded-packed testcase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151162

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/test/CodeGenCXX/warn-padded-packed.cpp
  clang/test/Misc/warning-wall.c


Index: clang/test/Misc/warning-wall.c
===
--- clang/test/Misc/warning-wall.c
+++ clang/test/Misc/warning-wall.c
@@ -99,6 +99,7 @@
 CHECK-NEXT:  -Wswitch
 CHECK-NEXT:  -Wswitch-bool
 CHECK-NEXT:  -Wmisleading-indentation
+CHECK-NEXT:  -Wpacked-non-pod
 
 
 CHECK-NOT:-W
Index: clang/test/CodeGenCXX/warn-padded-packed.cpp
===
--- clang/test/CodeGenCXX/warn-padded-packed.cpp
+++ clang/test/CodeGenCXX/warn-padded-packed.cpp
@@ -1,5 +1,9 @@
-// RUN: %clang_cc1 -triple=x86_64-none-none -Wpadded -Wpacked 
-verify=expected,top %s -emit-llvm-only
-// RUN: %clang_cc1 -triple=x86_64-none-none -Wpadded -Wpacked 
-verify=expected,abi15 -fclang-abi-compat=15 %s -emit-llvm-only
+// RUN: %clang_cc1 -Wpadded -Wpacked -verify=expected,top %s -emit-llvm-only
+// RUN: %clang_cc1 -Wpadded -Wpacked -verify=expected,abi15 
-fclang-abi-compat=15 %s -emit-llvm-only
+// -Wpacked-non-pod itself should not emit the "packed attribute is 
unnecessary" warnings.
+// RUN: %clang_cc1 -Wpacked-non-pod -verify=top %s -emit-llvm-only
+// RUN: %clang_cc1 -Wpacked-non-pod -fclang-abi-compat=15 %s -emit-llvm-only
+
 
 struct S1 {
   char c;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1060,7 +1060,7 @@
 // warning should be active _only_ when -Wall is passed in, mark it as
 // DefaultIgnore in addition to putting it here.
 def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool,
-MisleadingIndentation]>;
+MisleadingIndentation, PackedNonPod]>;
 
 // Warnings that should be in clang-cl /w4.
 def : DiagGroup<"CL4", [All, Extra]>;


Index: clang/test/Misc/warning-wall.c
===
--- clang/test/Misc/warning-wall.c
+++ clang/test/Misc/warning-wall.c
@@ -99,6 +99,7 @@
 CHECK-NEXT:  -Wswitch
 CHECK-NEXT:  -Wswitch-bool
 CHECK-NEXT:  -Wmisleading-indentation
+CHECK-NEXT:  -Wpacked-non-pod
 
 
 CHECK-NOT:-W
Index: clang/test/CodeGenCXX/warn-padded-packed.cpp
===
--- clang/test/CodeGenCXX/warn-padded-packed.cpp
+++ clang/test/CodeGenCXX/warn-padded-packed.cpp
@@ -1,5 +1,9 @@
-// RUN: %clang_cc1 -triple=x86_64-none-none -Wpadded -Wpacked -verify=expected,top %s -emit-llvm-only
-// RUN: %clang_cc1 -triple=x86_64-none-none -Wpadded -Wpacked -verify=expected,abi15 -fclang-abi-compat=15 %s -emit-llvm-only
+// RUN: %clang_cc1 -Wpadded -Wpacked -verify=expected,top %s -emit-llvm-only
+// RUN: %clang_cc1 -Wpadded -Wpacked -verify=expected,abi15 -fclang-abi-compat=15 %s -emit-llvm-only
+// -Wpacked-non-pod itself should not emit the "packed attribute is unnecessary" warnings.
+// RUN: %clang_cc1 -Wpacked-non-pod -verify=top %s -emit-llvm-only
+// RUN: %clang_cc1 -Wpacked-non-pod -fclang-abi-compat=15 %s -emit-llvm-only
+
 
 struct S1 {
   char c;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1060,7 +1060,7 @@
 // warning should be active _only_ when -Wall is passed in, mark it as
 // DefaultIgnore in addition to putting it here.
 def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool,
-MisleadingIndentation]>;
+MisleadingIndentation, PackedNonPod]>;
 
 // Warnings that should be in clang-cl /w4.
 def : DiagGroup<"CL4", [All, Extra]>;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151162: Add -Wpacked-non-pod to -Wall

2023-05-24 Thread Denis Nikitin via Phabricator via cfe-commits
denik added inline comments.



Comment at: clang/test/CodeGenCXX/warn-padded-packed.cpp:4
+// -Wpacked-non-pod itself should not emit the "packed attribute is 
unnecessary" warnings.
+// RUN: %clang_cc1 -triple=x86_64-none-none -Wpacked-non-pod -verify=top %s 
-emit-llvm-only
+// RUN: %clang_cc1 -triple=x86_64-none-none -Wpacked-non-pod 
-fclang-abi-compat=15 %s -emit-llvm-only

This one is a very neat test. I think it does what we want :)



Comment at: clang/test/CodeGenCXX/warn-padded-packed.cpp:5
+// RUN: %clang_cc1 -triple=x86_64-none-none -Wpacked-non-pod -verify=top %s 
-emit-llvm-only
+// RUN: %clang_cc1 -triple=x86_64-none-none -Wpacked-non-pod 
-fclang-abi-compat=15 %s -emit-llvm-only
+

Probably we don't need this one. But I'm not sure if there is any impact of the 
abi on`packed-non-pod`. According to the original test it checks only 
`-Wpacked` `packed attribute is unnecessary` warning.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151162

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


[PATCH] D150875: Make dereferencing a void* a hard-error instead of warn-as-error

2023-05-24 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfca4e2add0f8: Make dereferencing a void* a hard-error 
instead of warn-as-error (authored by erichkeane).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150875

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp
  clang/test/SemaCXX/decl-expr-ambiguity.cpp
  clang/test/SemaCXX/disallow_void_deref.cpp
  clang/test/SemaCXX/reinterpret-cast.cpp

Index: clang/test/SemaCXX/reinterpret-cast.cpp
===
--- clang/test/SemaCXX/reinterpret-cast.cpp
+++ clang/test/SemaCXX/reinterpret-cast.cpp
@@ -214,11 +214,11 @@
   (void)*reinterpret_cast(v_ptr);
 
   // Casting to void pointer
-  (void)*reinterpret_cast(); // expected-error {{ISO C++ does not allow}}
-  (void)*reinterpret_cast(); // expected-error {{ISO C++ does not allow}}
-  (void)*reinterpret_cast(); // expected-error {{ISO C++ does not allow}}
-  (void)*reinterpret_cast(); // expected-error {{ISO C++ does not allow}}
-  (void)*reinterpret_cast(); // expected-error {{ISO C++ does not allow}}
+  (void)*reinterpret_cast(); // expected-error {{indirection not permitted on operand of type 'void *'}}
+  (void)*reinterpret_cast(); // expected-error {{indirection not permitted on operand of type 'void *'}}
+  (void)*reinterpret_cast(); // expected-error {{indirection not permitted on operand of type 'void *'}}
+  (void)*reinterpret_cast(); // expected-error {{indirection not permitted on operand of type 'void *'}}
+  (void)*reinterpret_cast(); // expected-error {{indirection not permitted on operand of type 'void *'}}
 }
 
 void reinterpret_cast_allowlist () {
Index: clang/test/SemaCXX/disallow_void_deref.cpp
===
--- clang/test/SemaCXX/disallow_void_deref.cpp
+++ clang/test/SemaCXX/disallow_void_deref.cpp
@@ -1,8 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify=enabled,sfinae -std=c++20 %s
-// RUN: %clang_cc1 -fsyntax-only -verify=sfinae -std=c++20 -Wno-void-ptr-dereference %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
 
 void f(void* p) {
-  (void)*p; // enabled-error{{ISO C++ does not allow indirection on operand of type 'void *'}}
+  (void)*p; // expected-error{{indirection not permitted on operand of type 'void *'}}
 }
 
 template
@@ -11,6 +10,6 @@
 };
 
 static_assert(deref);
-// sfinae-error@-1{{static assertion failed}}
-// sfinae-note@-2{{because 'void *' does not satisfy 'deref'}}
-// sfinae-note@#FAILED_REQ{{because '*t' would be invalid: ISO C++ does not allow indirection on operand of type 'void *'}}
+// expected-error@-1{{static assertion failed}}
+// expected-note@-2{{because 'void *' does not satisfy 'deref'}}
+// expected-note@#FAILED_REQ{{because '*t' would be invalid: indirection not permitted on operand of type 'void *'}}
Index: clang/test/SemaCXX/decl-expr-ambiguity.cpp
===
--- clang/test/SemaCXX/decl-expr-ambiguity.cpp
+++ clang/test/SemaCXX/decl-expr-ambiguity.cpp
@@ -35,7 +35,7 @@
   extern T f3();
   __typeof(*T()) f4(); // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
   typedef void *V;
-  __typeof(*V()) f5(); // expected-error {{ISO C++ does not allow indirection on operand of type 'V' (aka 'void *')}}
+  __typeof(*V()) f5(); // expected-error {{indirection not permitted on operand of type 'V' (aka 'void *')}}
   T multi1,
 multi2(); // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
   T(d)[5]; // expected-error {{redefinition of 'd'}}
Index: clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp
+++ clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp
@@ -8,7 +8,7 @@
 
 template
 void X0::f(T *t, const U ) {
-  *t = u; // expected-error{{indirection on operand of type 'void *'}} expected-error{{not assignable}}
+  *t = u; // expected-error{{indirection not permitted on operand of type 'void *'}} expected-error{{not assignable}}
 }
 
 void test_f(X0 xfi, X0 xvi, float *fp, void *vp, int i) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -14957,7 +14957,7 @@
 //   be a pointer to an object type, or a pointer to a function type
 LangOptions LO = S.getLangOpts();
 if (LO.CPlusPlus)
-  S.Diag(OpLoc, 

[clang] fca4e2a - Make dereferencing a void* a hard-error instead of warn-as-error

2023-05-24 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2023-05-24T11:27:13-07:00
New Revision: fca4e2add0f8b0471e4dbae5cf647006ec360bb2

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

LOG: Make dereferencing a void* a hard-error instead of warn-as-error

Clang 16 changed to consider dereferencing a void* to be a
warning-as-error, plus made this an error in SFINAE contexts, since this
resulted in incorrect template instantiation.  When doing so, the Clang
16 documentation was updated to reflect that this was likely to change
again to a non-disablable error in the next version.

As there has been no response to changing from a warning to an error, I
believe this is a non-controversial change.

This patch changes this to be an Error, consistent with the standard and
other compilers.

This was discussed in this RFC:
https://discourse.llvm.org/t/rfc-can-we-stop-the-extension-to-allow-dereferencing-void-in-c/65708

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaExpr.cpp
clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp
clang/test/SemaCXX/decl-expr-ambiguity.cpp
clang/test/SemaCXX/disallow_void_deref.cpp
clang/test/SemaCXX/reinterpret-cast.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 53bc6b6c00270..0075f94e344ee 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -60,6 +60,10 @@ C++ Specific Potentially Breaking Changes
 -
 - Clang won't search for coroutine_traits in std::experimental namespace any 
more.
   Clang will only search for std::coroutine_traits for coroutines then.
+- Clang no longer allows dereferencing of a ``void *`` as an extension. Clang 
16
+  converted this to a default-error as ``-Wvoid-ptr-dereference``, as well as a
+  SFINAE error. This flag is still valid however, as it disables the equivalent
+  warning in C.
 
 ABI Changes in This Version
 ---

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 0cbc2fc8c8949..f203ac6c2a84e 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6981,9 +6981,8 @@ def err_typecheck_indirection_requires_pointer : Error<
 def ext_typecheck_indirection_through_void_pointer : ExtWarn<
   "ISO C does not allow indirection on operand of type %0">,
   InGroup;
-def ext_typecheck_indirection_through_void_pointer_cpp
-: ExtWarn<"ISO C++ does not allow indirection on operand of type %0">,
-  InGroup, DefaultError, SFINAEFailure;
+def err_typecheck_indirection_through_void_pointer_cpp
+: Error<"indirection not permitted on operand of type %0">;
 def warn_indirection_through_null : Warning<
   "indirection of non-volatile null pointer will be deleted, not trap">,
   InGroup;

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index ac0b2ad6eb7ee..fb55c95bd0689 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -14957,7 +14957,7 @@ static QualType CheckIndirectionOperand(Sema , Expr 
*Op, ExprValueKind ,
 //   be a pointer to an object type, or a pointer to a function type
 LangOptions LO = S.getLangOpts();
 if (LO.CPlusPlus)
-  S.Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer_cpp)
+  S.Diag(OpLoc, diag::err_typecheck_indirection_through_void_pointer_cpp)
   << OpTy << Op->getSourceRange();
 else if (!(LO.C99 && IsAfterAmp) && !S.isUnevaluatedContext())
   S.Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)

diff  --git 
a/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp 
b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp
index 6d591457ae149..9b570202b0635 100644
--- a/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp
+++ b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp
@@ -8,7 +8,7 @@ struct X0 {
 
 template
 void X0::f(T *t, const U ) {
-  *t = u; // expected-error{{indirection on operand of type 'void *'}} 
expected-error{{not assignable}}
+  *t = u; // expected-error{{indirection not permitted on operand of type 
'void *'}} expected-error{{not assignable}}
 }
 
 void test_f(X0 xfi, X0 xvi, float *fp, void *vp, int i) 
{

diff  --git a/clang/test/SemaCXX/decl-expr-ambiguity.cpp 
b/clang/test/SemaCXX/decl-expr-ambiguity.cpp
index a15ec397b4aed..89265494a0dd3 100644
--- a/clang/test/SemaCXX/decl-expr-ambiguity.cpp
+++ b/clang/test/SemaCXX/decl-expr-ambiguity.cpp
@@ -35,7 +35,7 @@ void f() {
   extern T f3();
   __typeof(*T()) 

[PATCH] D151162: Add -Wpacked-non-pod to -Wall

2023-05-24 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb accepted this revision.
cjdb added a comment.
This revision is now accepted and ready to land.

Thanks for working on this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151162

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


[PATCH] D147844: [clang][Sema]Print diagnostic warning about precedence when integer expression is used without parentheses in an conditional operator expression

2023-05-24 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

yeah, doesn't look like it found any bugs there (the `arrow` one seems the most 
non-trivwial, but I'm guessing the code as-is is correct), so seems a bit 
questionable as an addition

But @aaron.ballman if you figure this falls more under the "minor tweak to 
existing diagnostic" I won't stand in the way of it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147844

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


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

2023-05-24 Thread Aiden Grossman via Phabricator via cfe-commits
aidengrossman added a comment.

Do you have any more information? Do you have your own implementation of 
`__cpuidex` somewhere else before including `cpuid.h`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150646

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


[clang] 2daf91d - Fix shared library build again from 1c9a800. NFC

2023-05-24 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2023-05-24T14:09:38-04:00
New Revision: 2daf91dae3bc25d2ffb869d9781d9f4496a27d02

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

LOG: Fix shared library build again from 1c9a800. NFC

Added: 


Modified: 
clang/unittests/Serialization/CMakeLists.txt

Removed: 




diff  --git a/clang/unittests/Serialization/CMakeLists.txt 
b/clang/unittests/Serialization/CMakeLists.txt
index 6b82ad91e5ec..44e4ecb31436 100644
--- a/clang/unittests/Serialization/CMakeLists.txt
+++ b/clang/unittests/Serialization/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS
   BitReader
   BitstreamReader
+  FrontendOpenMP
   Support
   )
 



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


[PATCH] D150913: [Clang][Bfloat16] Upgrade __bf16 to arithmetic type, change mangling, and extend excess precision support.

2023-05-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:852
 ``double`` when passed to ``printf``, so the programmer must explicitly cast 
it to
 ``double`` before using it with an ``%f`` or similar specifier.
 

pengfei wrote:
> rjmccall wrote:
> > Suggested rework:
> > 
> > ```
> > Clang supports three half-precision (16-bit) floating point types: 
> > ``__fp16``,
> > ``_Float16`` and ``__bf16``.  These types are supported in all language
> > modes, but not on all targets:
> > 
> > - ``__fp16`` is supported on every target.
> > 
> > - ``_Float16`` is currently supported on the following targets:
> >   * 32-bit ARM (natively on some architecture versions)
> >   * 64-bit ARM (AArch64) (natively on ARMv8.2a and above)
> >   * AMDGPU (natively)
> >   * SPIR (natively)
> >   * X86 (if SSE2 is available; natively if AVX512-FP16 is also available)
> > 
> > - ``__bf16`` is currently supported on the following targets:
> >   * 32-bit ARM
> >   * 64-bit ARM (AArch64)
> >   * X86 (when SSE2 is available)
> > 
> > (For X86, SSE2 is available on 64-bit and all recent 32-bit processors.)
> > 
> > ``__fp16`` and ``_Float16`` both use the binary16 format from IEEE
> > 754-2008, which provides a 5-bit exponent and an 11-bit significand
> > (counting the implicit leading 1).  ``__bf16`` uses the `bfloat16
> > `_ format,
> > which provides an 8-bit exponent and an 8-bit significand; this is the same
> > exponent range as `float`, just with greatly reduced precision.
> > 
> > ``_Float16`` and ``__bf16`` follow the usual rules for arithmetic
> > floating-point types.  Most importantly, this means that arithmetic 
> > operations
> > on operands of these types are formally performed in the type and produce
> > values of the type.  ``__fp16`` does not follow those rules: most operations
> > immediately promote operands of type ``__fp16`` to ``float``, and so
> > arithmetic operations are defined to be performed in ``float`` and so 
> > result in
> > a value of type ``float`` (unless further promoted because of other 
> > operands).
> > See below for more information on the exact specifications of these types.
> > 
> > Only some of the supported processors for ``__fp16`` and ``__bf16`` offer
> > native hardware support for arithmetic in their corresponding formats.
> > The exact conditions are described in the lists above.  When compiling for a
> > processor without native support, Clang will perform the arithmetic in
> > ``float``, inserting extensions and truncations as necessary.  This can be
> > done in a way that exactly emulates the behavior of hardware support for
> > arithmetic, but it can require many extra operations.  By default, Clang 
> > takes
> > advantage of the C standard's allowances for excess precision in 
> > intermediate
> > operands in order to eliminate intermediate truncations within statements.
> > This is generally much faster but can generate different results from strict
> > operation-by-operation emulation.
> > 
> > The use of excess precision can be independently controlled for these two
> > types with the ``-ffloat16-excess-precision=`` and
> > ``-fbfloat16-excess-precision=`` options.  Valid values include:
> > - ``none`` (meaning to perform strict operation-by-operation emulation)
> > - ``standard`` (meaning that excess precision is permitted under the rules
> >   described in the standard, i.e. never across explicit casts or statements)
> > - ``fast`` (meaning that excess precision is permitted whenever the
> >   optimizer sees an opportunity to avoid truncations; currently this has no
> >   effect beyond ``standard``)
> > 
> > The ``_Float16`` type is an interchange floating type specified in
> >  ISO/IEC TS 18661-3:2015 ("Floating-point extensions for C").  It will
> > be supported on more targets as they define ABIs for it.
> > 
> > The ``__bf16`` type is a non-standard extension, but it generally follows
> > the rules for arithmetic interchange floating types from ISO/IEC TS
> > 18661-3:2015.  In previous versions of Clang, it was a storage-only type
> > that forbade arithmetic operations.  It will be supported on more targets
> > as they define ABIs for it.
> > 
> > The ``__fp16`` type was originally an ARM extension and is specified
> > by the `ARM C Language Extensions 
> > `_.
> > Clang uses the ``binary16`` format from IEEE 754-2008 for ``__fp16``,
> > not the ARM alternative format.  Operators that expect arithmetic operands
> > immediately promote ``__fp16`` operands to ``float``.
> > 
> > It is recommended that portable code use ``_Float16`` instead of ``__fp16``,
> > as it has been defined by the C standards committee and has behavior that is
> > more familiar to most programmers.
> > 
> > Because ``__fp16`` operands are always immediately promoted to ``float``, 
> > the
> > common real type of ``__fp16`` and 

[PATCH] D150985: [clang] Allow fp in atomic fetch max/min builtins

2023-05-24 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

As I said, I'm OK with the patch in principle, I just don't know what other 
factors I may be missing.

Tests seem to be missing for c11 variants of the builtins.




Comment at: clang/test/Sema/atomic-ops.c:209
+  __atomic_fetch_min(D, 3, memory_order_seq_cst);
+  __atomic_fetch_max(P, 3, memory_order_seq_cst);
   __atomic_fetch_max(p, 3);   // expected-error {{too few 
arguments to function call, expected 3, have 2}}

Is that intentional that we now allow atomic max on a `int **P` ? My 
understanding that we were supposed to allow additional FP types only.



Comment at: clang/test/SemaOpenCL/atomic-ops.cl:65
+  __opencl_atomic_fetch_min(f, 1, memory_order_seq_cst, 
memory_scope_work_group);
+  __opencl_atomic_fetch_max(f, 1, memory_order_seq_cst, 
memory_scope_work_group);
 

We probably want to add tests for `double`, too.


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

https://reviews.llvm.org/D150985

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


[PATCH] D151186: [Driver] Properly handle -pie and -nopie on Fuchsia

2023-05-24 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D151186#4369203 , @MaskRay wrote:

> In D151186#4369181 , @phosek wrote:
>
>> That alias is already recognized by the GNU driver. I'm sharing the 
>> implementation between the two drivers. Would you prefer to reject `-nopie` 
>> when targeting Fuchsia?
>
> Hmm, handling `OPT_nopie` in `clang/lib/Driver/ToolChains/Gnu.cpp` looks like 
> a mistake. We should reject it for Gnu.cpp...

I can send a separate change for that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151186

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


  1   2   3   >