[PATCH] D130894: [clang] Print more information about failed static assertions

2022-08-05 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

Thank you so much for working on this! It's been on my todo list for a while 
and just haven't gotten around to it.

In D130894#3702166 , @aaron.ballman 
wrote:

> In D130894#3701749 , @tbaeder wrote:
>
>> For the record, the output now looks something like this:
>>
>>   test.cpp:24:1: error: static assertion failed due to requirement 'c != c'
>>   static_assert(c != c);
>>   ^ ~~
>>   test.cpp:24:17: note: expression evaluates to '('0' != '0')'
>>   static_assert(c != c);
>> ~~^~~~
>
> This looks hard to read to me...
>
>> test.cpp:25:1: error: static assertion failed due to requirement 'c > 'a''
>> static_assert(c > 'a');
>> ^ ~~~
>> test.cpp:25:17: note: expression evaluates to '('0' > 'a')'
>
> Same confusion here -- it took me a while to realize what's happening is that 
> we're quoting the part outside of the parens and that's throwing me for a 
> loop. We typically quote things that are syntax but in this case, the parens 
> are not part of the syntax and so the surrounding quotes are catching me. 
> Given that parens are being used as a visual delimiter and a single quote 
> serves the same purpose, I would expect something more like:
>
>   test.cpp:25:17: note: expression evaluates to ''0' > 'a''
>   test.cpp:26:17: note: expression evaluates to '0 > 'a''
>   test.cpp:27:17: note: expression evaluates to '14 > 5'
>   test.cpp:28:17: note: expression evaluates to 'true == false'
>   test.cpp:29:17: note: expression evaluates to 'nullptr != nullptr'
>
> Adding a few more folks as reviewers to see if there is a consensus position 
> on how to proceed.

Agreed on confusion, but `''0' > 'a''` is painful to read. Sadly, short of 
changing quotes to backticks (something that'd be good for non-terminal-based 
consumers of SARIF), I'm not sure I can suggest anything better in one line. If 
we can span multiple lines, which I think would improve readability:

  test.cpp:25:17: note: expression evaluates with:
LHS: '0'
RHS: 'a'
  test.cpp:26:17: note: expression evaluates with:
LHS: 0
RHS: 'a'
  test.cpp:27:17: note: expression evaluates with:
LHS: 14
RHS: 5
  test.cpp:28:17: note: expression evaluates with:
LHS: true
RHS: false
  test.cpp:29:17: note: expression evaluates with:
LHS: nullptr
RHS: nullptr

My assertion library follows what Catch2 and simple-test do, and uses `Actual` 
and `Expected`, but I'm not sure hardcoding those terms into Clang is a good 
idea.


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

https://reviews.llvm.org/D130894

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


[PATCH] D131265: Fixed sm version for .and bmma operator.

2022-08-05 Thread Jack Kirk via Phabricator via cfe-commits
JackAKirk created this revision.
JackAKirk added a reviewer: tra.
Herald added subscribers: mattd, gchakrabarti, asavonic.
Herald added a project: All.
JackAKirk requested review of this revision.
Herald added subscribers: cfe-commits, jholewinski.
Herald added a project: clang.

As stated here 
(https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-instructions-wmma-mma):

".and operation in single-bit wmma requires sm_80 or higher."


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131265

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def


Index: clang/include/clang/Basic/BuiltinsNVPTX.def
===
--- clang/include/clang/Basic/BuiltinsNVPTX.def
+++ clang/include/clang/Basic/BuiltinsNVPTX.def
@@ -853,7 +853,7 @@
 TARGET_BUILTIN(__bmma_m8n8k128_ld_a_b1, "vi*iC*UiIi", "", AND(SM_75,PTX63))
 TARGET_BUILTIN(__bmma_m8n8k128_ld_b_b1, "vi*iC*UiIi", "", AND(SM_75,PTX63))
 TARGET_BUILTIN(__bmma_m8n8k128_ld_c, "vi*iC*UiIi", "", AND(SM_75,PTX63))
-TARGET_BUILTIN(__bmma_m8n8k128_mma_and_popc_b1, "vi*iC*iC*iC*Ii", "", 
AND(SM_75,PTX71))
+TARGET_BUILTIN(__bmma_m8n8k128_mma_and_popc_b1, "vi*iC*iC*iC*Ii", "", 
AND(SM_80,PTX71))
 TARGET_BUILTIN(__bmma_m8n8k128_mma_xor_popc_b1, "vi*iC*iC*iC*Ii", "", 
AND(SM_75,PTX63))
 TARGET_BUILTIN(__bmma_m8n8k128_st_c_i32, "vi*iC*UiIi", "", AND(SM_75,PTX63))
 TARGET_BUILTIN(__imma_m16n16k16_ld_a_s8, "vi*iC*UiIi", "", AND(SM_72,PTX63))


Index: clang/include/clang/Basic/BuiltinsNVPTX.def
===
--- clang/include/clang/Basic/BuiltinsNVPTX.def
+++ clang/include/clang/Basic/BuiltinsNVPTX.def
@@ -853,7 +853,7 @@
 TARGET_BUILTIN(__bmma_m8n8k128_ld_a_b1, "vi*iC*UiIi", "", AND(SM_75,PTX63))
 TARGET_BUILTIN(__bmma_m8n8k128_ld_b_b1, "vi*iC*UiIi", "", AND(SM_75,PTX63))
 TARGET_BUILTIN(__bmma_m8n8k128_ld_c, "vi*iC*UiIi", "", AND(SM_75,PTX63))
-TARGET_BUILTIN(__bmma_m8n8k128_mma_and_popc_b1, "vi*iC*iC*iC*Ii", "", AND(SM_75,PTX71))
+TARGET_BUILTIN(__bmma_m8n8k128_mma_and_popc_b1, "vi*iC*iC*iC*Ii", "", AND(SM_80,PTX71))
 TARGET_BUILTIN(__bmma_m8n8k128_mma_xor_popc_b1, "vi*iC*iC*iC*Ii", "", AND(SM_75,PTX63))
 TARGET_BUILTIN(__bmma_m8n8k128_st_c_i32, "vi*iC*UiIi", "", AND(SM_75,PTX63))
 TARGET_BUILTIN(__imma_m16n16k16_ld_a_s8, "vi*iC*UiIi", "", AND(SM_72,PTX63))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130394: [clang][CodeGen] Factor out Swift ABI hooks (NFCI)

2022-08-05 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 450294.
barannikov88 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130394

Files:
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/SwiftCallingConv.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h

Index: clang/lib/CodeGen/TargetInfo.h
===
--- clang/lib/CodeGen/TargetInfo.h
+++ clang/lib/CodeGen/TargetInfo.h
@@ -38,6 +38,7 @@
 class CallArgList;
 class CodeGenFunction;
 class CGBlockInfo;
+class SwiftABIInfo;
 
 /// TargetCodeGenInfo - This class organizes various target-specific
 /// codegeneration issues, like target-specific attributes, builtins and so
@@ -45,6 +46,12 @@
 class TargetCodeGenInfo {
   std::unique_ptr Info;
 
+protected:
+  // Target hooks supporting Swift calling conventions. The target must
+  // initialize this field if it claims to support these calling conventions
+  // by returning true from TargetInfo::checkCallingConvention for them.
+  std::unique_ptr SwiftInfo;
+
 public:
   TargetCodeGenInfo(std::unique_ptr Info);
   virtual ~TargetCodeGenInfo();
@@ -52,6 +59,9 @@
   /// getABIInfo() - Returns ABI info helper for the target.
   const ABIInfo () const { return *Info; }
 
+  /// Returns Swift ABI info helper for the target.
+  const SwiftABIInfo () const { return *SwiftInfo; }
+
   /// setTargetAttributes - Provides a convenient hook to handle extra
   /// target-specific attributes for the given global.
   virtual void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -23,7 +23,6 @@
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/DiagnosticFrontend.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
-#include "clang/CodeGen/SwiftCallingConv.h"
 #include "llvm/ADT/SmallBitVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
@@ -117,7 +116,9 @@
   return false;
 }
 
-ABIInfo::~ABIInfo() {}
+ABIInfo::~ABIInfo() = default;
+
+SwiftABIInfo::~SwiftABIInfo() = default;
 
 /// Does the given lowering require more than the given number of
 /// registers when expanded?
@@ -151,12 +152,16 @@
   return (intCount + fpCount > maxAllRegisters);
 }
 
-bool SwiftABIInfo::isLegalVectorTypeForSwift(CharUnits vectorSize,
- llvm::Type *eltTy,
- unsigned numElts) const {
+bool SwiftABIInfo::shouldPassIndirectly(ArrayRef ComponentTys,
+bool AsReturnValue) const {
+  return occupiesMoreThan(CGT, ComponentTys, /*total=*/4);
+}
+
+bool SwiftABIInfo::isLegalVectorType(CharUnits VectorSize, llvm::Type *EltTy,
+ unsigned NumElts) const {
   // The default implementation of this assumes that the target guarantees
   // 128-bit SIMD support but nothing more.
-  return (vectorSize.getQuantity() > 8 && vectorSize.getQuantity() <= 16);
+  return (VectorSize.getQuantity() > 8 && VectorSize.getQuantity() <= 16);
 }
 
 static CGCXXABI::RecordArgABI getRecordArgABI(const RecordType *RT,
@@ -814,7 +819,7 @@
 // This is a very simple ABI that relies a lot on DefaultABIInfo.
 //===--===//
 
-class WebAssemblyABIInfo final : public SwiftABIInfo {
+class WebAssemblyABIInfo final : public ABIInfo {
 public:
   enum ABIKind {
 MVP = 0,
@@ -827,7 +832,7 @@
 
 public:
   explicit WebAssemblyABIInfo(CodeGen::CodeGenTypes , ABIKind Kind)
-  : SwiftABIInfo(CGT), defaultInfo(CGT), Kind(Kind) {}
+  : ABIInfo(CGT), defaultInfo(CGT), Kind(Kind) {}
 
 private:
   ABIArgInfo classifyReturnType(QualType RetTy) const;
@@ -845,22 +850,16 @@
 
   Address EmitVAArg(CodeGenFunction , Address VAListAddr,
 QualType Ty) const override;
-
-  bool shouldPassIndirectlyForSwift(ArrayRef scalars,
-bool asReturnValue) const override {
-return occupiesMoreThan(CGT, scalars, /*total*/ 4);
-  }
-
-  bool isSwiftErrorInRegister() const override {
-return false;
-  }
 };
 
 class WebAssemblyTargetCodeGenInfo final : public TargetCodeGenInfo {
 public:
   explicit WebAssemblyTargetCodeGenInfo(CodeGen::CodeGenTypes ,
 WebAssemblyABIInfo::ABIKind K)
-  : TargetCodeGenInfo(std::make_unique(CGT, K)) {}
+  : TargetCodeGenInfo(std::make_unique(CGT, K)) {
+SwiftInfo =
+std::make_unique(CGT, /*SwiftErrorInRegister=*/false);
+  }
 
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule ) const override {
@@ -1136,7 +1135,7 @@
 };
 
 /// X86_32ABIInfo - The X86-32 ABI 

[PATCH] D130394: [clang][CodeGen] Factor out Swift ABI hooks (NFCI)

2022-08-05 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 450298.
barannikov88 added a comment.

Assert that Swift ABI info is initialized before accessing it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130394

Files:
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/SwiftCallingConv.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h

Index: clang/lib/CodeGen/TargetInfo.h
===
--- clang/lib/CodeGen/TargetInfo.h
+++ clang/lib/CodeGen/TargetInfo.h
@@ -38,6 +38,7 @@
 class CallArgList;
 class CodeGenFunction;
 class CGBlockInfo;
+class SwiftABIInfo;
 
 /// TargetCodeGenInfo - This class organizes various target-specific
 /// codegeneration issues, like target-specific attributes, builtins and so
@@ -45,6 +46,12 @@
 class TargetCodeGenInfo {
   std::unique_ptr Info;
 
+protected:
+  // Target hooks supporting Swift calling conventions. The target must
+  // initialize this field if it claims to support these calling conventions
+  // by returning true from TargetInfo::checkCallingConvention for them.
+  std::unique_ptr SwiftInfo;
+
 public:
   TargetCodeGenInfo(std::unique_ptr Info);
   virtual ~TargetCodeGenInfo();
@@ -52,6 +59,12 @@
   /// getABIInfo() - Returns ABI info helper for the target.
   const ABIInfo () const { return *Info; }
 
+  /// Returns Swift ABI info helper for the target.
+  const SwiftABIInfo () const {
+assert(SwiftInfo && "Swift ABI info has not been initialized");
+return *SwiftInfo;
+  }
+
   /// setTargetAttributes - Provides a convenient hook to handle extra
   /// target-specific attributes for the given global.
   virtual void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -23,7 +23,6 @@
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/DiagnosticFrontend.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
-#include "clang/CodeGen/SwiftCallingConv.h"
 #include "llvm/ADT/SmallBitVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
@@ -117,7 +116,9 @@
   return false;
 }
 
-ABIInfo::~ABIInfo() {}
+ABIInfo::~ABIInfo() = default;
+
+SwiftABIInfo::~SwiftABIInfo() = default;
 
 /// Does the given lowering require more than the given number of
 /// registers when expanded?
@@ -151,12 +152,16 @@
   return (intCount + fpCount > maxAllRegisters);
 }
 
-bool SwiftABIInfo::isLegalVectorTypeForSwift(CharUnits vectorSize,
- llvm::Type *eltTy,
- unsigned numElts) const {
+bool SwiftABIInfo::shouldPassIndirectly(ArrayRef ComponentTys,
+bool AsReturnValue) const {
+  return occupiesMoreThan(CGT, ComponentTys, /*total=*/4);
+}
+
+bool SwiftABIInfo::isLegalVectorType(CharUnits VectorSize, llvm::Type *EltTy,
+ unsigned NumElts) const {
   // The default implementation of this assumes that the target guarantees
   // 128-bit SIMD support but nothing more.
-  return (vectorSize.getQuantity() > 8 && vectorSize.getQuantity() <= 16);
+  return (VectorSize.getQuantity() > 8 && VectorSize.getQuantity() <= 16);
 }
 
 static CGCXXABI::RecordArgABI getRecordArgABI(const RecordType *RT,
@@ -814,7 +819,7 @@
 // This is a very simple ABI that relies a lot on DefaultABIInfo.
 //===--===//
 
-class WebAssemblyABIInfo final : public SwiftABIInfo {
+class WebAssemblyABIInfo final : public ABIInfo {
 public:
   enum ABIKind {
 MVP = 0,
@@ -827,7 +832,7 @@
 
 public:
   explicit WebAssemblyABIInfo(CodeGen::CodeGenTypes , ABIKind Kind)
-  : SwiftABIInfo(CGT), defaultInfo(CGT), Kind(Kind) {}
+  : ABIInfo(CGT), defaultInfo(CGT), Kind(Kind) {}
 
 private:
   ABIArgInfo classifyReturnType(QualType RetTy) const;
@@ -845,22 +850,16 @@
 
   Address EmitVAArg(CodeGenFunction , Address VAListAddr,
 QualType Ty) const override;
-
-  bool shouldPassIndirectlyForSwift(ArrayRef scalars,
-bool asReturnValue) const override {
-return occupiesMoreThan(CGT, scalars, /*total*/ 4);
-  }
-
-  bool isSwiftErrorInRegister() const override {
-return false;
-  }
 };
 
 class WebAssemblyTargetCodeGenInfo final : public TargetCodeGenInfo {
 public:
   explicit WebAssemblyTargetCodeGenInfo(CodeGen::CodeGenTypes ,
 WebAssemblyABIInfo::ABIKind K)
-  : TargetCodeGenInfo(std::make_unique(CGT, K)) {}
+  : TargetCodeGenInfo(std::make_unique(CGT, K)) {
+SwiftInfo =
+std::make_unique(CGT, /*SwiftErrorInRegister=*/false);
+  }
 
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
   

[PATCH] D129231: [Builtins] Do not claim all libfuncs are readnone with trapping math.

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

ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129231

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


[PATCH] D130894: [clang] Print more information about failed static assertions

2022-08-05 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Any tests with macros?


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

https://reviews.llvm.org/D130894

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


[PATCH] D130894: [clang] Print more information about failed static assertions

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

In D130894#3702233 , @tbaeder wrote:

> I don't know much about fixit hints, would they be appropriate to display it 
> below the line itself, e.g.
>
>   test.cpp:24:17: note: expression evaluates to
>   static_assert(c != c);
>   '0' != '0'
> ~~^~~~

Nope, that would be a bad thing -- Clang has the ability to automatically apply 
fix-it hints to the source, so this would modify the static assertion to 
continue to be false which isn't much of a fix.

> Or would it be even better to just inline the evaluated expression into the 
> `static_assert` ala
>
>   test.cpp:24:17: note: expression evaluates to
>   static_assert('0' != '0');
>   ~~^~~~

Making sure I'm following along, you mean that we'd display the error for the 
static assertion, and then the note would show `static_assert()`?

I think this might work for very simple static asserts, but what about more 
complicated ones like `static_assert(foo() && (bar() == 12 || baz()) && 'a' != 
quux(4000));`?


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

https://reviews.llvm.org/D130894

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


[PATCH] D131255: Fix Wbitfield-constant-conversion on 1-bit signed bitfield

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

In D131255#3702286 , @ShawnZhong 
wrote:

> Thanks for the quick reply and the reference on the C standard!
>
> On the C++ side, Section C.1.8 specified that `int` bit-fields are signed:
>
>> Change: Bit-fields of type plain int are signed.
>> Rationale: Leaving the choice of signedness to implementations could lead to 
>> inconsistent definitions of template specializations. For consistency, the 
>> implementation freedom was eliminated for non-dependent types, too.
>> Effect on original feature: The choise is implementation-defined in C, but 
>> not so in C++.

Agreed; I think that's falling out from 
https://eel.is/c++draft/class.bit#4.sentence-1 and 
https://eel.is/c++draft/basic.fundamental#1.sentence-1.

> Implementation-wise, I'll see what I can find in CodeGen on whether `int` 
> bit-fields are signed for C

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131255

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


[PATCH] D131255: Fix Wbitfield-constant-conversion on 1-bit signed bitfield

2022-08-05 Thread Shawn Zhong via Phabricator via cfe-commits
ShawnZhong added a comment.

Thanks for the quick reply and the reference on the C standard!

On the C++ side, Section C.1.8 specified that `int` bit-fields are signed:

> Change: Bit-fields of type plain int are signed.
> Rationale: Leaving the choice of signedness to implementations could lead to 
> inconsistent definitions of template specializations. For consistency, the 
> implementation freedom was eliminated for non-dependent types, too.
> Effect on original feature: The choise is implementation-defined in C, but 
> not so in C++.

Implementation-wise, I'll see what I can find in CodeGen on whether `int` 
bit-fields are signed for C


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131255

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


[PATCH] D131258: [Sema] Merge variable template specializations

2022-08-05 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: ChuanqiXu.
Herald added a project: All.
ilya-biryukov requested review of this revision.
Herald added a project: clang.

Clang used to produce redefinition errors, see tests for examples.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131258

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Modules/merge-var-template-spec-cxx-modules.cpp
  clang/test/Modules/merge-var-template-spec.cpp

Index: clang/test/Modules/merge-var-template-spec.cpp
===
--- /dev/null
+++ clang/test/Modules/merge-var-template-spec.cpp
@@ -0,0 +1,67 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -xc++ -std=c++17 -fmodules -fmodule-name=library \
+// RUN: -emit-module %t/modules.map \
+// RUN: -o %t/module.pcm
+//
+//
+// RUN: %clang_cc1 -xc++ -std=c++17 -fmodules -fmodule-file=%t/module.pcm  \
+// RUN: -fmodule-map-file=%t/modules.map \
+// RUN: -fsyntax-only -verify %t/use.cpp
+//
+//--- use.cpp
+
+#include "var1.h"
+#include "var2.h"
+
+auto foo = zero;
+auto bar = zero;
+auto baz = zero;
+
+template  constexpr T zero = 0; // expected-error {{redefinition}} expected-note@* {{previous}}
+template <> constexpr Int zero = {0}; // expected-error {{redefinition}} expected-note@* {{previous}}
+template  constexpr T* zero = nullptr; // expected-error {{redefinition}} expected-note@* {{previous}}
+
+template <> constexpr int** zero = nullptr; // ok, new specialization.
+template  constexpr T** zero = nullptr; // ok, new partial specilization.
+
+//--- modules.map
+module "library" {
+	export *
+	module "var1" {
+		export *
+		header "var1.h"
+	}
+	module "var2" {
+		export *
+		header "var2.h"
+	}
+}
+
+//--- var1.h
+#ifndef VAR1_H
+#define VAR1_H
+
+template  constexpr T zero = 0;
+struct Int {
+int value;
+};
+template <> constexpr int zero = {0};
+template  constexpr T* zero = nullptr;
+
+#endif // VAR1_H
+
+//--- var2.h
+#ifndef VAR2_H
+#define VAR2_H
+
+template  constexpr T zero = 0;
+struct Int {
+int value;
+};
+template <> constexpr int zero = {0};
+template  constexpr T* zero = nullptr;
+
+#endif // VAR2_H
\ No newline at end of file
Index: clang/test/Modules/merge-var-template-spec-cxx-modules.cpp
===
--- /dev/null
+++ clang/test/Modules/merge-var-template-spec-cxx-modules.cpp
@@ -0,0 +1,44 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/var_def.cppm -o %t/var_def.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fprebuilt-module-path=%t %t/reexport1.cppm -o %t/reexport1.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fprebuilt-module-path=%t %t/reexport2.cppm -o %t/reexport2.pcm
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/use.cppm -fsyntax-only -verify
+
+//--- use.cppm
+import reexport1;
+import reexport2;
+
+auto foo = zero;
+auto bar = zero;
+auto baz = zero;
+
+template  constexpr T zero = 0; // expected-error-re {{declaration{{.*}}in the global module follows declaration in module var_def}}
+ // expected-note@* {{previous}}
+template <> constexpr Int zero = {0}; // expected-error-re {{declaration{{.*}}in the global module follows declaration in module var_def}}
+   // expected-note@* {{previous}}
+template  constexpr T* zero = nullptr; // expected-error-re {{declaration{{.*}}in the global module follows declaration in module var_def}}
+// expected-note@* {{previous}}
+
+template <> constexpr int** zero = nullptr; // ok, new specialization.
+template  constexpr T** zero = nullptr; // ok, new partial specilization.
+
+//--- var_def.cppm
+export module var_def;
+
+export template  constexpr T zero = 0;
+export struct Int {
+int value;
+};
+export template <> constexpr Int zero = {0};
+export template  constexpr T* zero = nullptr;
+
+//--- reexport1.cppm
+export module reexport1;
+export import var_def;
+
+//--- reexport2.cppm
+export module reexport2;
+export import var_def;
\ No newline at end of file
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -4665,6 +4665,7 @@
   if (!hasVisibleDefinition(Old) &&
   (New->getFormalLinkage() == InternalLinkage ||
New->isInline() ||
+   isa(New) ||
New->getDescribedVarTemplate() ||
New->getNumTemplateParameterLists() ||
New->getDeclContext()->isDependentContext())) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130894: [clang] Print more information about failed static assertions

2022-08-05 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

I don't know much about fixit hints, would they be appropriate to display it 
below the line itself, e.g.

  test.cpp:24:17: note: expression evaluates to
  static_assert(c != c);
  '0' != '0'
~~^~~~

Or would it be even better to just inline the evaluated expression into the 
`static_assert` ala

  test.cpp:24:17: note: expression evaluates to
  static_assert('0' != '0');
  ~~^~~~


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

https://reviews.llvm.org/D130894

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


[PATCH] D130951: [HLSL] CodeGen hlsl resource binding.

2022-08-05 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added inline comments.



Comment at: clang/lib/CodeGen/CGHLSLRuntime.h:64
   CodeGenModule 
   uint32_t ResourceCounters[static_cast(
   hlsl::ResourceClass::NumClasses)] = {0};

Anastasia wrote:
> This is not part of this change but any reason why it is a protected member 
> and not private?
I wrote that code, and had a vague idea of a use case in my head where we might 
provide subclasses of the HLSLRuntime, but in retrospect that is unlikely 
anytime soon, so we could safely make that `private.`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130951

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


[PATCH] D128440: [WebAssembly] Initial support for reference type funcref in clang

2022-08-05 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added a comment.

It would be great to get this landed. Can someone pls take a look at it? It's 
quite independent from the remainder of the work and self-contained.

maybe @tlively ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128440

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


[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2022-08-05 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added a comment.

It would be great to get this landed. Can someone pls take a look at it? It's 
quite independent from the remainder of the work and self-contained.

maybe @tlively ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122215

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


[PATCH] D131065: [clang][dataflow] Store DeclContext of block being analysed in Environment if available.

2022-08-05 Thread weiyi via Phabricator via cfe-commits
wyt updated this revision to Diff 450276.
wyt marked an inline comment as done.
wyt added a comment.

Rebase to head.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131065

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp

Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -154,7 +154,7 @@
 : DACtx(), FlowConditionToken(()) {}
 
 Environment::Environment(const Environment )
-: DACtx(Other.DACtx), ReturnLoc(Other.ReturnLoc),
+: DACtx(Other.DACtx), DeclCtx(Other.DeclCtx), ReturnLoc(Other.ReturnLoc),
   ThisPointeeLoc(Other.ThisPointeeLoc), DeclToLoc(Other.DeclToLoc),
   ExprToLoc(Other.ExprToLoc), LocToVal(Other.LocToVal),
   MemberLocToStruct(Other.MemberLocToStruct),
@@ -168,9 +168,11 @@
 }
 
 Environment::Environment(DataflowAnalysisContext ,
- const DeclContext )
+ const DeclContext )
 : Environment(DACtx) {
-  if (const auto *FuncDecl = dyn_cast()) {
+  setDeclCtx();
+
+  if (const auto *FuncDecl = dyn_cast(DeclCtx)) {
 assert(FuncDecl->getBody() != nullptr);
 initGlobalVars(*FuncDecl->getBody(), *this);
 for (const auto *ParamDecl : FuncDecl->parameters()) {
@@ -185,7 +187,7 @@
 ReturnLoc = (ReturnType);
   }
 
-  if (const auto *MethodDecl = dyn_cast()) {
+  if (const auto *MethodDecl = dyn_cast(DeclCtx)) {
 auto *Parent = MethodDecl->getParent();
 assert(Parent != nullptr);
 if (Parent->isLambda())
@@ -210,6 +212,9 @@
 
   const auto *FuncDecl = Call->getDirectCallee();
   assert(FuncDecl != nullptr);
+
+  Env.setDeclCtx(FuncDecl);
+
   // FIXME: In order to allow the callee to reference globals, we probably need
   // to call `initGlobalVars` here in some way.
 
@@ -252,12 +257,12 @@
 
 void Environment::popCall(const Environment ) {
   // We ignore `DACtx` because it's already the same in both. We don't want the
-  // callee's `ReturnLoc` or `ThisPointeeLoc`. We don't bring back `DeclToLoc`
-  // and `ExprToLoc` because we want to be able to later analyze the same callee
-  // in a different context, and `setStorageLocation` requires there to not
-  // already be a storage location assigned. Conceptually, these maps capture
-  // information from the local scope, so when popping that scope, we do not
-  // propagate the maps.
+  // callee's `DeclCtx`, `ReturnLoc` or `ThisPointeeLoc`. We don't bring back
+  // `DeclToLoc` and `ExprToLoc` because we want to be able to later analyze the
+  // same callee in a different context, and `setStorageLocation` requires there
+  // to not already be a storage location assigned. Conceptually, these maps
+  // capture information from the local scope, so when popping that scope, we do
+  // not propagate the maps.
   this->LocToVal = std::move(CalleeEnv.LocToVal);
   this->MemberLocToStruct = std::move(CalleeEnv.MemberLocToStruct);
   this->FlowConditionToken = std::move(CalleeEnv.FlowConditionToken);
@@ -304,11 +309,13 @@
   assert(DACtx == Other.DACtx);
   assert(ReturnLoc == Other.ReturnLoc);
   assert(ThisPointeeLoc == Other.ThisPointeeLoc);
+  assert(DeclCtx == Other.DeclCtx);
 
   auto Effect = LatticeJoinEffect::Unchanged;
 
   Environment JoinedEnv(*DACtx);
 
+  JoinedEnv.setDeclCtx(DeclCtx);
   JoinedEnv.ReturnLoc = ReturnLoc;
   JoinedEnv.ThisPointeeLoc = ThisPointeeLoc;
 
Index: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
===
--- clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -172,6 +172,13 @@
   LatticeJoinEffect join(const Environment ,
  Environment::ValueModel );
 
+  /// Returns the `DeclContext` of the block being analysed if provided,
+  /// otherwise returns nullptr.
+  const DeclContext *getDeclCtx() { return DeclCtx; }
+
+  /// Sets the `DeclContext` of the block being analysed.
+  void setDeclCtx(const DeclContext *Ctx) { DeclCtx = Ctx; }
+
   // FIXME: Rename `createOrGetStorageLocation` to `getOrCreateStorageLocation`,
   // `getStableStorageLocation`, or something more appropriate.
 
@@ -377,6 +384,9 @@
   // `DACtx` is not null and not owned by this object.
   DataflowAnalysisContext *DACtx;
 
+  // `DeclContext` of the block being analysed if provided.
+  const DeclContext *DeclCtx;
+
   // In a properly initialized `Environment`, `ReturnLoc` should only be null if
   // its `DeclContext` could not be cast to a `FunctionDecl`.
   StorageLocation *ReturnLoc = nullptr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[clang] 4bc9e60 - Removing redundant code; NFC

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

Author: Aaron Ballman
Date: 2022-08-05T09:17:20-04:00
New Revision: 4bc9e603065b59976f3a16b7ecc6b5fb109f5f2d

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

LOG: Removing redundant code; NFC

The same predicate is checked on line 12962 just above the removed code.

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index d71114e33f31f..293239c7b0d78 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -12976,9 +12976,6 @@ static bool AnalyzeBitFieldAssignment(Sema , 
FieldDecl *Bitfield, Expr *Init,
 }
   }
 
-  if (Bitfield->getType()->isBooleanType())
-return false;
-
   // Ignore value- or type-dependent expressions.
   if (Bitfield->getBitWidth()->isValueDependent() ||
   Bitfield->getBitWidth()->isTypeDependent() ||



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


[PATCH] D131255: Fix Wbitfield-constant-conversion on 1-bit signed bitfield

2022-08-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: aaron.ballman, clang-language-wg.
aaron.ballman added a comment.

Thank you for working on this! I think this is going in the right direction, 
but I think there's some more work needed here because the rules depend on the 
type of the bit-field (at least in C, I've not checked C++ yet). See C2x 
6.7.2.1p12 (and it's footnote): "A bit-field is interpreted as having a signed 
or unsigned integer type consisting of the specified number of bits. ..." (and 
the footnote goes on to say "As specified in 6.7.2 above, if the actual type 
specifier used is `int` or a typedef-name defined as `int`, then it is 
implementation-defined whether the bit-field is signed or unsigned. ...").

Assuming that we actually do treat plain `int` bit-fields as being signed 
(which I'm pretty sure we do), then I agree that these changes are fine. But 
you should add some CodeGen test coverage (or find existing coverage) that 
proves how we behave in that case and an `int` test in `Sema` showing we match 
the codegen behavior.

Also, can you add a release note for the fix?




Comment at: clang/test/Sema/constant-conversion.c:137
+  struct S {
+signed char c : 1;  // the only valid values are 0 and -1
+  } s;




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131255

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


[PATCH] D130894: [clang] Print more information about failed static assertions

2022-08-05 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

or

  test.cpp:25:17: note: evaluated expression: '0' > 'a'


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

https://reviews.llvm.org/D130894

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


[PATCH] D131255: Fix Wbitfield-constant-conversion on 1-bit signed bitfield

2022-08-05 Thread Shawn Zhong via Phabricator via cfe-commits
ShawnZhong updated this revision to Diff 450274.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131255

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/constant-conversion.c


Index: clang/test/Sema/constant-conversion.c
===
--- clang/test/Sema/constant-conversion.c
+++ clang/test/Sema/constant-conversion.c
@@ -15,8 +15,16 @@
 }
 
 void test(void) {
-  struct { int bit : 1; } a;
-  a.bit = 1; // shouldn't warn
+  struct S {
+signed char c : 1;  // the only valid values are 0 and -1
+  } s;
+
+  s.c = -3; // expected-warning {{implicit truncation from 'int' to bit-field 
changes value from -3 to -1}}
+  s.c = -2; // expected-warning {{implicit truncation from 'int' to bit-field 
changes value from -2 to 0}}
+  s.c = -1; // no-warning
+  s.c = 0;  // no-warning
+  s.c = 1;  // expected-warning {{implicit truncation from 'int' to bit-field 
changes value from 1 to -1}}
+  s.c = 2;  // expected-warning {{implicit truncation from 'int' to bit-field 
changes value from 2 to 0}}
 }
 
 enum Test2 { K_zero, K_one };
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -13067,11 +13067,6 @@
   if (llvm::APSInt::isSameValue(Value, TruncatedValue))
 return false;
 
-  // Special-case bitfields of width 1: booleans are naturally 0/1, and
-  // therefore don't strictly fit into a signed bitfield of width 1.
-  if (FieldWidth == 1 && Value == 1)
-return false;
-
   std::string PrettyValue = toString(Value, 10);
   std::string PrettyTrunc = toString(TruncatedValue, 10);
 


Index: clang/test/Sema/constant-conversion.c
===
--- clang/test/Sema/constant-conversion.c
+++ clang/test/Sema/constant-conversion.c
@@ -15,8 +15,16 @@
 }
 
 void test(void) {
-  struct { int bit : 1; } a;
-  a.bit = 1; // shouldn't warn
+  struct S {
+signed char c : 1;  // the only valid values are 0 and -1
+  } s;
+
+  s.c = -3; // expected-warning {{implicit truncation from 'int' to bit-field changes value from -3 to -1}}
+  s.c = -2; // expected-warning {{implicit truncation from 'int' to bit-field changes value from -2 to 0}}
+  s.c = -1; // no-warning
+  s.c = 0;  // no-warning
+  s.c = 1;  // expected-warning {{implicit truncation from 'int' to bit-field changes value from 1 to -1}}
+  s.c = 2;  // expected-warning {{implicit truncation from 'int' to bit-field changes value from 2 to 0}}
 }
 
 enum Test2 { K_zero, K_one };
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -13067,11 +13067,6 @@
   if (llvm::APSInt::isSameValue(Value, TruncatedValue))
 return false;
 
-  // Special-case bitfields of width 1: booleans are naturally 0/1, and
-  // therefore don't strictly fit into a signed bitfield of width 1.
-  if (FieldWidth == 1 && Value == 1)
-return false;
-
   std::string PrettyValue = toString(Value, 10);
   std::string PrettyTrunc = toString(TruncatedValue, 10);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130894: [clang] Print more information about failed static assertions

2022-08-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: erichkeane, cjdb, clang-language-wg, jyknight.
aaron.ballman added a comment.

In D130894#3701749 , @tbaeder wrote:

> For the record, the output now looks something like this:
>
>   test.cpp:24:1: error: static assertion failed due to requirement 'c != c'
>   static_assert(c != c);
>   ^ ~~
>   test.cpp:24:17: note: expression evaluates to '('0' != '0')'
>   static_assert(c != c);
> ~~^~~~

This looks hard to read to me...

> test.cpp:25:1: error: static assertion failed due to requirement 'c > 'a''
> static_assert(c > 'a');
> ^ ~~~
> test.cpp:25:17: note: expression evaluates to '('0' > 'a')'

Same confusion here -- it took me a while to realize what's happening is that 
we're quoting the part outside of the parens and that's throwing me for a loop. 
We typically quote things that are syntax but in this case, the parens are not 
part of the syntax and so the surrounding quotes are catching me. Given that 
parens are being used as a visual delimiter and a single quote serves the same 
purpose, I would expect something more like:

  test.cpp:25:17: note: expression evaluates to ''0' > 'a''
  test.cpp:26:17: note: expression evaluates to '0 > 'a''
  test.cpp:27:17: note: expression evaluates to '14 > 5'
  test.cpp:28:17: note: expression evaluates to 'true == false'
  test.cpp:29:17: note: expression evaluates to 'nullptr != nullptr'

Adding a few more folks as reviewers to see if there is a consensus position on 
how to proceed.


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

https://reviews.llvm.org/D130894

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


[PATCH] D131255: Fix Wbitfield-constant-conversion on 1-bit signed bitfield

2022-08-05 Thread Shawn Zhong via Phabricator via cfe-commits
ShawnZhong created this revision.
ShawnZhong added a reviewer: rsmith.
ShawnZhong added a project: clang.
Herald added a project: All.
ShawnZhong requested review of this revision.
Herald added a subscriber: cfe-commits.

Fix https://github.com/llvm/llvm-project/issues/53253


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131255

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/constant-conversion.c


Index: clang/test/Sema/constant-conversion.c
===
--- clang/test/Sema/constant-conversion.c
+++ clang/test/Sema/constant-conversion.c
@@ -131,3 +131,15 @@
   s.a = -9;  // expected-warning{{implicit truncation from 'int' to bit-field 
changes value from -9 to 7}}
   s.a = 16;  // expected-warning{{implicit truncation from 'int' to bit-field 
changes value from 16 to 0}}
 }
+
+void test11(void) {
+  struct S {
+signed char c : 1;  // the only valid values are 0 and -1
+  } s;
+
+  s.c = -2; // expected-warning {{implicit conversion from 'int' to 'char' 
changes value from -2 to 0}}
+  s.c = -1; // no-warning
+  s.c = 0;  // no-warning
+  s.c = 1;  // expected-warning {{implicit conversion from 'int' to 'char' 
changes value from 1 to -1}}
+  s.c = 2;  // expected-warning {{implicit conversion from 'int' to 'char' 
changes value from 2 to 0}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -13067,11 +13067,6 @@
   if (llvm::APSInt::isSameValue(Value, TruncatedValue))
 return false;
 
-  // Special-case bitfields of width 1: booleans are naturally 0/1, and
-  // therefore don't strictly fit into a signed bitfield of width 1.
-  if (FieldWidth == 1 && Value == 1)
-return false;
-
   std::string PrettyValue = toString(Value, 10);
   std::string PrettyTrunc = toString(TruncatedValue, 10);
 


Index: clang/test/Sema/constant-conversion.c
===
--- clang/test/Sema/constant-conversion.c
+++ clang/test/Sema/constant-conversion.c
@@ -131,3 +131,15 @@
   s.a = -9;  // expected-warning{{implicit truncation from 'int' to bit-field changes value from -9 to 7}}
   s.a = 16;  // expected-warning{{implicit truncation from 'int' to bit-field changes value from 16 to 0}}
 }
+
+void test11(void) {
+  struct S {
+signed char c : 1;  // the only valid values are 0 and -1
+  } s;
+
+  s.c = -2; // expected-warning {{implicit conversion from 'int' to 'char' changes value from -2 to 0}}
+  s.c = -1; // no-warning
+  s.c = 0;  // no-warning
+  s.c = 1;  // expected-warning {{implicit conversion from 'int' to 'char' changes value from 1 to -1}}
+  s.c = 2;  // expected-warning {{implicit conversion from 'int' to 'char' changes value from 2 to 0}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -13067,11 +13067,6 @@
   if (llvm::APSInt::isSameValue(Value, TruncatedValue))
 return false;
 
-  // Special-case bitfields of width 1: booleans are naturally 0/1, and
-  // therefore don't strictly fit into a signed bitfield of width 1.
-  if (FieldWidth == 1 && Value == 1)
-return false;
-
   std::string PrettyValue = toString(Value, 10);
   std::string PrettyTrunc = toString(TruncatedValue, 10);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130058: [Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values

2022-08-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

+1 on downgrading to a warning, so that users can have time to do cleanup on 
their codebase.

We also see internal breakages caused by this change. It breaks some code using 
the magic_enum  library, a simple repro 
example:

  #include
  
  #include "magic_enum.hpp"

  
  enum Color { Red, Black };
  
  int main(int argc, char* argv[]) {
  
 Color color = Black;   
   
 switch (color) {   
   
   case Red:
   
 break; 
   
   default: 
   
 std::cout << magic_enum::enum_name(color); 
   
 break; 
   
 }  

   
 return 0;  
   
   }

Errors:

  ./magic_enum/magic_enum.hpp:436:10: note: in instantiation of function 
template specialization 'magic_enum::detail::values' requested here
return values>(std::make_index_sequence{});
   ^
  ./magic_enum/magic_enum.hpp:440:34: note: in instantiation of function 
template specialization 'magic_enum::detail::values' requested here
  inline constexpr auto values_v = values();
   ^
  ./magic_enum/magic_enum.hpp:446:33: note: in instantiation of variable 
template specialization 'magic_enum::detail::values_v' requested here
  inline constexpr auto count_v = values_v.size();
  ^
  ./magic_enum/magic_enum.hpp:567:17: note: in instantiation of variable 
template specialization 'magic_enum::detail::count_v' requested here
static_assert(count_v > 0, "magic_enum requires enum 
implementation and valid max and min.");
  ^
  ./magic_enum/magic_enum.hpp:579:1: note: in instantiation of template class 
'magic_enum::detail::enable_if_enum' 
requested here
  using enable_if_enum_t = typename 
enable_if_enum>, false, T, R>::type;
  ^
  ./magic_enum/magic_enum.hpp:690:69: note: in instantiation of template type 
alias 'enable_if_enum_t' requested here
  [[nodiscard]] constexpr auto enum_name(E value) noexcept -> 
detail::enable_if_enum_t {
  ^
  main.cc:17:20: note: while substituting deduced template arguments into 
function template 'enum_name' [with E = Color]
std::cout << magic_enum::enum_name(color);


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

https://reviews.llvm.org/D130058

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


[PATCH] D131194: [C++20] Fix crash-on-valid with consteval temporary construction through list initialization

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

In D131194#3700688 , @efriedma wrote:

> Instead of trying to dig through subexpressions of the ConstantExpr to try to 
> infer the type we need, can we just compute it directly?
>
>   QualType RetType = CE->getType();
>   if (CE->isGLValue())
> RetType = CGM.getContext().getLValueReferenceType(RetType);

Oh wow, that's a *much* better approach, thank you for the suggestion! It 
passed my local testing, so hopefully precommit CI doesn't spot any concerns 
from it.


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

https://reviews.llvm.org/D131194

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


[PATCH] D131194: [C++20] Fix crash-on-valid with consteval temporary construction through list initialization

2022-08-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 450271.
aaron.ballman added a comment.

Improved from review feedback.


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

https://reviews.llvm.org/D131194

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/test/CodeGenCXX/cxx20-consteval-crash.cpp


Index: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
===
--- clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
+++ clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
@@ -56,3 +56,18 @@
 // CHECK: define{{.*}} signext i8 @_ZN10Issue545782f2IcEEcT_(
 // CHECK: ret i8 4
 }
+
+namespace Issue55871 {
+struct Item {
+  consteval Item(char c) :_char{c}{}
+  char _char;
+};
+
+int function(const Item& item1, const Item& item2) {
+  return 0;
+}
+
+int foo() {
+  return function(Item{'a'}, Item{'a'});
+}
+} // namespace Issue58871
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1395,15 +1395,13 @@
 llvm::Constant *ConstantEmitter::tryEmitConstantExpr(const ConstantExpr *CE) {
   if (!CE->hasAPValueResult())
 return nullptr;
-  const Expr *Inner = CE->getSubExpr()->IgnoreImplicit();
-  QualType RetType;
-  if (auto *Call = dyn_cast(Inner))
-RetType = Call->getCallReturnType(CGM.getContext());
-  else if (auto *Ctor = dyn_cast(Inner))
-RetType = Ctor->getType();
-  llvm::Constant *Res =
-  emitAbstract(CE->getBeginLoc(), CE->getAPValueResult(), RetType);
-  return Res;
+
+  QualType RetType = CE->getType();
+  if (CE->isGLValue())
+RetType = CGM.getContext().getLValueReferenceType(RetType);
+  assert(!RetType.isNull() && "Not certain of the constant expression's type");
+
+  return emitAbstract(CE->getBeginLoc(), CE->getAPValueResult(), RetType);
 }
 
 llvm::Constant *
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -65,7 +65,9 @@
 - Fix a crash when evaluating a multi-dimensional array's array filler
   expression is element-dependent. This fixes
   `Issue 50601 `_.
-
+- Fixed a crash-on-valid with consteval evaluation of a list-initialized
+  constructor for a temporary object. This fixes
+  `Issue 55871 `_.
 
 Improvements to Clang's diagnostics
 ^^^


Index: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
===
--- clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
+++ clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
@@ -56,3 +56,18 @@
 // CHECK: define{{.*}} signext i8 @_ZN10Issue545782f2IcEEcT_(
 // CHECK: ret i8 4
 }
+
+namespace Issue55871 {
+struct Item {
+  consteval Item(char c) :_char{c}{}
+  char _char;
+};
+
+int function(const Item& item1, const Item& item2) {
+  return 0;
+}
+
+int foo() {
+  return function(Item{'a'}, Item{'a'});
+}
+} // namespace Issue58871
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1395,15 +1395,13 @@
 llvm::Constant *ConstantEmitter::tryEmitConstantExpr(const ConstantExpr *CE) {
   if (!CE->hasAPValueResult())
 return nullptr;
-  const Expr *Inner = CE->getSubExpr()->IgnoreImplicit();
-  QualType RetType;
-  if (auto *Call = dyn_cast(Inner))
-RetType = Call->getCallReturnType(CGM.getContext());
-  else if (auto *Ctor = dyn_cast(Inner))
-RetType = Ctor->getType();
-  llvm::Constant *Res =
-  emitAbstract(CE->getBeginLoc(), CE->getAPValueResult(), RetType);
-  return Res;
+
+  QualType RetType = CE->getType();
+  if (CE->isGLValue())
+RetType = CGM.getContext().getLValueReferenceType(RetType);
+  assert(!RetType.isNull() && "Not certain of the constant expression's type");
+
+  return emitAbstract(CE->getBeginLoc(), CE->getAPValueResult(), RetType);
 }
 
 llvm::Constant *
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -65,7 +65,9 @@
 - Fix a crash when evaluating a multi-dimensional array's array filler
   expression is element-dependent. This fixes
   `Issue 50601 `_.
-
+- Fixed a crash-on-valid with consteval evaluation of a list-initialized
+  constructor for a temporary object. This fixes
+  `Issue 55871 `_.
 
 Improvements to Clang's diagnostics
 ^^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D130394: [clang][CodeGen] Factor out Swift ABI hooks (NFCI)

2022-08-05 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.h:63
+  /// Returns Swift ABI info helper for the target.
+  const SwiftABIInfo () const { return *SwiftInfo; }
+

aaron.ballman wrote:
> `SwiftInfo` isn't always initialized to a nonnull pointer; should this have 
> an assert to help point out when someone's forgotten to initialize that 
> properly?
Good point, thank you


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130394

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


[PATCH] D131213: [clang][Headers] Fix unintentional error in D130800

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

> Undefined macros evaluate to zero, so when checking for a smaller value, we 
> need to include the case when the macro is undefined.

The code being changed already checks `defined(__cplusplus)` so there no 
undefined macro value being tested. What's more, if `__cplusplus` is not 
defined, we wouldn't even get into this block because we'd have hit line 19 
instead. I think the current form is easier to read given the subsequent 
comment talking about being in C++98 mode (which would be weird to consider for 
when `__cplusplus` is not defined), even if the test for `defined(__cplusplus)` 
isn't strictly needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131213

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


[PATCH] D131065: [clang][dataflow] Store DeclContext of block being analysed in Environment if available.

2022-08-05 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev accepted this revision.
sgatev added inline comments.



Comment at: clang/lib/Analysis/FlowSensitive/Transfer.cpp:537-539
+  auto *Caller = Env.getDeclCtx();
+  Env = Environment(ExitState->Env);
+  Env.setDeclCtx(Caller);

I believe you'll need to rebase because this has changed: 
https://github.com/llvm/llvm-project/blob/main/clang/lib/Analysis/FlowSensitive/Transfer.cpp#L567


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131065

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


[PATCH] D131067: [analyzer] Treat values passed as parameter as escaped

2022-08-05 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/test/Analysis/dead-stores.cpp:225
+void functionReferenceParameter(int ) {
+  i = 5; // no warning
+}

By checking it on godbolt, this line never raised a warning.
https://godbolt.org/z/n7fP5od5q

You must be referring to L230 and L241 instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131067

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


[PATCH] D130268: [NFC] Add SmallVector constructor to allow creation of SmallVector from ArrayRef of items convertible to type T

2022-08-05 Thread Dawid Jurczak 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 rG1bd31a689844: [NFC] Add SmallVector constructor to allow 
creation of SmallVectorT from… (authored by yurai007).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130268

Files:
  llvm/include/llvm/ADT/SmallVector.h
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86MCInstLower.cpp
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
  llvm/unittests/ADT/SmallVectorTest.cpp

Index: llvm/unittests/ADT/SmallVectorTest.cpp
===
--- llvm/unittests/ADT/SmallVectorTest.cpp
+++ llvm/unittests/ADT/SmallVectorTest.cpp
@@ -246,6 +246,18 @@
   assertValuesInOrder(V, 3u, 1, 2, 3);
 }
 
+// Constructor test.
+TYPED_TEST(SmallVectorTest, ConstructorFromArrayRefSimpleTest) {
+  SCOPED_TRACE("ConstructorFromArrayRefSimpleTest");
+  std::array StdArray = {Constructable(1), Constructable(2),
+   Constructable(3)};
+  ArrayRef Array = StdArray;
+  auto  = this->theVector;
+  V = SmallVector(Array);
+  assertValuesInOrder(V, 3u, 1, 2, 3);
+  ASSERT_EQ(NumBuiltinElts(TypeParam{}), NumBuiltinElts(V));
+}
+
 // New vector test.
 TYPED_TEST(SmallVectorTest, EmptyVectorTest) {
   SCOPED_TRACE("EmptyVectorTest");
@@ -1130,6 +1142,44 @@
   EXPECT_TRUE(makeArrayRef(V2).equals({4, 5, 3, 2}));
 }
 
+struct To {
+  int Content;
+  friend bool operator==(const To , const To ) {
+return LHS.Content == RHS.Content;
+  }
+};
+
+class From {
+public:
+  From() = default;
+  From(To M) { T = M; }
+  operator To() const { return T; }
+
+private:
+  To T;
+};
+
+TEST(SmallVectorTest, ConstructFromArrayRefOfConvertibleType) {
+  To to1{1}, to2{2}, to3{3};
+  std::vector StdVector = {From(to1), From(to2), From(to3)};
+  ArrayRef Array = StdVector;
+  {
+llvm::SmallVector Vector(Array);
+
+ASSERT_EQ(Array.size(), Vector.size());
+for (size_t I = 0; I < Array.size(); ++I)
+  EXPECT_EQ(Array[I], Vector[I]);
+  }
+  {
+llvm::SmallVector Vector(Array);
+
+ASSERT_EQ(Array.size(), Vector.size());
+ASSERT_EQ(4u, NumBuiltinElts(Vector));
+for (size_t I = 0; I < Array.size(); ++I)
+  EXPECT_EQ(Array[I], Vector[I]);
+  }
+}
+
 template 
 class SmallVectorReferenceInvalidationTest : public SmallVectorTestBase {
 protected:
Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -7659,7 +7659,7 @@
 
   /// Functions adds masks, merging them into  single one.
   void addMask(ArrayRef SubMask) {
-SmallVector NewMask(SubMask.begin(), SubMask.end());
+SmallVector NewMask(SubMask);
 addMask(NewMask);
   }
 
@@ -8755,7 +8755,7 @@
   return PoisonValue::get(FixedVectorType::get(
   cast(V1->getType())->getElementType(), Mask.size()));
 Value *Op = V1;
-SmallVector CombinedMask(Mask.begin(), Mask.end());
+SmallVector CombinedMask(Mask);
 PeekThroughShuffles(Op, CombinedMask);
 if (!isa(Op->getType()) ||
 !IsIdentityMask(CombinedMask, cast(Op->getType( {
Index: llvm/lib/Target/X86/X86MCInstLower.cpp
===
--- llvm/lib/Target/X86/X86MCInstLower.cpp
+++ llvm/lib/Target/X86/X86MCInstLower.cpp
@@ -1865,7 +1865,7 @@
   SrcOp2.isReg() ? GetRegisterName(SrcOp2.getReg()) : "mem";
 
   // One source operand, fix the mask to print all elements in one span.
-  SmallVector ShuffleMask(Mask.begin(), Mask.end());
+  SmallVector ShuffleMask(Mask);
   if (Src1Name == Src2Name)
 for (int i = 0, e = ShuffleMask.size(); i != e; ++i)
   if (ShuffleMask[i] >= e)
Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -6158,7 +6158,7 @@
 SmallVectorImpl ) {
   // Create an alternative mask with info about zeroable elements.
   // Here we do not set undef elements as zeroable.
-  SmallVector ZeroableMask(Mask.begin(), Mask.end());
+  SmallVector ZeroableMask(Mask);
   if (V2IsZero) {
 assert(!Zeroable.isZero() && "V2's non-undef elements are used?!");
 for (int i = 0, Size = Mask.size(); i != Size; ++i)
@@ -11927,7 +11927,7 @@
 

[PATCH] D130394: [clang][CodeGen] Factor out Swift ABI hooks (NFCI)

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

This seems like a reasonable set of changes, but I'd prefer someone more 
well-versed in codegen make the final call.




Comment at: clang/lib/CodeGen/TargetInfo.h:63
+  /// Returns Swift ABI info helper for the target.
+  const SwiftABIInfo () const { return *SwiftInfo; }
+

`SwiftInfo` isn't always initialized to a nonnull pointer; should this have an 
assert to help point out when someone's forgotten to initialize that properly?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130394

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


[PATCH] D131067: [analyzer] Treat values passed as parameter as escaped

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

Please, consider stating the motivation behind this change.
For me, by looking at the modified test, it feels like we would lose legitimate 
findings (aka. true-positive reports) by applying this change.
From my perspective, the store to `i` is //dead//, since it will be immediately 
overwritten in the `referenceParameters()` function.




Comment at: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp:536-537
+  void findReferenceParameter(const FunctionDecl *FD, const Expr *const *Args) 
{
+unsigned numParams = FD->getNumParams();
+for (unsigned i = 0; i < numParams; ++i) {
+  if (FD->getParamDecl(i)->getType()->isReferenceType()) {

You don't seem to use the index, only for iterating over the parameters.
I believe, `FD->parameters()` would simplify this code.



Comment at: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp:538-545
+  if (FD->getParamDecl(i)->getType()->isReferenceType()) {
+if (auto *DRE = dyn_cast(Args[i])) {
+  if (auto *VD = dyn_cast(DRE->getDecl())) {
+Escaped.insert(VD);
+  }
+}
+  }

By looking at e.g. `findLambdaReferenceCaptures()`, it seems like we should 
prefer `continue` statements for filtering; probably to avoid such deeply 
nested intendations.
Along with that, I think the llvm style guide prefers not wrapping single 
statement branches by courly braces.



Comment at: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp:549
+  void findCallReferenceParameters(const CallExpr *CE) {
+if (auto *FD = dyn_cast(CE->getCalleeDecl())) {
+  findReferenceParameter(FD, CE->getArgs());

I'm not sure `getCalleeDecl()` always returns a valid pointer.
I believe the `dyn_cast_or_null` would be more appropriate in this case.
This theory is underpinned by the other uses of the `getCalleeDecl()` API.



Comment at: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp:555
+  void findConstructorReferenceParameters(const CXXConstructExpr *CE) {
+findReferenceParameter(CE->getConstructor(), CE->getArgs());
+  }

Why don't you use the `CE->arguments()` method instead? That would result in a 
range (begin + end).
I believe that is superior in most cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131067

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


[PATCH] D130015: [clangd] Add "usedAsMutablePointer" highlighting modifier

2022-08-05 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added a comment.

IMO the relevant point is the (non-)const-ness of the corresponding parameter, 
i.e. can the passed object get mutated or not. The fact that there's an 
ampersand at the call site (which is not even the case if the variable is 
itself a pointer) does not tell me that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130015

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


[PATCH] D130268: [NFC] Add SmallVector constructor to allow creation of SmallVector from ArrayRef of items convertible to type T

2022-08-05 Thread Dawid Jurczak via Phabricator via cfe-commits
yurai007 updated this revision to Diff 450259.
yurai007 added a comment.

Fix std::initializer_list lifetime issue in test case revealed on CI


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130268

Files:
  llvm/include/llvm/ADT/SmallVector.h
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86MCInstLower.cpp
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
  llvm/unittests/ADT/SmallVectorTest.cpp

Index: llvm/unittests/ADT/SmallVectorTest.cpp
===
--- llvm/unittests/ADT/SmallVectorTest.cpp
+++ llvm/unittests/ADT/SmallVectorTest.cpp
@@ -246,6 +246,18 @@
   assertValuesInOrder(V, 3u, 1, 2, 3);
 }
 
+// Constructor test.
+TYPED_TEST(SmallVectorTest, ConstructorFromArrayRefSimpleTest) {
+  SCOPED_TRACE("ConstructorFromArrayRefSimpleTest");
+  std::array StdArray = {Constructable(1), Constructable(2),
+   Constructable(3)};
+  ArrayRef Array = StdArray;
+  auto  = this->theVector;
+  V = SmallVector(Array);
+  assertValuesInOrder(V, 3u, 1, 2, 3);
+  ASSERT_EQ(NumBuiltinElts(TypeParam{}), NumBuiltinElts(V));
+}
+
 // New vector test.
 TYPED_TEST(SmallVectorTest, EmptyVectorTest) {
   SCOPED_TRACE("EmptyVectorTest");
@@ -1130,6 +1142,44 @@
   EXPECT_TRUE(makeArrayRef(V2).equals({4, 5, 3, 2}));
 }
 
+struct To {
+  int Content;
+  friend bool operator==(const To , const To ) {
+return LHS.Content == RHS.Content;
+  }
+};
+
+class From {
+public:
+  From() = default;
+  From(To M) { T = M; }
+  operator To() const { return T; }
+
+private:
+  To T;
+};
+
+TEST(SmallVectorTest, ConstructFromArrayRefOfConvertibleType) {
+  To to1{1}, to2{2}, to3{3};
+  std::vector StdVector = {From(to1), From(to2), From(to3)};
+  ArrayRef Array = StdVector;
+  {
+llvm::SmallVector Vector(Array);
+
+ASSERT_EQ(Array.size(), Vector.size());
+for (size_t I = 0; I < Array.size(); ++I)
+  EXPECT_EQ(Array[I], Vector[I]);
+  }
+  {
+llvm::SmallVector Vector(Array);
+
+ASSERT_EQ(Array.size(), Vector.size());
+ASSERT_EQ(4u, NumBuiltinElts(Vector));
+for (size_t I = 0; I < Array.size(); ++I)
+  EXPECT_EQ(Array[I], Vector[I]);
+  }
+}
+
 template 
 class SmallVectorReferenceInvalidationTest : public SmallVectorTestBase {
 protected:
Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -7662,7 +7662,7 @@
 
   /// Functions adds masks, merging them into  single one.
   void addMask(ArrayRef SubMask) {
-SmallVector NewMask(SubMask.begin(), SubMask.end());
+SmallVector NewMask(SubMask);
 addMask(NewMask);
   }
 
@@ -8758,7 +8758,7 @@
   return PoisonValue::get(FixedVectorType::get(
   cast(V1->getType())->getElementType(), Mask.size()));
 Value *Op = V1;
-SmallVector CombinedMask(Mask.begin(), Mask.end());
+SmallVector CombinedMask(Mask);
 PeekThroughShuffles(Op, CombinedMask);
 if (!isa(Op->getType()) ||
 !IsIdentityMask(CombinedMask, cast(Op->getType( {
Index: llvm/lib/Target/X86/X86MCInstLower.cpp
===
--- llvm/lib/Target/X86/X86MCInstLower.cpp
+++ llvm/lib/Target/X86/X86MCInstLower.cpp
@@ -1856,7 +1856,7 @@
   SrcOp2.isReg() ? GetRegisterName(SrcOp2.getReg()) : "mem";
 
   // One source operand, fix the mask to print all elements in one span.
-  SmallVector ShuffleMask(Mask.begin(), Mask.end());
+  SmallVector ShuffleMask(Mask);
   if (Src1Name == Src2Name)
 for (int i = 0, e = ShuffleMask.size(); i != e; ++i)
   if (ShuffleMask[i] >= e)
Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -6158,7 +6158,7 @@
 SmallVectorImpl ) {
   // Create an alternative mask with info about zeroable elements.
   // Here we do not set undef elements as zeroable.
-  SmallVector ZeroableMask(Mask.begin(), Mask.end());
+  SmallVector ZeroableMask(Mask);
   if (V2IsZero) {
 assert(!Zeroable.isZero() && "V2's non-undef elements are used?!");
 for (int i = 0, Size = Mask.size(); i != Size; ++i)
@@ -11927,7 +11927,7 @@
   MVT VT = MVT::getVectorVT(EltVT, Mask.size());
 
   // We can't assume a canonical shuffle mask, so try the 

[clang] 809b416 - [NFC] Requires x86-registered-target for test/pr56919.cpp

2022-08-05 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-08-05T16:46:38+08:00
New Revision: 809b4166413f157ce8e45ba0f80438701bf2e133

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

LOG: [NFC] Requires x86-registered-target for test/pr56919.cpp

Added: 


Modified: 
clang/test/CodeGenCoroutines/pr56919.cpp

Removed: 




diff  --git a/clang/test/CodeGenCoroutines/pr56919.cpp 
b/clang/test/CodeGenCoroutines/pr56919.cpp
index ecd9515acb81..dd6df99a5623 100644
--- a/clang/test/CodeGenCoroutines/pr56919.cpp
+++ b/clang/test/CodeGenCoroutines/pr56919.cpp
@@ -1,4 +1,7 @@
 // Test for PR56919. Tests the destroy function contains the call to delete 
function only.
+//
+// REQUIRES: x86-registered-target
+//
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 %s -O3 -S -o - 
| FileCheck %s
 
 #include "Inputs/coroutine.h"



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


[PATCH] D131134: [X86] Report error if the amx enabled on the non-64-bits target

2022-08-05 Thread LiuChen via Phabricator via cfe-commits
LiuChen3 added a comment.

In D131134#3699742 , @craig.topper 
wrote:

> How does this interact with `-march=native -m32`. Won't that pick up the amx 
> flag from CPUID?

Good point. I will continue the work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131134

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


[PATCH] D131134: [X86] Report error if the amx enabled on the non-64-bits target

2022-08-05 Thread LiuChen via Phabricator via cfe-commits
LiuChen3 added a comment.

In D131134#3699742 , @craig.topper 
wrote:

> How does this interact with `-march=native -m32`. Won't that pick up the amx 
> flag from CPUID?



In D131134#3699344 , @aaron.ballman 
wrote:

> I think the precommit CI failures might be relevant here -- can you 
> double-check those?

Yes. This test is only supported on  amdgpu-registered-target so I didn't catch 
this fail on my local machine. Thanks for point out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131134

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


[PATCH] D130470: [clang][analyzer] Add more wide-character functions to CStringChecker

2022-08-05 Thread Balázs Kéri 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 rG501faaa0d65e: [clang][analyzer] Add more wide-character 
functions to CStringChecker (authored by balazske).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130470

Files:
  clang/docs/analyzer/checkers.rst
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/wstring.c

Index: clang/test/Analysis/wstring.c
===
--- clang/test/Analysis/wstring.c
+++ clang/test/Analysis/wstring.c
@@ -33,7 +33,7 @@
 void clang_analyzer_eval(int);
 
 //===--===
-// wwmemcpy()
+// wmemcpy()
 //===--===
 
 #define wmemcpy BUILTIN(wmemcpy)
@@ -139,6 +139,255 @@
   clang_analyzer_eval(result == a); // no-warning (above is fatal)
 }
 
+//===--===
+// wmempcpy()
+//===--===
+
+wchar_t *wmempcpy(wchar_t *restrict s1, const wchar_t *restrict s2, size_t n);
+
+void wmempcpy0 (void) {
+  wchar_t src[] = {1, 2, 3, 4};
+  wchar_t dst[5] = {0};
+
+  wmempcpy(dst, src, 4); // no-warning
+
+  clang_analyzer_eval(wmempcpy(dst, src, 4) == [4]); // expected-warning{{TRUE}}
+
+  // If we actually model the copy, we can make this known.
+  // The important thing for now is that the old value has been invalidated.
+  clang_analyzer_eval(dst[0] != 0); // expected-warning{{UNKNOWN}}
+}
+
+void wmempcpy1 (void) {
+  wchar_t src[] = {1, 2, 3, 4};
+  wchar_t dst[10];
+
+  wmempcpy(dst, src, 5); // expected-warning{{Memory copy function accesses out-of-bound array element}}
+}
+
+void wmempcpy2 (void) {
+  wchar_t src[] = {1, 2, 3, 4};
+  wchar_t dst[1];
+
+  wmempcpy(dst, src, 4); // expected-warning{{Memory copy function overflows the destination buffer}}
+}
+
+void wmempcpy3 (void) {
+  wchar_t src[] = {1, 2, 3, 4};
+  wchar_t dst[3];
+
+  wmempcpy(dst+1, src+2, 2); // no-warning
+}
+
+void wmempcpy4 (void) {
+  wchar_t src[] = {1, 2, 3, 4};
+  wchar_t dst[10];
+
+  wmempcpy(dst+2, src+2, 3); // expected-warning{{Memory copy function accesses out-of-bound array element}}
+}
+
+void wmempcpy5(void) {
+  wchar_t src[] = {1, 2, 3, 4};
+  wchar_t dst[3];
+
+  wmempcpy(dst + 2, src + 2, 2); // expected-warning{{Memory copy function overflows the destination buffer}}
+}
+
+void wmempcpy6(void) {
+  wchar_t a[4] = {0};
+  wmempcpy(a, a, 2); // expected-warning{{overlapping}}
+}
+
+void wmempcpy7(void) {
+  wchar_t a[4] = {0};
+  wmempcpy(a+2, a+1, 2); // expected-warning{{overlapping}}
+}
+
+void wmempcpy8(void) {
+  wchar_t a[4] = {0};
+  wmempcpy(a+1, a+2, 2); // expected-warning{{overlapping}}
+}
+
+void wmempcpy9(void) {
+  wchar_t a[4] = {0};
+  wmempcpy(a+2, a+1, 1); // no-warning
+  wmempcpy(a+1, a+2, 1); // no-warning
+}
+
+void wmempcpy10(void) {
+  wchar_t a[4] = {0};
+  wmempcpy(0, a, 1); // expected-warning{{Null pointer passed as 1st argument to memory copy function}}
+}
+
+void wmempcpy11(void) {
+  wchar_t a[4] = {0};
+  wmempcpy(a, 0, 1); // expected-warning{{Null pointer passed as 2nd argument to memory copy function}}
+}
+
+void wmempcpy12(void) {
+  wchar_t a[4] = {0};
+  wmempcpy(0, a, 0); // no-warning
+}
+
+void wmempcpy13(void) {
+  wchar_t a[4] = {0};
+  wmempcpy(a, 0, 0); // no-warning
+}
+
+void wmempcpy14(void) {
+  wchar_t src[] = {1, 2, 3, 4};
+  wchar_t dst[5] = {0};
+  wchar_t *p;
+
+  p = wmempcpy(dst, src, 4);
+
+  clang_analyzer_eval(p == [4]); // expected-warning{{TRUE}}
+}
+
+struct st {
+  wchar_t i;
+  wchar_t j;
+};
+
+void wmempcpy15(void) {
+  struct st s1 = {0};
+  struct st s2;
+  struct st *p1;
+  struct st *p2;
+
+  p1 = () + 1;
+  p2 = (struct st *)wmempcpy((wchar_t *), (wchar_t *), 2);
+
+  clang_analyzer_eval(p1 == p2); // expected-warning{{TRUE}}
+}
+
+void wmempcpy16(void) {
+  struct st s1[10] = {{0}};
+  struct st s2[10];
+  struct st *p1;
+  struct st *p2;
+
+  p1 = ([0]) + 5;
+  p2 = (struct st *)wmempcpy((wchar_t *)[0], (wchar_t *)[0], 5 * 2);
+
+  clang_analyzer_eval(p1 == p2); // expected-warning{{TRUE}}
+}
+
+void wmempcpy_unknown_size_warn (size_t n) {
+  wchar_t a[4];
+  void *result = wmempcpy(a, 0, n); // expected-warning{{Null pointer passed as 2nd argument to memory copy function}}
+  clang_analyzer_eval(result == a); // no-warning (above is fatal)
+}
+
+void wmempcpy_unknownable_size (wchar_t *src, float n) {
+  wchar_t a[4];
+  // This used to crash because we don't model floats.
+  wmempcpy(a, src, (size_t)n);
+}
+
+//===--===
+// wmemmove()
+//===--===
+
+#define wmemmove 

[clang] 501faaa - [clang][analyzer] Add more wide-character functions to CStringChecker

2022-08-05 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2022-08-05T10:32:53+02:00
New Revision: 501faaa0d65e9814566ef65e58d834c13b8a

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

LOG: [clang][analyzer] Add more wide-character functions to CStringChecker

Support for functions wmempcpy, wmemmove, wmemcmp is added to the checker.
The same tests are copied that exist for the non-wide versions, with
non-wide functions and character types changed to the wide version.

Reviewed By: martong

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

Added: 


Modified: 
clang/docs/analyzer/checkers.rst
clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
clang/test/Analysis/wstring.c

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index 81312a8fa229b..623a520574e2b 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -2699,7 +2699,7 @@ Check stream handling functions: ``fopen, tmpfile, 
fclose, fread, fwrite, fseek,
 
 alpha.unix.cstring.BufferOverlap (C)
 
-Checks for overlap in two buffer arguments. Applies to:  ``memcpy, mempcpy, 
wmemcpy``.
+Checks for overlap in two buffer arguments. Applies to:  ``memcpy, mempcpy, 
wmemcpy, wmempcpy``.
 
 .. code-block:: c
 

diff  --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
index 9a6c013bcf66a..09549534fcfd2 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -75,6 +75,16 @@ static ErrorMessage createOutOfBoundErrorMsg(StringRef 
FunctionDescription,
 }
 
 enum class ConcatFnKind { none = 0, strcat = 1, strlcat = 2 };
+
+enum class CharKind { Regular = 0, Wide };
+constexpr CharKind CK_Regular = CharKind::Regular;
+constexpr CharKind CK_Wide = CharKind::Wide;
+
+static QualType getCharPtrType(ASTContext , CharKind CK) {
+  return Ctx.getPointerType(CK == CharKind::Regular ? Ctx.CharTy
+: Ctx.WideCharTy);
+}
+
 class CStringChecker : public Checker< eval::Call,
  check::PreStmt,
  check::LiveSymbols,
@@ -125,12 +135,21 @@ class CStringChecker : public Checker< eval::Call,
 
   CallDescriptionMap Callbacks = {
   {{CDF_MaybeBuiltin, "memcpy", 3},
-   std::bind(::evalMemcpy, _1, _2, _3, false)},
+   std::bind(::evalMemcpy, _1, _2, _3, CK_Regular)},
   {{CDF_MaybeBuiltin, "wmemcpy", 3},
-   std::bind(::evalMemcpy, _1, _2, _3, true)},
-  {{CDF_MaybeBuiltin, "mempcpy", 3}, ::evalMempcpy},
-  {{CDF_MaybeBuiltin, "memcmp", 3}, ::evalMemcmp},
-  {{CDF_MaybeBuiltin, "memmove", 3}, ::evalMemmove},
+   std::bind(::evalMemcpy, _1, _2, _3, CK_Wide)},
+  {{CDF_MaybeBuiltin, "mempcpy", 3},
+   std::bind(::evalMempcpy, _1, _2, _3, CK_Regular)},
+  {{CDF_None, "wmempcpy", 3},
+   std::bind(::evalMempcpy, _1, _2, _3, CK_Wide)},
+  {{CDF_MaybeBuiltin, "memcmp", 3},
+   std::bind(::evalMemcmp, _1, _2, _3, CK_Regular)},
+  {{CDF_MaybeBuiltin, "wmemcmp", 3},
+   std::bind(::evalMemcmp, _1, _2, _3, CK_Wide)},
+  {{CDF_MaybeBuiltin, "memmove", 3},
+   std::bind(::evalMemmove, _1, _2, _3, CK_Regular)},
+  {{CDF_MaybeBuiltin, "wmemmove", 3},
+   std::bind(::evalMemmove, _1, _2, _3, CK_Wide)},
   {{CDF_MaybeBuiltin, "memset", 3}, ::evalMemset},
   {{CDF_MaybeBuiltin, "explicit_memset", 3}, ::evalMemset},
   {{CDF_MaybeBuiltin, "strcpy", 2}, ::evalStrcpy},
@@ -150,7 +169,8 @@ class CStringChecker : public Checker< eval::Call,
   {{CDF_MaybeBuiltin, "strncasecmp", 3}, ::evalStrncasecmp},
   {{CDF_MaybeBuiltin, "strsep", 2}, ::evalStrsep},
   {{CDF_MaybeBuiltin, "bcopy", 3}, ::evalBcopy},
-  {{CDF_MaybeBuiltin, "bcmp", 3}, ::evalMemcmp},
+  {{CDF_MaybeBuiltin, "bcmp", 3},
+   std::bind(::evalMemcmp, _1, _2, _3, CK_Regular)},
   {{CDF_MaybeBuiltin, "bzero", 2}, ::evalBzero},
   {{CDF_MaybeBuiltin, "explicit_bzero", 2}, ::evalBzero},
   };
@@ -160,16 +180,16 @@ class CStringChecker : public Checker< eval::Call,
   StdCopyBackward{{"std", "copy_backward"}, 3};
 
   FnCheck identifyCall(const CallEvent , CheckerContext ) const;
-  void evalMemcpy(CheckerContext , const CallExpr *CE, bool IsWide) const;
-  void evalMempcpy(CheckerContext , const CallExpr *CE) const;
-  void evalMemmove(CheckerContext , const CallExpr *CE) const;
+  void evalMemcpy(CheckerContext , const CallExpr *CE, CharKind CK) const;
+  void evalMempcpy(CheckerContext , const CallExpr *CE, CharKind CK) const;
+  void evalMemmove(CheckerContext , const CallExpr *CE, CharKind CK) const;
   void 

[PATCH] D130754: [X86] Support ``-mindirect-branch-cs-prefix`` for call and jmp to indirect thunk

2022-08-05 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

In D130754#3701858 , @pengfei wrote:

> In D130754#3701837 , @nikic wrote:
>
>> This change caused a significant compile-time regression for `O0` builds 
>> (about 1%): 
>> http://llvm-compile-time-tracker.com/compare.php?from=45bae1be90472c696f6ba3bb4f8fabee76040fa9=6f867f9102838ebe314c1f3661fdf95700386e5a=instructions
>>
>> At a guess, fetching a module flag for every single instruction is slow?
>
> Thanks for reporting it. I guess so. I'll try to move it outside :)

D131245  should help with it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130754

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


[PATCH] D131241: [Clang][Lex] Extend HeaderSearch::LookupFile to control OpenFile behavior.

2022-08-05 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

Maybe we can add a little more context. In the case of static compilation the 
file system is pretty much read-only and taking a snapshot of it usually is 
sufficient. In the interactive C++ case the compilation is longer and people 
can create and include files, etc. In that case we often do not want to open 
files or cache failures unless is absolutely necessary. We might be able to 
write a test for this in `clang/unittests/Lex/HeaderSearchTest.cpp`. However, 
this patch improves consistency in the interfaces by forwarding the already 
provided flags to the callees and if we cannot write a reasonable test we 
should be able to accept it without.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131241

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


[clang-tools-extra] 4c106c9 - [clangd] Change the url for clang-tidy check documentation

2022-08-05 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2022-08-05T08:42:52+01:00
New Revision: 4c106c93eb68f8f9f201202677cd31e326c16823

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

LOG: [clangd] Change the url for clang-tidy check documentation

In 
https://github.com/llvm/llvm-project/commit/6e566bc5523f743bc34a7e26f050f1f2b4d699a8,
 The directory structure of the documentation for clang-tidy checks was 
changed, however clangd wasn't updated.
Now all the links generated will point to old dead pages.
This updated clangd to use the new page structure.

Reviewed By: sammccall, kadircet

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

Added: 


Modified: 
clang-tools-extra/clangd/Diagnostics.cpp
clang-tools-extra/clangd/test/diagnostics-tidy.test

Removed: 




diff  --git a/clang-tools-extra/clangd/Diagnostics.cpp 
b/clang-tools-extra/clangd/Diagnostics.cpp
index e70d45769fe46..031192f763e6e 100644
--- a/clang-tools-extra/clangd/Diagnostics.cpp
+++ b/clang-tools-extra/clangd/Diagnostics.cpp
@@ -918,9 +918,19 @@ llvm::Optional 
getDiagnosticDocURI(Diag::DiagSource Source,
 // information to be worth linking.
 // https://clang.llvm.org/docs/DiagnosticsReference.html
 break;
-  case Diag::ClangTidy:
-return {("https://clang.llvm.org/extra/clang-tidy/checks/; + Name + 
".html")
-.str()};
+  case Diag::ClangTidy: {
+StringRef Module, Check;
+// This won't correctly get the module for clang-analyzer checks, but as we
+// don't link in the analyzer that shouldn't be an issue.
+// This would also need updating if anyone decides to create a module with 
a
+// '-' in the name.
+std::tie(Module, Check) = Name.split('-');
+if (Module.empty() || Check.empty())
+  return llvm::None;
+return ("https://clang.llvm.org/extra/clang-tidy/checks/; + Module + "/" +
+Check + ".html")
+.str();
+  }
   case Diag::Clangd:
 if (Name == "unused-includes")
   return {"https://clangd.llvm.org/guides/include-cleaner"};

diff  --git a/clang-tools-extra/clangd/test/diagnostics-tidy.test 
b/clang-tools-extra/clangd/test/diagnostics-tidy.test
index c7e79b0c6d5f5..a100c9f4359d1 100644
--- a/clang-tools-extra/clangd/test/diagnostics-tidy.test
+++ b/clang-tools-extra/clangd/test/diagnostics-tidy.test
@@ -9,7 +9,7 @@
 # CHECK-NEXT:  {
 # CHECK-NEXT:"code": "bugprone-sizeof-expression",
 # CHECK-NEXT:"codeDescription": {
-# CHECK-NEXT:  "href": 
"https://clang.llvm.org/extra/clang-tidy/checks/bugprone-sizeof-expression.html;
+# CHECK-NEXT:  "href": 
"https://clang.llvm.org/extra/clang-tidy/checks/bugprone/sizeof-expression.html;
 # CHECK-NEXT:},
 # CHECK-NEXT:"message": "Suspicious usage of 'sizeof(K)'; did you mean 
'K'?",
 # CHECK-NEXT:"range": {



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


[PATCH] D128379: [clangd] Change the url for clang-tidy check documentation

2022-08-05 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4c106c93eb68: [clangd] Change the url for clang-tidy check 
documentation (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128379

Files:
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/test/diagnostics-tidy.test


Index: clang-tools-extra/clangd/test/diagnostics-tidy.test
===
--- clang-tools-extra/clangd/test/diagnostics-tidy.test
+++ clang-tools-extra/clangd/test/diagnostics-tidy.test
@@ -9,7 +9,7 @@
 # CHECK-NEXT:  {
 # CHECK-NEXT:"code": "bugprone-sizeof-expression",
 # CHECK-NEXT:"codeDescription": {
-# CHECK-NEXT:  "href": 
"https://clang.llvm.org/extra/clang-tidy/checks/bugprone-sizeof-expression.html;
+# CHECK-NEXT:  "href": 
"https://clang.llvm.org/extra/clang-tidy/checks/bugprone/sizeof-expression.html;
 # CHECK-NEXT:},
 # CHECK-NEXT:"message": "Suspicious usage of 'sizeof(K)'; did you mean 
'K'?",
 # CHECK-NEXT:"range": {
Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -918,9 +918,19 @@
 // information to be worth linking.
 // https://clang.llvm.org/docs/DiagnosticsReference.html
 break;
-  case Diag::ClangTidy:
-return {("https://clang.llvm.org/extra/clang-tidy/checks/; + Name + 
".html")
-.str()};
+  case Diag::ClangTidy: {
+StringRef Module, Check;
+// This won't correctly get the module for clang-analyzer checks, but as we
+// don't link in the analyzer that shouldn't be an issue.
+// This would also need updating if anyone decides to create a module with 
a
+// '-' in the name.
+std::tie(Module, Check) = Name.split('-');
+if (Module.empty() || Check.empty())
+  return llvm::None;
+return ("https://clang.llvm.org/extra/clang-tidy/checks/; + Module + "/" +
+Check + ".html")
+.str();
+  }
   case Diag::Clangd:
 if (Name == "unused-includes")
   return {"https://clangd.llvm.org/guides/include-cleaner"};


Index: clang-tools-extra/clangd/test/diagnostics-tidy.test
===
--- clang-tools-extra/clangd/test/diagnostics-tidy.test
+++ clang-tools-extra/clangd/test/diagnostics-tidy.test
@@ -9,7 +9,7 @@
 # CHECK-NEXT:  {
 # CHECK-NEXT:"code": "bugprone-sizeof-expression",
 # CHECK-NEXT:"codeDescription": {
-# CHECK-NEXT:  "href": "https://clang.llvm.org/extra/clang-tidy/checks/bugprone-sizeof-expression.html;
+# CHECK-NEXT:  "href": "https://clang.llvm.org/extra/clang-tidy/checks/bugprone/sizeof-expression.html;
 # CHECK-NEXT:},
 # CHECK-NEXT:"message": "Suspicious usage of 'sizeof(K)'; did you mean 'K'?",
 # CHECK-NEXT:"range": {
Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -918,9 +918,19 @@
 // information to be worth linking.
 // https://clang.llvm.org/docs/DiagnosticsReference.html
 break;
-  case Diag::ClangTidy:
-return {("https://clang.llvm.org/extra/clang-tidy/checks/; + Name + ".html")
-.str()};
+  case Diag::ClangTidy: {
+StringRef Module, Check;
+// This won't correctly get the module for clang-analyzer checks, but as we
+// don't link in the analyzer that shouldn't be an issue.
+// This would also need updating if anyone decides to create a module with a
+// '-' in the name.
+std::tie(Module, Check) = Name.split('-');
+if (Module.empty() || Check.empty())
+  return llvm::None;
+return ("https://clang.llvm.org/extra/clang-tidy/checks/; + Module + "/" +
+Check + ".html")
+.str();
+  }
   case Diag::Clangd:
 if (Name == "unused-includes")
   return {"https://clangd.llvm.org/guides/include-cleaner"};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130754: [X86] Support ``-mindirect-branch-cs-prefix`` for call and jmp to indirect thunk

2022-08-05 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

In D130754#3701837 , @nikic wrote:

> This change caused a significant compile-time regression for `O0` builds 
> (about 1%): 
> http://llvm-compile-time-tracker.com/compare.php?from=45bae1be90472c696f6ba3bb4f8fabee76040fa9=6f867f9102838ebe314c1f3661fdf95700386e5a=instructions
>
> At a guess, fetching a module flag for every single instruction is slow?

Thanks for reporting it. I guess so. I'll try to move it outside :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130754

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


[PATCH] D128845: [HLSL]Add -O and -Od option for dxc mode.

2022-08-05 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 450243.
python3kgae added a comment.

Rebase and fix test fail.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128845

Files:
  clang/include/clang/Basic/TargetOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGHLSLRuntime.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/HLSL.cpp
  clang/test/CodeGenHLSL/disable_opt.hlsl
  clang/test/Driver/dxc_O.hlsl
  clang/test/Driver/dxc_fcgl.hlsl

Index: clang/test/Driver/dxc_fcgl.hlsl
===
--- clang/test/Driver/dxc_fcgl.hlsl
+++ clang/test/Driver/dxc_fcgl.hlsl
@@ -1,5 +1,6 @@
 // RUN: %clang_dxc -fcgl -T lib_6_7 foo.hlsl -### %s 2>&1 | FileCheck %s
 
 // Make sure fcgl option flag which translated into "-S" "-emit-llvm" "-disable-llvm-passes".
-// CHECK:"-S" "-emit-llvm" "-disable-llvm-passes"
+// CHECK:"-S"
+// CHECK-SAME:"-emit-llvm" "-disable-llvm-passes"
 
Index: clang/test/Driver/dxc_O.hlsl
===
--- /dev/null
+++ clang/test/Driver/dxc_O.hlsl
@@ -0,0 +1,19 @@
+// RUN: %clang_dxc -T lib_6_7  foo.hlsl -### %s 2>&1 | FileCheck %s
+// RUN: %clang_dxc -T lib_6_7 -Od foo.hlsl -### %s 2>&1 | FileCheck %s --check-prefix=Od
+// RUN: %clang_dxc -T lib_6_7 -O0 foo.hlsl -### %s 2>&1 | FileCheck %s --check-prefix=O0
+// RUN: %clang_dxc -T lib_6_7 -O1 foo.hlsl -### %s 2>&1 | FileCheck %s --check-prefix=O1
+// RUN: %clang_dxc -T lib_6_7 -O2 foo.hlsl -### %s 2>&1 | FileCheck %s --check-prefix=O2
+// RUN: %clang_dxc -T lib_6_7 -O3 foo.hlsl -### %s 2>&1 | FileCheck %s --check-prefix=O3
+
+// Make sure default is O3.
+// CHECK: "-O3"
+
+// Make sure Od option flag which translated into "-O0" "-dxc-opt-disable"
+// Od: "-O0"
+// Od-SAME: "-dxc-opt-disable"
+
+// Make sure O0/O1/O2/O3 is send to cc1.
+// O0: "-O0"
+// O1: "-O1"
+// O2: "-O2"
+// O3: "-O3"
Index: clang/test/CodeGenHLSL/disable_opt.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/disable_opt.hlsl
@@ -0,0 +1,12 @@
+// RUN: %clang -cc1 -S -triple dxil-pc-shadermodel6.3-library -dxc-opt-disable -emit-llvm -xhlsl  -o - %s | FileCheck %s
+// RUN: %clang -cc1 -S -triple dxil-pc-shadermodel6.3-library -emit-llvm -xhlsl  -o - %s | FileCheck %s --check-prefix=OPT
+
+// CHECK:!"dx.disable_optimizations", i32 1}
+
+// OPT-NOT:"dx.disable_optimizations"
+
+float bar(float a, float b);
+
+float foo(float a, float b) {
+  return bar(a, b);
+}
Index: clang/lib/Driver/ToolChains/HLSL.cpp
===
--- clang/lib/Driver/ToolChains/HLSL.cpp
+++ clang/lib/Driver/ToolChains/HLSL.cpp
@@ -164,6 +164,19 @@
   A->claim();
   continue;
 }
+if (A->getOption().getID() == options::OPT__SLASH_O) {
+  StringRef OStr = A->getValue();
+  if (OStr == "d") {
+DAL->AddFlagArg(nullptr, Opts.getOption(options::OPT_dxc_opt_disable));
+DAL->AddFlagArg(nullptr, Opts.getOption(options::OPT_O0));
+A->claim();
+continue;
+  } else {
+DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_O), OStr);
+A->claim();
+continue;
+  }
+}
 if (A->getOption().getID() == options::OPT_emit_pristine_llvm) {
   // Translate fcgl into -S -emit-llvm and -disable-llvm-passes.
   DAL->AddFlagArg(nullptr, Opts.getOption(options::OPT_S));
@@ -183,6 +196,9 @@
 Opts.getOption(options::OPT_dxil_validator_version),
 DefaultValidatorVer);
   }
+  if (!DAL->hasArg(options::OPT_O_Group)) {
+DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_O), "3");
+  }
   // FIXME: add validation for enable_16bit_types should be after HLSL 2018 and
   // shader model 6.2.
   return DAL;
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3512,6 +3512,8 @@
  options::OPT_D,
  options::OPT_I,
  options::OPT_S,
+ options::OPT_O,
+ options::OPT_dxc_opt_disable,
  options::OPT_emit_llvm,
  options::OPT_disable_llvm_passes,
  options::OPT_fnative_half_type,
Index: clang/lib/CodeGen/CGHLSLRuntime.cpp
===
--- clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -43,6 +43,11 @@
   StringRef DxilValKey = "dx.valver";
   M.addModuleFlag(llvm::Module::ModFlagBehavior::AppendUnique, 

[clang] 230d6f9 - [Coroutines] Remove lifetime intrinsics for spliied allocas in coroutine frames

2022-08-05 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-08-05T14:50:43+08:00
New Revision: 230d6f93aaabae985e9fafd071bb3737533c6083

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

LOG: [Coroutines] Remove lifetime intrinsics for spliied allocas in coroutine 
frames

Closing https://github.com/llvm/llvm-project/issues/56919

It is meaningless to preserve the lifetime markers for the spilled
allocas in the coroutine frames and it would block some optimizations
too.

Added: 
clang/test/CodeGenCoroutines/pr56919.cpp
llvm/test/Transforms/Coroutines/coro-split-no-lieftime.ll

Modified: 
llvm/lib/Transforms/Coroutines/CoroFrame.cpp

Removed: 




diff  --git a/clang/test/CodeGenCoroutines/pr56919.cpp 
b/clang/test/CodeGenCoroutines/pr56919.cpp
new file mode 100644
index ..ecd9515acb81
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/pr56919.cpp
@@ -0,0 +1,119 @@
+// Test for PR56919. Tests the destroy function contains the call to delete 
function only.
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 %s -O3 -S -o - 
| FileCheck %s
+
+#include "Inputs/coroutine.h"
+
+namespace std {
+
+template  struct remove_reference { using type = T; };
+template  struct remove_reference { using type = T; };
+template  struct remove_reference { using type = T; };
+
+template 
+constexpr typename std::remove_reference::type&& move(T &) noexcept {
+  return static_cast::type &&>(t);
+}
+
+}
+
+template 
+class Task final {
+ public:
+  using value_type = T;
+
+  class promise_type final {
+   public: 
+Task get_return_object() { return 
Task(std::coroutine_handle::from_promise(*this)); }
+
+void unhandled_exception();
+
+std::suspend_always initial_suspend() { return {}; }
+
+auto await_transform(Task co) {
+  return await_transform(std::move(co.handle_.promise()));
+}
+
+auto await_transform(promise_type&& awaited) {
+  struct Awaitable {
+promise_type&& awaited;
+
+bool await_ready() { return false; }
+
+std::coroutine_handle<> await_suspend(
+const std::coroutine_handle<> handle) {
+  // Register our handle to be resumed once the awaited promise's 
coroutine
+  // finishes, and then resume that coroutine.
+  awaited.registered_handle_ = handle;
+  return std::coroutine_handle::from_promise(awaited);
+}
+
+void await_resume() {}
+
+   private:
+  };
+
+  return Awaitable{std::move(awaited)};
+}
+
+void return_void() {}
+
+// At final suspend resume our registered handle.
+auto final_suspend() noexcept {
+  struct FinalSuspendAwaitable final {
+bool await_ready() noexcept { return false; }
+
+std::coroutine_handle<> await_suspend(
+std::coroutine_handle<> h) noexcept {
+  return to_resume;
+}
+
+void await_resume() noexcept {}
+
+std::coroutine_handle<> to_resume;
+  };
+
+  return FinalSuspendAwaitable{registered_handle_};
+}
+
+   private:
+std::coroutine_handle my_handle() {
+  return std::coroutine_handle::from_promise(*this);
+}
+
+std::coroutine_handle<> registered_handle_;
+  };
+
+  ~Task() {
+// Teach llvm that we are only ever destroyed when the coroutine body is 
done,
+// so there is no need for the jump table in the destroy function. Our 
coroutine
+// library doesn't expose handles to the user, so we know this constraint 
isn't
+// violated.
+if (!handle_.done()) {
+  __builtin_unreachable();
+}
+
+handle_.destroy();
+  }
+
+ private:
+  explicit Task(const std::coroutine_handle handle)
+  : handle_(handle) {}
+
+  const std::coroutine_handle handle_;
+};
+
+Task Qux() { co_return; }
+Task Baz() { co_await Qux(); }
+Task Bar() { co_await Baz(); }
+
+// CHECK: _Z3Quxv.destroy:{{.*}}
+// CHECK-NEXT: #
+// CHECK-NEXT: jmp _ZdlPv
+
+// CHECK: _Z3Bazv.destroy:{{.*}}
+// CHECK-NEXT: #
+// CHECK-NEXT: jmp _ZdlPv
+
+// CHECK: _Z3Barv.destroy:{{.*}}
+// CHECK-NEXT: #
+// CHECK-NEXT: jmp _ZdlPv

diff  --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp 
b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index 51eb8ebf0369..627886316730 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -1777,8 +1777,15 @@ static void insertSpills(const FrameDataInfo , 
coro::Shape ) {
 for (auto *DVI : DIs)
   DVI->replaceUsesOfWith(Alloca, G);
 
-for (Instruction *I : UsersToUpdate)
+for (Instruction *I : UsersToUpdate) {
+  // It is meaningless to remain the lifetime intrinsics refer for the
+  // member of coroutine frames and the meaningless lifetime intrinsics
+  // are possible to block further optimizations.
+  if 

[PATCH] D130754: [X86] Support ``-mindirect-branch-cs-prefix`` for call and jmp to indirect thunk

2022-08-05 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

This change caused a significant compile-time regression for `O0` builds (about 
1%): 
http://llvm-compile-time-tracker.com/compare.php?from=45bae1be90472c696f6ba3bb4f8fabee76040fa9=6f867f9102838ebe314c1f3661fdf95700386e5a=instructions

At a guess, fetching a module flag for every single instruction is slow?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130754

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


[PATCH] D130516: [llvm] compression classes

2022-08-05 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp:54-60
+  OptionalCompressionScheme = compression::noneIfUnsupported(
+  (Compress && DoInstrProfNameCompression) ? OptionalCompressionScheme
+   : llvm::NoneType());
+
+  bool doCompression = bool(OptionalCompressionScheme);
+
+  if (doCompression) {

This still seems like a lot of hoops to jump through - why "noneIfUnsupported" 
rather than either having the compression scheme (I think it could be the 
CompressionAlgorithm itself, rather than having the separate 
OptionalCompressionKind abstraction) either be null itself, or expose an 
"isAvailable" operation directly on the CompressionAlgorithm?

Even if the CompressionKind/OptionalCompressionKind/CompressionAlgorithm 
abstractions are kept, I'm not sure why the above code is preferred over, say:

```
if (Compress && DoInstrProfNameCompression && OptionalCompressionScheme /* 
.isAvailable(), if we want to be more explicit */) {
  ...
}
```

What's the benefit that `noneIfUnsupported` is providing? (& generally I'd 
expect the `Compress && DoInstrProfNameCompression` to be tested/exit early 
before even naming/constructing/querying/doing anything with the compression 
scheme/algorithm/etc - so there'd be no need to combine the tests for 
availability and the tests for whether compression was requested)

Perhaps this API is motivated by a desire to implement something much closer to 
the original code than is necessary/suitable? Or some other use case/benefit 
I'm not quite understanding yet?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130516

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


[PATCH] D131241: [Clang][Lex] Extend HeaderSearch::LookupFile to control OpenFile behavior.

2022-08-05 Thread Jun Zhang via Phabricator via cfe-commits
junaire created this revision.
Herald added a project: All.
junaire requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In the downstream projects (ROOT and Cling), we want to do header files
lookups but no `OpenFile` behavior as we only need to register the file
name.

This patch extends the original API call by adding some optional flags
so we can continue use it in the previous way with no breakage.
Signed-off-by: Jun Zhang 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131241

Files:
  clang/include/clang/Lex/DirectoryLookup.h
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Lex/PPDirectives.cpp

Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -949,7 +949,7 @@
 ConstSearchDirIterator *CurDirArg, SmallVectorImpl *SearchPath,
 SmallVectorImpl *RelativePath,
 ModuleMap::KnownHeader *SuggestedModule, bool *IsMapped,
-bool *IsFrameworkFound, bool SkipCache) {
+bool *IsFrameworkFound, bool SkipCache, bool OpenFile, bool CacheFailures) {
   ConstSearchDirIterator CurDirLocal = nullptr;
   ConstSearchDirIterator  = CurDirArg ? *CurDirArg : CurDirLocal;
 
@@ -1028,7 +1028,7 @@
   Optional FE = HeaderInfo.LookupFile(
   Filename, FilenameLoc, isAngled, FromDir, , Includers, SearchPath,
   RelativePath, RequestingModule, SuggestedModule, IsMapped,
-  IsFrameworkFound, SkipCache, BuildSystemModule);
+  IsFrameworkFound, SkipCache, BuildSystemModule, OpenFile, CacheFailures);
   if (FE) {
 if (SuggestedModule && !LangOpts.AsmPreprocessor)
   HeaderInfo.getModuleMap().diagnoseHeaderInclusion(
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -398,10 +398,11 @@
 Optional HeaderSearch::getFileAndSuggestModule(
 StringRef FileName, SourceLocation IncludeLoc, const DirectoryEntry *Dir,
 bool IsSystemHeaderDir, Module *RequestingModule,
-ModuleMap::KnownHeader *SuggestedModule) {
+ModuleMap::KnownHeader *SuggestedModule, bool OpenFile /*=true*/,
+bool CacheFailures /*=true*/) {
   // If we have a module map that might map this header, load it and
   // check whether we'll have a suggestion for a module.
-  auto File = getFileMgr().getFileRef(FileName, /*OpenFile=*/true);
+  auto File = getFileMgr().getFileRef(FileName, OpenFile, CacheFailures);
   if (!File) {
 // For rare, surprising errors (e.g. "out of file handles"), diag the EC
 // message.
@@ -431,7 +432,8 @@
 SmallVectorImpl *SearchPath, SmallVectorImpl *RelativePath,
 Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule,
 bool , bool ,
-bool , SmallVectorImpl ) const {
+bool , SmallVectorImpl ,
+bool OpenFile) const {
   InUserSpecifiedSystemFramework = false;
   IsInHeaderMap = false;
   MappedName.clear();
@@ -451,9 +453,9 @@
   RelativePath->append(Filename.begin(), Filename.end());
 }
 
-return HS.getFileAndSuggestModule(TmpDir, IncludeLoc, getDir(),
-  isSystemHeaderDirectory(),
-  RequestingModule, SuggestedModule);
+return HS.getFileAndSuggestModule(
+TmpDir, IncludeLoc, getDir(), isSystemHeaderDirectory(),
+RequestingModule, SuggestedModule, OpenFile);
   }
 
   if (isFramework())
@@ -491,7 +493,7 @@
 Dest = HM->lookupFilename(Filename, Path);
   }
 
-  if (auto Res = HS.getFileMgr().getOptionalFileRef(Dest)) {
+  if (auto Res = HS.getFileMgr().getOptionalFileRef(Dest, OpenFile)) {
 FixupSearchPath();
 return *Res;
   }
@@ -840,7 +842,7 @@
 SmallVectorImpl *SearchPath, SmallVectorImpl *RelativePath,
 Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule,
 bool *IsMapped, bool *IsFrameworkFound, bool SkipCache,
-bool BuildSystemModule) {
+bool BuildSystemModule, bool OpenFile, bool CacheFailures) {
   ConstSearchDirIterator CurDirLocal = nullptr;
   ConstSearchDirIterator  = CurDirArg ? *CurDirArg : CurDirLocal;
 
@@ -869,8 +871,9 @@
 }
 // Otherwise, just return the file.
 return getFileAndSuggestModule(Filename, IncludeLoc, nullptr,
-   /*IsSystemHeaderDir*/false,
-   RequestingModule, SuggestedModule);
+   /*IsSystemHeaderDir*/ false,
+   RequestingModule, SuggestedModule, OpenFile,
+   CacheFailures);
   }
 
   // This is the header that MSVC's header search would have found.
@@ -1010,7 +1013,7 @@
 Optional File = It->LookupFile(
 Filename, *this, IncludeLoc, SearchPath, RelativePath, RequestingModule,
 

[PATCH] D130894: [clang] Print more information about failed static assertions

2022-08-05 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

looks great


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

https://reviews.llvm.org/D130894

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


[PATCH] D131240: [NFC][HLSL] Fix build error caused missing typo update.

2022-08-05 Thread Xiang Li via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb2c9ff727379: [NFC][HLSL] Fix build error caused missing 
typo update. (authored by python3kgae).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131240

Files:
  clang/lib/CodeGen/CodeGenModule.cpp


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1680,7 +1680,7 @@
   F->setCallingConv(static_cast(CallingConv));
   if (getLangOpts().HLSL) {
 if (const FunctionDecl *FD = dyn_cast_or_null(GD.getDecl()))
-  getHLSLRuntime().setHLSLFnuctionAttributes(F, FD);
+  getHLSLRuntime().setHLSLFunctionAttributes(F, FD);
   }
 }
 


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1680,7 +1680,7 @@
   F->setCallingConv(static_cast(CallingConv));
   if (getLangOpts().HLSL) {
 if (const FunctionDecl *FD = dyn_cast_or_null(GD.getDecl()))
-  getHLSLRuntime().setHLSLFnuctionAttributes(F, FD);
+  getHLSLRuntime().setHLSLFunctionAttributes(F, FD);
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b2c9ff7 - [NFC][HLSL] Fix build error caused missing typo update.

2022-08-05 Thread Xiang Li via cfe-commits

Author: Xiang Li
Date: 2022-08-04T23:20:25-07:00
New Revision: b2c9ff727379992ef472e32620635b7e5d561d60

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

LOG: [NFC][HLSL] Fix build error caused missing typo update.

setHLSLFnuctionAttributes to setHLSLFunctionAttributes.

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index d607cae0bc7e6..b67655ebfca69 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1680,7 +1680,7 @@ void CodeGenModule::SetLLVMFunctionAttributes(GlobalDecl 
GD,
   F->setCallingConv(static_cast(CallingConv));
   if (getLangOpts().HLSL) {
 if (const FunctionDecl *FD = dyn_cast_or_null(GD.getDecl()))
-  getHLSLRuntime().setHLSLFnuctionAttributes(F, FD);
+  getHLSLRuntime().setHLSLFunctionAttributes(F, FD);
   }
 }
 



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


[PATCH] D131240: [NFC][HLSL] Fix build error caused missing typo update.

2022-08-05 Thread Xiang Li via Phabricator via cfe-commits
python3kgae created this revision.
python3kgae added a reviewer: beanz.
Herald added a subscriber: Anastasia.
Herald added a project: All.
python3kgae requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

setHLSLFnuctionAttributes to setHLSLFunctionAttributes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131240

Files:
  clang/lib/CodeGen/CodeGenModule.cpp


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1680,7 +1680,7 @@
   F->setCallingConv(static_cast(CallingConv));
   if (getLangOpts().HLSL) {
 if (const FunctionDecl *FD = dyn_cast_or_null(GD.getDecl()))
-  getHLSLRuntime().setHLSLFnuctionAttributes(F, FD);
+  getHLSLRuntime().setHLSLFunctionAttributes(F, FD);
   }
 }
 


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1680,7 +1680,7 @@
   F->setCallingConv(static_cast(CallingConv));
   if (getLangOpts().HLSL) {
 if (const FunctionDecl *FD = dyn_cast_or_null(GD.getDecl()))
-  getHLSLRuntime().setHLSLFnuctionAttributes(F, FD);
+  getHLSLRuntime().setHLSLFunctionAttributes(F, FD);
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131239: [NFC][HLSL] Fix typo in CGHLSLRuntime.

2022-08-05 Thread Xiang Li via Phabricator via cfe-commits
python3kgae created this revision.
python3kgae added a reviewer: beanz.
Herald added a subscriber: Anastasia.
Herald added a project: All.
python3kgae requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Change setHLSLFnuctionAttributes to setHLSLFunctionAttributes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131239

Files:
  clang/lib/CodeGen/CGHLSLRuntime.cpp
  clang/lib/CodeGen/CGHLSLRuntime.h


Index: clang/lib/CodeGen/CGHLSLRuntime.h
===
--- clang/lib/CodeGen/CGHLSLRuntime.h
+++ clang/lib/CodeGen/CGHLSLRuntime.h
@@ -47,7 +47,7 @@
 
   void finishCodeGen();
 
-  void setHLSLFnuctionAttributes(llvm::Function *, const FunctionDecl *);
+  void setHLSLFunctionAttributes(llvm::Function *, const FunctionDecl *);
 };
 
 } // namespace CodeGen
Index: clang/lib/CodeGen/CGHLSLRuntime.cpp
===
--- clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -87,7 +87,7 @@
 ConstantAsMetadata::get(B.getInt32(Counter))}));
 }
 
-void clang::CodeGen::CGHLSLRuntime::setHLSLFnuctionAttributes(
+void clang::CodeGen::CGHLSLRuntime::setHLSLFunctionAttributes(
 llvm::Function *F, const FunctionDecl *FD) {
   if (HLSLShaderAttr *ShaderAttr = FD->getAttr()) {
 const StringRef ShaderAttrKindStr = "dx.shader";


Index: clang/lib/CodeGen/CGHLSLRuntime.h
===
--- clang/lib/CodeGen/CGHLSLRuntime.h
+++ clang/lib/CodeGen/CGHLSLRuntime.h
@@ -47,7 +47,7 @@
 
   void finishCodeGen();
 
-  void setHLSLFnuctionAttributes(llvm::Function *, const FunctionDecl *);
+  void setHLSLFunctionAttributes(llvm::Function *, const FunctionDecl *);
 };
 
 } // namespace CodeGen
Index: clang/lib/CodeGen/CGHLSLRuntime.cpp
===
--- clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -87,7 +87,7 @@
 ConstantAsMetadata::get(B.getInt32(Counter))}));
 }
 
-void clang::CodeGen::CGHLSLRuntime::setHLSLFnuctionAttributes(
+void clang::CodeGen::CGHLSLRuntime::setHLSLFunctionAttributes(
 llvm::Function *F, const FunctionDecl *FD) {
   if (HLSLShaderAttr *ShaderAttr = FD->getAttr()) {
 const StringRef ShaderAttrKindStr = "dx.shader";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131238: [NFC][HLSL] Fix typo in CGHLSLRuntime.

2022-08-05 Thread Xiang Li via Phabricator via cfe-commits
python3kgae created this revision.
python3kgae added a reviewer: beanz.
Herald added a subscriber: Anastasia.
Herald added a project: All.
python3kgae requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Change setHLSLFnuctionAttributes to setHLSLFunctionAttributes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131238

Files:
  clang/lib/CodeGen/CGHLSLRuntime.cpp
  clang/lib/CodeGen/CGHLSLRuntime.h


Index: clang/lib/CodeGen/CGHLSLRuntime.h
===
--- clang/lib/CodeGen/CGHLSLRuntime.h
+++ clang/lib/CodeGen/CGHLSLRuntime.h
@@ -47,7 +47,7 @@
 
   void finishCodeGen();
 
-  void setHLSLFnuctionAttributes(llvm::Function *, const FunctionDecl *);
+  void setHLSLFunctionAttributes(llvm::Function *, const FunctionDecl *);
 };
 
 } // namespace CodeGen
Index: clang/lib/CodeGen/CGHLSLRuntime.cpp
===
--- clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -87,7 +87,7 @@
 ConstantAsMetadata::get(B.getInt32(Counter))}));
 }
 
-void clang::CodeGen::CGHLSLRuntime::setHLSLFnuctionAttributes(
+void clang::CodeGen::CGHLSLRuntime::setHLSLFunctionAttributes(
 llvm::Function *F, const FunctionDecl *FD) {
   if (HLSLShaderAttr *ShaderAttr = FD->getAttr()) {
 const StringRef ShaderAttrKindStr = "dx.shader";


Index: clang/lib/CodeGen/CGHLSLRuntime.h
===
--- clang/lib/CodeGen/CGHLSLRuntime.h
+++ clang/lib/CodeGen/CGHLSLRuntime.h
@@ -47,7 +47,7 @@
 
   void finishCodeGen();
 
-  void setHLSLFnuctionAttributes(llvm::Function *, const FunctionDecl *);
+  void setHLSLFunctionAttributes(llvm::Function *, const FunctionDecl *);
 };
 
 } // namespace CodeGen
Index: clang/lib/CodeGen/CGHLSLRuntime.cpp
===
--- clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -87,7 +87,7 @@
 ConstantAsMetadata::get(B.getInt32(Counter))}));
 }
 
-void clang::CodeGen::CGHLSLRuntime::setHLSLFnuctionAttributes(
+void clang::CodeGen::CGHLSLRuntime::setHLSLFunctionAttributes(
 llvm::Function *F, const FunctionDecl *FD) {
   if (HLSLShaderAttr *ShaderAttr = FD->getAttr()) {
 const StringRef ShaderAttrKindStr = "dx.shader";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130894: [clang] Print more information about failed static assertions

2022-08-05 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

For the record, the output now looks something like this:

  test.cpp:24:1: error: static assertion failed due to requirement 'c != c'
  static_assert(c != c);
  ^ ~~
  test.cpp:24:17: note: expression evaluates to '('0' != '0')'
  static_assert(c != c);
~~^~~~
  test.cpp:25:1: error: static assertion failed due to requirement 'c > 'a''
  static_assert(c > 'a');
  ^ ~~~
  test.cpp:25:17: note: expression evaluates to '('0' > 'a')'
  static_assert(c > 'a');
~~^
  2 errors generated.


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

https://reviews.llvm.org/D130894

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


[PATCH] D131238: [NFC][HLSL] Fix typo in CGHLSLRuntime.

2022-08-05 Thread Xiang Li via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6134629af087: [NFC][HLSL] Fix typo in CGHLSLRuntime. 
(authored by python3kgae).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131238

Files:
  clang/lib/CodeGen/CGHLSLRuntime.cpp
  clang/lib/CodeGen/CGHLSLRuntime.h


Index: clang/lib/CodeGen/CGHLSLRuntime.h
===
--- clang/lib/CodeGen/CGHLSLRuntime.h
+++ clang/lib/CodeGen/CGHLSLRuntime.h
@@ -47,7 +47,7 @@
 
   void finishCodeGen();
 
-  void setHLSLFnuctionAttributes(llvm::Function *, const FunctionDecl *);
+  void setHLSLFunctionAttributes(llvm::Function *, const FunctionDecl *);
 };
 
 } // namespace CodeGen
Index: clang/lib/CodeGen/CGHLSLRuntime.cpp
===
--- clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -87,7 +87,7 @@
 ConstantAsMetadata::get(B.getInt32(Counter))}));
 }
 
-void clang::CodeGen::CGHLSLRuntime::setHLSLFnuctionAttributes(
+void clang::CodeGen::CGHLSLRuntime::setHLSLFunctionAttributes(
 llvm::Function *F, const FunctionDecl *FD) {
   if (HLSLShaderAttr *ShaderAttr = FD->getAttr()) {
 const StringRef ShaderAttrKindStr = "dx.shader";


Index: clang/lib/CodeGen/CGHLSLRuntime.h
===
--- clang/lib/CodeGen/CGHLSLRuntime.h
+++ clang/lib/CodeGen/CGHLSLRuntime.h
@@ -47,7 +47,7 @@
 
   void finishCodeGen();
 
-  void setHLSLFnuctionAttributes(llvm::Function *, const FunctionDecl *);
+  void setHLSLFunctionAttributes(llvm::Function *, const FunctionDecl *);
 };
 
 } // namespace CodeGen
Index: clang/lib/CodeGen/CGHLSLRuntime.cpp
===
--- clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -87,7 +87,7 @@
 ConstantAsMetadata::get(B.getInt32(Counter))}));
 }
 
-void clang::CodeGen::CGHLSLRuntime::setHLSLFnuctionAttributes(
+void clang::CodeGen::CGHLSLRuntime::setHLSLFunctionAttributes(
 llvm::Function *F, const FunctionDecl *FD) {
   if (HLSLShaderAttr *ShaderAttr = FD->getAttr()) {
 const StringRef ShaderAttrKindStr = "dx.shader";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6134629 - [NFC][HLSL] Fix typo in CGHLSLRuntime.

2022-08-05 Thread Xiang Li via cfe-commits

Author: Xiang Li
Date: 2022-08-04T23:08:40-07:00
New Revision: 6134629af08705e1f495171221deb46f6ba3d65d

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

LOG: [NFC][HLSL] Fix typo in CGHLSLRuntime.

Change setHLSLFnuctionAttributes to setHLSLFunctionAttributes.

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

Added: 


Modified: 
clang/lib/CodeGen/CGHLSLRuntime.cpp
clang/lib/CodeGen/CGHLSLRuntime.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index b4f364dbf940..70c582285136 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -87,7 +87,7 @@ void CGHLSLRuntime::annotateHLSLResource(const VarDecl *D, 
GlobalVariable *GV) {
 ConstantAsMetadata::get(B.getInt32(Counter))}));
 }
 
-void clang::CodeGen::CGHLSLRuntime::setHLSLFnuctionAttributes(
+void clang::CodeGen::CGHLSLRuntime::setHLSLFunctionAttributes(
 llvm::Function *F, const FunctionDecl *FD) {
   if (HLSLShaderAttr *ShaderAttr = FD->getAttr()) {
 const StringRef ShaderAttrKindStr = "dx.shader";

diff  --git a/clang/lib/CodeGen/CGHLSLRuntime.h 
b/clang/lib/CodeGen/CGHLSLRuntime.h
index 25261be28ab4..a8a7c9c7929e 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -47,7 +47,7 @@ class CGHLSLRuntime {
 
   void finishCodeGen();
 
-  void setHLSLFnuctionAttributes(llvm::Function *, const FunctionDecl *);
+  void setHLSLFunctionAttributes(llvm::Function *, const FunctionDecl *);
 };
 
 } // namespace CodeGen



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


<    1   2