[PATCH] D149723: [clang-tidy] Optimize performance of RenamerClangTidyCheck

2023-05-02 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL created this revision.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
PiotrZSL requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Refactor RenamerClangTidyCheck to achieve better performance
by removing object copies, duplicated function calls and by
using RecursiveASTVisitor.

Measured -72% execution time on bugprone-reserved-identifier.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149723

Files:
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h

Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
===
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
@@ -102,24 +102,26 @@
 NamingCheckFailure() = default;
   };
 
-  using NamingCheckId = std::pair;
+  using NamingCheckId = std::pair;
 
   using NamingCheckFailureMap =
   llvm::DenseMap;
 
   /// Check Macros for style violations.
-  void checkMacro(SourceManager , const Token ,
+  void checkMacro(const SourceManager , const Token ,
   const MacroInfo *MI);
 
   /// Add a usage of a macro if it already has a violation.
   void expandMacro(const Token , const MacroInfo *MI);
 
   void addUsage(const RenamerClangTidyCheck::NamingCheckId ,
-SourceRange Range, SourceManager *SourceMgr = nullptr);
+SourceRange Range, const SourceManager *SourceMgr = nullptr);
 
   /// Convenience method when the usage to be added is a NamedDecl.
   void addUsage(const NamedDecl *Decl, SourceRange Range,
-SourceManager *SourceMgr = nullptr);
+const SourceManager *SourceMgr = nullptr);
+
+  void checkNamedDecl(const NamedDecl *Decl, const SourceManager );
 
 protected:
   /// Overridden by derived classes, returns information about if and how a Decl
Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -9,6 +9,7 @@
 #include "RenamerClangTidyCheck.h"
 #include "ASTUtils.h"
 #include "clang/AST/CXXInheritance.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Frontend/CompilerInstance.h"
@@ -43,9 +44,9 @@
 assert(Val != getEmptyKey() && "Cannot hash the empty key!");
 assert(Val != getTombstoneKey() && "Cannot hash the tombstone key!");
 
-std::hash SecondHash;
-return DenseMapInfo::getHashValue(Val.first) +
-   SecondHash(Val.second);
+return hash_combine(
+DenseMapInfo::getHashValue(Val.first),
+DenseMapInfo::getHashValue(Val.second));
   }
 
   static bool isEqual(const NamingCheckId , const NamingCheckId ) {
@@ -61,153 +62,6 @@
 
 namespace clang::tidy {
 
-namespace {
-
-/// Callback supplies macros to RenamerClangTidyCheck::checkMacro
-class RenamerClangTidyCheckPPCallbacks : public PPCallbacks {
-public:
-  RenamerClangTidyCheckPPCallbacks(Preprocessor *PP,
-   RenamerClangTidyCheck *Check)
-  : PP(PP), Check(Check) {}
-
-  /// MacroDefined calls checkMacro for macros in the main file
-  void MacroDefined(const Token ,
-const MacroDirective *MD) override {
-if (MD->getMacroInfo()->isBuiltinMacro())
-  return;
-if (PP->getSourceManager().isWrittenInBuiltinFile(
-MacroNameTok.getLocation()))
-  return;
-if (PP->getSourceManager().isWrittenInCommandLineFile(
-MacroNameTok.getLocation()))
-  return;
-Check->checkMacro(PP->getSourceManager(), MacroNameTok, MD->getMacroInfo());
-  }
-
-  /// MacroExpands calls expandMacro for macros in the main file
-  void MacroExpands(const Token , const MacroDefinition ,
-SourceRange /*Range*/,
-const MacroArgs * /*Args*/) override {
-Check->expandMacro(MacroNameTok, MD.getMacroInfo());
-  }
-
-private:
-  Preprocessor *PP;
-  RenamerClangTidyCheck *Check;
-};
-
-} // namespace
-
-RenamerClangTidyCheck::RenamerClangTidyCheck(StringRef CheckName,
- ClangTidyContext *Context)
-: ClangTidyCheck(CheckName, Context),
-  AggressiveDependentMemberLookup(
-  Options.getLocalOrGlobal("AggressiveDependentMemberLookup", false)) {}
-RenamerClangTidyCheck::~RenamerClangTidyCheck() = default;
-
-void RenamerClangTidyCheck::storeOptions(ClangTidyOptions::OptionMap ) {
-  Options.store(Opts, "AggressiveDependentMemberLookup",
-AggressiveDependentMemberLookup);
-}
-
-void 

[PATCH] D146178: [Clang][Sema] Fix comparison of constraint expressions

2023-05-02 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov updated this revision to Diff 518966.
alexander-shaposhnikov added a comment.

1. If innermost != nullptr (in getTemplateInstantiationArgs) and NS is a 
ClassTemplatePartialSpecializationDecl we were incorrectly adding the inner 
level of template args twice (once as an array of arguments and once as a 
retained level inside HandlePartialClassTemplateSpec )
2. Add more tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146178

Files:
  clang/include/clang/AST/DeclTemplate.h
  clang/include/clang/Sema/Template.h
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaTemplate/concepts-friends.cpp
  clang/test/SemaTemplate/concepts-out-of-line-def.cpp
  clang/test/SemaTemplate/concepts.cpp

Index: clang/test/SemaTemplate/concepts.cpp
===
--- clang/test/SemaTemplate/concepts.cpp
+++ clang/test/SemaTemplate/concepts.cpp
@@ -816,3 +816,101 @@
 static_assert(Parent::TakesBinary::i == 0);
 }
 
+namespace TemplateInsideNonTemplateClass {
+template concept C = true;
+
+template auto L = [] U>() {};
+
+struct Q {
+  template U> friend constexpr auto decltype(L)::operator()() const;
+};
+
+template 
+concept C1 = false;
+
+struct Foo {
+  template 
+  struct Bar {};
+
+  template 
+requires(C1)
+  struct Bar;
+};
+
+Foo::Bar BarInstance;
+} // namespace TemplateInsideNonTemplateClass
+
+namespace GH61959 {
+template 
+concept C = (sizeof(T0) >= 4);
+
+template
+struct Orig { };
+
+template
+struct Orig {
+  template requires C
+  void f() { }
+
+  template requires true
+  void f() { }
+};
+
+template  struct Mod {};
+
+template 
+struct Mod {
+  template  requires C
+  constexpr static int f() { return 1; }
+
+  template  requires C
+  constexpr static int f() { return 2; }
+};
+
+static_assert(Mod::f() == 1);
+static_assert(Mod::f() == 2);
+
+template
+struct Outer {
+  template
+  struct Inner {};
+
+  template
+  struct Inner {
+template
+void foo()  requires C && C && C{}
+template
+void foo()  requires true{}
+  };
+};
+
+void bar() {
+  Outer::Inner I;
+  I.foo();
+}
+} // namespace GH61959
+
+
+namespace TemplateInsideTemplateInsideTemplate {
+template
+concept C1 = false;
+
+template 
+struct W0 {
+  template 
+  struct W1 {
+template 
+struct F {
+  enum { value = 1 };
+};
+
+template 
+  requires C1
+struct F {
+  enum { value = 2 };
+};
+  };
+};
+
+static_assert(W0<0>::W1<1>::F::value == 1);
+} // TemplateInsideTemplateInsideTemplate
Index: clang/test/SemaTemplate/concepts-out-of-line-def.cpp
===
--- clang/test/SemaTemplate/concepts-out-of-line-def.cpp
+++ clang/test/SemaTemplate/concepts-out-of-line-def.cpp
@@ -127,3 +127,220 @@
 static_assert(S::specialization("str") == SPECIALIZATION_REQUIRES);
 
 } // namespace multiple_template_parameter_lists
+
+static constexpr int CONSTRAINED_METHOD_1 = 1;
+static constexpr int CONSTRAINED_METHOD_2 = 2;
+
+namespace constrained_members {
+
+template 
+struct S {
+  template 
+  static constexpr int constrained_method();
+};
+
+template <>
+template 
+constexpr int S<1>::constrained_method() { return CONSTRAINED_METHOD_1; }
+
+template <>
+template 
+constexpr int S<2>::constrained_method() { return CONSTRAINED_METHOD_2; }
+
+static_assert(S<1>::constrained_method() == CONSTRAINED_METHOD_1);
+static_assert(S<2>::constrained_method() == CONSTRAINED_METHOD_2);
+
+
+template 
+concept ConceptT1T2 = true;
+
+template
+struct S12 {
+  template T4>
+  static constexpr int constrained_method();
+};
+
+template<>
+template T5>
+constexpr int S12::constrained_method() { return CONSTRAINED_METHOD_1; }
+
+template<>
+template T5>
+constexpr int S12::constrained_method() { return CONSTRAINED_METHOD_2; }
+
+static_assert(S12::constrained_method() == CONSTRAINED_METHOD_1);
+static_assert(S12::constrained_method() == CONSTRAINED_METHOD_2);
+
+} // namespace constrained members
+
+namespace constrained_members_of_nested_types {
+
+template 
+struct S {
+  struct Inner0 {
+struct Inner1 {
+  template 
+  static constexpr int constrained_method();
+};
+  };
+};
+
+template <>
+template 
+constexpr int S<1>::Inner0::Inner1::constrained_method() { return CONSTRAINED_METHOD_1; }
+
+template <>
+template 
+constexpr int S<2>::Inner0::Inner1::constrained_method() { return CONSTRAINED_METHOD_2; }
+
+static_assert(S<1>::Inner0::Inner1::constrained_method() == CONSTRAINED_METHOD_1);
+static_assert(S<2>::Inner0::Inner1::constrained_method() == CONSTRAINED_METHOD_2);
+
+
+template 
+concept ConceptT1T2 = true;
+
+template
+struct S12 {
+  struct Inner0 {
+struct Inner1 {
+  template T4>
+  static constexpr int 

[PATCH] D149710: [RISCV] Add sifive-x280 processor with all of its extensions

2023-05-02 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149710

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


[PATCH] D141215: [clang-repl] Introduce Value to capture expression results

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

Fix typos


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141215

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/Value.h
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/InterpreterUtils.cpp
  clang/lib/Interpreter/InterpreterUtils.h
  clang/lib/Interpreter/Value.cpp
  clang/tools/clang-repl/CMakeLists.txt
  clang/unittests/Interpreter/CMakeLists.txt
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -17,6 +17,7 @@
 #include "clang/AST/Mangle.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Interpreter/Value.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Sema.h"
 
@@ -33,6 +34,11 @@
 #define CLANG_INTERPRETER_NO_SUPPORT_EXEC
 #endif
 
+int Global = 42;
+// JIT reports symbol not found on Windows without the visibility attribute.
+REPL_EXTERNAL_VISIBILITY int getGlobal() { return Global; }
+REPL_EXTERNAL_VISIBILITY void setGlobal(int val) { Global = val; }
+
 namespace {
 using Args = std::vector;
 static std::unique_ptr
@@ -276,8 +282,7 @@
   std::vector Args = {"-fno-delayed-template-parsing"};
   std::unique_ptr Interp = createInterpreter(Args);
 
-  llvm::cantFail(Interp->Parse("void* operator new(__SIZE_TYPE__, void* __p);"
-   "extern \"C\" int printf(const char*,...);"
+  llvm::cantFail(Interp->Parse("extern \"C\" int printf(const char*,...);"
"class A {};"
"struct B {"
"  template"
@@ -315,4 +320,95 @@
   free(NewA);
 }
 
+TEST(InterpreterTest, Value) {
+  std::unique_ptr Interp = createInterpreter();
+
+  Value V1;
+  llvm::cantFail(Interp->ParseAndExecute("int x = 42;"));
+  llvm::cantFail(Interp->ParseAndExecute("x", ));
+  EXPECT_TRUE(V1.isValid());
+  EXPECT_TRUE(V1.hasValue());
+  EXPECT_EQ(V1.getInt(), 42);
+  EXPECT_EQ(V1.convertTo(), 42);
+  EXPECT_TRUE(V1.getType()->isIntegerType());
+  EXPECT_EQ(V1.getKind(), Value::K_Int);
+  EXPECT_FALSE(V1.isManuallyAlloc());
+
+  Value V2;
+  llvm::cantFail(Interp->ParseAndExecute("double y = 3.14;"));
+  llvm::cantFail(Interp->ParseAndExecute("y", ));
+  EXPECT_TRUE(V2.isValid());
+  EXPECT_TRUE(V2.hasValue());
+  EXPECT_EQ(V2.getDouble(), 3.14);
+  EXPECT_EQ(V2.convertTo(), 3.14);
+  EXPECT_TRUE(V2.getType()->isFloatingType());
+  EXPECT_EQ(V2.getKind(), Value::K_Double);
+  EXPECT_FALSE(V2.isManuallyAlloc());
+
+  Value V3;
+  llvm::cantFail(Interp->ParseAndExecute(
+  "struct S { int* p; S() { p = new int(42); } ~S() { delete p; }};"));
+  llvm::cantFail(Interp->ParseAndExecute("S{}", ));
+  EXPECT_TRUE(V3.isValid());
+  EXPECT_TRUE(V3.hasValue());
+  EXPECT_TRUE(V3.getType()->isRecordType());
+  EXPECT_EQ(V3.getKind(), Value::K_PtrOrObj);
+  EXPECT_TRUE(V3.isManuallyAlloc());
+
+  Value V4;
+  llvm::cantFail(Interp->ParseAndExecute("int getGlobal();"));
+  llvm::cantFail(Interp->ParseAndExecute("void setGlobal(int);"));
+  llvm::cantFail(Interp->ParseAndExecute("getGlobal()", ));
+  EXPECT_EQ(V4.getInt(), 42);
+  EXPECT_TRUE(V4.getType()->isIntegerType());
+
+  Value V5;
+  // Change the global from the compiled code.
+  setGlobal(43);
+  llvm::cantFail(Interp->ParseAndExecute("getGlobal()", ));
+  EXPECT_EQ(V5.getInt(), 43);
+  EXPECT_TRUE(V5.getType()->isIntegerType());
+
+  // Change the global from the interpreted code.
+  llvm::cantFail(Interp->ParseAndExecute("setGlobal(44);"));
+  EXPECT_EQ(getGlobal(), 44);
+
+  Value V6;
+  llvm::cantFail(Interp->ParseAndExecute("void foo() {}"));
+  llvm::cantFail(Interp->ParseAndExecute("foo()", ));
+  EXPECT_TRUE(V6.isValid());
+  EXPECT_FALSE(V6.hasValue());
+  EXPECT_TRUE(V6.getType()->isVoidType());
+  EXPECT_EQ(V6.getKind(), Value::K_Void);
+  EXPECT_FALSE(V2.isManuallyAlloc());
+
+  Value V7;
+  llvm::cantFail(Interp->ParseAndExecute("foo", ));
+  EXPECT_TRUE(V7.isValid());
+  EXPECT_TRUE(V7.hasValue());
+  EXPECT_TRUE(V7.getType()->isFunctionProtoType());
+  EXPECT_EQ(V7.getKind(), Value::K_PtrOrObj);
+  EXPECT_FALSE(V7.isManuallyAlloc());
+
+  Value V8;
+  llvm::cantFail(Interp->ParseAndExecute("struct SS{ void f() {} };"));
+  llvm::cantFail(Interp->ParseAndExecute("::f", ));
+  EXPECT_TRUE(V8.isValid());
+  EXPECT_TRUE(V8.hasValue());
+  EXPECT_TRUE(V8.getType()->isMemberFunctionPointerType());
+  EXPECT_EQ(V8.getKind(), Value::K_PtrOrObj);
+  EXPECT_TRUE(V8.isManuallyAlloc());
+
+  Value V9;
+  

[PATCH] D149612: [Sema] avoid merge error type

2023-05-02 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a subscriber: rsmith.
shafik added a comment.

In D149612#4314209 , @HerrCai0907 
wrote:

> in SemaType.cpp#BuildArrayType, It will generate `DependentSizedArrayType` 
> which cannot be merged. 
> So we can either add additional check in `MergeVarDeclTypes` or directly 
> ignore to generate this type in `BuildArrayType`.
> Which one is better?
>
>   } else if (ArraySize->isTypeDependent() || ArraySize->isValueDependent()) {
> T = Context.getDependentSizedArrayType(T, ArraySize, ASM, Quals, 
> Brackets);

I am not sure where the right place to fix this is, or when it is correct to 
use `containsErrors()`

Maybe @aaron.ballman or @rsmith might have some advice


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149612

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


[PATCH] D141215: [clang-repl] Introduce Value to capture expression results

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



Comment at: clang/include/clang/Interpreter/Interpreter.h:59
+
+  Value LastValue;
 

v.g.vassilev wrote:
> aaron.ballman wrote:
> > I think I'm surprised to see this as a data member of `Interpreter` but 
> > mostly because my brain keeps thinking this interpreter is to interpret 
> > whole programs, so the idea of a "last value" is a bit odd from that 
> > context. The name is probably fine as-is, but I figured it may be worth 
> > mentioning just the same.
> One way to think of this is every `repl` has some way to access the last 
> result it created when executed its last chunk of input. In python that's the 
> `_` value. In the debugger it is the `%N` where N is some number. Here this 
> variable would enable implementing a similar to these in future.
I added some comments.



Comment at: clang/include/clang/Interpreter/Value.h:83
+  Value() = default;
+  Value(void /*Interpreter*/ *In, void /*QualType*/ *Ty);
+  Value(const Value );

aaron.ballman wrote:
> junaire wrote:
> > aaron.ballman wrote:
> > > v.g.vassilev wrote:
> > > > junaire wrote:
> > > > > aaron.ballman wrote:
> > > > > > Why do these take `void *` instead of the expected type?
> > > > > Yeah for the first parameter, we could just use `Interpreter*` but 
> > > > > the second one is an opaque type so I think we should keep it?
> > > > See my previous comments on performance. We cannot include anything 
> > > > bulky in the header file.
> > > I think I understand why the design is the way it is, but it still makes 
> > > me uneasy. The constructor takes a pointer to some bucket of bytes... no 
> > > size information, no type information, etc. Just "here's a random 
> > > pointer". And then later, we hope the user calls `setKind()` in a way 
> > > that makes sense.
> > > 
> > > We need it to be fast, but we also need it to be correct -- the type 
> > > system is the best tool for helping with that.
> > Not really... The user doesn't need to call `setKind()` explicitly to 
> > construct a `Value`, the constructor will handle it automatically. See 
> > `ConvertQualTypeToKind` in `Value.cpp`. So if the pointer is just some 
> > garbage data, the constructor should fail before yielding out a valid 
> > instance.
> Yeah, that's a fair point, except nothing actually validates that the opaque 
> pointer you are handed is actually valid for anything because it eventually 
> just does a reinterpret_cast, so I don't think the constructor will fail.
OK, let me try to answer why we're passing `QualType` in an opaque pointer way. 
So the `Value` is *constructed* in `__clang_Interpreter_SetValue*` variants, 
and these functions (let's call them runtime interfaces) are synthesized when 
we want to do value printing (like we have a `x` without semi). So it makes 
things pretty hard if we use a complete type (How can we synthesize that type? 
That dramatically complicated the code) In addition, we want `Value.h`, which 
is part of the runtime, as lightweight as possible, so we can't use the 
complete type in its constructor, or we have to include the corresponding 
header file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141215

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


[PATCH] D141215: [clang-repl] Introduce Value to capture expression results

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

Add more comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141215

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/Value.h
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/InterpreterUtils.cpp
  clang/lib/Interpreter/InterpreterUtils.h
  clang/lib/Interpreter/Value.cpp
  clang/tools/clang-repl/CMakeLists.txt
  clang/unittests/Interpreter/CMakeLists.txt
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -17,6 +17,7 @@
 #include "clang/AST/Mangle.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Interpreter/Value.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Sema.h"
 
@@ -33,6 +34,11 @@
 #define CLANG_INTERPRETER_NO_SUPPORT_EXEC
 #endif
 
+int Global = 42;
+// JIT reports symbol not found on Windows without the visibility attribute.
+REPL_EXTERNAL_VISIBILITY int getGlobal() { return Global; }
+REPL_EXTERNAL_VISIBILITY void setGlobal(int val) { Global = val; }
+
 namespace {
 using Args = std::vector;
 static std::unique_ptr
@@ -276,8 +282,7 @@
   std::vector Args = {"-fno-delayed-template-parsing"};
   std::unique_ptr Interp = createInterpreter(Args);
 
-  llvm::cantFail(Interp->Parse("void* operator new(__SIZE_TYPE__, void* __p);"
-   "extern \"C\" int printf(const char*,...);"
+  llvm::cantFail(Interp->Parse("extern \"C\" int printf(const char*,...);"
"class A {};"
"struct B {"
"  template"
@@ -315,4 +320,95 @@
   free(NewA);
 }
 
+TEST(InterpreterTest, Value) {
+  std::unique_ptr Interp = createInterpreter();
+
+  Value V1;
+  llvm::cantFail(Interp->ParseAndExecute("int x = 42;"));
+  llvm::cantFail(Interp->ParseAndExecute("x", ));
+  EXPECT_TRUE(V1.isValid());
+  EXPECT_TRUE(V1.hasValue());
+  EXPECT_EQ(V1.getInt(), 42);
+  EXPECT_EQ(V1.convertTo(), 42);
+  EXPECT_TRUE(V1.getType()->isIntegerType());
+  EXPECT_EQ(V1.getKind(), Value::K_Int);
+  EXPECT_FALSE(V1.isManuallyAlloc());
+
+  Value V2;
+  llvm::cantFail(Interp->ParseAndExecute("double y = 3.14;"));
+  llvm::cantFail(Interp->ParseAndExecute("y", ));
+  EXPECT_TRUE(V2.isValid());
+  EXPECT_TRUE(V2.hasValue());
+  EXPECT_EQ(V2.getDouble(), 3.14);
+  EXPECT_EQ(V2.convertTo(), 3.14);
+  EXPECT_TRUE(V2.getType()->isFloatingType());
+  EXPECT_EQ(V2.getKind(), Value::K_Double);
+  EXPECT_FALSE(V2.isManuallyAlloc());
+
+  Value V3;
+  llvm::cantFail(Interp->ParseAndExecute(
+  "struct S { int* p; S() { p = new int(42); } ~S() { delete p; }};"));
+  llvm::cantFail(Interp->ParseAndExecute("S{}", ));
+  EXPECT_TRUE(V3.isValid());
+  EXPECT_TRUE(V3.hasValue());
+  EXPECT_TRUE(V3.getType()->isRecordType());
+  EXPECT_EQ(V3.getKind(), Value::K_PtrOrObj);
+  EXPECT_TRUE(V3.isManuallyAlloc());
+
+  Value V4;
+  llvm::cantFail(Interp->ParseAndExecute("int getGlobal();"));
+  llvm::cantFail(Interp->ParseAndExecute("void setGlobal(int);"));
+  llvm::cantFail(Interp->ParseAndExecute("getGlobal()", ));
+  EXPECT_EQ(V4.getInt(), 42);
+  EXPECT_TRUE(V4.getType()->isIntegerType());
+
+  Value V5;
+  // Change the global from the compiled code.
+  setGlobal(43);
+  llvm::cantFail(Interp->ParseAndExecute("getGlobal()", ));
+  EXPECT_EQ(V5.getInt(), 43);
+  EXPECT_TRUE(V5.getType()->isIntegerType());
+
+  // Change the global from the interpreted code.
+  llvm::cantFail(Interp->ParseAndExecute("setGlobal(44);"));
+  EXPECT_EQ(getGlobal(), 44);
+
+  Value V6;
+  llvm::cantFail(Interp->ParseAndExecute("void foo() {}"));
+  llvm::cantFail(Interp->ParseAndExecute("foo()", ));
+  EXPECT_TRUE(V6.isValid());
+  EXPECT_FALSE(V6.hasValue());
+  EXPECT_TRUE(V6.getType()->isVoidType());
+  EXPECT_EQ(V6.getKind(), Value::K_Void);
+  EXPECT_FALSE(V2.isManuallyAlloc());
+
+  Value V7;
+  llvm::cantFail(Interp->ParseAndExecute("foo", ));
+  EXPECT_TRUE(V7.isValid());
+  EXPECT_TRUE(V7.hasValue());
+  EXPECT_TRUE(V7.getType()->isFunctionProtoType());
+  EXPECT_EQ(V7.getKind(), Value::K_PtrOrObj);
+  EXPECT_FALSE(V7.isManuallyAlloc());
+
+  Value V8;
+  llvm::cantFail(Interp->ParseAndExecute("struct SS{ void f() {} };"));
+  llvm::cantFail(Interp->ParseAndExecute("::f", ));
+  EXPECT_TRUE(V8.isValid());
+  EXPECT_TRUE(V8.hasValue());
+  EXPECT_TRUE(V8.getType()->isMemberFunctionPointerType());
+  EXPECT_EQ(V8.getKind(), Value::K_PtrOrObj);
+  

[PATCH] D149149: [clang][Interp] Check one-past-the-end pointers in GetPtrField

2023-05-02 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/test/AST/Interp/records.cpp:500
 
 namespace PointerArith {
   struct A {};

aaron.ballman wrote:
> Neat! For the tests in this namespace, Clang and ICC agree, GCC and MSVC 
> agree, and users get to cry: https://godbolt.org/z/7EWWrY5z6
Yeah, unfortunate but I am pretty sure clang is correct on both of those.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149149

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


[PATCH] D141215: [clang-repl] Introduce Value to capture expression results

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



Comment at: clang/include/clang/Interpreter/Value.h:46
+
+#define REPL_BUILTIN_TYPES 
\
+  X(bool, Bool)
\

aaron.ballman wrote:
> v.g.vassilev wrote:
> > aaron.ballman wrote:
> > > v.g.vassilev wrote:
> > > > aaron.ballman wrote:
> > > > > Is this expected to be a complete list of builtin types? e.g., should 
> > > > > this have `char8_t` and `void` and `wchar_t`, etc? Should this be 
> > > > > including `clang/include/clang/AST/BuiltinTypes.def` instead of 
> > > > > manually maintaining the list?
> > > > This is used for various things including storing the bits into a 
> > > > big-endian agnostic way. For `void` we have a special case in the Value 
> > > > and we cannot define a union of a `void` type. We can include the 
> > > > others that you suggest. All the relevant ones are described in 
> > > > `clang::BuiltinType::getName`.
> > > > 
> > > > We cannot use `BuiltinTypes.def` because we want to have a mapping 
> > > > between the type as written in the language (eg, `bool`, `unsigned`, 
> > > > etc) and its underlying type name. That mapping is not available in 
> > > > `BuiltinTypes.def`. Ideally we should extend `BuiltinTypes.def` somehow 
> > > > but I'd prefer outside of this patch. One of the challenges is that 
> > > > some of the types depend on the language options (eg. `_Bool` vs 
> > > > `bool`) and I am not sure this can be resolved by tablegen.
> > > > 
> > > > On a broader perspective, the `Value` class is responsible for two 
> > > > things: (a) get a value from the interpreter to compiled code (see test 
> > > > case); (b) set a value from compiled code to the interpreter. The 
> > > > second case is not yet covered (I can open soon another patch). The 
> > > > major use-case is calling at runtime functions and taking input 
> > > > parameters from compiled code.
> > > > 
> > > > FWIW, we should probably move all of these entities in a separate 
> > > > namespace. I'd suggest `caas` (compiler-as-a-service) and possibly 
> > > > rename the `Value` to `InterpreterValue` since `Value` is very generic 
> > > > and there are already a couple of classes with that name in llvm and 
> > > > clang. 
> > > > We can include the others that you suggest. All the relevant ones are 
> > > > described in clang::BuiltinType::getName.
> > > 
> > > Okay, so the plan is to handle all the builtin types (`_BitInt`, 
> > > `_Complex`, various floating point formats, etc)? Will that be part of 
> > > this patch or in follow-up work? (My intuition is that we should consider 
> > > it up front because some of the builtin types are interesting -- like 
> > > `_BitInt` because it's parameterized, which makes it novel compared to 
> > > the other types.)
> > > 
> > > > We cannot use BuiltinTypes.def because we want to have a mapping 
> > > > between the type as written in the language (eg, bool, unsigned, etc) 
> > > > and its underlying type name. That mapping is not available in 
> > > > BuiltinTypes.def. Ideally we should extend BuiltinTypes.def somehow but 
> > > > I'd prefer outside of this patch. One of the challenges is that some of 
> > > > the types depend on the language options (eg. _Bool vs bool) and I am 
> > > > not sure this can be resolved by tablegen.
> > > 
> > > Thanks for the explanation! BuiltinTypes.def works well enough for times 
> > > when we want to use macros and include the file to generate switch cases 
> > > and the likes, but you're right that it's not well-suited for this. One 
> > > thing to consider is whether we should change `BuiltinTypes.def` to be 
> > > `BuiltinTypes.td` instead and use tablegen to generate the macro/include 
> > > dance form as well as other output (such as for your needs, that can then 
> > > consider language options or more complex predicates).
> > > 
> > > > FWIW, we should probably move all of these entities in a separate 
> > > > namespace. I'd suggest caas (compiler-as-a-service) and possibly rename 
> > > > the Value to InterpreterValue since Value is very generic and there are 
> > > > already a couple of classes with that name in llvm and clang.
> > > 
> > > I'm not in love with the name `caas` because that's not really a common 
> > > acronym or abbreviation (and it looks like a typo due to `aa`). However, 
> > > we already have an `interp` namespace in Clang for one of the other 
> > > interpreters (constant expression evaluation), so that's not available 
> > > for use. How about `repl` though?
> > > 
> > > As for considering changing the name from `Value` because of how many 
> > > other `Value` types we have already... that's both a reason to rename and 
> > > reason not to rename. I think I'm fine leaving it as `Value` so long as 
> > > it's in a novel namespace.
> > > > We can include the others that you suggest. All the relevant ones are 
> > > > described 

[PATCH] D141215: [clang-repl] Introduce Value to capture expression results

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

Address comments from @aaron.ballman, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141215

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/Value.h
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/InterpreterUtils.cpp
  clang/lib/Interpreter/InterpreterUtils.h
  clang/lib/Interpreter/Value.cpp
  clang/tools/clang-repl/CMakeLists.txt
  clang/unittests/Interpreter/CMakeLists.txt
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -17,6 +17,7 @@
 #include "clang/AST/Mangle.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Interpreter/Value.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Sema.h"
 
@@ -33,6 +34,11 @@
 #define CLANG_INTERPRETER_NO_SUPPORT_EXEC
 #endif
 
+int Global = 42;
+// JIT reports symbol not found on Windows without the visibility attribute.
+REPL_EXTERNAL_VISIBILITY int getGlobal() { return Global; }
+REPL_EXTERNAL_VISIBILITY void setGlobal(int val) { Global = val; }
+
 namespace {
 using Args = std::vector;
 static std::unique_ptr
@@ -276,8 +282,7 @@
   std::vector Args = {"-fno-delayed-template-parsing"};
   std::unique_ptr Interp = createInterpreter(Args);
 
-  llvm::cantFail(Interp->Parse("void* operator new(__SIZE_TYPE__, void* __p);"
-   "extern \"C\" int printf(const char*,...);"
+  llvm::cantFail(Interp->Parse("extern \"C\" int printf(const char*,...);"
"class A {};"
"struct B {"
"  template"
@@ -315,4 +320,95 @@
   free(NewA);
 }
 
+TEST(InterpreterTest, Value) {
+  std::unique_ptr Interp = createInterpreter();
+
+  Value V1;
+  llvm::cantFail(Interp->ParseAndExecute("int x = 42;"));
+  llvm::cantFail(Interp->ParseAndExecute("x", ));
+  EXPECT_TRUE(V1.isValid());
+  EXPECT_TRUE(V1.hasValue());
+  EXPECT_EQ(V1.getInt(), 42);
+  EXPECT_EQ(V1.convertTo(), 42);
+  EXPECT_TRUE(V1.getType()->isIntegerType());
+  EXPECT_EQ(V1.getKind(), Value::K_Int);
+  EXPECT_FALSE(V1.isManuallyAlloc());
+
+  Value V2;
+  llvm::cantFail(Interp->ParseAndExecute("double y = 3.14;"));
+  llvm::cantFail(Interp->ParseAndExecute("y", ));
+  EXPECT_TRUE(V2.isValid());
+  EXPECT_TRUE(V2.hasValue());
+  EXPECT_EQ(V2.getDouble(), 3.14);
+  EXPECT_EQ(V2.convertTo(), 3.14);
+  EXPECT_TRUE(V2.getType()->isFloatingType());
+  EXPECT_EQ(V2.getKind(), Value::K_Double);
+  EXPECT_FALSE(V2.isManuallyAlloc());
+
+  Value V3;
+  llvm::cantFail(Interp->ParseAndExecute(
+  "struct S { int* p; S() { p = new int(42); } ~S() { delete p; }};"));
+  llvm::cantFail(Interp->ParseAndExecute("S{}", ));
+  EXPECT_TRUE(V3.isValid());
+  EXPECT_TRUE(V3.hasValue());
+  EXPECT_TRUE(V3.getType()->isRecordType());
+  EXPECT_EQ(V3.getKind(), Value::K_PtrOrObj);
+  EXPECT_TRUE(V3.isManuallyAlloc());
+
+  Value V4;
+  llvm::cantFail(Interp->ParseAndExecute("int getGlobal();"));
+  llvm::cantFail(Interp->ParseAndExecute("void setGlobal(int);"));
+  llvm::cantFail(Interp->ParseAndExecute("getGlobal()", ));
+  EXPECT_EQ(V4.getInt(), 42);
+  EXPECT_TRUE(V4.getType()->isIntegerType());
+
+  Value V5;
+  // Change the global from the compiled code.
+  setGlobal(43);
+  llvm::cantFail(Interp->ParseAndExecute("getGlobal()", ));
+  EXPECT_EQ(V5.getInt(), 43);
+  EXPECT_TRUE(V5.getType()->isIntegerType());
+
+  // Change the global from the interpreted code.
+  llvm::cantFail(Interp->ParseAndExecute("setGlobal(44);"));
+  EXPECT_EQ(getGlobal(), 44);
+
+  Value V6;
+  llvm::cantFail(Interp->ParseAndExecute("void foo() {}"));
+  llvm::cantFail(Interp->ParseAndExecute("foo()", ));
+  EXPECT_TRUE(V6.isValid());
+  EXPECT_FALSE(V6.hasValue());
+  EXPECT_TRUE(V6.getType()->isVoidType());
+  EXPECT_EQ(V6.getKind(), Value::K_Void);
+  EXPECT_FALSE(V2.isManuallyAlloc());
+
+  Value V7;
+  llvm::cantFail(Interp->ParseAndExecute("foo", ));
+  EXPECT_TRUE(V7.isValid());
+  EXPECT_TRUE(V7.hasValue());
+  EXPECT_TRUE(V7.getType()->isFunctionProtoType());
+  EXPECT_EQ(V7.getKind(), Value::K_PtrOrObj);
+  EXPECT_FALSE(V7.isManuallyAlloc());
+
+  Value V8;
+  llvm::cantFail(Interp->ParseAndExecute("struct SS{ void f() {} };"));
+  llvm::cantFail(Interp->ParseAndExecute("::f", ));
+  EXPECT_TRUE(V8.isValid());
+  EXPECT_TRUE(V8.hasValue());
+  EXPECT_TRUE(V8.getType()->isMemberFunctionPointerType());
+  EXPECT_EQ(V8.getKind(), Value::K_PtrOrObj);
+  

[PATCH] D149709: Fix a typo in head comment of CurPPLexer

2023-05-02 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe46aa7f92729: Fix a typo in head comment of `CurPPLexer`. 
(authored by zhouyizhou, committed by vsapsai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149709

Files:
  clang/include/clang/Lex/Preprocessor.h


Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -729,7 +729,7 @@
   /// Only one of CurLexer, or CurTokenLexer will be non-null.
   std::unique_ptr CurLexer;
 
-  /// The current top of the stack what we're lexing from
+  /// The current top of the stack that we're lexing from
   /// if not expanding a macro.
   ///
   /// This is an alias for CurLexer.


Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -729,7 +729,7 @@
   /// Only one of CurLexer, or CurTokenLexer will be non-null.
   std::unique_ptr CurLexer;
 
-  /// The current top of the stack what we're lexing from
+  /// The current top of the stack that we're lexing from
   /// if not expanding a macro.
   ///
   /// This is an alias for CurLexer.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e46aa7f - Fix a typo in head comment of `CurPPLexer`.

2023-05-02 Thread Volodymyr Sapsai via cfe-commits

Author: Zhouyi Zhou
Date: 2023-05-02T19:49:21-07:00
New Revision: e46aa7f927293989dae40817c0087cba9cf5fae7

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

LOG: Fix a typo in head comment of `CurPPLexer`.

In head comment of CurPPLexer field of class Preprocessor,
'The current top of the stack what we're lexing from' should be
'The current top of the stack that we're lexing from'.

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

Added: 


Modified: 
clang/include/clang/Lex/Preprocessor.h

Removed: 




diff  --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index a34a451f4bad1..8bdaf25e9b870 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -729,7 +729,7 @@ class Preprocessor {
   /// Only one of CurLexer, or CurTokenLexer will be non-null.
   std::unique_ptr CurLexer;
 
-  /// The current top of the stack what we're lexing from
+  /// The current top of the stack that we're lexing from
   /// if not expanding a macro.
   ///
   /// This is an alias for CurLexer.



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


[PATCH] D149709: Fix a typo in head comment of CurPPLexer

2023-05-02 Thread zhouyizhou via Phabricator via cfe-commits
zhouyizhou added a comment.

In D149709#4314390 , @vsapsai wrote:

> Thanks for the fix! Don't see any other places in the file to fix.

Thanks for review my patch ;-)
I have no write access to LLVM project,  can you commit it for me ?

Thanks in Advance ;-)
Zhouyi Zhou  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149709

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


[PATCH] D149718: [NFC][Clang] Fix Coverity issues of copy without assign

2023-05-02 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added a reviewer: tahonermann.
Herald added a reviewer: NoQ.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

This patch adds missing assignment operator to the class which has user-defined 
copy/move constructor.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149718

Files:
  clang/include/clang/Analysis/BodyFarm.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp


Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -42,6 +42,7 @@
   Code(serialization::STMT_NULL_PTR), AbbrevToUse(0) {}
 
 ASTStmtWriter(const ASTStmtWriter&) = delete;
+ASTStmtWriter =(const ASTStmtWriter&) = delete;
 
 uint64_t Emit() {
   assert(Code != serialization::STMT_NULL_PTR &&
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -762,6 +762,7 @@
 public:
   Strategy() = default;
   Strategy(const Strategy &) = delete; // Let's avoid copies.
+  Strategy =(const Strategy &) = delete;
   Strategy(Strategy &&) = default;
 
   void set(const VarDecl *VD, Kind K) { Map[VD] = K; }
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -1783,6 +1783,7 @@
 SemaDiagnosticBuilder(Kind K, SourceLocation Loc, unsigned DiagID,
   const FunctionDecl *Fn, Sema );
 SemaDiagnosticBuilder(SemaDiagnosticBuilder &);
+SemaDiagnosticBuilder =(SemaDiagnosticBuilder &);
 SemaDiagnosticBuilder(const SemaDiagnosticBuilder &) = default;
 ~SemaDiagnosticBuilder();
 
Index: clang/include/clang/Sema/ParsedAttr.h
===
--- clang/include/clang/Sema/ParsedAttr.h
+++ clang/include/clang/Sema/ParsedAttr.h
@@ -696,6 +696,7 @@
   AttributePool(AttributeFactory ) : Factory(factory) {}
 
   AttributePool(const AttributePool &) = delete;
+  AttributePool =(const AttributePool &) = delete;
 
   ~AttributePool() { Factory.reclaimPool(*this); }
 
@@ -912,6 +913,7 @@
 public:
   ParsedAttributes(AttributeFactory ) : pool(factory) {}
   ParsedAttributes(const ParsedAttributes &) = delete;
+  ParsedAttributes =(const ParsedAttributes &) = delete;
 
   AttributePool () const { return pool; }
 
Index: clang/include/clang/Analysis/BodyFarm.h
===
--- clang/include/clang/Analysis/BodyFarm.h
+++ clang/include/clang/Analysis/BodyFarm.h
@@ -40,6 +40,9 @@
   /// Remove copy constructor to avoid accidental copying.
   BodyFarm(const BodyFarm ) = delete;
 
+  /// Copy assignment opearator.
+  BodyFarm =(const BodyFarm ) = delete;
+
 private:
   typedef llvm::DenseMap> BodyMap;
 


Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -42,6 +42,7 @@
   Code(serialization::STMT_NULL_PTR), AbbrevToUse(0) {}
 
 ASTStmtWriter(const ASTStmtWriter&) = delete;
+ASTStmtWriter =(const ASTStmtWriter&) = delete;
 
 uint64_t Emit() {
   assert(Code != serialization::STMT_NULL_PTR &&
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -762,6 +762,7 @@
 public:
   Strategy() = default;
   Strategy(const Strategy &) = delete; // Let's avoid copies.
+  Strategy =(const Strategy &) = delete;
   Strategy(Strategy &&) = default;
 
   void set(const VarDecl *VD, Kind K) { Map[VD] = K; }
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -1783,6 +1783,7 @@
 SemaDiagnosticBuilder(Kind K, SourceLocation Loc, unsigned DiagID,
   const FunctionDecl *Fn, Sema );
 SemaDiagnosticBuilder(SemaDiagnosticBuilder &);
+SemaDiagnosticBuilder =(SemaDiagnosticBuilder &);
 SemaDiagnosticBuilder(const SemaDiagnosticBuilder &) = default;
 ~SemaDiagnosticBuilder();
 
Index: clang/include/clang/Sema/ParsedAttr.h
===
--- clang/include/clang/Sema/ParsedAttr.h
+++ clang/include/clang/Sema/ParsedAttr.h
@@ -696,6 +696,7 @@
   AttributePool(AttributeFactory ) : Factory(factory) {}
 
   AttributePool(const AttributePool &) = 

[PATCH] D149716: clang: Use new frexp intrinsic for builtins and add f16 version

2023-05-02 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 518947.

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

https://reviews.llvm.org/D149716

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aix-builtin-mapping.c
  clang/test/CodeGen/builtin-attributes.c
  clang/test/CodeGen/math-builtins-long.c
  clang/test/CodeGen/math-builtins.c
  clang/test/CodeGenOpenCL/builtins-generic-amdgcn.cl

Index: clang/test/CodeGenOpenCL/builtins-generic-amdgcn.cl
===
--- clang/test/CodeGenOpenCL/builtins-generic-amdgcn.cl
+++ clang/test/CodeGenOpenCL/builtins-generic-amdgcn.cl
@@ -39,3 +39,18 @@
 double test_builtin_ldexp(double v, int e) {
   return __builtin_ldexp(v, e);
 }
+
+// CHECK-LABEL: @test_builtin_frexpf16(
+half test_builtin_frexpf16(half v, int* e) {
+  return __builtin_frexpf16(v, e);
+}
+
+// CHECK-LABEL: @test_builtin_frexpf(
+float test_builtin_frexpf(float v, int* e) {
+  return __builtin_frexpf(v, e);
+}
+
+// CHECK-LABEL: @test_builtin_builtin_frexp(
+double test_builtin_frexp(double v, int* e) {
+  return __builtin_frexp(v, e);
+}
Index: clang/test/CodeGen/math-builtins.c
===
--- clang/test/CodeGen/math-builtins.c
+++ clang/test/CodeGen/math-builtins.c
@@ -12,6 +12,30 @@
 // NO__ERRNO: frem float
 // NO__ERRNO: frem x86_fp80
 // NO__ERRNO: frem fp128
+
+// NO__ERRNO: [[FREXP_F64:%.+]] = call { double, i32 } @llvm.frexp.f64.i32(double %{{.+}})
+// NO__ERRNO-NEXT: [[FREXP_F64_1:%.+]] = extractvalue { double, i32 } [[FREXP_F64]], 1
+// NO__ERRNO-NEXT: store i32 [[FREXP_F64_1]], ptr %{{.+}}, align 4
+// NO__ERRNO-NEXT: [[FREXP_F64_0:%.+]] = extractvalue { double, i32 } [[FREXP_F64]], 0
+
+// NO__ERRNO: [[FREXP_F32:%.+]] = call { float, i32 } @llvm.frexp.f32.i32(float %{{.+}})
+// NO__ERRNO-NEXT: [[FREXP_F32_1:%.+]] = extractvalue { float, i32 } [[FREXP_F32]], 1
+// NO__ERRNO-NEXT: store i32 [[FREXP_F32_1]], ptr %{{.+}}, align 4
+// NO__ERRNO-NEXT: [[FREXP_F32_0:%.+]] = extractvalue { float, i32 } [[FREXP_F32]], 0
+
+
+// NO__ERRNO: [[FREXP_F80:%.+]] = call { x86_fp80, i32 } @llvm.frexp.f80.i32(x86_fp80 %{{.+}})
+// NO__ERRNO-NEXT: [[FREXP_F80_1:%.+]] = extractvalue { x86_fp80, i32 } [[FREXP_F80]], 1
+// NO__ERRNO-NEXT: store i32 [[FREXP_F80_1]], ptr %{{.+}}, align 4
+// NO__ERRNO-NEXT: [[FREXP_F80_0:%.+]] = extractvalue { x86_fp80, i32 } [[FREXP_F80]], 0
+
+
+// NO__ERRNO: [[FREXP_F128:%.+]] = call { fp128, i32 } @llvm.frexp.f128.i32(fp128 %{{.+}})
+// NO__ERRNO-NEXT: [[FREXP_F128_1:%.+]] = extractvalue { fp128, i32 } [[FREXP_F128]], 1
+// NO__ERRNO-NEXT: store i32 [[FREXP_F128_1]], ptr %{{.+}}, align 4
+// NO__ERRNO-NEXT: [[FREXP_F128_0:%.+]] = extractvalue { fp128, i32 } [[FREXP_F128]], 0
+
+
 // HAS_ERRNO: declare double @fmod(double noundef, double noundef) [[NOT_READNONE:#[0-9]+]]
 // HAS_ERRNO: declare float @fmodf(float noundef, float noundef) [[NOT_READNONE]]
 // HAS_ERRNO: declare x86_fp80 @fmodl(x86_fp80 noundef, x86_fp80 noundef) [[NOT_READNONE]]
@@ -52,14 +76,14 @@
 
   __builtin_frexp(f,i);__builtin_frexpf(f,i);   __builtin_frexpl(f,i); __builtin_frexpf128(f,i);
 
-// NO__ERRNO: declare double @frexp(double noundef, ptr noundef) [[NOT_READNONE:#[0-9]+]]
-// NO__ERRNO: declare float @frexpf(float noundef, ptr noundef) [[NOT_READNONE]]
-// NO__ERRNO: declare x86_fp80 @frexpl(x86_fp80 noundef, ptr noundef) [[NOT_READNONE]]
-// NO__ERRNO: declare fp128 @frexpf128(fp128 noundef, ptr noundef) [[NOT_READNONE]]
-// HAS_ERRNO: declare double @frexp(double noundef, ptr noundef) [[NOT_READNONE]]
-// HAS_ERRNO: declare float @frexpf(float noundef, ptr noundef) [[NOT_READNONE]]
-// HAS_ERRNO: declare x86_fp80 @frexpl(x86_fp80 noundef, ptr noundef) [[NOT_READNONE]]
-// HAS_ERRNO: declare fp128 @frexpf128(fp128 noundef, ptr noundef) [[NOT_READNONE]]
+// NO__ERRNO: declare { double, i32 } @llvm.frexp.f64.i32(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare { float, i32 } @llvm.frexp.f32.i32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare { x86_fp80, i32 } @llvm.frexp.f80.i32(x86_fp80) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare { fp128, i32 } @llvm.frexp.f128.i32(fp128) [[READNONE_INTRINSIC]]
+// HAS_ERRNO: declare { double, i32 } @llvm.frexp.f64.i32(double) [[READNONE_INTRINSIC]]
+// HAS_ERRNO: declare { float, i32 } @llvm.frexp.f32.i32(float) [[READNONE_INTRINSIC]]
+// HAS_ERRNO: declare { x86_fp80, i32 } @llvm.frexp.f80.i32(x86_fp80) [[READNONE_INTRINSIC]]
+// HAS_ERRNO: declare { fp128, i32 } @llvm.frexp.f128.i32(fp128) [[READNONE_INTRINSIC]]
 
   __builtin_huge_val();__builtin_huge_valf();   __builtin_huge_vall(); __builtin_huge_valf128();
 
@@ -88,7 +112,7 @@
 
   __builtin_modf(f,d);   __builtin_modff(f,fp);  __builtin_modfl(f,l); __builtin_modff128(f,l);
 
-// NO__ERRNO: declare double @modf(double noundef, ptr noundef) [[NOT_READNONE]]
+// NO__ERRNO: declare double @modf(double noundef, ptr 

[PATCH] D149716: clang: Use new frexp intrinsic for builtins and add f16 version

2023-05-02 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: yaxunl, jcranmer-intel, kpn, andrew.w.kaylor, 
sepavloff, tra.
Herald added subscribers: kosarev, jdoerfert, pengfei, jvesely.
Herald added a project: All.
arsenm requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

https://reviews.llvm.org/D149716

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aix-builtin-mapping.c
  clang/test/CodeGen/builtin-attributes.c
  clang/test/CodeGen/math-builtins-long.c
  clang/test/CodeGen/math-builtins.c
  clang/test/CodeGenOpenCL/builtins-generic-amdgcn.cl
  llvm/test/CodeGen/X86/llvm.frexp.ll

Index: llvm/test/CodeGen/X86/llvm.frexp.ll
===
--- llvm/test/CodeGen/X86/llvm.frexp.ll
+++ llvm/test/CodeGen/X86/llvm.frexp.ll
@@ -59,7 +59,7 @@
 ; WIN32-NEXT:fsts (%esp)
 ; WIN32-NEXT:movl (%esp), %eax
 ; WIN32-NEXT:movl %eax, %ecx
-; WIN32-NEXT:andl $-2147483648, %ecx # imm = 0x8000
+; WIN32-NEXT:andl $2147483647, %ecx # imm = 0x7FFF
 ; WIN32-NEXT:cmpl $8388608, %ecx # imm = 0x80
 ; WIN32-NEXT:jb LBB0_1
 ; WIN32-NEXT:  # %bb.2:
@@ -121,7 +121,7 @@
 ; WIN32-NEXT:fstps {{[0-9]+}}(%esp)
 ; WIN32-NEXT:movl (%esp), %ecx
 ; WIN32-NEXT:movl %ecx, %eax
-; WIN32-NEXT:andl $-2147483648, %eax # imm = 0x8000
+; WIN32-NEXT:andl $2147483647, %eax # imm = 0x7FFF
 ; WIN32-NEXT:cmpl $8388608, %eax # imm = 0x80
 ; WIN32-NEXT:jae LBB1_2
 ; WIN32-NEXT:  # %bb.1:
@@ -166,7 +166,7 @@
 ; WIN32-NEXT:fmuls __real@4c00
 ; WIN32-NEXT:fstps {{[0-9]+}}(%esp)
 ; WIN32-NEXT:fstps (%esp)
-; WIN32-NEXT:movl $-2147483648, %ecx # imm = 0x8000
+; WIN32-NEXT:movl $2147483647, %ecx # imm = 0x7FFF
 ; WIN32-NEXT:andl (%esp), %ecx
 ; WIN32-NEXT:cmpl $8388608, %ecx # imm = 0x80
 ; WIN32-NEXT:jb LBB2_1
@@ -273,7 +273,7 @@
 ; WIN32-NEXT:fsts {{[0-9]+}}(%esp)
 ; WIN32-NEXT:movl {{[0-9]+}}(%esp), %ebx
 ; WIN32-NEXT:movl %ebx, %eax
-; WIN32-NEXT:andl $-2147483648, %eax # imm = 0x8000
+; WIN32-NEXT:andl $2147483647, %eax # imm = 0x7FFF
 ; WIN32-NEXT:cmpl $8388608, %eax # imm = 0x80
 ; WIN32-NEXT:jb LBB3_1
 ; WIN32-NEXT:  # %bb.2:
@@ -298,7 +298,7 @@
 ; WIN32-NEXT:movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
 ; WIN32-NEXT:movl {{[0-9]+}}(%esp), %ecx
 ; WIN32-NEXT:movl %ecx, %edx
-; WIN32-NEXT:andl $-2147483648, %edx # imm = 0x8000
+; WIN32-NEXT:andl $2147483647, %edx # imm = 0x7FFF
 ; WIN32-NEXT:cmpl $8388608, %edx # imm = 0x80
 ; WIN32-NEXT:jb LBB3_6
 ; WIN32-NEXT:  # %bb.7:
@@ -323,7 +323,7 @@
 ; WIN32-NEXT:movl %esi, (%esp) # 4-byte Spill
 ; WIN32-NEXT:movl {{[0-9]+}}(%esp), %edi
 ; WIN32-NEXT:movl %edi, %ebp
-; WIN32-NEXT:andl $-2147483648, %ebp # imm = 0x8000
+; WIN32-NEXT:andl $2147483647, %ebp # imm = 0x7FFF
 ; WIN32-NEXT:cmpl $8388608, %ebp # imm = 0x80
 ; WIN32-NEXT:jb LBB3_11
 ; WIN32-NEXT:  # %bb.12:
@@ -351,7 +351,7 @@
 ; WIN32-NEXT:movl %esi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
 ; WIN32-NEXT:movl {{[0-9]+}}(%esp), %eax
 ; WIN32-NEXT:movl %eax, %edx
-; WIN32-NEXT:andl $-2147483648, %edx # imm = 0x8000
+; WIN32-NEXT:andl $2147483647, %edx # imm = 0x7FFF
 ; WIN32-NEXT:cmpl $8388608, %edx # imm = 0x80
 ; WIN32-NEXT:jb LBB3_16
 ; WIN32-NEXT:  # %bb.17:
@@ -529,7 +529,7 @@
 ; WIN32-NEXT:fstps {{[0-9]+}}(%esp)
 ; WIN32-NEXT:movl {{[0-9]+}}(%esp), %ecx
 ; WIN32-NEXT:movl %ecx, %eax
-; WIN32-NEXT:andl $-2147483648, %eax # imm = 0x8000
+; WIN32-NEXT:andl $2147483647, %eax # imm = 0x7FFF
 ; WIN32-NEXT:cmpl $8388608, %eax # imm = 0x80
 ; WIN32-NEXT:jae LBB4_2
 ; WIN32-NEXT:  # %bb.1:
@@ -540,7 +540,7 @@
 ; WIN32-NEXT:movl %ecx, {{[0-9]+}}(%esp)
 ; WIN32-NEXT:movl {{[0-9]+}}(%esp), %edx
 ; WIN32-NEXT:movl %edx, %ecx
-; WIN32-NEXT:andl $-2147483648, %ecx # imm = 0x8000
+; WIN32-NEXT:andl $2147483647, %ecx # imm = 0x7FFF
 ; WIN32-NEXT:cmpl $8388608, %ecx # imm = 0x80
 ; WIN32-NEXT:jae LBB4_4
 ; WIN32-NEXT:  # %bb.3:
@@ -551,7 +551,7 @@
 ; WIN32-NEXT:movl %edx, {{[0-9]+}}(%esp)
 ; WIN32-NEXT:movl {{[0-9]+}}(%esp), %esi
 ; WIN32-NEXT:movl %esi, %edx
-; WIN32-NEXT:andl $-2147483648, %edx # imm = 0x8000
+; WIN32-NEXT:andl $2147483647, %edx # imm = 0x7FFF
 ; WIN32-NEXT:cmpl $8388608, %edx # imm = 0x80
 ; WIN32-NEXT:jae LBB4_6
 ; WIN32-NEXT:  # %bb.5:
@@ -562,7 +562,7 @@
 ; WIN32-NEXT:movl %esi, {{[0-9]+}}(%esp)
 ; WIN32-NEXT:movl (%esp), %edi
 ; WIN32-NEXT:movl %edi, %esi
-; WIN32-NEXT:andl $-2147483648, %esi # imm = 0x8000
+; WIN32-NEXT:andl $2147483647, %esi # imm = 0x7FFF
 ; WIN32-NEXT:cmpl $8388608, %esi # imm = 0x80
 ; WIN32-NEXT:jae LBB4_8
 ; 

[PATCH] D149709: Fix a typo in head comment of CurPPLexer

2023-05-02 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai accepted this revision.
vsapsai added a comment.
This revision is now accepted and ready to land.

Thanks for the fix! Don't see any other places in the file to fix.




Comment at: clang/include/clang/Lex/Preprocessor.h:726
 
   /// The current top of the stack that we're lexing from if
   /// not expanding a macro and we are lexing directly from source code.

This already uses "that".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149709

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


[PATCH] D149713: [Sema] Avoid emitting warnings for constant destruction.

2023-05-02 Thread Peter Kasting via Phabricator via cfe-commits
pkasting created this revision.
pkasting added a reviewer: rsmith.
Herald added a project: All.
pkasting requested review of this revision.
Herald added a project: clang.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149713

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/warn-exit-time-destructors.cpp
  clang/test/SemaCXX/warn-global-constructors.cpp


Index: clang/test/SemaCXX/warn-global-constructors.cpp
===
--- clang/test/SemaCXX/warn-global-constructors.cpp
+++ clang/test/SemaCXX/warn-global-constructors.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wglobal-constructors %s -verify
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wglobal-constructors %s 
-verify=expected,cxx11
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -Wglobal-constructors %s 
-verify=expected
 
 int opaque_int();
 
@@ -145,3 +146,16 @@
   const HasUnnamedBitfield nonConstexprConst{1}; // expected-warning {{global 
constructor}}
   HasUnnamedBitfield nonConstexprMutable{1}; // expected-warning {{global 
constructor}}
 }
+
+namespace test7 {
+#if __cplusplus >= 202002L
+#define CPP20_CONSTEXPR constexpr
+#else
+#define CPP20_CONSTEXPR
+#endif
+  struct S {
+CPP20_CONSTEXPR ~S() {}
+  };
+  CPP20_CONSTEXPR S s; // cxx11-warning {{global constructor}}
+#undef CPP20_CONSTEXPR
+}
Index: clang/test/SemaCXX/warn-exit-time-destructors.cpp
===
--- clang/test/SemaCXX/warn-exit-time-destructors.cpp
+++ clang/test/SemaCXX/warn-exit-time-destructors.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wexit-time-destructors %s -verify
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wexit-time-destructors %s 
-verify=expected,cxx11
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -Wexit-time-destructors %s 
-verify=expected
 
 namespace test1 {
   struct A { ~A(); };
@@ -48,3 +49,16 @@
 struct A { ~A(); };
 [[clang::no_destroy]] A a; // no warning
 }
+
+namespace test5 {
+#if __cplusplus >= 202002L
+#define CPP20_CONSTEXPR constexpr
+#else
+#define CPP20_CONSTEXPR
+#endif
+  struct S {
+CPP20_CONSTEXPR ~S() {}
+  };
+  CPP20_CONSTEXPR S s; // cxx11-warning {{exit-time destructor}}
+#undef CPP20_CONSTEXPR
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -15718,7 +15718,8 @@
 }
   }
 
-  if (!VD->hasGlobalStorage()) return;
+  if (!VD->hasGlobalStorage() || !VD->needsDestruction(Context))
+return;
 
   // Emit warning for non-trivial dtor in global scope (a real global,
   // class-static, function-static).


Index: clang/test/SemaCXX/warn-global-constructors.cpp
===
--- clang/test/SemaCXX/warn-global-constructors.cpp
+++ clang/test/SemaCXX/warn-global-constructors.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wglobal-constructors %s -verify
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wglobal-constructors %s -verify=expected,cxx11
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -Wglobal-constructors %s -verify=expected
 
 int opaque_int();
 
@@ -145,3 +146,16 @@
   const HasUnnamedBitfield nonConstexprConst{1}; // expected-warning {{global constructor}}
   HasUnnamedBitfield nonConstexprMutable{1}; // expected-warning {{global constructor}}
 }
+
+namespace test7 {
+#if __cplusplus >= 202002L
+#define CPP20_CONSTEXPR constexpr
+#else
+#define CPP20_CONSTEXPR
+#endif
+  struct S {
+CPP20_CONSTEXPR ~S() {}
+  };
+  CPP20_CONSTEXPR S s; // cxx11-warning {{global constructor}}
+#undef CPP20_CONSTEXPR
+}
Index: clang/test/SemaCXX/warn-exit-time-destructors.cpp
===
--- clang/test/SemaCXX/warn-exit-time-destructors.cpp
+++ clang/test/SemaCXX/warn-exit-time-destructors.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wexit-time-destructors %s -verify
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wexit-time-destructors %s -verify=expected,cxx11
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -Wexit-time-destructors %s -verify=expected
 
 namespace test1 {
   struct A { ~A(); };
@@ -48,3 +49,16 @@
 struct A { ~A(); };
 [[clang::no_destroy]] A a; // no warning
 }
+
+namespace test5 {
+#if __cplusplus >= 202002L
+#define CPP20_CONSTEXPR constexpr
+#else
+#define CPP20_CONSTEXPR
+#endif
+  struct S {
+CPP20_CONSTEXPR ~S() {}
+  };
+  CPP20_CONSTEXPR S s; // cxx11-warning {{exit-time destructor}}
+#undef CPP20_CONSTEXPR
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -15718,7 +15718,8 @@
 }
   }
 
-  if (!VD->hasGlobalStorage()) return;
+  if (!VD->hasGlobalStorage() || 

[PATCH] D148654: Modify BoundsSan to improve debuggability

2023-05-02 Thread Oskar Wirga via Phabricator via cfe-commits
oskarwirga updated this revision to Diff 518933.
oskarwirga edited the summary of this revision.
oskarwirga added a comment.

Update the diff to use the `nomerge` attribute


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

https://reviews.llvm.org/D148654

Files:
  clang/lib/CodeGen/CGExpr.cpp
  llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp


Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -47,6 +47,11 @@
 using namespace clang;
 using namespace CodeGen;
 
+// Experiment to make sanitizers easier to debug
+static llvm::cl::opt ClSanitizeDebugDeoptimization(
+"sanitizer-de-opt-traps", llvm::cl::Optional,
+llvm::cl::desc("Deoptimize traps for sanitizers"), llvm::cl::init(false));
+
 //======//
 //Miscellaneous Helper Methods
 //======//
@@ -3576,7 +3581,8 @@
 TrapBBs.resize(CheckHandlerID + 1);
   llvm::BasicBlock * = TrapBBs[CheckHandlerID];
 
-  if (!CGM.getCodeGenOpts().OptimizationLevel || !TrapBB) {
+  if (ClSanitizeDebugDeoptimization ||
+  !CGM.getCodeGenOpts().OptimizationLevel || !TrapBB) {
 TrapBB = createBasicBlock("trap");
 Builder.CreateCondBr(Checked, Cont, TrapBB);
 EmitBlock(TrapBB);
@@ -3590,6 +3596,8 @@
 CGM.getCodeGenOpts().TrapFuncName);
   TrapCall->addFnAttr(A);
 }
+if (ClSanitizeDebugDeoptimization)
+  TrapCall->addFnAttr(llvm::Attribute::NoMerge);
 TrapCall->setDoesNotReturn();
 TrapCall->setDoesNotThrow();
 Builder.CreateUnreachable();
Index: llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
===
--- llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
+++ llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
@@ -39,6 +39,11 @@
 static cl::opt SingleTrapBB("bounds-checking-single-trap",
   cl::desc("Use one trap block per function"));
 
+// Experiment to make sanitizers easier to debug
+static llvm::cl::opt ClBoundsSanitizeDebugDeoptimization(
+"bounds-de-opt-traps", llvm::cl::Optional,
+llvm::cl::desc("Deoptimize traps for sanitizers"), llvm::cl::init(false));
+
 STATISTIC(ChecksAdded, "Bounds checks added");
 STATISTIC(ChecksSkipped, "Bounds checks skipped");
 STATISTIC(ChecksUnable, "Bounds checks unable to add");
@@ -181,7 +186,7 @@
   // will create a fresh block every time it is called.
   BasicBlock *TrapBB = nullptr;
   auto GetTrapBB = [](BuilderTy ) {
-if (TrapBB && SingleTrapBB)
+if (!ClBoundsSanitizeDebugDeoptimization && TrapBB && SingleTrapBB)
   return TrapBB;
 
 Function *Fn = IRB.GetInsertBlock()->getParent();
@@ -194,6 +199,8 @@
 
 auto *F = Intrinsic::getDeclaration(Fn->getParent(), Intrinsic::trap);
 CallInst *TrapCall = IRB.CreateCall(F, {});
+if (ClBoundsSanitizeDebugDeoptimization)
+  TrapCall->addFnAttr(llvm::Attribute::NoMerge);
 TrapCall->setDoesNotReturn();
 TrapCall->setDoesNotThrow();
 TrapCall->setDebugLoc(DebugLoc);


Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -47,6 +47,11 @@
 using namespace clang;
 using namespace CodeGen;
 
+// Experiment to make sanitizers easier to debug
+static llvm::cl::opt ClSanitizeDebugDeoptimization(
+"sanitizer-de-opt-traps", llvm::cl::Optional,
+llvm::cl::desc("Deoptimize traps for sanitizers"), llvm::cl::init(false));
+
 //======//
 //Miscellaneous Helper Methods
 //======//
@@ -3576,7 +3581,8 @@
 TrapBBs.resize(CheckHandlerID + 1);
   llvm::BasicBlock * = TrapBBs[CheckHandlerID];
 
-  if (!CGM.getCodeGenOpts().OptimizationLevel || !TrapBB) {
+  if (ClSanitizeDebugDeoptimization ||
+  !CGM.getCodeGenOpts().OptimizationLevel || !TrapBB) {
 TrapBB = createBasicBlock("trap");
 Builder.CreateCondBr(Checked, Cont, TrapBB);
 EmitBlock(TrapBB);
@@ -3590,6 +3596,8 @@
 CGM.getCodeGenOpts().TrapFuncName);
   TrapCall->addFnAttr(A);
 }
+if (ClSanitizeDebugDeoptimization)
+  TrapCall->addFnAttr(llvm::Attribute::NoMerge);
 TrapCall->setDoesNotReturn();
 TrapCall->setDoesNotThrow();
 Builder.CreateUnreachable();
Index: llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
===
--- llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
+++ llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
@@ -39,6 +39,11 @@
 static cl::opt 

[PATCH] D149187: [clang] Canonicalize system headers in dependency file when -canonical-prefixes

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

This commit came up in the following bug report: 
https://github.com/llvm/llvm-project/issues/62505

Please take a look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149187

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


[PATCH] D149710: [RISCV] Add sifive-x280 processor with all of its extensions

2023-05-02 Thread Philip Reames via Phabricator via cfe-commits
reames accepted this revision.
reames added a comment.
This revision is now accepted and ready to land.

Mechanically, this looks fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149710

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


[PATCH] D148654: Modify BoundsSan to improve debuggability

2023-05-02 Thread Oskar Wirga via Phabricator via cfe-commits
oskarwirga added a comment.

In D148654#4312478 , @smeenai wrote:

> Thinking about this a bit more, should the trap not have an associated stack 
> trace that can be symbolicated to tell you which line of code was crashing? 
> If the issue is that multiple traps can get folded together, the `nomerge` 
> attribute (D78659 ) could be useful.

I tried adding the `nomerge` attribute to `TrapCall` but I still found the call 
being optimized to a single site :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148654

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


[PATCH] D149498: [RISCV] Add Scheduling information for Zfh to SiFive7 model

2023-05-02 Thread Michael Maitland via Phabricator via cfe-commits
michaelmaitland updated this revision to Diff 518925.
michaelmaitland added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149498

Files:
  llvm/lib/Target/RISCV/RISCVSchedSiFive7.td

Index: llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
===
--- llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
+++ llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
@@ -239,6 +239,7 @@
 def : WriteRes;
 def : WriteRes;
 def : WriteRes;
+def : WriteRes;
 def : WriteRes;
 def : WriteRes;
 
@@ -250,6 +251,7 @@
 }
 
 let Latency = 2 in {
+def : WriteRes;
 def : WriteRes;
 def : WriteRes;
 }
@@ -265,6 +267,22 @@
 def : WriteRes;
 }
 
+// Half precision.
+let Latency = 5 in {
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+}
+let Latency = 3 in {
+def : WriteRes;
+def : WriteRes;
+}
+
+let Latency = 14, ResourceCycles = [1, 13] in {
+def :  WriteRes;
+def :  WriteRes;
+}
+
 // Single precision.
 let Latency = 5 in {
 def : WriteRes;
@@ -299,21 +317,33 @@
 
 // Conversions
 let Latency = 3 in {
+def : WriteRes;
 def : WriteRes;
 def : WriteRes;
+def : WriteRes;
 def : WriteRes;
 def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
 def : WriteRes;
 def : WriteRes;
+def : WriteRes;
 def : WriteRes;
 def : WriteRes;
 def : WriteRes;
+def : WriteRes;
 def : WriteRes;
 
+def : WriteRes;
 def : WriteRes;
 def : WriteRes;
+def : WriteRes;
 def : WriteRes;
 def : WriteRes;
+def : WriteRes;
+def : WriteRes;
 def : WriteRes;
 def : WriteRes;
 def : WriteRes;
@@ -690,36 +720,55 @@
 def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
 
@@ -911,5 +960,4 @@
 defm : UnsupportedSchedZbkb;
 defm : UnsupportedSchedZbkx;
 defm : UnsupportedSchedZfa;
-defm : UnsupportedSchedZfh;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149497: [RISCV] Add scheduling information for Zba and Zbb to RISCVSchedSiFive7.td

2023-05-02 Thread Michael Maitland via Phabricator via cfe-commits
michaelmaitland updated this revision to Diff 518924.
michaelmaitland marked an inline comment as done.
michaelmaitland added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149497

Files:
  llvm/lib/Target/RISCV/RISCVSchedSiFive7.td


Index: llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
===
--- llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
+++ llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
@@ -205,6 +205,35 @@
   let ResourceCycles = [1, 15];
 }
 
+// Bitmanip
+let Latency = 3 in {
+// Rotates are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// clz[w]/ctz[w] are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// cpop[w] look exactly like multiply.
+def : WriteRes;
+def : WriteRes;
+
+// orc.b is in the late-B ALU.
+def : WriteRes;
+
+// rev8 is in the late-A and late-B ALUs.
+def : WriteRes;
+
+// shNadd[.uw] is on the early-B and late-B ALUs.
+def : WriteRes;
+def : WriteRes;
+}
+
 // Memory
 def : WriteRes;
 def : WriteRes;
@@ -859,10 +888,24 @@
 // Others
 def : ReadAdvance;
 
+// Bitmanip
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+
 
//===--===//
 // Unsupported extensions
-defm : UnsupportedSchedZba;
-defm : UnsupportedSchedZbb;
 defm : UnsupportedSchedZbc;
 defm : UnsupportedSchedZbs;
 defm : UnsupportedSchedZbkb;


Index: llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
===
--- llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
+++ llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
@@ -205,6 +205,35 @@
   let ResourceCycles = [1, 15];
 }
 
+// Bitmanip
+let Latency = 3 in {
+// Rotates are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// clz[w]/ctz[w] are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// cpop[w] look exactly like multiply.
+def : WriteRes;
+def : WriteRes;
+
+// orc.b is in the late-B ALU.
+def : WriteRes;
+
+// rev8 is in the late-A and late-B ALUs.
+def : WriteRes;
+
+// shNadd[.uw] is on the early-B and late-B ALUs.
+def : WriteRes;
+def : WriteRes;
+}
+
 // Memory
 def : WriteRes;
 def : WriteRes;
@@ -859,10 +888,24 @@
 // Others
 def : ReadAdvance;
 
+// Bitmanip
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+
 //===--===//
 // Unsupported extensions
-defm : UnsupportedSchedZba;
-defm : UnsupportedSchedZbb;
 defm : UnsupportedSchedZbc;
 defm : UnsupportedSchedZbs;
 defm : UnsupportedSchedZbkb;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149495: [RISCV] Add sifive-x280 processor and support V extension in SiFive7

2023-05-02 Thread Michael Maitland via Phabricator via cfe-commits
michaelmaitland updated this revision to Diff 518923.
michaelmaitland added a comment.

Split adding sifive-x280 and vector model between this patch and 
https://reviews.llvm.org/D149710


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149495

Files:
  llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
  llvm/lib/Target/RISCV/RISCVScheduleV.td

Index: llvm/lib/Target/RISCV/RISCVScheduleV.td
===
--- llvm/lib/Target/RISCV/RISCVScheduleV.td
+++ llvm/lib/Target/RISCV/RISCVScheduleV.td
@@ -9,7 +9,7 @@
 //===--===//
 /// Define scheduler resources associated with def operands.
 
-defvar SchedMxList = ["M1", "M2", "M4", "M8", "MF2", "MF4", "MF8"];
+defvar SchedMxList = ["MF8", "MF4", "MF2", "M1", "M2", "M4", "M8"];
 // Used for widening and narrowing instructions as it doesn't contain M8.
 defvar SchedMxListW = !listremove(SchedMxList, ["M8"]);
 defvar SchedMxListFW = !listremove(SchedMxList, ["M8", "MF8"]);
@@ -38,6 +38,32 @@
 !eq(mx, "MF4"): [16]);
 }
 
+// Helper function to get the largest LMUL from MxList
+// Precondition: MxList is sorted in ascending LMUL order.
+class LargestLMUL MxList> {
+  // MX list is sorted from smallest to largest
+  string r = !foldl(!head(MxList), MxList, last, curr, curr);
+}
+// Helper function to get the smallest SEW that can be used with LMUL mx
+// Precondition: MxList is sorted in ascending LMUL order and SchedSEWSet
+class SmallestSEW {
+  int r = !head(!if(isF, SchedSEWSetF.val, SchedSEWSet.val));
+}
+
+// Creates WriteRes for (name, mx, resources) tuple
+multiclass LMULWriteResMX resources,
+  string mx, bit IsWorstCase> {
+  def : WriteRes(name # "_" # mx), resources>;
+  if IsWorstCase then
+def : WriteRes(name # "_WorstCase"), resources>;
+}
+multiclass LMULSEWWriteResMXSEW resources,
+ string mx, int sew,  bit IsWorstCase> {
+  def : WriteRes(name # "_" # mx # "_E" # sew), resources>;
+  if IsWorstCase then
+def : WriteRes(name # "_WorstCase"), resources>;
+}
+
 // Define multiclasses to define SchedWrite, SchedRead,  WriteRes, and
 // ReadAdvance for each (name, LMUL) pair and for each LMUL in each of the
 // SchedMxList variants above. Each multiclass is responsible for defining
Index: llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
===
--- llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
+++ llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
@@ -8,6 +8,131 @@
 
 //===--===//
 
+/// c is true if mx has the worst case behavior compared to LMULs in MxList.
+/// On the SiFive7, the worst case LMUL is the Largest LMUL
+/// and the worst case sew is the smallest SEW for that LMUL.
+class SiFive7IsWorstCaseMX MxList> {
+  string LLMUL = LargestLMUL.r;
+  bit c = !eq(mx, LLMUL);
+}
+
+/// c is true if mx and sew have the worst case behavior compared to LMULs in
+/// MxList. On the SiFive7, the worst case LMUL is the Largest LMUL
+/// and the worst case sew is the smallest SEW for that LMUL.
+class SiFive7IsWorstCaseMXSEW MxList,
+   bit isF = 0> {
+  string LLMUL = LargestLMUL.r;
+  int SSEW = SmallestSEW.r;
+  bit c = !and(!eq(mx, LLMUL), !eq(sew, SSEW));
+}
+
+class SiFive7GetCyclesDefault {
+  int c = !cond(
+!eq(mx, "M1") : 2,
+!eq(mx, "M2") : 4,
+!eq(mx, "M4") : 8,
+!eq(mx, "M8") : 16,
+!eq(mx, "MF2") : 1,
+!eq(mx, "MF4") : 1,
+!eq(mx, "MF8") : 1
+  );
+}
+
+class SiFive7GetCyclesWidening {
+  int c = !cond(
+!eq(mx, "M1") : 2,
+!eq(mx, "M2") : 4,
+!eq(mx, "M4") : 8,
+!eq(mx, "MF2") : 1,
+!eq(mx, "MF4") : 1,
+!eq(mx, "MF8") : 1
+  );
+}
+
+class SiFive7GetCyclesNarrowing {
+  int c = !cond(
+!eq(mx, "M1") : 4,
+!eq(mx, "M2") : 8,
+!eq(mx, "M4") : 16,
+!eq(mx, "MF2") : 2,
+!eq(mx, "MF4") : 1,
+!eq(mx, "MF8") : 1
+  );
+}
+
+class SiFive7GetCyclesOutputLMUL {
+  int c = !cond(
+!eq(mx, "M1") : 1,
+!eq(mx, "M2") : 2,
+!eq(mx, "M4") : 4,
+!eq(mx, "M8") : 8,
+!eq(mx, "MF2") : 1,
+!eq(mx, "MF4") : 1,
+!eq(mx, "MF8") : 1
+  );
+}
+
+class SiFive7GetCyclesVMask {
+  int c = !cond(
+!eq(mx, "M1") : 1,
+!eq(mx, "M2") : 1,
+!eq(mx, "M4") : 1,
+!eq(mx, "M8") : 2,
+!eq(mx, "MF2") : 1,
+!eq(mx, "MF4") : 1,
+!eq(mx, "MF8") : 1
+  );
+}
+
+// Cycles for segmented loads and stores are calculated using the
+// formula ceil(2 * nf * lmul).
+class SiFive7GetCyclesSegmented {
+  int c = !cond(
+!eq(mx, "M1") : !mul(!mul(2, nf), 1),
+!eq(mx, "M2") : !mul(!mul(2, nf), 2),
+!eq(mx, "M4") : !mul(!mul(2, nf), 4),
+!eq(mx, "M8") : !mul(!mul(2, nf), 8),
+// We can calculate ceil(a/b) using (a + b - 1) / b.
+// 

[PATCH] D149710: [RISCV] Add sifive-x280 processor with all of its extensions

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

Add sifive-x280 processor that uses the SiFive7 scheduler model.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149710

Files:
  clang/test/Driver/riscv-cpus.c
  llvm/docs/ReleaseNotes.rst
  llvm/lib/Target/RISCV/RISCVProcessors.td


Index: llvm/lib/Target/RISCV/RISCVProcessors.td
===
--- llvm/lib/Target/RISCV/RISCVProcessors.td
+++ llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -166,6 +166,22 @@
   FeatureStdExtC],
  [TuneSiFive7]>;
 
+def SIFIVE_X280 : RISCVProcessorModel<"sifive-x280", SiFive7Model,
+  [Feature64Bit,
+   FeatureStdExtZifencei,
+   FeatureStdExtM,
+   FeatureStdExtA,
+   FeatureStdExtF,
+   FeatureStdExtD,
+   FeatureStdExtC,
+   FeatureStdExtV,
+   FeatureStdExtZvl512b,
+   FeatureStdExtZfh,
+   FeatureStdExtZvfh,
+   FeatureStdExtZba,
+   FeatureStdExtZbb],
+  [TuneSiFive7]>;
+
 def SYNTACORE_SCR1_BASE : RISCVProcessorModel<"syntacore-scr1-base",
   SyntacoreSCR1Model,
   [Feature32Bit,
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -171,6 +171,7 @@
 * Updated support experimental vector crypto extensions to version 0.5.1 of
   the specification.
 * Removed N extension (User-Level Interrupts) CSR names in the assembler.
+* Add sifive-x280 processor.
 
 Changes to the WebAssembly Backend
 --
Index: clang/test/Driver/riscv-cpus.c
===
--- clang/test/Driver/riscv-cpus.c
+++ clang/test/Driver/riscv-cpus.c
@@ -167,6 +167,20 @@
 // MTUNE-E31-MCPU-E76-SAME: "-target-feature" "+zicsr" "-target-feature" 
"+zifencei"
 // MTUNE-E31-MCPU-E76-SAME: "-tune-cpu" "sifive-e76"
 
+// mcpu with default march include experimental extensions
+// RUN: %clang -target riscv64 -### -c %s 2>&1 
-menable-experimental-extensions -mcpu=sifive-x280 | FileCheck 
-check-prefix=MCPU-SIFIVE-X280 %s
+// MCPU-SIFIVE-X280: "-nostdsysteminc" "-target-cpu" "sifive-x280"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+f" "-target-feature" "+d"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+c" "-target-feature" "+v"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zicsr" "-target-feature" 
"+zifencei"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zfh"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zba" "-target-feature" "+zbb"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+experimental-zvfh"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl128b"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl256b" "-target-feature" 
"+zvl32b"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl512b" "-target-feature" 
"+zvl64b"
+// MCPU-SIFIVE-X280-SAME: "-target-abi" "lp64d"
+
 // Check failed cases
 
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv321 | 
FileCheck -check-prefix=FAIL-MCPU-NAME %s


Index: llvm/lib/Target/RISCV/RISCVProcessors.td
===
--- llvm/lib/Target/RISCV/RISCVProcessors.td
+++ llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -166,6 +166,22 @@
   FeatureStdExtC],
  [TuneSiFive7]>;
 
+def SIFIVE_X280 : RISCVProcessorModel<"sifive-x280", SiFive7Model,
+  [Feature64Bit,
+   FeatureStdExtZifencei,
+   FeatureStdExtM,
+   FeatureStdExtA,
+   FeatureStdExtF,
+

[PATCH] D149709: Fix a typo in head comment of CurPPLexer

2023-05-02 Thread zhouyizhou via Phabricator via cfe-commits
zhouyizhou created this revision.
zhouyizhou added reviewers: vsapsai, zequanwu, ChuanqiXu, MaskRay, pengfei.
Herald added a project: All.
zhouyizhou requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In head comment of CurPPLexer field of class Preprocessor, 
'The current top of the stack what we're lexing from' should be
'The current top of the stack that we're lexing from'

Signed-off-by: Zhouyi Zhou 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149709

Files:
  clang/include/clang/Lex/Preprocessor.h


Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -729,7 +729,7 @@
   /// Only one of CurLexer, or CurTokenLexer will be non-null.
   std::unique_ptr CurLexer;
 
-  /// The current top of the stack what we're lexing from
+  /// The current top of the stack that we're lexing from
   /// if not expanding a macro.
   ///
   /// This is an alias for CurLexer.


Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -729,7 +729,7 @@
   /// Only one of CurLexer, or CurTokenLexer will be non-null.
   std::unique_ptr CurLexer;
 
-  /// The current top of the stack what we're lexing from
+  /// The current top of the stack that we're lexing from
   /// if not expanding a macro.
   ///
   /// This is an alias for CurLexer.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149334: [RISCV] Enable strict fp for RISC-V in clang.

2023-05-02 Thread Yeting Kuo via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfa53ce0faaa0: [RISCV] Enable strict fp for RISC-V in clang. 
(authored by fakepaper56).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149334

Files:
  clang/lib/Basic/Targets/RISCV.h
  clang/test/CodeGen/RISCV/fpconstrained.c


Index: clang/test/CodeGen/RISCV/fpconstrained.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/fpconstrained.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple riscv64 -frounding-math 
-ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm 
-o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
+// RUN: %clang_cc1 -triple riscv64 -ffp-contract=fast -emit-llvm -o - %s | 
FileCheck %s -check-prefix=PRECISE
+// RUN: %clang_cc1 -triple riscv64 -ffast-math -ffp-contract=fast -emit-llvm 
-o - %s | FileCheck %s -check-prefix=FAST
+// RUN: %clang_cc1 -triple riscv64 -ffast-math -emit-llvm -o - %s | FileCheck 
%s -check-prefix=FASTNOCONTRACT
+// RUN: %clang_cc1 -triple riscv64 -ffast-math -ffp-contract=fast 
-ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s 
-check-prefix=FAST
+// RUN: %clang_cc1 -triple riscv64 -ffast-math -ffp-contract=fast 
-ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm 
-o - %s | FileCheck %s -check-prefix=EXCEPT
+// RUN: %clang_cc1 -triple riscv64 -ffast-math -ffp-contract=fast 
-ffp-exception-behavior=maytrap -fexperimental-strict-floating-point -emit-llvm 
-o - %s | FileCheck %s -check-prefix=MAYTRAP
+
+// Test strict-fp support in RISC-V.
+
+float f0, f1, f2;
+
+void foo(void) {
+  // CHECK-LABEL: define {{.*}}void @foo()
+
+  // MAYTRAP: llvm.experimental.constrained.fadd.f32(float %{{.*}}, float 
%{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
+  // EXCEPT: llvm.experimental.constrained.fadd.f32(float %{{.*}}, float 
%{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // FPMODELSTRICT: llvm.experimental.constrained.fadd.f32(float %{{.*}}, 
float %{{.*}}, metadata !"round.dynamic", metadata !"fpexcept.strict")
+  // STRICTEXCEPT: llvm.experimental.constrained.fadd.f32(float %{{.*}}, float 
%{{.*}}, metadata !"round.dynamic", metadata !"fpexcept.strict")
+  // STRICTNOEXCEPT: llvm.experimental.constrained.fadd.f32(float %{{.*}}, 
float %{{.*}}, metadata !"round.dynamic", metadata !"fpexcept.ignore")
+  // PRECISE: fadd contract float %{{.*}}, %{{.*}}
+  // FAST: fadd fast
+  // FASTNOCONTRACT: fadd reassoc nnan ninf nsz arcp afn float
+  f0 = f1 + f2;
+
+  // CHECK: ret
+}
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -41,6 +41,7 @@
 HasRISCVVTypes = true;
 MCountName = "_mcount";
 HasFloat16 = true;
+HasStrictFP = true;
   }
 
   bool setCPU(const std::string ) override {


Index: clang/test/CodeGen/RISCV/fpconstrained.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/fpconstrained.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple riscv64 -frounding-math -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
+// RUN: %clang_cc1 -triple riscv64 -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s -check-prefix=PRECISE
+// RUN: %clang_cc1 -triple riscv64 -ffast-math -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST
+// RUN: %clang_cc1 -triple riscv64 -ffast-math -emit-llvm -o - %s | FileCheck %s -check-prefix=FASTNOCONTRACT
+// RUN: %clang_cc1 -triple riscv64 -ffast-math -ffp-contract=fast -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST
+// RUN: %clang_cc1 -triple riscv64 -ffast-math -ffp-contract=fast -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT
+// RUN: %clang_cc1 -triple riscv64 -ffast-math -ffp-contract=fast -ffp-exception-behavior=maytrap -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=MAYTRAP
+
+// Test strict-fp support in RISC-V.
+
+float f0, f1, f2;
+
+void foo(void) {
+  // CHECK-LABEL: define {{.*}}void @foo()
+
+  // MAYTRAP: llvm.experimental.constrained.fadd.f32(float %{{.*}}, float %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
+  // EXCEPT: llvm.experimental.constrained.fadd.f32(float %{{.*}}, float %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // FPMODELSTRICT: llvm.experimental.constrained.fadd.f32(float %{{.*}}, float %{{.*}}, metadata !"round.dynamic", metadata !"fpexcept.strict")
+  // STRICTEXCEPT: llvm.experimental.constrained.fadd.f32(float %{{.*}}, float %{{.*}}, metadata !"round.dynamic", metadata 

[clang] fa53ce0 - [RISCV] Enable strict fp for RISC-V in clang.

2023-05-02 Thread Yeting Kuo via cfe-commits

Author: Yeting Kuo
Date: 2023-05-03T08:32:27+08:00
New Revision: fa53ce0faaa0cb6956a201c7a01c06da34ab9936

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

LOG: [RISCV] Enable strict fp for RISC-V in clang.

Reviewed By: craig.topper

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

Added: 
clang/test/CodeGen/RISCV/fpconstrained.c

Modified: 
clang/lib/Basic/Targets/RISCV.h

Removed: 




diff  --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h
index f8240e7f09483..e4e39506bccf5 100644
--- a/clang/lib/Basic/Targets/RISCV.h
+++ b/clang/lib/Basic/Targets/RISCV.h
@@ -41,6 +41,7 @@ class RISCVTargetInfo : public TargetInfo {
 HasRISCVVTypes = true;
 MCountName = "_mcount";
 HasFloat16 = true;
+HasStrictFP = true;
   }
 
   bool setCPU(const std::string ) override {

diff  --git a/clang/test/CodeGen/RISCV/fpconstrained.c 
b/clang/test/CodeGen/RISCV/fpconstrained.c
new file mode 100644
index 0..d5a7a4aab1556
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/fpconstrained.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple riscv64 -frounding-math 
-ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm 
-o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
+// RUN: %clang_cc1 -triple riscv64 -ffp-contract=fast -emit-llvm -o - %s | 
FileCheck %s -check-prefix=PRECISE
+// RUN: %clang_cc1 -triple riscv64 -ffast-math -ffp-contract=fast -emit-llvm 
-o - %s | FileCheck %s -check-prefix=FAST
+// RUN: %clang_cc1 -triple riscv64 -ffast-math -emit-llvm -o - %s | FileCheck 
%s -check-prefix=FASTNOCONTRACT
+// RUN: %clang_cc1 -triple riscv64 -ffast-math -ffp-contract=fast 
-ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s 
-check-prefix=FAST
+// RUN: %clang_cc1 -triple riscv64 -ffast-math -ffp-contract=fast 
-ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm 
-o - %s | FileCheck %s -check-prefix=EXCEPT
+// RUN: %clang_cc1 -triple riscv64 -ffast-math -ffp-contract=fast 
-ffp-exception-behavior=maytrap -fexperimental-strict-floating-point -emit-llvm 
-o - %s | FileCheck %s -check-prefix=MAYTRAP
+
+// Test strict-fp support in RISC-V.
+
+float f0, f1, f2;
+
+void foo(void) {
+  // CHECK-LABEL: define {{.*}}void @foo()
+
+  // MAYTRAP: llvm.experimental.constrained.fadd.f32(float %{{.*}}, float 
%{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
+  // EXCEPT: llvm.experimental.constrained.fadd.f32(float %{{.*}}, float 
%{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // FPMODELSTRICT: llvm.experimental.constrained.fadd.f32(float %{{.*}}, 
float %{{.*}}, metadata !"round.dynamic", metadata !"fpexcept.strict")
+  // STRICTEXCEPT: llvm.experimental.constrained.fadd.f32(float %{{.*}}, float 
%{{.*}}, metadata !"round.dynamic", metadata !"fpexcept.strict")
+  // STRICTNOEXCEPT: llvm.experimental.constrained.fadd.f32(float %{{.*}}, 
float %{{.*}}, metadata !"round.dynamic", metadata !"fpexcept.ignore")
+  // PRECISE: fadd contract float %{{.*}}, %{{.*}}
+  // FAST: fadd fast
+  // FASTNOCONTRACT: fadd reassoc nnan ninf nsz arcp afn float
+  f0 = f1 + f2;
+
+  // CHECK: ret
+}



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


[PATCH] D149666: [OpenMP][OMPIRBuilder] Migrate MapCombinedInfoTy from Clang to OpenMPIRBuilder

2023-05-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:6848
+  class MapCombinedInfoTy : public llvm::OpenMPIRBuilder::MapCombinedInfoTy {
+  public:
 MapExprsArrayTy Exprs;

TIFitis wrote:
> jdoerfert wrote:
> > Not sure why you made it a class with public, but I guess it doesn't matter.
> > Do we really want to use the same name though? I would add "Base" or sth to 
> > the llvm class.
> The clang code, and eventually the OMPIRBuilder code accesses the members 
> directly so they need to be public.
> 
> I have kept it the same name in similar fashion to the TargetDataInfo type 
> that also got migrated. From OMPBuilder's perspective the type is sufficient 
> and when using it from MLIR I don't think we would need the extra data 
> structures that clang uses.
> 
> Let me know what you think, I can change it to a different name as you 
> suggested.
Two structures with the same name is not a good idea. Rename one.

struct A === class A + public,
so why did you move from struct A to class A + public?



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:6872
   NonContigInfo.Strides.append(CurInfo.NonContigInfo.Strides.begin(),
 CurInfo.NonContigInfo.Strides.end());
 }

TIFitis wrote:
> jdoerfert wrote:
> > We should use the base append function, no?
> The base append function is missing append for the members we introduced here 
> like `Exprs` and `Mappers`.
I understand that. I did not say the base function is sufficient, I said we 
should use it.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149666

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


[PATCH] D148370: [Clang][Flang][OpenMP] Add loadOffloadInfoMetadata and createOffloadEntriesAndInfoMetadata into OMPIRBuilder's finalize and initialize

2023-05-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:561
+
+  llvm::OpenMPIRBuilder::EmitMetadataErrorReportFunctionTy & =
+  [](llvm::OpenMPIRBuilder::EmitMetadataErrorKind kind,

no llvm::
style: ErrorReportFn

similarly elsewhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148370

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


[PATCH] D149612: [Sema] avoid merge error type

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

fix in `Sema::BuildArrayType`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149612

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/merge-decls.c


Index: clang/test/Sema/merge-decls.c
===
--- clang/test/Sema/merge-decls.c
+++ clang/test/Sema/merge-decls.c
@@ -91,3 +91,7 @@
   int x[5];
   test7_f(); // expected-warning {{incompatible pointer types passing 'int 
(*)[5]' to parameter of type 'int (*)[10]}}
 }
+
+char d;
+char x[sizeof(d.data) == 8]; // expected-error {{member reference base type 
'char' is not a structure or union}}
+char x[sizeof(d.data) == 4]; // expected-error {{member reference base type 
'char' is not a structure or union}}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2546,6 +2546,9 @@
 return QualType();
   }
 
+  if (!getLangOpts().CPlusPlus && ArraySize && ArraySize->containsErrors())
+return QualType();
+
   // VLAs always produce at least a -Wvla diagnostic, sometimes an error.
   unsigned VLADiag;
   bool VLAIsError;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -338,6 +338,8 @@
 - Fix crash when attempting to perform parenthesized initialization of an
   aggregate with a base class with only non-public constructors.
   (`#62296 `_)
+- Fix crash when redefine variant with invalid type as another invalid type.
+  (`#62447 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/Sema/merge-decls.c
===
--- clang/test/Sema/merge-decls.c
+++ clang/test/Sema/merge-decls.c
@@ -91,3 +91,7 @@
   int x[5];
   test7_f(); // expected-warning {{incompatible pointer types passing 'int (*)[5]' to parameter of type 'int (*)[10]}}
 }
+
+char d;
+char x[sizeof(d.data) == 8]; // expected-error {{member reference base type 'char' is not a structure or union}}
+char x[sizeof(d.data) == 4]; // expected-error {{member reference base type 'char' is not a structure or union}}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2546,6 +2546,9 @@
 return QualType();
   }
 
+  if (!getLangOpts().CPlusPlus && ArraySize && ArraySize->containsErrors())
+return QualType();
+
   // VLAs always produce at least a -Wvla diagnostic, sometimes an error.
   unsigned VLADiag;
   bool VLAIsError;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -338,6 +338,8 @@
 - Fix crash when attempting to perform parenthesized initialization of an
   aggregate with a base class with only non-public constructors.
   (`#62296 `_)
+- Fix crash when redefine variant with invalid type as another invalid type.
+  (`#62447 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146054: [RISCV] Add --print-supported-extensions and -march=help support

2023-05-02 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:110
 
+extern void RISCVMarchHelp();
+

craig.topper wrote:
> Can we declare this in RISCVISAInfo.h and include that here?
Yes, we can.



Comment at: clang/tools/driver/cc1_main.cpp:187-188
+/// Print supported extensions of the given target.
+static int PrintSupportedExtensions(std::string TargetStr) {
+  llvm::riscvMarchHelp();
+

kito-cheng wrote:
> Plz make sure only RISC-V print that, x86 or other target print RISC-V's ext 
> is really weird. 
The check is in clang/lib/Driver/Driver.cpp:4225~



Comment at: clang/tools/driver/cc1_main.cpp:189
+  std::string Error;
+  const llvm::Target *TheTarget =
+  llvm::TargetRegistry::lookupTarget(TargetStr, Error);

craig.topper wrote:
> Why do we need to lookup the TargetRegistry?
I forgot to remove lol~


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146054

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


[PATCH] D149655: [tests] Add missing REQUIRES: riscv-registered-target to clang test

2023-05-02 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat closed this revision.
4vtomat added a comment.

Merged.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149655

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


[PATCH] D149612: [Sema] avoid merge error type

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

in SemaType.cpp#BuildArrayType, It will generate `DependentSizedArrayType` 
which cannot be merged. 
So we can either add additional check in `MergeVarDeclTypes` or directly ignore 
to generate this type in `BuildArrayType`.
Which one is better?

  } else if (ArraySize->isTypeDependent() || ArraySize->isValueDependent()) {
T = Context.getDependentSizedArrayType(T, ArraySize, ASM, Quals, Brackets);




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149612

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


[PATCH] D146178: [Clang][Sema] Fix comparison of constraint expressions

2023-05-02 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov added a comment.

upd.
In the reduced example above MLTAL is incorrect

  (lldb) p MLTAL.dump()
  NumRetainedOuterLevels: 1
  1: 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146178

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


[PATCH] D148665: Change -fsanitize=function to place two words before the function entry

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

Ping:)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148665

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


[PATCH] D148769: Split out `CodeGenTypes` from `CodeGen` for LLT/MVT

2023-05-02 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D148769#4311232 , @dblaikie wrote:

> I wouldn't mind a follow-up commit that creates a new/separate directory 
> (llvm/{lib,include/llvm}/CodeGenTypes) but that's probably a lot of 
> unnecessary churn too, so I can appreciate the argument against it - if folks 
> reckon it's better this way, that's OK too. It can just get a bit confusing 
> when the directory/naming doesn't match the layering, etc. Might make it more 
> likely someone regresses these boundaries by introducing new dependencies 
> that break the layering here.

I'd really like to see this. That's how virtually all LLVM libraries are laid 
out, and it removes the PARTIAL_SOURCES_INTENDED kludge.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148769

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


[clang] 3e3c6f2 - Revert "[Demangle] make llvm::demangle take std::string_view rather than const std::string&"

2023-05-02 Thread Nick Desaulniers via cfe-commits

Author: Nick Desaulniers
Date: 2023-05-02T15:54:09-07:00
New Revision: 3e3c6f24ff85ea52ed67d4c26f1d3d0eacd1ad1b

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

LOG: Revert "[Demangle] make llvm::demangle take std::string_view rather than 
const std::string&"

This reverts commit c117c2c8ba4afd45a006043ec6dd858652b2ffcc.

itaniumDemangle calls std::strlen with the results of
std::string_view::data() which may not be NUL-terminated. This causes
lld/test/wasm/why-extract.s  to fail when "expensive checks" are enabled
via -DLLVM_ENABLE_EXPENSIVE_CHECKS=ON. See D149675 for further
discussion. Back this out until the individual demanglers are converted
to use std::string_view.

Added: 


Modified: 
clang/lib/CodeGen/CodeGenAction.cpp
lld/COFF/Symbols.cpp
lld/ELF/SymbolTable.cpp
lld/ELF/Symbols.cpp
lld/MachO/Symbols.cpp
lld/wasm/Symbols.cpp
llvm/docs/ReleaseNotes.rst
llvm/include/llvm/Demangle/Demangle.h
llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp
llvm/lib/Demangle/Demangle.cpp
llvm/lib/IR/DiagnosticInfo.cpp
llvm/tools/llvm-objdump/ELFDump.cpp
llvm/tools/llvm-objdump/XCOFFDump.cpp
llvm/tools/llvm-objdump/llvm-objdump.cpp
llvm/tools/llvm-readobj/ELFDumper.cpp
llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index b054147e2d0ce..29adf88acd704 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -633,8 +633,9 @@ BackendConsumer::StackSizeDiagHandler(const 
llvm::DiagnosticInfoStackSize ) {
 return false;
 
   Diags.Report(*Loc, diag::warn_fe_frame_larger_than)
-  << D.getStackSize() << D.getStackLimit()
-  << llvm::demangle(D.getFunction().getName());
+  << D.getStackSize()
+  << D.getStackLimit()
+  << llvm::demangle(D.getFunction().getName().str());
   return true;
 }
 
@@ -648,7 +649,7 @@ bool BackendConsumer::ResourceLimitDiagHandler(
 
   Diags.Report(*Loc, DiagID)
   << D.getResourceName() << D.getResourceSize() << D.getResourceLimit()
-  << llvm::demangle(D.getFunction().getName());
+  << llvm::demangle(D.getFunction().getName().str());
   return true;
 }
 
@@ -853,7 +854,7 @@ void BackendConsumer::DontCallDiagHandler(const 
DiagnosticInfoDontCall ) {
   Diags.Report(LocCookie, D.getSeverity() == DiagnosticSeverity::DS_Error
   ? diag::err_fe_backend_error_attr
   : diag::warn_fe_backend_warning_attr)
-  << llvm::demangle(D.getFunctionName()) << D.getNote();
+  << llvm::demangle(D.getFunctionName().str()) << D.getNote();
 }
 
 void BackendConsumer::MisExpectDiagHandler(

diff  --git a/lld/COFF/Symbols.cpp b/lld/COFF/Symbols.cpp
index f4efcf2266cd6..c042386e01064 100644
--- a/lld/COFF/Symbols.cpp
+++ b/lld/COFF/Symbols.cpp
@@ -38,9 +38,9 @@ static std::string maybeDemangleSymbol(const 
COFFLinkerContext ,
 StringRef demangleInput = prefixless;
 if (ctx.config.machine == I386)
   demangleInput.consume_front("_");
-std::string demangled = demangle(demangleInput);
+std::string demangled = demangle(demangleInput.str());
 if (demangled != demangleInput)
-  return prefix + demangled;
+  return prefix + demangle(demangleInput.str());
 return (prefix + prefixless).str();
   }
   return std::string(symName);

diff  --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp
index c5ef6d3f0cbf3..f09d0d7f90958 100644
--- a/lld/ELF/SymbolTable.cpp
+++ b/lld/ELF/SymbolTable.cpp
@@ -145,16 +145,13 @@ StringMap> 
::getDemangledSyms() {
   if (canBeVersioned(*sym)) {
 StringRef name = sym->getName();
 size_t pos = name.find('@');
-std::string substr;
 if (pos == std::string::npos)
-  demangled = demangle(name);
-else if (pos + 1 == name.size() || name[pos + 1] == '@') {
-  substr = name.substr(0, pos);
-  demangled = demangle(substr);
-} else {
-  substr = name.substr(0, pos);
-  demangled = (demangle(substr) + name.substr(pos)).str();
-}
+  demangled = demangle(name.str());
+else if (pos + 1 == name.size() || name[pos + 1] == '@')
+  demangled = demangle(name.substr(0, pos).str());
+else
+  demangled =
+  (demangle(name.substr(0, pos).str()) + name.substr(pos)).str();
 (*demangledSyms)[demangled].push_back(sym);
   }
   }

diff  --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index 840385aabea35..62a8a3c30664e 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -45,7 +45,9 @@ LLVM_ATTRIBUTE_UNUSED static inline void assertSymbols() {
 
 // Returns a symbol for an error 

[PATCH] D149693: [clang][deps] Make clang-scan-deps write modules in raw format

2023-05-02 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir updated this revision to Diff 518891.
Herald added a subscriber: kadircet.
Herald added a project: clang-tools-extra.

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

https://reviews.llvm.org/D149693

Files:
  clang-tools-extra/clangd/Compiler.cpp
  clang/include/clang/CodeGen/ObjectFilePCHContainerOperations.h
  clang/include/clang/Serialization/PCHContainerOperations.h
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Serialization/PCHContainerOperations.cpp
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/test/ClangScanDeps/module-format.c
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/Indexing.cpp

Index: clang/tools/libclang/Indexing.cpp
===
--- clang/tools/libclang/Indexing.cpp
+++ clang/tools/libclang/Indexing.cpp
@@ -552,7 +552,7 @@
 
   // Make sure to use the raw module format.
   CInvok->getHeaderSearchOpts().ModuleFormat = std::string(
-  CXXIdx->getPCHContainerOperations()->getRawReader().getFormat());
+  CXXIdx->getPCHContainerOperations()->getRawReader().getFormats().front());
 
   auto Unit = ASTUnit::create(CInvok, Diags, CaptureDiagnostics,
   /*UserFilesAreVolatile=*/true);
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3964,7 +3964,7 @@
   TUKind, CacheCodeCompletionResults, IncludeBriefCommentsInCodeCompletion,
   /*AllowPCHWithCompilerErrors=*/true, SkipFunctionBodies, SingleFileParse,
   /*UserFilesAreVolatile=*/true, ForSerialization, RetainExcludedCB,
-  CXXIdx->getPCHContainerOperations()->getRawReader().getFormat(),
+  CXXIdx->getPCHContainerOperations()->getRawReader().getFormats().front(),
   ));
 
   // Early failures in LoadFromCommandLine may return with ErrUnit unset.
Index: clang/test/ClangScanDeps/module-format.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/module-format.c
@@ -0,0 +1,64 @@
+// Check that the scanner produces raw ast files, even when builds produce the
+// obj format, and that the scanner can read obj format from PCH and modules
+// imported by PCH.
+
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: target={{.*}}-aix{{.*}}
+
+// REQUIRES: shell
+
+// RUN: rm -rf %t && mkdir %t
+// RUN: cp %S/Inputs/modules-pch/* %t
+
+// Scan dependencies of the PCH:
+//
+// RUN: rm -f %t/cdb_pch.json
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_pch.json > %t/cdb_pch.json
+// RUN: clang-scan-deps -compilation-database %t/cdb_pch.json -format experimental-full \
+// RUN:   -module-files-dir %t/build > %t/result_pch.json
+
+// Explicitly build the PCH:
+//
+// RUN: %deps-to-rsp %t/result_pch.json --module-name=ModCommon1 > %t/mod_common_1.cc1.rsp
+// RUN: %deps-to-rsp %t/result_pch.json --module-name=ModCommon2 > %t/mod_common_2.cc1.rsp
+// RUN: %deps-to-rsp %t/result_pch.json --module-name=ModPCH > %t/mod_pch.cc1.rsp
+// RUN: %deps-to-rsp %t/result_pch.json --tu-index=0 > %t/pch.rsp
+//
+// RUN: %clang @%t/mod_common_1.cc1.rsp
+// RUN: %clang @%t/mod_common_2.cc1.rsp
+// RUN: %clang @%t/mod_pch.cc1.rsp
+// RUN: %clang @%t/pch.rsp
+
+// Scan dependencies of the TU:
+//
+// RUN: rm -f %t/cdb_tu.json
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu.json > %t/cdb_tu.json
+// RUN: clang-scan-deps -compilation-database %t/cdb_tu.json -format experimental-full \
+// RUN:   -module-files-dir %t/build > %t/result_tu.json
+
+// Explicitly build the TU:
+//
+// RUN: %deps-to-rsp %t/result_tu.json --module-name=ModTU > %t/mod_tu.cc1.rsp
+// RUN: %deps-to-rsp %t/result_tu.json --tu-index=0 > %t/tu.rsp
+//
+// RUN: %clang @%t/mod_tu.cc1.rsp
+// RUN: %clang @%t/tu.rsp
+
+// Check the module format for scanner modules:
+//
+// RUN: find %t/cache -name "*.pcm" -exec %clang_cc1 -module-file-info "{}" ";" | FileCheck %s -check-prefix=SCAN
+// SCAN: Module format: raw
+// SCAN: Module format: raw
+// SCAN: Module format: raw
+// SCAN: Module format: raw
+
+// Check the module format for built modules:
+//
+// RUN: find %t/build -name "*.pcm" -exec %clang_cc1 -module-file-info "{}" ";" | FileCheck %s -check-prefix=BUILD
+// BUILD: Module format: obj
+// BUILD: Module format: obj
+// BUILD: Module format: obj
+// BUILD: Module format: obj
+
+// FIXME: check pch format as well; -module-file-info does not work with a PCH
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -181,6 +181,7 @@
 ScanInstance.getFrontendOpts().GenerateGlobalModuleIndex 

[PATCH] D146764: [clang] Make predefined expressions string literals under -fms-extensions

2023-05-02 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

added the warning, not sure if this needs more tests for testing the 
interaction between `-pedantic`, `-Wmicrosoft`, 
`-Wmicrosoft-init-from-predefined` or if that's already assumed to work




Comment at: clang/test/Modules/predefined.cpp:6
+// RUN: %clang_cc1 -x c++ -std=c++20 -emit-module-interface a.h -o a.pcm 
-fms-extensions
+// RUN: %clang_cc1 -std=c++20 a.cpp -fmodule-file=A=a.pcm -fms-extensions 
-fsyntax-only
+

aaron.ballman wrote:
> Er, should we have a `-verify` on this as well as `// 
> expected-no-diagnostics`?
isn't that tested by the Sema test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146764

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


[PATCH] D148800: [C2x] Update 'nullptr' implementation based on CD comments

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



Comment at: clang/lib/Sema/SemaExpr.cpp:10087
+// a conversion.
+Kind = CK_NoOp;
+return Compatible;

I'd like to see testcases for:

- Codegen (LLVM IR emission)
- Constant evaluation.  (Is a cast like this allowed in an integer constant 
expression?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148800

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


[PATCH] D149643: [clang-format] Correctly limit formatted ranges when specifying qualifier alignment

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



Comment at: clang/unittests/Format/QualifierFixerTest.cpp:1351
+
+  // Only the first line should be formatted the second should remain as is
+  EXPECT_EQ("template  const Foo f();\n"





Comment at: clang/unittests/Format/QualifierFixerTest.cpp:1352-1357
+  EXPECT_EQ("template  const Foo f();\n"
+"template  Foo const f();",
+format("template  Foo const f();\n"
+   "template  Foo const f();",
+   Style, SC_ExpectComplete,
+   std::vector(1, tooling::Range(0, 36;

Please use `verifyFormat` instead of `EXPECT_EQ` here and below.



Comment at: clang/unittests/Format/QualifierFixerTest.cpp:1359-1360
+
+  // Only the middle line should be formatted the first and last should remain
+  // as is
+  EXPECT_EQ("template  Foo const f();\n"




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149643

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


[PATCH] D146764: [clang] Make predefined expressions string literals under -fms-extensions

2023-05-02 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 518887.
aeubanks added a comment.

add warning


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146764

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/IgnoreExpr.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/Modules/predefined.cpp
  clang/test/Sema/ms_predefined_expr.cpp

Index: clang/test/Sema/ms_predefined_expr.cpp
===
--- /dev/null
+++ clang/test/Sema/ms_predefined_expr.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -fsyntax-only -Wmicrosoft -verify -fms-extensions
+
+void f() {
+ const char a[] = __FUNCTION__; // expected-warning{{initializing an array from a '__FUNCTION__' predefined identifier is a Microsoft extension}}
+ const char b[] = __FUNCDNAME__; // expected-warning{{initializing an array from a '__FUNCDNAME__' predefined identifier is a Microsoft extension}}
+ const char c[] = __FUNCSIG__; // expected-warning{{initializing an array from a '__FUNCSIG__' predefined identifier is a Microsoft extension}}
+ const char d[] = __func__; // expected-warning{{initializing an array from a '__func__' predefined identifier is a Microsoft extension}}
+ const char e[] = __PRETTY_FUNCTION__; // expected-warning{{initializing an array from a '__PRETTY_FUNCTION__' predefined identifier is a Microsoft extension}}
+}
Index: clang/test/Modules/predefined.cpp
===
--- /dev/null
+++ clang/test/Modules/predefined.cpp
@@ -0,0 +1,23 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -x c++ -std=c++20 -emit-module-interface a.h -o a.pcm -fms-extensions
+// RUN: %clang_cc1 -std=c++20 a.cpp -fmodule-file=A=a.pcm -fms-extensions -fsyntax-only
+
+//--- a.h
+
+export module A;
+
+export template 
+void f() {
+char a[] = __func__;
+}
+
+//--- a.cpp
+
+import A;
+
+void g() {
+f();
+}
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -593,6 +593,7 @@
   bool HasFunctionName = E->getFunctionName() != nullptr;
   Record.push_back(HasFunctionName);
   Record.push_back(E->getIdentKind()); // FIXME: stable encoding
+  Record.push_back(E->isTransparent());
   Record.AddSourceLocation(E->getLocation());
   if (HasFunctionName)
 Record.AddStmt(E->getFunctionName());
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -582,6 +582,7 @@
   bool HasFunctionName = Record.readInt();
   E->PredefinedExprBits.HasFunctionName = HasFunctionName;
   E->PredefinedExprBits.Kind = Record.readInt();
+  E->PredefinedExprBits.IsTransparent = Record.readInt();
   E->setLocation(readSourceLocation());
   if (HasFunctionName)
 E->setFunctionName(cast(Record.readSubExpr()));
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -173,6 +173,8 @@
   E = GSE->getResultExpr();
 } else if (ChooseExpr *CE = dyn_cast(E)) {
   E = CE->getChosenSubExpr();
+} else if (PredefinedExpr *PE = dyn_cast(E)) {
+  E = PE->getFunctionName();
 } else {
   llvm_unreachable("unexpected expr in string literal init");
 }
@@ -8500,6 +8502,15 @@
 << Init->getSourceRange();
   }
 
+  if (S.getLangOpts().MicrosoftExt && Args.size() == 1 &&
+  isa(Args[0])) {
+// Produce a Microsoft compatibility warning when initializing from a
+// predefined expression since MSVC treats predefined expressions as string
+// literals.
+Expr *Init = Args[0];
+S.Diag(Init->getBeginLoc(), diag::ext_init_from_predefined) << Init;
+  }
+
   // OpenCL v2.0 s6.13.11.1. atomic variables can be initialized in global scope
   QualType ETy = Entity.getType();
   bool HasGlobalAS = ETy.hasAddressSpace() &&
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -3580,7 +3580,8 @@
 }
   }
 
-  return PredefinedExpr::Create(Context, Loc, ResTy, IK, SL);
+  return PredefinedExpr::Create(Context, Loc, ResTy, IK, LangOpts.MicrosoftExt,
+SL);
 }
 
 ExprResult Sema::BuildSYCLUniqueStableNameExpr(SourceLocation OpLoc,
Index: clang/lib/AST/Expr.cpp

[PATCH] D149193: [Driver] Add -dumpdir and change -gsplit-dwarf .dwo names for linking

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

Thank you:)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149193

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


[PATCH] D148370: [Clang][Flang][OpenMP] Add loadOffloadInfoMetadata and createOffloadEntriesAndInfoMetadata into OMPIRBuilder's finalize and initialize

2023-05-02 Thread Andrew Gozillon via Phabricator via cfe-commits
agozillon added a comment.

Thank you very much for the quick response time on the review and the review 
@jdoerfert! I believe I have applied all of your current feedback in the last 
update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148370

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


[PATCH] D148370: [Clang][Flang][OpenMP] Add loadOffloadInfoMetadata and createOffloadEntriesAndInfoMetadata into OMPIRBuilder's finalize and initialize

2023-05-02 Thread Andrew Gozillon via Phabricator via cfe-commits
agozillon updated this revision to Diff 518875.
agozillon marked 4 inline comments as done.
agozillon added a comment.

- Move hostIRFilePath initialize invocation to ModuleTranslation.cpp to respect 
TargetOp patch
- Apply reviewer feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148370

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/CMakeLists.txt
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
  mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Index: mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -1259,19 +1259,23 @@
 llvm::OpenMPIRBuilder *ModuleTranslation::getOpenMPBuilder() {
   if (!ompBuilder) {
 ompBuilder = std::make_unique(*llvmModule);
-ompBuilder->initialize();
 
 bool isDevice = false;
+llvm::StringRef hostIRFilePath = "";
 if (auto offloadMod =
-dyn_cast(mlirModule))
+dyn_cast(mlirModule)) {
   isDevice = offloadMod.getIsDevice();
+  hostIRFilePath = offloadMod.getHostIRFilePath();
+}
+
+ompBuilder->initialize(hostIRFilePath);
 
 // TODO: set the flags when available
-llvm::OpenMPIRBuilderConfig Config(
+llvm::OpenMPIRBuilderConfig config(
 isDevice, /* IsTargetCodegen */ false,
 /* HasRequiresUnifiedSharedMemory */ false,
 /* OpenMPOffloadMandatory */ false);
-ompBuilder->setConfig(Config);
+ompBuilder->setConfig(config);
   }
   return ompBuilder.get();
 }
Index: mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
===
--- mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
+++ mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
@@ -15,6 +15,7 @@
 #define MLIR_TARGET_LLVMIR_MODULETRANSLATION_H
 
 #include "mlir/Dialect/LLVMIR/LLVMInterfaces.h"
+#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
 #include "mlir/IR/Operation.h"
 #include "mlir/IR/SymbolTable.h"
 #include "mlir/IR/Value.h"
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -21,6 +21,7 @@
 #include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
+#include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/IR/CFG.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DebugInfoMetadata.h"
@@ -445,7 +446,29 @@
   return Fn;
 }
 
-void OpenMPIRBuilder::initialize() { initializeTypes(M); }
+void OpenMPIRBuilder::initialize(StringRef HostFilePath) {
+  initializeTypes(M);
+
+  if (HostFilePath.empty())
+return;
+
+  auto Buf = MemoryBuffer::getFile(HostFilePath);
+  if (auto Err = Buf.getError())
+report_fatal_error(("error opening host file from host file path inside of "
+"OpenMPIRBuilder: " +
+Err.message())
+   .c_str());
+
+  LLVMContext Ctx;
+  auto M = expectedToErrorOrAndEmitErrors(
+  Ctx, parseBitcodeFile(Buf.get()->getMemBufferRef(), Ctx));
+  if (auto Err = M.getError())
+report_fatal_error(
+("error parsing host file inside of OpenMPIRBuilder: " + Err.message())
+.c_str());
+
+  loadOffloadInfoMetadata(*M.get());
+}
 
 void OpenMPIRBuilder::finalize(Function *Fn) {
   SmallPtrSet ParallelRegionBlockSet;
@@ -534,6 +557,17 @@
 
   // Remove work items that have been completed.
   OutlineInfos = std::move(DeferredOutlines);
+
+  llvm::OpenMPIRBuilder::EmitMetadataErrorReportFunctionTy & =
+  [](llvm::OpenMPIRBuilder::EmitMetadataErrorKind kind,
+ const llvm::TargetRegionEntryInfo ) -> void {
+llvm::errs() << "Error of kind: " << kind
+ << " when emitting offload entries and metadata during "
+"OMPIRBuilder finalization \n";
+  };
+
+  if (!OffloadInfoManager.empty())
+createOffloadEntriesAndInfoMetadata(errorReportFn);
 }
 
 OpenMPIRBuilder::~OpenMPIRBuilder() {
Index: llvm/lib/Frontend/OpenMP/CMakeLists.txt
===
--- llvm/lib/Frontend/OpenMP/CMakeLists.txt
+++ llvm/lib/Frontend/OpenMP/CMakeLists.txt
@@ -19,4 +19,5 @@
   Analysis
   MC
   Scalar
+  BitReader
   )
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -418,8 +418,14 @@
 
   /// Initialize the internal state, this will put structures types and
   

[PATCH] D149695: MS inline asm: remove obsolete code adding AOK_SizeDirective (e.g. dword ptr)

2023-05-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: alvinhochun, epastor, hans, thakis, ayzhao.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

The AOK_SizeDirective part from 5b37c181291210bedfbb7a6af5d51229f3652ef0
(2014-08) seems unneeded nowadays (the root cause has likely been fixed
elsewhere). The part abuses that `call dword ptr foo` assembles the same way as 
`call
foo` in Intel syntax, which is going to be fixed (changed) by D149579 
.

The generated object files for CodeGen/ms-inline-asm-functions.c,
CodeGen/ms-inline-asm-functions.c, and CodeGenCXX/ms-inline-asm-fields.cpp are
unchanged with just this patch.
When D149579  is subsequently applied, the 
FIXME part of `kptr` in
CodeGen/ms-inline-asm-functions.c will be fixed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149695

Files:
  clang/test/CodeGen/mozilla-ms-inline-asm.c
  clang/test/CodeGen/ms-inline-asm-64.c
  clang/test/CodeGen/ms-inline-asm.c
  clang/test/CodeGen/ms-inline-asm.cpp
  clang/test/CodeGen/ms_this.cpp
  clang/test/CodeGenCXX/ms-inline-asm-fields.cpp
  llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp

Index: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
===
--- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -1748,12 +1748,6 @@
   // If we found a decl other than a VarDecl, then assume it is a FuncDecl or
   // some other label reference.
   if (Info.isKind(InlineAsmIdentifierInfo::IK_Label)) {
-// Insert an explicit size if the user didn't have one.
-if (!Size) {
-  Size = getPointerWidth();
-  InstInfo->AsmRewrites->emplace_back(AOK_SizeDirective, Start,
-  /*Len=*/0, Size);
-}
 // Create an absolute memory reference in order to match against
 // instructions taking a PC relative operand.
 Operands.push_back(X86Operand::CreateMem(getPointerWidth(), Disp, Start,
Index: clang/test/CodeGenCXX/ms-inline-asm-fields.cpp
===
--- clang/test/CodeGenCXX/ms-inline-asm-fields.cpp
+++ clang/test/CodeGenCXX/ms-inline-asm-fields.cpp
@@ -53,4 +53,4 @@
 // CHECK: %[[P:.*]] = alloca %"struct.make_storage_type::type", align 4
 // CHECK: %[[B:.*]] = getelementptr inbounds %"struct.make_storage_type::type", ptr %[[P]], i32 0, i32 0
 // CHECK: %[[X:.*]] = getelementptr inbounds %"struct.make_storage_type::type::B", ptr %[[B]], i32 0, i32 1
-// CHECK: call void asm sideeffect inteldialect "mov edx, dword ptr $0", "*m,~{edx},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) %[[X]])
+// CHECK: call void asm sideeffect inteldialect "mov edx, $0", "*m,~{edx},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) %[[X]])
Index: clang/test/CodeGen/ms_this.cpp
===
--- clang/test/CodeGen/ms_this.cpp
+++ clang/test/CodeGen/ms_this.cpp
@@ -20,7 +20,7 @@
   mov rax,[this]
   // CHECK: [[THIS_ADDR_T2:%.+]] = alloca ptr
   // CHECK: [[THIS1_T2:%.+]] = load ptr, ptr [[THIS_ADDR_T2]],
-  // CHECK: call void asm sideeffect inteldialect "mov rax,qword ptr $1{{.*}}ptr [[THIS1_T2]]
+  // CHECK: call void asm sideeffect inteldialect "mov rax,$1\0A\09mov rbx,[rax]\0A\09mov $0, rbx", "=*m,m,~{rax},~{rbx},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(double) %num, ptr [[THIS1_T2]])
   mov rbx,[rax]
   mov num, rbx
 	   };
@@ -33,7 +33,7 @@
mov rax,[this]
// CHECK: [[THIS_ADDR_T1:%.+]] = alloca ptr
// CHECK: [[THIS1_T1:%.+]] = load ptr, ptr [[THIS_ADDR_T1]],
-   // CHECK: call void asm sideeffect inteldialect "mov rax,qword ptr $1{{.*}}ptr [[THIS1_T1]]
+   // CHECK: call void asm sideeffect inteldialect "mov rax,$1{{.*}}ptr [[THIS1_T1]]
 mov rbx,[rax]
 mov num, rbx
 	   };
@@ -46,7 +46,7 @@
 __asm mov rax, [this]
 // CHECK: [[THIS_ADDR_S:%.+]] = alloca ptr
 // CHECK: [[THIS1_S:%.+]] = load ptr, ptr [[THIS_ADDR_S]],
-// CHECK: call void asm sideeffect inteldialect "mov rax, qword ptr $0{{.*}}ptr [[THIS1_S]]
+// CHECK: call void asm sideeffect inteldialect "mov rax, $0{{.*}}ptr [[THIS1_S]]
   }
 } f3;
 
Index: clang/test/CodeGen/ms-inline-asm.cpp
===
--- clang/test/CodeGen/ms-inline-asm.cpp
+++ clang/test/CodeGen/ms-inline-asm.cpp
@@ -109,7 +109,7 @@
   __asm mov x, eax
   // CHECK: call void asm sideeffect inteldialect
   // CHECK-SAME: push $0
-  // CHECK-SAME: call dword ptr ${2:P}
+  // CHECK-SAME: call ${2:P}
   // CHECK-SAME: mov $1, eax
   // CHECK-SAME: "=*m,=*m,*m,~{esp},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) %y, ptr elementtype(i32) %x, ptr 

[PATCH] D149553: [clang] Use -std=c++23 instead of -std=c++2b

2023-05-02 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

Thanks for doing this! No objection, will let Aaron give the thumbs up.




Comment at: clang/test/Parser/cxx2b-label.cpp:1
-// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx2b -std=c++2b 
-Wpre-c++2b-compat %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx23 -std=c++23 
-Wpre-c++23-compat %s
 // RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx20 -std=c++20 %s

We could also consider renaming those files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149553

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


[PATCH] D149647: [NFC][Clang]Fix static analyzer tool remarks about large copies by value

2023-05-02 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/Format.cpp:3486-3489
+  Expanded.InsertBraces = true;
+  Passes.emplace_back([&](const Environment ) {
+return BracesInserter(Env, Expanded).process(/*SkipAnnotation=*/true);
   });

tahonermann wrote:
> How about using an init capture instead? This will suffice to avoid one of 
> the copies but means that `InsertBraces` doesn't get set until the lambda is 
> invoked. I wouldn't expect that to matter though.
I'm not sure if it's worth the trouble, but if I really had to bother, I would 
do something like the above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149647

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


[PATCH] D149694: [Clang] Update warning on some designator initializer cases involving unions

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

Currently when using designated initializers in C++ we have a few extension. 
Two extension which are dangerous involved assigning to multiple members of 
union which will likely be a mistake since unions can only have one active 
member. I have updated to be a warning by default.

The second case if when we assign to multiple union members and one of the 
previous members had a non-trivial destructor, which could lead to leaking 
resources. This one is now an error by default.

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


https://reviews.llvm.org/D149694

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaInit.cpp
  clang/test/SemaCXX/cxx2b-designated-initializers.cpp


Index: clang/test/SemaCXX/cxx2b-designated-initializers.cpp
===
--- clang/test/SemaCXX/cxx2b-designated-initializers.cpp
+++ clang/test/SemaCXX/cxx2b-designated-initializers.cpp
@@ -19,3 +19,27 @@
 }
 
 } // end namespace PR61118
+
+namespace GH62156 {
+union U1 {
+   int x;
+   float y;
+};
+
+struct NonTrivial {
+  NonTrivial();
+  ~NonTrivial();
+};
+
+union U2 {
+   NonTrivial x;
+   float y;
+};
+
+void f() {
+   U1 u{.x=2,  // expected-note {{previous initialization is here}}
+.y=1}; // expected-error {{initializer partially overrides prior 
initialization of this subobject}}
+   new U2{.x = NonTrivial{}, // expected-note {{previous initialization is 
here}}
+  .y=1}; // expected-error {{initializer would partially override 
prior initialization of object of type 'NonTrivial' with non-trivial 
destruction}}
+}
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -393,12 +393,15 @@
 
   /// Diagnose that OldInit (or part thereof) has been overridden by NewInit.
   void diagnoseInitOverride(Expr *OldInit, SourceRange NewInitRange,
+bool UnionOverride = false,
 bool FullyOverwritten = true) {
 // Overriding an initializer via a designator is valid with C99 designated
 // initializers, but ill-formed with C++20 designated initializers.
-unsigned DiagID = SemaRef.getLangOpts().CPlusPlus
-  ? diag::ext_initializer_overrides
-  : diag::warn_initializer_overrides;
+unsigned DiagID =
+SemaRef.getLangOpts().CPlusPlus
+? (UnionOverride ? diag::ext_initializer_union_overrides
+ : diag::ext_initializer_overrides)
+: diag::warn_initializer_overrides;
 
 if (InOverloadResolution && SemaRef.getLangOpts().CPlusPlus) {
   // In overload resolution, we have to strictly enforce the rules, and so
@@ -2544,6 +2547,7 @@
 // subobject [0].b.
 diagnoseInitOverride(ExistingInit,
  SourceRange(D->getBeginLoc(), DIE->getEndLoc()),
+ /*UnionOverride=*/false,
  /*FullyOverwritten=*/false);
 
 if (!VerifyOnly) {
@@ -2689,7 +2693,9 @@
   if (ExistingInit) {
 // We're about to throw away an initializer, emit warning.
 diagnoseInitOverride(
-ExistingInit, SourceRange(D->getBeginLoc(), DIE->getEndLoc()));
+ExistingInit, SourceRange(D->getBeginLoc(), DIE->getEndLoc()),
+/*UnionOverride=*/true,
+/*FullyOverwritten=*/SemaRef.getLangOpts().CPlusPlus ? false : 
true);
   }
 
   // remove existing initializer
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -186,6 +186,8 @@
   "this subobject">, InGroup;
 def ext_initializer_overrides : ExtWarn,
   InGroup, SFINAEFailure;
+def ext_initializer_union_overrides : 
ExtWarn,
+  InGroup, DefaultError, SFINAEFailure;
 def err_initializer_overrides_destructed : Error<
   "initializer would partially override prior initialization of object of "
   "type %1 with non-trivial destruction">;


Index: clang/test/SemaCXX/cxx2b-designated-initializers.cpp
===
--- clang/test/SemaCXX/cxx2b-designated-initializers.cpp
+++ clang/test/SemaCXX/cxx2b-designated-initializers.cpp
@@ -19,3 +19,27 @@
 }
 
 } // end namespace PR61118
+
+namespace GH62156 {
+union U1 {
+   int x;
+   float y;
+};
+
+struct NonTrivial {
+  NonTrivial();
+  ~NonTrivial();
+};
+
+union U2 {
+   NonTrivial x;
+   float y;
+};
+
+void f() {
+   U1 u{.x=2,  // expected-note {{previous initialization is here}}
+.y=1}; // 

[PATCH] D148800: [C2x] Update 'nullptr' implementation based on CD comments

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

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148800

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


[PATCH] D149693: [clang][deps] Make clang-scan-deps write modules in raw format

2023-05-02 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir created this revision.
benlangmuir added reviewers: jansvoboda11, akyrtzi, Bigcheese.
Herald added a subscriber: arphaman.
Herald added a project: All.
benlangmuir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We have no use for debug info for the scanner modules, and writing raw ast 
files speeds up scanning ~15% in some cases. Note that the compile commands 
produced by the scanner will still build the obj format (if requested), and the 
scanner can *read* obj format pcms, e.g. from a PCH.

rdar://108807592


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149693

Files:
  clang/include/clang/CodeGen/ObjectFilePCHContainerOperations.h
  clang/include/clang/Serialization/PCHContainerOperations.h
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Serialization/PCHContainerOperations.cpp
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/test/ClangScanDeps/module-format.c
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/Indexing.cpp

Index: clang/tools/libclang/Indexing.cpp
===
--- clang/tools/libclang/Indexing.cpp
+++ clang/tools/libclang/Indexing.cpp
@@ -552,7 +552,7 @@
 
   // Make sure to use the raw module format.
   CInvok->getHeaderSearchOpts().ModuleFormat = std::string(
-  CXXIdx->getPCHContainerOperations()->getRawReader().getFormat());
+  CXXIdx->getPCHContainerOperations()->getRawReader().getFormats().front());
 
   auto Unit = ASTUnit::create(CInvok, Diags, CaptureDiagnostics,
   /*UserFilesAreVolatile=*/true);
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3964,7 +3964,7 @@
   TUKind, CacheCodeCompletionResults, IncludeBriefCommentsInCodeCompletion,
   /*AllowPCHWithCompilerErrors=*/true, SkipFunctionBodies, SingleFileParse,
   /*UserFilesAreVolatile=*/true, ForSerialization, RetainExcludedCB,
-  CXXIdx->getPCHContainerOperations()->getRawReader().getFormat(),
+  CXXIdx->getPCHContainerOperations()->getRawReader().getFormats().front(),
   ));
 
   // Early failures in LoadFromCommandLine may return with ErrUnit unset.
Index: clang/test/ClangScanDeps/module-format.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/module-format.c
@@ -0,0 +1,64 @@
+// Check that the scanner produces raw ast files, even when builds produce the
+// obj format, and that the scanner can read obj format from PCH and modules
+// imported by PCH.
+
+// Unsupported on AIX because we don't support the requisite "__clangast"
+// section in XCOFF yet.
+// UNSUPPORTED: target={{.*}}-aix{{.*}}
+
+// REQUIRES: shell
+
+// RUN: rm -rf %t && mkdir %t
+// RUN: cp %S/Inputs/modules-pch/* %t
+
+// Scan dependencies of the PCH:
+//
+// RUN: rm -f %t/cdb_pch.json
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_pch.json > %t/cdb_pch.json
+// RUN: clang-scan-deps -compilation-database %t/cdb_pch.json -format experimental-full \
+// RUN:   -module-files-dir %t/build > %t/result_pch.json
+
+// Explicitly build the PCH:
+//
+// RUN: %deps-to-rsp %t/result_pch.json --module-name=ModCommon1 > %t/mod_common_1.cc1.rsp
+// RUN: %deps-to-rsp %t/result_pch.json --module-name=ModCommon2 > %t/mod_common_2.cc1.rsp
+// RUN: %deps-to-rsp %t/result_pch.json --module-name=ModPCH > %t/mod_pch.cc1.rsp
+// RUN: %deps-to-rsp %t/result_pch.json --tu-index=0 > %t/pch.rsp
+//
+// RUN: %clang @%t/mod_common_1.cc1.rsp
+// RUN: %clang @%t/mod_common_2.cc1.rsp
+// RUN: %clang @%t/mod_pch.cc1.rsp
+// RUN: %clang @%t/pch.rsp
+
+// Scan dependencies of the TU:
+//
+// RUN: rm -f %t/cdb_tu.json
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch/cdb_tu.json > %t/cdb_tu.json
+// RUN: clang-scan-deps -compilation-database %t/cdb_tu.json -format experimental-full \
+// RUN:   -module-files-dir %t/build > %t/result_tu.json
+
+// Explicitly build the TU:
+//
+// RUN: %deps-to-rsp %t/result_tu.json --module-name=ModTU > %t/mod_tu.cc1.rsp
+// RUN: %deps-to-rsp %t/result_tu.json --tu-index=0 > %t/tu.rsp
+//
+// RUN: %clang @%t/mod_tu.cc1.rsp
+// RUN: %clang @%t/tu.rsp
+
+// Check the module format for scanner modules:
+//
+// RUN: find %t/cache -name "*.pcm" -exec %clang_cc1 -module-file-info "{}" ";" | FileCheck %s -check-prefix=SCAN
+// SCAN: Module format: raw
+// SCAN: Module format: raw
+// SCAN: Module format: raw
+// SCAN: Module format: raw
+
+// Check the module format for built modules:
+//
+// RUN: find %t/build -name "*.pcm" -exec %clang_cc1 -module-file-info "{}" ";" | FileCheck %s -check-prefix=BUILD
+// BUILD: Module format: obj
+// BUILD: Module format: obj
+// BUILD: Module format: obj
+// BUILD: Module format: obj
+
+// FIXME: check pch format as well; 

[PATCH] D149013: [clang][Interp] Check pointers when accessing base class

2023-05-02 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/test/AST/Interp/records.cpp:509-512
+  constexpr A *a2 =  + 1; // expected-error {{must be initialized by a 
constant expression}} \
+// expected-note {{cannot access base class of 
pointer past the end of object}} \
+// ref-error {{must be initialized by a constant 
expression}} \
+// ref-note {{cannot access base class of pointer 
past the end of object}}

aaron.ballman wrote:
> I may have jumped the gun on accepting this, actually. Forming the pointer to 
> ` + 1` is fine, but evaluating it by dereferencing it would be UB. e.g., 
> http://eel.is/c++draft/expr.const#13.3
We probably want tests that ensure `+2` is invalid in all cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149013

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


[PATCH] D149013: [clang][Interp] Check pointers when accessing base class

2023-05-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added inline comments.
This revision now requires changes to proceed.



Comment at: clang/test/AST/Interp/records.cpp:509-512
+  constexpr A *a2 =  + 1; // expected-error {{must be initialized by a 
constant expression}} \
+// expected-note {{cannot access base class of 
pointer past the end of object}} \
+// ref-error {{must be initialized by a constant 
expression}} \
+// ref-note {{cannot access base class of pointer 
past the end of object}}

I may have jumped the gun on accepting this, actually. Forming the pointer to 
` + 1` is fine, but evaluating it by dereferencing it would be UB. e.g., 
http://eel.is/c++draft/expr.const#13.3


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149013

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


[PATCH] D146921: [clang-tidy] Implement cppcoreguidelines F.19

2023-05-02 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL accepted this revision.
PiotrZSL added a comment.
This revision is now accepted and ready to land.

Overall looks fine. My main concern are lambdas (and maybe functions/classes in 
functions, but that should only hit performance).
Please close all comments before pushing this.




Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp:61
+
+  StatementMatcher ForwardCallMatcher = callExpr(
+  argumentCountIs(1),

probably `auto` would be sufficient.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp:70
+  Finder->addMatcher(
+  parmVarDecl(
+  parmVarDecl().bind("param"), isTemplateTypeOfFunction(),

maybe think like: "functionDecl(forEachDescendant(parmVarDecl" could work.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp:71
+  parmVarDecl(
+  parmVarDecl().bind("param"), isTemplateTypeOfFunction(),
+  hasAncestor(functionDecl(isDefinition(), ToParam,

probably this could be named like isTemplateTypeParameter, current name suggest 
more that it's a FunctionDecl matcher, not ParmVarDecl.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp:71
+  parmVarDecl(
+  parmVarDecl().bind("param"), isTemplateTypeOfFunction(),
+  hasAncestor(functionDecl(isDefinition(), ToParam,

PiotrZSL wrote:
> probably this could be named like isTemplateTypeParameter, current name 
> suggest more that it's a FunctionDecl matcher, not ParmVarDecl.
consider excluding system code, or code inside std namespace.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp:72
+  parmVarDecl().bind("param"), isTemplateTypeOfFunction(),
+  hasAncestor(functionDecl(isDefinition(), ToParam,
+   
unless(hasDescendant(ForwardCallMatcher),

maybe we should skip also template instances.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp:73
+  hasAncestor(functionDecl(isDefinition(), ToParam,
+   
unless(hasDescendant(ForwardCallMatcher),
+  this);

consider `std::move` those matchers, always check construction could be 
faster...



Comment at: clang-tools-extra/docs/clang-tidy/checks/list.rst:192
`cppcoreguidelines-macro-usage `_,
+   `cppcoreguidelines-missing-std-forward 
`_, "Yes"
`cppcoreguidelines-narrowing-conversions 
`_,

no fixes provided, remove



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp:137
+};
+
+} // namespace negative_cases

Add test with std::forward happen in lambda, like:
```
template 
void does_something(T&& t) {
   [=] { call_other(std::forward(t)); }
}
```

this may not be detected. 
I usually solve those things like this:
```
  auto ForwardCallMatcher = callExpr(forCallable(equalsBoundNode("first")));

...
  hasAncestor(functionDecl().bind("first")),
  hasAncestor(functionDecl(isDefinition(), equalsBoundNode("first"), ToParam, 
unless(hasDescendant(ForwardCallMatcher),
```

Problem with hasAncestor, is that if first ancestor does not match then it's 
trying parent one. equalsBoundNode can be used to limit this only to first 
hasAncestor of specific type (unless there is other matcher for that).


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

https://reviews.llvm.org/D146921

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


[PATCH] D149013: [clang][Interp] Check pointers when accessing base class

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149013

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


[PATCH] D149149: [clang][Interp] Check one-past-the-end pointers in GetPtrField

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

LGTM




Comment at: clang/test/AST/Interp/records.cpp:500
 
 namespace PointerArith {
   struct A {};

Neat! For the tests in this namespace, Clang and ICC agree, GCC and MSVC agree, 
and users get to cry: https://godbolt.org/z/7EWWrY5z6


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149149

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


[PATCH] D149666: [OpenMP][OMPIRBuilder] Migrate MapCombinedInfoTy from Clang to OpenMPIRBuilder

2023-05-02 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 518847.
TIFitis marked 2 inline comments as done.
TIFitis added a comment.

Merged MapDevPtrsArrayTy and MapMappersArrayTy into single type named 
MapValueDeclsArrayTy in CGOpenMPRuntime.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149666

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h

Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -1445,6 +1445,48 @@
 bool separateBeginEndCalls() { return SeparateBeginEndCalls; }
   };
 
+  using MapValuesArrayTy = SmallVector;
+  using MapFlagsArrayTy = SmallVector;
+  using MapNamesArrayTy = SmallVector;
+  using MapDimArrayTy = SmallVector;
+  using MapNonContiguousArrayTy = SmallVector;
+
+  /// This structure contains combined information generated for mappable
+  /// clauses, including base pointers, pointers, sizes, map types, user-defined
+  /// mappers, and non-contiguous information.
+  struct MapCombinedInfoTy {
+struct StructNonContiguousInfo {
+  bool IsNonContiguous = false;
+  MapDimArrayTy Dims;
+  MapNonContiguousArrayTy Offsets;
+  MapNonContiguousArrayTy Counts;
+  MapNonContiguousArrayTy Strides;
+};
+MapValuesArrayTy BasePointers;
+MapValuesArrayTy Pointers;
+MapValuesArrayTy Sizes;
+MapFlagsArrayTy Types;
+MapNamesArrayTy Names;
+StructNonContiguousInfo NonContigInfo;
+
+/// Append arrays in \a CurInfo.
+void append(MapCombinedInfoTy ) {
+  BasePointers.append(CurInfo.BasePointers.begin(),
+  CurInfo.BasePointers.end());
+  Pointers.append(CurInfo.Pointers.begin(), CurInfo.Pointers.end());
+  Sizes.append(CurInfo.Sizes.begin(), CurInfo.Sizes.end());
+  Types.append(CurInfo.Types.begin(), CurInfo.Types.end());
+  NonContigInfo.Dims.append(CurInfo.NonContigInfo.Dims.begin(),
+CurInfo.NonContigInfo.Dims.end());
+  NonContigInfo.Offsets.append(CurInfo.NonContigInfo.Offsets.begin(),
+   CurInfo.NonContigInfo.Offsets.end());
+  NonContigInfo.Counts.append(CurInfo.NonContigInfo.Counts.begin(),
+  CurInfo.NonContigInfo.Counts.end());
+  NonContigInfo.Strides.append(CurInfo.NonContigInfo.Strides.begin(),
+   CurInfo.NonContigInfo.Strides.end());
+}
+  };
+
   /// Emit the arguments to be passed to the runtime library based on the
   /// arrays of base pointers, pointers, sizes, map types, and mappers.  If
   /// ForEndCall, emit map types to be passed for the end of the region instead
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6831,58 +6831,35 @@
 const Expr *getMapExpr() const { return MapExpr; }
   };
 
-  /// Class that associates information with a base pointer to be passed to the
-  /// runtime library.
-  class BasePointerInfo {
-/// The base pointer.
-llvm::Value *Ptr = nullptr;
-/// The base declaration that refers to this device pointer, or null if
-/// there is none.
-const ValueDecl *DevPtrDecl = nullptr;
-
-  public:
-BasePointerInfo(llvm::Value *Ptr, const ValueDecl *DevPtrDecl = nullptr)
-: Ptr(Ptr), DevPtrDecl(DevPtrDecl) {}
-llvm::Value *operator*() const { return Ptr; }
-const ValueDecl *getDevicePtrDecl() const { return DevPtrDecl; }
-void setDevicePtrDecl(const ValueDecl *D) { DevPtrDecl = D; }
-  };
-
+  using MapBaseValuesArrayTy = llvm::OpenMPIRBuilder::MapValuesArrayTy;
+  using MapValuesArrayTy = llvm::OpenMPIRBuilder::MapValuesArrayTy;
+  using MapFlagsArrayTy = llvm::OpenMPIRBuilder::MapFlagsArrayTy;
+  using MapDimArrayTy = llvm::OpenMPIRBuilder::MapDimArrayTy;
+  using MapNonContiguousArrayTy =
+  llvm::OpenMPIRBuilder::MapNonContiguousArrayTy;
   using MapExprsArrayTy = SmallVector;
-  using MapBaseValuesArrayTy = SmallVector;
-  using MapValuesArrayTy = SmallVector;
-  using MapFlagsArrayTy = SmallVector;
-  using MapMappersArrayTy = SmallVector;
-  using MapDimArrayTy = SmallVector;
-  using MapNonContiguousArrayTy = SmallVector;
+  using MapValueDeclsArrayTy = SmallVector;
 
   /// This structure contains combined information generated for mappable
   /// clauses, including base pointers, pointers, sizes, map types, user-defined
   /// mappers, and non-contiguous information.
-  struct MapCombinedInfoTy {
-struct StructNonContiguousInfo {
-  bool IsNonContiguous = false;
-  MapDimArrayTy Dims;
-  MapNonContiguousArrayTy Offsets;
-  MapNonContiguousArrayTy Counts;
-  

[PATCH] D149666: [OpenMP][OMPIRBuilder] Migrate MapCombinedInfoTy from Clang to OpenMPIRBuilder

2023-05-02 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis marked 2 inline comments as done.
TIFitis added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:6848
+  class MapCombinedInfoTy : public llvm::OpenMPIRBuilder::MapCombinedInfoTy {
+  public:
 MapExprsArrayTy Exprs;

jdoerfert wrote:
> Not sure why you made it a class with public, but I guess it doesn't matter.
> Do we really want to use the same name though? I would add "Base" or sth to 
> the llvm class.
The clang code, and eventually the OMPIRBuilder code accesses the members 
directly so they need to be public.

I have kept it the same name in similar fashion to the TargetDataInfo type that 
also got migrated. From OMPBuilder's perspective the type is sufficient and 
when using it from MLIR I don't think we would need the extra data structures 
that clang uses.

Let me know what you think, I can change it to a different name as you 
suggested.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:6872
   NonContigInfo.Strides.append(CurInfo.NonContigInfo.Strides.begin(),
 CurInfo.NonContigInfo.Strides.end());
 }

jdoerfert wrote:
> We should use the base append function, no?
The base append function is missing append for the members we introduced here 
like `Exprs` and `Mappers`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149666

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


[PATCH] D149550: [clang][Interp] Fix compound assign operator evaluation order

2023-05-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:683-685
+  // C++17 onwards require that we evaluate the RHS first.
+  // Compute RHS and save it in a temporary variable so we can
+  // load it again later.

In C, the evaluation of the operands are unsequenced. C doesn't currently have 
constexpr functions, only constexpr objects, but that eliminates mutating 
operations like compound assignment... for the moment. Perhaps a FIXME comment 
for figuring out how to handle C?

(The situation I'm worried about in C is with UB dealing with unsequenced 
operations, like rejecting: https://godbolt.org/z/W11jchrKc)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149550

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


[PATCH] D141451: [clang] report inlining decisions with -Wattribute-{warning|error}

2023-05-02 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added inline comments.



Comment at: llvm/include/llvm/IR/DiagnosticInfo.h:1122
   }
+  void
+  getInliningDecisions(SmallVectorImpl ) const;

can this return a SmallVector instead of taking one as a mutable param?



Comment at: llvm/lib/IR/DiagnosticInfo.cpp:462
+  const MDOperand  = MDN->getOperand(0);
+  if (auto *MDT = dyn_cast(MO)) {
+for (const MDOperand  : MDT->operands()) {

seems simpler if this is always a `MDTuple` instead of special casing one entry 
to be `MDString`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141451

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


[PATCH] D145441: [AMDGPU] Define data layout entries for buffers

2023-05-02 Thread Krzysztof Drewniak via Phabricator via cfe-commits
krzysz00 updated this revision to Diff 518843.
krzysz00 added a comment.

Rebase to handle new legalization tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145441

Files:
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/test/CodeGen/target-data.c
  clang/test/CodeGenOpenCL/amdgpu-env-amdgcn.cl
  llvm/docs/AMDGPUUsage.rst
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/Target/AMDGPU/AMDGPU.h
  llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.f32-no-rtn.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.f32-rtn.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.f64.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.v2f16-no-rtn.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.v2f16-rtn.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-non-integral-address-spaces.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.atomic.dim.a16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.dim.a16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.load.2d.d16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.load.2d.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.load.2darraymsaa.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.load.3d.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.sample.a16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.sample.d.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.sample.g16.a16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.sample.g16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.store.2d.d16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.image.atomic.dim.mir
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.atomic.add.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.atomic.cmpswap.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.atomic.fadd-with-ret.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.atomic.fadd.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.load.format.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.load.format.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.store.format.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.store.format.f32.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.store.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.load.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.store.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.store.i8.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.store.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.atomic.add.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.atomic.cmpswap.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.atomic.fadd-with-ret.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.atomic.fadd.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.load.format.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.load.format.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.load.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.store.format.f16.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.store.format.f32.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.store.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.tbuffer.load.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.tbuffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.image.load.1d.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.image.sample.1d.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.raw.buffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.struct.buffer.load.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.struct.buffer.store.ll
  llvm/test/CodeGen/AMDGPU/addrspacecast-captured.ll
  llvm/test/CodeGen/AMDGPU/annotate-kernel-features-hsa.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.f32-no-rtn.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.f32-rtn.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.f64.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.v2f16-no-rtn.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.v2f16-rtn.ll
  

[PATCH] D146342: [-Wunsafe-buffer-usage] Move the whole analysis to the end of a translation unit

2023-05-02 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:2320-2323
+void traverseTU(const TranslationUnitDecl *TU) {
+  for (auto I = TU->decls_begin(); I != TU->decls_end(); ++I)
+TraverseDecl(*I);
+}

`RecursiveASTVisitor` does this automatically. Just ask it to `Visit(TU)`.



Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:2335
+  // To analyze callables:
+  if (isa(Node)) {
+// For code in dependent contexts, we'll do this at instantiation time:

The intended way to make recursive visitors is to have `TraverseFunctionDecl`, 
`TraverseBlockDecl`, etc., which automatically do the `isa` check and fall 
through to the superclass if the method isn't defined. Then they can all call a 
common method to analyze the body.

This doesn't necessarily lead to better code though, just to more traditional 
code, so up to you^^ in this case it probably doesn't matter. But it's 
definitely nice to separate the common part (the part that invokes all 
individual analyses) into its own method. And then you can eg. isolate the 
special `hasBody()` check in the `TraverseFunctionDecl()` method, so that other 
code paths didn't have an extra runtime check.



Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:2343-2345
+  // `FunctionDecl->hasBody()` returns true if the function has a body
+  // somewhere defined.  But we want to know if this `Node` has a body
+  // child.  So we use `doesThisDeclarationHaveABody`:

I wonder if `ObjCMethodDecl` has the same problem. They too can have prototypes 
and definitions separate from each other.



Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:2363-2364
+  if (isa(Node)) {
+// to visit implicit children of `LambdaExpr`s:
+IsVisitingLambda = true;
+

I suspect that you might have reinvented `shouldVisitLambdaBody()`.


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

https://reviews.llvm.org/D146342

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


[PATCH] D146178: [Clang][Sema] Fix comparison of constraint expressions

2023-05-02 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov added a comment.

reduced test case:

  template 
  concept Concept = false;
  
  struct Foo {
template 
struct result {};
  
template 
  requires(Concept<_Tp>)
struct result<_Tp>;
  };


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146178

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


[PATCH] D149647: [NFC][Clang]Fix static analyzer tool remarks about large copies by value

2023-05-02 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

Thank you for catching that @HazardyKnusperkeks! I completely missed (somehow) 
that the changed code modified `Expanded`. I offered another suggestion.




Comment at: clang/lib/Format/Format.cpp:3486-3489
+  Expanded.InsertBraces = true;
+  Passes.emplace_back([&](const Environment ) {
+return BracesInserter(Env, Expanded).process(/*SkipAnnotation=*/true);
   });

How about using an init capture instead? This will suffice to avoid one of the 
copies but means that `InsertBraces` doesn't get set until the lambda is 
invoked. I wouldn't expect that to matter though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149647

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


[PATCH] D148088: [RFC][clangd] Move preamble index task to a seperate task

2023-05-02 Thread Kugan Vivekanandarajah via Phabricator via cfe-commits
kuganv marked an inline comment as done.
kuganv added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:88
+if (PreambleIndexTask)
+  PreambleIndexTask->runAsync("task:" + Path + Version,
+  std::move(Task));

ilya-biryukov wrote:
> This definitely does not work. After `onPreambleAST` returns, the AST will be 
> destroyed and async tasks may access it afterwards.
> 
Thanks for the review and suggestion. Let me rework the prototype to address 
this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148088

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


[PATCH] D149647: [NFC][Clang]Fix static analyzer tool remarks about large copies by value

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

In D149647#4313311 , 
@HazardyKnusperkeks wrote:

> But it is plain wrong.
> It was done on purpose, so that e.g. `RemoveBracesLLVM` is not set when the 
> `SemiRemover` does its work.

Ah, shoot, you're right!  I missed that the 'return' was in a lambda!  Thanks 
for the good catch!  I think this patch is just 'wrong' in its entirety, and 
this is a case where Coverity needs to be suppressed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149647

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


[PATCH] D129951: adds `__disable_adl` attribute

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

In D129951#4310046 , @cjdb wrote:

> Ping (moving my pings from Thursday afternoon to Monday mornings)

Apologies for the delay in responding, but I was actually silent in the hopes 
that the discussion around proposing to WG21 and how much general use this 
feature sees would materialize a bit more. 
https://clang.llvm.org/get_involved.html#criteria has two criteria that I think 
apply here: "Evidence of a significant user community" and "Representation 
within the appropriate governing organization". The fact that this could 
potentially be used by an STL or Abseil and drastically reduce compile times 
with a more direct approach than function objects suggests that there might be 
a significant user community that would benefit from this, but if those 
projects would struggle to adopt this feature because they need to handle older 
Clang versions or non-Clang compilers, that community may not materialize. 
Further, because this is being proposed as a keyword (which I think makes sense 
over an attribute because a correct program with this construct will not 
necessarily remain correct in its absence due to different lookup results) and 
it seems to be functionality that would be appropriate to standardize, there 
should be some collaboration with WG21 if only to hear back "we don't see a 
reason such an extension would be a problem for us or conflict with existing 
efforts".

Specific to this review, however, this is missing documentation in 
LanguageExtensions.rst for the feature, how to use it, etc. as well as release 
notes. How does this marking fit into the language? How does it impact 
redeclaration merging (do all declarations have to have the marking, or is it 
additive like attributes often are?), how does it impact ODR (do declarations 
have to match across TU boundaries?), is this a declaration specifier or 
something else (can  you do `void __disable_adl func()` or does it have to be 
`__disable_adl void func();`?), that sort of stuff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129951

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


[PATCH] D149637: [Clang] Correctly expand pack in binary subscript expression.

2023-05-02 Thread Corentin Jabot 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 rG2528f1c84588: [Clang] Correctly expand pack in binary 
subscript expression. (authored by cor3ntin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149637

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/cxx2b-overloaded-operator.cpp


Index: clang/test/SemaCXX/cxx2b-overloaded-operator.cpp
===
--- clang/test/SemaCXX/cxx2b-overloaded-operator.cpp
+++ clang/test/SemaCXX/cxx2b-overloaded-operator.cpp
@@ -73,3 +73,47 @@
 static_assert(T2{}[] == 1);
 static_assert(T2{}[1] == 2);
 static_assert(T2{}[1, 1] == 3);
+
+namespace test_packs {
+
+struct foo_t {
+template
+constexpr int operator[](Ts... idx) {
+return (0 + ... + idx);
+}
+};
+
+template
+constexpr int cxx_subscript() {
+  foo_t foo;
+  return foo[Is...];
+}
+
+template
+int cxx_subscript_unexpanded() {
+  foo_t foo;
+  return foo[Is]; // expected-error {{expression contains unexpanded parameter 
pack 'Is'}}
+}
+
+template
+constexpr int c_array() {
+  int arr[] = {1, 2, 3};
+  return arr[Is...]; // expected-error 2{{type 'int[3]' does not provide a 
subscript operator}}
+}
+
+template
+int c_array_unexpanded() {
+  int arr[] = {1, 2, 3};
+  return arr[Is]; // expected-error {{expression contains unexpanded parameter 
pack 'Is'}}
+}
+
+void test() {
+  static_assert(cxx_subscript<1, 2, 3>() == 6);
+  static_assert(c_array<1>() == 2);
+
+  c_array<>(); // expected-note {{in instantiation}}
+  c_array<1>();
+  c_array<1, 2>(); // expected-note {{in instantiation}}
+}
+
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -4924,7 +4924,8 @@
   // Build an unanalyzed expression if either operand is type-dependent.
   if (getLangOpts().CPlusPlus && ArgExprs.size() == 1 &&
   (base->isTypeDependent() ||
-   Expr::hasAnyTypeDependentArguments(ArgExprs))) {
+   Expr::hasAnyTypeDependentArguments(ArgExprs)) &&
+  !isa(ArgExprs[0])) {
 return new (Context) ArraySubscriptExpr(
 base, ArgExprs.front(),
 getDependentArraySubscriptType(base, ArgExprs.front(), 
getASTContext()),
@@ -4958,7 +4959,8 @@
   // to overload resolution and so should not take this path.
   if (getLangOpts().CPlusPlus && !base->getType()->isObjCObjectPointerType() &&
   ((base->getType()->isRecordType() ||
-(ArgExprs.size() != 1 || ArgExprs[0]->getType()->isRecordType() {
+(ArgExprs.size() != 1 || isa(ArgExprs[0]) ||
+ ArgExprs[0]->getType()->isRecordType() {
 return CreateOverloadedArraySubscriptExpr(lbLoc, rbLoc, base, ArgExprs);
   }
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -386,6 +386,7 @@
 - Fix overly aggressive lifetime checks for parenthesized aggregate
   initialization.
   (`#61567 `_)
+- Fix a crash when expanding a pack as the index of a subscript expression.
 
 Bug Fixes to AST Handling
 ^


Index: clang/test/SemaCXX/cxx2b-overloaded-operator.cpp
===
--- clang/test/SemaCXX/cxx2b-overloaded-operator.cpp
+++ clang/test/SemaCXX/cxx2b-overloaded-operator.cpp
@@ -73,3 +73,47 @@
 static_assert(T2{}[] == 1);
 static_assert(T2{}[1] == 2);
 static_assert(T2{}[1, 1] == 3);
+
+namespace test_packs {
+
+struct foo_t {
+template
+constexpr int operator[](Ts... idx) {
+return (0 + ... + idx);
+}
+};
+
+template
+constexpr int cxx_subscript() {
+  foo_t foo;
+  return foo[Is...];
+}
+
+template
+int cxx_subscript_unexpanded() {
+  foo_t foo;
+  return foo[Is]; // expected-error {{expression contains unexpanded parameter pack 'Is'}}
+}
+
+template
+constexpr int c_array() {
+  int arr[] = {1, 2, 3};
+  return arr[Is...]; // expected-error 2{{type 'int[3]' does not provide a subscript operator}}
+}
+
+template
+int c_array_unexpanded() {
+  int arr[] = {1, 2, 3};
+  return arr[Is]; // expected-error {{expression contains unexpanded parameter pack 'Is'}}
+}
+
+void test() {
+  static_assert(cxx_subscript<1, 2, 3>() == 6);
+  static_assert(c_array<1>() == 2);
+
+  c_array<>(); // expected-note {{in instantiation}}
+  c_array<1>();
+  c_array<1, 2>(); // expected-note {{in instantiation}}
+}
+
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -4924,7 +4924,8 @@
   // Build an unanalyzed expression if either operand is type-dependent.
   if (getLangOpts().CPlusPlus && 

[clang] 2528f1c - [Clang] Correctly expand pack in binary subscript expression.

2023-05-02 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2023-05-02T21:22:03+02:00
New Revision: 2528f1c84588f4a549c12dd1435cbba4a502a077

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

LOG: [Clang] Correctly expand pack in binary subscript expression.

When constructing an array expression where the index expression
was a pack expansion, we would construct an ArraySubscriptExpr
instead of an CreateOverloadedArraySubscriptExpr, and pack
expansion would not occur - leading a crash during code gen
or a failure during constant evaluation

Reviewed By: erichkeane, shafik

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/cxx2b-overloaded-operator.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d90a2b53eb616..8d0a9c96a9579 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -386,6 +386,7 @@ Bug Fixes to C++ Support
 - Fix overly aggressive lifetime checks for parenthesized aggregate
   initialization.
   (`#61567 `_)
+- Fix a crash when expanding a pack as the index of a subscript expression.
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 4edaf6970a2d7..8789e4c3cb25f 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -4924,7 +4924,8 @@ ExprResult Sema::ActOnArraySubscriptExpr(Scope *S, Expr 
*base,
   // Build an unanalyzed expression if either operand is type-dependent.
   if (getLangOpts().CPlusPlus && ArgExprs.size() == 1 &&
   (base->isTypeDependent() ||
-   Expr::hasAnyTypeDependentArguments(ArgExprs))) {
+   Expr::hasAnyTypeDependentArguments(ArgExprs)) &&
+  !isa(ArgExprs[0])) {
 return new (Context) ArraySubscriptExpr(
 base, ArgExprs.front(),
 getDependentArraySubscriptType(base, ArgExprs.front(), 
getASTContext()),
@@ -4958,7 +4959,8 @@ ExprResult Sema::ActOnArraySubscriptExpr(Scope *S, Expr 
*base,
   // to overload resolution and so should not take this path.
   if (getLangOpts().CPlusPlus && !base->getType()->isObjCObjectPointerType() &&
   ((base->getType()->isRecordType() ||
-(ArgExprs.size() != 1 || ArgExprs[0]->getType()->isRecordType() {
+(ArgExprs.size() != 1 || isa(ArgExprs[0]) ||
+ ArgExprs[0]->getType()->isRecordType() {
 return CreateOverloadedArraySubscriptExpr(lbLoc, rbLoc, base, ArgExprs);
   }
 

diff  --git a/clang/test/SemaCXX/cxx2b-overloaded-operator.cpp 
b/clang/test/SemaCXX/cxx2b-overloaded-operator.cpp
index f9a83c813dcf0..47218e1f2dab5 100644
--- a/clang/test/SemaCXX/cxx2b-overloaded-operator.cpp
+++ b/clang/test/SemaCXX/cxx2b-overloaded-operator.cpp
@@ -73,3 +73,47 @@ struct T2 {
 static_assert(T2{}[] == 1);
 static_assert(T2{}[1] == 2);
 static_assert(T2{}[1, 1] == 3);
+
+namespace test_packs {
+
+struct foo_t {
+template
+constexpr int operator[](Ts... idx) {
+return (0 + ... + idx);
+}
+};
+
+template
+constexpr int cxx_subscript() {
+  foo_t foo;
+  return foo[Is...];
+}
+
+template
+int cxx_subscript_unexpanded() {
+  foo_t foo;
+  return foo[Is]; // expected-error {{expression contains unexpanded parameter 
pack 'Is'}}
+}
+
+template
+constexpr int c_array() {
+  int arr[] = {1, 2, 3};
+  return arr[Is...]; // expected-error 2{{type 'int[3]' does not provide a 
subscript operator}}
+}
+
+template
+int c_array_unexpanded() {
+  int arr[] = {1, 2, 3};
+  return arr[Is]; // expected-error {{expression contains unexpanded parameter 
pack 'Is'}}
+}
+
+void test() {
+  static_assert(cxx_subscript<1, 2, 3>() == 6);
+  static_assert(c_array<1>() == 2);
+
+  c_array<>(); // expected-note {{in instantiation}}
+  c_array<1>();
+  c_array<1, 2>(); // expected-note {{in instantiation}}
+}
+
+}



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


[PATCH] D149647: [NFC][Clang]Fix static analyzer tool remarks about large copies by value

2023-05-02 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks requested changes to this revision.
HazardyKnusperkeks added a comment.
This revision now requires changes to proceed.

But it is plain wrong.
It was done on purpose, so that e.g. `RemoveBracesLLVM` is not set when the 
`SemiRemover` does its work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149647

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


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

2023-05-02 Thread Eric Li via Phabricator via cfe-commits
li.zhe.hua created this revision.
Herald added a project: All.
li.zhe.hua requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Elaborated types are sugar that represent how the type was spelled in
the original source. When printing a type outside of that original
context, the qualifiers as saved in the elaborated type will be
incorrect. Additionally, their existence also inhibits the use of
`PrintingCallbacks::isScopeVisible` as a customization point.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149677

Files:
  clang/include/clang/AST/PrettyPrinter.h
  clang/lib/AST/TypePrinter.cpp
  clang/unittests/AST/TypePrinterTest.cpp

Index: clang/unittests/AST/TypePrinterTest.cpp
===
--- clang/unittests/AST/TypePrinterTest.cpp
+++ clang/unittests/AST/TypePrinterTest.cpp
@@ -97,6 +97,35 @@
  "const f *", Clean));
 }
 
+TEST(TypePrinter, IgnoreElaboratedQualifiers) {
+  llvm::StringLiteral Code = R"cpp(
+namespace shared {
+namespace a {
+template 
+struct S {};
+}  // namespace a
+namespace b {
+struct Foo {};
+}  // namespace b
+using Alias = a::S;
+}  // namespace shared
+  )cpp";
+
+  auto Matcher = typedefNameDecl(hasName("::shared::Alias"),
+ hasType(qualType().bind("id")));
+  ASSERT_TRUE(PrintedTypeMatches(Code, {}, Matcher, //
+ "a::S",//
+ [](PrintingPolicy ) {
+   Policy.FullyQualifiedName = true; //
+ }));
+  ASSERT_TRUE(PrintedTypeMatches(Code, {}, Matcher,
+ "shared::a::S",
+ [](PrintingPolicy ) {
+   Policy.IgnoreElaboratedQualifiers = true;
+   Policy.FullyQualifiedName = true;
+ }));
+}
+
 TEST(TypePrinter, TemplateIdWithNTTP) {
   constexpr char Code[] = R"cpp(
 template 
Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -1567,6 +1567,11 @@
 return;
   }
 
+  if (Policy.IgnoreElaboratedQualifiers) {
+printBefore(T->getNamedType(), OS);
+return;
+  }
+
   // The tag definition will take care of these.
   if (!Policy.IncludeTagDefinition)
   {
@@ -1586,6 +1591,12 @@
 raw_ostream ) {
   if (Policy.IncludeTagDefinition && T->getOwnedTagDecl())
 return;
+
+  if (Policy.IgnoreElaboratedQualifiers) {
+printAfter(T->getNamedType(), OS);
+return;
+  }
+
   ElaboratedTypePolicyRAII PolicyRAII(Policy);
   printAfter(T->getNamedType(), OS);
 }
Index: clang/include/clang/AST/PrettyPrinter.h
===
--- clang/include/clang/AST/PrettyPrinter.h
+++ clang/include/clang/AST/PrettyPrinter.h
@@ -60,14 +60,15 @@
   : Indentation(2), SuppressSpecifiers(false),
 SuppressTagKeyword(LO.CPlusPlus), IncludeTagDefinition(false),
 SuppressScope(false), SuppressUnwrittenScope(false),
-SuppressInlineNamespace(true), SuppressInitializers(false),
-ConstantArraySizeAsWritten(false), AnonymousTagLocations(true),
-SuppressStrongLifetime(false), SuppressLifetimeQualifiers(false),
+SuppressInlineNamespace(true), IgnoreElaboratedQualifiers(false),
+SuppressInitializers(false), ConstantArraySizeAsWritten(false),
+AnonymousTagLocations(true), SuppressStrongLifetime(false),
+SuppressLifetimeQualifiers(false),
 SuppressTemplateArgsInCXXConstructors(false),
 SuppressDefaultTemplateArgs(true), Bool(LO.Bool),
 Nullptr(LO.CPlusPlus11 || LO.C2x), NullptrTypeInNamespace(LO.CPlusPlus),
-Restrict(LO.C99), Alignof(LO.CPlusPlus11),
-UnderscoreAlignof(LO.C11), UseVoidForZeroParams(!LO.CPlusPlus),
+Restrict(LO.C99), Alignof(LO.CPlusPlus11), UnderscoreAlignof(LO.C11),
+UseVoidForZeroParams(!LO.CPlusPlus),
 SplitTemplateClosers(!LO.CPlusPlus11), TerseOutput(false),
 PolishForDeclaration(false), Half(LO.Half),
 MSWChar(LO.MicrosoftExt && !LO.WChar), IncludeNewlines(true),
@@ -139,6 +140,10 @@
   /// removed.
   unsigned SuppressInlineNamespace : 1;
 
+  /// Ignore qualifiers as specified by elaborated type sugar, instead letting
+  /// the underlying type handle printing the qualifiers.
+  unsigned IgnoreElaboratedQualifiers : 1;
+
   /// Suppress printing of variable initializers.
   ///
   /// This flag is used when printing the loop variable in a for-range
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149215: [MemProf] Control availability of hot/cold operator new from LTO link

2023-05-02 Thread Snehasish Kumar via Phabricator via cfe-commits
snehasish accepted this revision.
snehasish added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp:3163
 
+  // TODO: If/when other types of memprof cloning are enabled beyond just for
+  // hot and cold, we will need to change this to individually control the

Thanks for adding this comment to clarify


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149215

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


[PATCH] D146764: [clang] Make predefined expressions string literals under -fms-extensions

2023-05-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/Modules/predefined.cpp:6
+// RUN: %clang_cc1 -x c++ -std=c++20 -emit-module-interface a.h -o a.pcm 
-fms-extensions
+// RUN: %clang_cc1 -std=c++20 a.cpp -fmodule-file=A=a.pcm -fms-extensions 
-fsyntax-only
+

Er, should we have a `-verify` on this as well as `// expected-no-diagnostics`?



Comment at: clang/test/Sema/ms_predefined_expr.cpp:5-9
+ const char a[] = __FUNCTION__;
+ const char b[] = __FUNCDNAME__;
+ const char c[] = __FUNCSIG__;
+ const char d[] = __func__;
+ const char e[] = __PRETTY_FUNCTION__;

Apologies for not noticing this earlier, but because this code isn't portable 
(for the standard predefined identifiers), I think we should also have a 
`-pedantic` test that ensures we get a diagnostic about accepting this code 
being a Microsoft extension.

I would recommend something along the lines of: `initializing an array from a 
'%0' predefined identifier is a Microsoft extension` put into a new warning 
group named `-Wmicrosoft-init-from-predefined` which is added to the 
`-Wmicrosoft` warning group.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146764

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


[PATCH] D149104: [Demangle] make llvm::demangle take std::string_view rather than const std::string

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

In D149104#4313210 , @nickdesaulniers 
wrote:

> Looks like this is causing a regression in lld/test/wasm/why-extract.s when 
> `-DLLVM_ENABLE_EXPENSIVE_CHECKS=ON` is enabled. I'm looking into it and 
> hoping to fix forward by EOD.

Fixup: https://reviews.llvm.org/D149675


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149104

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


[PATCH] D148458: [clang-tidy][NFC] Split bugprone-exception-escape tests

2023-05-02 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

@isuckatcs 
Ifdefs are ugly, to avoid messing with multiple runs in same unit test, I 
decided to split into 2 test files (C++11 and above, and C++11,C++14).

And to be honest this change does nothing for caching (zero impact), let me 
explain:
`super_throws_again` alone won't be tested, because its not `noexcept`, it will 
be tested only once (no cache hit) when testing `sub_throws_again`.
Same goes for `throwing_throw_nothing`, its not called from anywhere, so there 
will be no hit into cache.

Simply code that were moved into new file didn't utilize cache before and now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148458

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


[PATCH] D149451: [NVPTX] Add NVPTXCtorDtorLoweringPass to handle global ctors / dtors

2023-05-02 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.

LGTM.




Comment at: llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.cpp:31
+GlobalStr("nvptx-lower-global-ctor-dtor-id",
+  cl::desc("Override the name of ctor/dtor globals."), 
cl::init(""),
+  cl::Hidden);

We're not overriding the name, but rather the unique suffix for the names we 
generate.
Perhaps rephrase along the lines of "Override unique ID for ctor/dtor globals" ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149451

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


[PATCH] D149553: [clang] Use -std=c++23 instead of -std=c++2b

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

In D149553#4312788 , @Mordante wrote:

> In D149553#4310478 , @aaron.ballman 
> wrote:
>
>> Thank you for working on this! The Clang changes are mostly all good, but I 
>> think we should hold off on changing the value of `__cplusplus` for the 
>> moment as it's not set in stone in the standard yet (I thought it was 
>> though, so I'm checking with the editor).
>
> I noticed the same and I was wondering whether I should contact the editor. I 
> noticed some approved papers also have not been merged yet. (These papers are 
> still open issues in the paper repository.)
>
> I'll wait a few days to see whether the draft gets updated otherwise I revert 
> the macro change.
>
> I would be very surprised if the macro gets a different value, that's why I 
> already bumped it.

I heard back from the editor yesterday and he said that the macro would be 
replaced with an appropriate value for the DIS, and that he hopes to ensure 
that value is published in the next meeting mailing (which would be roughly May 
15). So I think we can either wait until that mailing comes out and see if it 
has a concrete value to land these changes, or we can land everything but the 
macro value changes and deal with that in a follow up (this might be easier due 
to rebasing woes given how large this patch is).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149553

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


[PATCH] D149104: [Demangle] make llvm::demangle take std::string_view rather than const std::string

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

Looks like this is causing a regression in lld/test/wasm/why-extract.s when 
`-DLLVM_ENABLE_EXPENSIVE_CHECKS=ON` is enabled. I'm looking into it and hoping 
to fix forward by EOD.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149104

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


[PATCH] D148458: [clang-tidy][NFC] Split bugprone-exception-escape tests

2023-05-02 Thread Domján Dániel via Phabricator via cfe-commits
isuckatcs added a comment.

> Yes, throw specifier is removed in C++17, split allows to support C++17 and 
> above in main test file

A lot of our test files uses macros to differentiate between specific C++ 
standards, why not do that here too?
There are only a few occurences of functions with `throw()`.

  #if __cplusplus  < 201703L
// put functions with throw() here
  #endif



> Those tests never tested caching (not failing if you disable cache)

They weren't tested explicitly, but it still happened in the background by 
default.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148458

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


[PATCH] D137872: Implement lambdas with inalloca parameters by forwarding to function without inalloca calling convention.

2023-05-02 Thread Amy Huang via Phabricator via cfe-commits
akhuang added a comment.

whoops, I've left this here for a while.. @efriedma, are you able to review it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137872

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


[PATCH] D149104: [Demangle] make llvm::demangle take std::string_view rather than const std::string

2023-05-02 Thread Nick Desaulniers via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
nickdesaulniers marked an inline comment as done.
Closed by commit rGc117c2c8ba4a: [Demangle] make llvm::demangle take 
std::string_view rather than const std… (authored by nickdesaulniers).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149104

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  lld/COFF/Symbols.cpp
  lld/ELF/SymbolTable.cpp
  lld/ELF/Symbols.cpp
  lld/MachO/Symbols.cpp
  lld/wasm/Symbols.cpp
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/Demangle/Demangle.h
  llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp
  llvm/lib/Demangle/Demangle.cpp
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/tools/llvm-objdump/ELFDump.cpp
  llvm/tools/llvm-objdump/XCOFFDump.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-readobj/ELFDumper.cpp
  llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp

Index: llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
===
--- llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
+++ llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
@@ -107,7 +107,7 @@
   std::string OutputName = "'";
   OutputName += Name;
   OutputName += "'";
-  std::string DemangledName(demangle(Name.str()));
+  std::string DemangledName(demangle(Name));
   if (Name != DemangledName) {
 OutputName += " aka ";
 OutputName += DemangledName;
Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -908,7 +908,7 @@
 }
 
 static std::string maybeDemangle(StringRef Name) {
-  return opts::Demangle ? demangle(std::string(Name)) : Name.str();
+  return opts::Demangle ? demangle(Name) : Name.str();
 }
 
 template 
Index: llvm/tools/llvm-objdump/llvm-objdump.cpp
===
--- llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1548,7 +1548,7 @@
   if (Demangle) {
 // Fetch the demangled names and store them locally.
 for (const SymbolInfoTy  : SymbolsHere)
-  DemangledSymNamesHere.push_back(demangle(Symbol.Name.str()));
+  DemangledSymNamesHere.push_back(demangle(Symbol.Name));
 // Now we've finished modifying that vector, it's safe to make
 // a vector of StringRefs pointing into it.
 SymNamesHere.insert(SymNamesHere.begin(), DemangledSymNamesHere.begin(),
@@ -1909,9 +1909,8 @@
   if (TargetSym != nullptr) {
 uint64_t TargetAddress = TargetSym->Addr;
 uint64_t Disp = Target - TargetAddress;
-std::string TargetName = TargetSym->Name.str();
-if (Demangle)
-  TargetName = demangle(TargetName);
+std::string TargetName = Demangle ? demangle(TargetSym->Name)
+  : TargetSym->Name.str();
 
 *TargetOS << " <";
 if (!Disp) {
@@ -2511,10 +2510,8 @@
 
 if (NameOrErr) {
   outs() << " (csect:";
-  std::string SymName(NameOrErr.get());
-
-  if (Demangle)
-SymName = demangle(SymName);
+  std::string SymName =
+  Demangle ? demangle(*NameOrErr) : NameOrErr->str();
 
   if (SymbolDescription)
 SymName = getXCOFFSymbolDescription(createSymbolInfo(O, *SymRef),
@@ -2568,10 +2565,7 @@
 outs() << " .hidden";
   }
 
-  std::string SymName(Name);
-  if (Demangle)
-SymName = demangle(SymName);
-
+  std::string SymName = Demangle ? demangle(Name) : Name.str();
   if (O.isXCOFF() && SymbolDescription)
 SymName = getXCOFFSymbolDescription(createSymbolInfo(O, Symbol), SymName);
 
Index: llvm/tools/llvm-objdump/XCOFFDump.cpp
===
--- llvm/tools/llvm-objdump/XCOFFDump.cpp
+++ llvm/tools/llvm-objdump/XCOFFDump.cpp
@@ -32,10 +32,8 @@
   if (!SymNameOrErr)
 return SymNameOrErr.takeError();
 
-  std::string SymName = (*SymNameOrErr).str();
-  if (Demangle)
-SymName = demangle(SymName);
-
+  std::string SymName =
+  Demangle ? demangle(*SymNameOrErr) : SymNameOrErr->str();
   if (SymbolDescription)
 SymName = getXCOFFSymbolDescription(createSymbolInfo(Obj, *SymI), SymName);
 
Index: llvm/tools/llvm-objdump/ELFDump.cpp
===
--- llvm/tools/llvm-objdump/ELFDump.cpp
+++ llvm/tools/llvm-objdump/ELFDump.cpp
@@ -108,10 +108,7 @@
   Expected SymName = SI->getName();
   if (!SymName)
 return SymName.takeError();
-  if (Demangle)
-Fmt << demangle(std::string(*SymName));
-  else
-Fmt << *SymName;
+  Fmt << 

[clang] c117c2c - [Demangle] make llvm::demangle take std::string_view rather than const std::string

2023-05-02 Thread Nick Desaulniers via cfe-commits

Author: Nick Desaulniers
Date: 2023-05-02T11:20:15-07:00
New Revision: c117c2c8ba4afd45a006043ec6dd858652b2ffcc

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

LOG: [Demangle] make llvm::demangle take std::string_view rather than const 
std::string&

As suggested by @erichkeane in
https://reviews.llvm.org/D141451#inline-1429549

There's potential for a lot more cleanups around these APIs. This is
just a start.

Callers need to be more careful about sub-expressions producing strings
that don't outlast the expression using ``llvm::demangle``. Add a
release note.

Reviewed By: MaskRay, #lld-macho

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenAction.cpp
lld/COFF/Symbols.cpp
lld/ELF/SymbolTable.cpp
lld/ELF/Symbols.cpp
lld/MachO/Symbols.cpp
lld/wasm/Symbols.cpp
llvm/docs/ReleaseNotes.rst
llvm/include/llvm/Demangle/Demangle.h
llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp
llvm/lib/Demangle/Demangle.cpp
llvm/lib/IR/DiagnosticInfo.cpp
llvm/tools/llvm-objdump/ELFDump.cpp
llvm/tools/llvm-objdump/XCOFFDump.cpp
llvm/tools/llvm-objdump/llvm-objdump.cpp
llvm/tools/llvm-readobj/ELFDumper.cpp
llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index 29adf88acd704..b054147e2d0ce 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -633,9 +633,8 @@ BackendConsumer::StackSizeDiagHandler(const 
llvm::DiagnosticInfoStackSize ) {
 return false;
 
   Diags.Report(*Loc, diag::warn_fe_frame_larger_than)
-  << D.getStackSize()
-  << D.getStackLimit()
-  << llvm::demangle(D.getFunction().getName().str());
+  << D.getStackSize() << D.getStackLimit()
+  << llvm::demangle(D.getFunction().getName());
   return true;
 }
 
@@ -649,7 +648,7 @@ bool BackendConsumer::ResourceLimitDiagHandler(
 
   Diags.Report(*Loc, DiagID)
   << D.getResourceName() << D.getResourceSize() << D.getResourceLimit()
-  << llvm::demangle(D.getFunction().getName().str());
+  << llvm::demangle(D.getFunction().getName());
   return true;
 }
 
@@ -854,7 +853,7 @@ void BackendConsumer::DontCallDiagHandler(const 
DiagnosticInfoDontCall ) {
   Diags.Report(LocCookie, D.getSeverity() == DiagnosticSeverity::DS_Error
   ? diag::err_fe_backend_error_attr
   : diag::warn_fe_backend_warning_attr)
-  << llvm::demangle(D.getFunctionName().str()) << D.getNote();
+  << llvm::demangle(D.getFunctionName()) << D.getNote();
 }
 
 void BackendConsumer::MisExpectDiagHandler(

diff  --git a/lld/COFF/Symbols.cpp b/lld/COFF/Symbols.cpp
index c042386e01064..f4efcf2266cd6 100644
--- a/lld/COFF/Symbols.cpp
+++ b/lld/COFF/Symbols.cpp
@@ -38,9 +38,9 @@ static std::string maybeDemangleSymbol(const 
COFFLinkerContext ,
 StringRef demangleInput = prefixless;
 if (ctx.config.machine == I386)
   demangleInput.consume_front("_");
-std::string demangled = demangle(demangleInput.str());
+std::string demangled = demangle(demangleInput);
 if (demangled != demangleInput)
-  return prefix + demangle(demangleInput.str());
+  return prefix + demangled;
 return (prefix + prefixless).str();
   }
   return std::string(symName);

diff  --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp
index f09d0d7f90958..c5ef6d3f0cbf3 100644
--- a/lld/ELF/SymbolTable.cpp
+++ b/lld/ELF/SymbolTable.cpp
@@ -145,13 +145,16 @@ StringMap> 
::getDemangledSyms() {
   if (canBeVersioned(*sym)) {
 StringRef name = sym->getName();
 size_t pos = name.find('@');
+std::string substr;
 if (pos == std::string::npos)
-  demangled = demangle(name.str());
-else if (pos + 1 == name.size() || name[pos + 1] == '@')
-  demangled = demangle(name.substr(0, pos).str());
-else
-  demangled =
-  (demangle(name.substr(0, pos).str()) + name.substr(pos)).str();
+  demangled = demangle(name);
+else if (pos + 1 == name.size() || name[pos + 1] == '@') {
+  substr = name.substr(0, pos);
+  demangled = demangle(substr);
+} else {
+  substr = name.substr(0, pos);
+  demangled = (demangle(substr) + name.substr(pos)).str();
+}
 (*demangledSyms)[demangled].push_back(sym);
   }
   }

diff  --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index 62a8a3c30664e..840385aabea35 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -45,9 +45,7 @@ LLVM_ATTRIBUTE_UNUSED static inline void assertSymbols() {
 
 // Returns a symbol for an error message.
 static 

[PATCH] D146178: [Clang][Sema] Fix comparison of constraint expressions

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

In D146178#4313058 , 
@alexander-shaposhnikov wrote:

> @erichkeane  - feel free to take over this patch.

If I get time, I will!  Else it'll be here when you get back :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146178

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


[PATCH] D147626: [clang] Reject flexible array member in a union in C++

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

I have no specific objections.  I do worry about removing support for something 
that's apparently been accepted for a long time, just on general 
source-compatibility grounds, but I don't think there's an ObjC-specific 
problem with it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147626

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


[PATCH] D149104: [Demangle] make llvm::demangle take std::string_view rather than const std::string

2023-05-02 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers marked an inline comment as done.
nickdesaulniers added a comment.

Thanks for the review!




Comment at: llvm/docs/ReleaseNotes.rst:289
 
+* ``llvm::demangle`` now takes a ``std::string_view`` rather than a
+  ``const std::string&``. Be careful passing temporaries into

MaskRay wrote:
> The text wrapping appears to use a very small `set textwidth` (neovim)?
No, just me manually correcting it; otherwise we have a line ending like 
`const`
which looks odd to me.  I don't think it matters for rendering restructured 
text either way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149104

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


[PATCH] D146178: [Clang][Sema] Fix comparison of constraint expressions

2023-05-02 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov added a comment.

@erichkeane  - feel free to take over this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146178

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


[PATCH] D148690: [clang][Interp] Handle __extension__ unary operators

2023-05-02 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/test/AST/Interp/literals.cpp:791
+#endif
 return __FUNCTION__[index];
   }

aaron.ballman wrote:
> tbaeder wrote:
> > erichkeane wrote:
> > > tbaeder wrote:
> > > > It's weird that the above two statements warn about using 
> > > > `__FUNCTION__` and the return statement doesn't.
> > > Aren't they warning about it being 'unused'?  If so, the 'return' uses 
> > > them...
> > Right, my message wasn't clear but I meant the c++14 extension diagnostic: 
> > https://godbolt.org/z/Kso8qv7jh
> That is pretty strange, tbh. Might be worth investigating in a follow-up.
Yeah, in `CheckConstexprFunctionStmt` in `SemaDeclCXX.cpp`, the return 
expression is not checked.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148690

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


[PATCH] D149666: [OpenMP][OMPIRBuilder] Migrate MapCombinedInfoTy from Clang to OpenMPIRBuilder

2023-05-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:6848
+  class MapCombinedInfoTy : public llvm::OpenMPIRBuilder::MapCombinedInfoTy {
+  public:
 MapExprsArrayTy Exprs;

Not sure why you made it a class with public, but I guess it doesn't matter.
Do we really want to use the same name though? I would add "Base" or sth to the 
llvm class.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:6872
   NonContigInfo.Strides.append(CurInfo.NonContigInfo.Strides.begin(),
 CurInfo.NonContigInfo.Strides.end());
 }

We should use the base append function, no?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149666

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


[PATCH] D133863: [RISCV] Add MC support of RISCV zcmt Extension

2023-05-02 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133863

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


[PATCH] D132819: [RISCV] Add MC support of RISCV zcmp Extension

2023-05-02 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM with the last 4 few comments addressed.




Comment at: llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h:550
+  if (RlistVal == RLISTENCODE::INVALID_RLIST)
+assert(0 && "{ra, s0-s10} is not supported, s11 must be included.");
+  if (IsEABI)

assert(RlistVal != RLISTENCODE::INVALID_RLIST && "{ra, s0-s10} is not 
supported, s11 must be included.")



Comment at: llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp:494
+  MCOperand MO = MI.getOperand(OpNo);
+  assert(MO.isImm() && "Rlist operand must be immidiate");
+  auto Imm = MO.getImm();

craig.topper wrote:
> immidiate -> immediate
This wasn't fixed. immediate is still misspelled



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoZc.td:47
+
+def rlist : Operand, ImmLeaf(Imm);}]> {
+   let ParserMatchClass = RlistAsmOperand;

I think you can drop the ImmLeaf. That's only needed if this is used in an isel 
pattern, but I don't think it ever will be.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoZc.td:62
+
+def spimm : Operand, ImmLeaf(Imm);}]>{
+  let ParserMatchClass = SpimmAsmOperand;

I think you can drop ImmLeaf. That's only needed for isel patterns.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132819

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


[PATCH] D149612: [Sema] avoid merge error type

2023-05-02 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:4395
  bool MergeTypeWithOld) {
-  if (New->isInvalidDecl() || Old->isInvalidDecl())
+  if (New->isInvalidDecl() || Old->isInvalidDecl() || 
New->getType()->containsErrors() || Old->getType()->containsErrors())
 return;

I wonder why it is not an `InvalidDecl()` as well? I don't see that we check 
both of these anywhere else.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149612

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


[PATCH] D143624: Inlining: Run the legacy AlwaysInliner before the regular inliner.

2023-05-02 Thread Dave Green via Phabricator via cfe-commits
dmgreen added subscribers: nikic, spatel, efriedma.
dmgreen added a comment.

Hello. It sounds like it is really close to being OK. The combine of the shift 
just seem to make things more difficult.

The `icmp ult i1 %cmp4.i, true` is just a not, would it help if it was actually 
an xor? Or if the `not(icmp sgt)` was changed to a slt earlier?

I was taking a look at the example but I am not super sure what to suggest. 
Would it be best if the code that detect min/max looked through not's?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143624

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


[PATCH] D148370: [Clang][Flang][OpenMP] Add loadOffloadInfoMetadata and createOffloadEntriesAndInfoMetadata into OMPIRBuilder's finalize and initialize

2023-05-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:1063
+  // Initialize Types used in OpenMPIRBuilder from OMPKinds.def as well as load
+  // offload metadata for device from an OpenMP host IR file.
+  OMPBuilder.initialize(CGM.getLangOpts().OpenMPIsDevice

Move the additional comment to the initialize function instead to explain what 
the argument is for.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:452
+
+  if (!HostFilePath.empty()) {
+auto Buf = llvm::MemoryBuffer::getFile(HostFilePath);

early exit plz.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:453
+  if (!HostFilePath.empty()) {
+auto Buf = llvm::MemoryBuffer::getFile(HostFilePath);
+if (auto Err = Buf.getError())

No llvm::



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:455
+if (auto Err = Buf.getError())
+  assert(false && ("error opening host file from host file path inside of "
+   "OpenMPIRBuilder" +

no assert false please. Use unreachable or report fatal error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148370

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


[PATCH] D149162: [Clang][OpenMP][IRBuilder] Move registerTargetGlobalVariable & getAddrOfDeclareTargetVar into the OMPIRBuilder

2023-05-02 Thread Andrew Gozillon via Phabricator via cfe-commits
agozillon added a comment.

A small ping to ask for some reviewer attention on this patch if at all 
possible please! Thank you for your time as always, it is greatly appreciated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149162

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


[PATCH] D149666: [OpenMP][OMPIRBuilder] Migrate MapCombinedInfoTy from Clang to OpenMPIRBuilder

2023-05-02 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis created this revision.
TIFitis added reviewers: jsjodin, jdoerfert, dpalermo.
Herald added subscribers: sunshaoce, guansong, yaxunl.
Herald added a project: All.
TIFitis requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, jplehr, sstefan1.
Herald added projects: clang, LLVM.

This patch migrates the MapCombinedInfoTy from Clang codegen to OpenMPIRBuilder.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149666

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h

Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -1445,6 +1445,48 @@
 bool separateBeginEndCalls() { return SeparateBeginEndCalls; }
   };
 
+  using MapValuesArrayTy = SmallVector;
+  using MapFlagsArrayTy = SmallVector;
+  using MapNamesArrayTy = SmallVector;
+  using MapDimArrayTy = SmallVector;
+  using MapNonContiguousArrayTy = SmallVector;
+
+  /// This structure contains combined information generated for mappable
+  /// clauses, including base pointers, pointers, sizes, map types, user-defined
+  /// mappers, and non-contiguous information.
+  struct MapCombinedInfoTy {
+struct StructNonContiguousInfo {
+  bool IsNonContiguous = false;
+  MapDimArrayTy Dims;
+  MapNonContiguousArrayTy Offsets;
+  MapNonContiguousArrayTy Counts;
+  MapNonContiguousArrayTy Strides;
+};
+MapValuesArrayTy BasePointers;
+MapValuesArrayTy Pointers;
+MapValuesArrayTy Sizes;
+MapFlagsArrayTy Types;
+MapNamesArrayTy Names;
+StructNonContiguousInfo NonContigInfo;
+
+/// Append arrays in \a CurInfo.
+void append(MapCombinedInfoTy ) {
+  BasePointers.append(CurInfo.BasePointers.begin(),
+  CurInfo.BasePointers.end());
+  Pointers.append(CurInfo.Pointers.begin(), CurInfo.Pointers.end());
+  Sizes.append(CurInfo.Sizes.begin(), CurInfo.Sizes.end());
+  Types.append(CurInfo.Types.begin(), CurInfo.Types.end());
+  NonContigInfo.Dims.append(CurInfo.NonContigInfo.Dims.begin(),
+CurInfo.NonContigInfo.Dims.end());
+  NonContigInfo.Offsets.append(CurInfo.NonContigInfo.Offsets.begin(),
+   CurInfo.NonContigInfo.Offsets.end());
+  NonContigInfo.Counts.append(CurInfo.NonContigInfo.Counts.begin(),
+  CurInfo.NonContigInfo.Counts.end());
+  NonContigInfo.Strides.append(CurInfo.NonContigInfo.Strides.begin(),
+   CurInfo.NonContigInfo.Strides.end());
+}
+  };
+
   /// Emit the arguments to be passed to the runtime library based on the
   /// arrays of base pointers, pointers, sizes, map types, and mappers.  If
   /// ForEndCall, emit map types to be passed for the end of the region instead
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6831,58 +6831,36 @@
 const Expr *getMapExpr() const { return MapExpr; }
   };
 
-  /// Class that associates information with a base pointer to be passed to the
-  /// runtime library.
-  class BasePointerInfo {
-/// The base pointer.
-llvm::Value *Ptr = nullptr;
-/// The base declaration that refers to this device pointer, or null if
-/// there is none.
-const ValueDecl *DevPtrDecl = nullptr;
-
-  public:
-BasePointerInfo(llvm::Value *Ptr, const ValueDecl *DevPtrDecl = nullptr)
-: Ptr(Ptr), DevPtrDecl(DevPtrDecl) {}
-llvm::Value *operator*() const { return Ptr; }
-const ValueDecl *getDevicePtrDecl() const { return DevPtrDecl; }
-void setDevicePtrDecl(const ValueDecl *D) { DevPtrDecl = D; }
-  };
-
+  using MapBaseValuesArrayTy = llvm::OpenMPIRBuilder::MapValuesArrayTy;
+  using MapValuesArrayTy = llvm::OpenMPIRBuilder::MapValuesArrayTy;
+  using MapFlagsArrayTy = llvm::OpenMPIRBuilder::MapFlagsArrayTy;
+  using MapDimArrayTy = llvm::OpenMPIRBuilder::MapDimArrayTy;
+  using MapNonContiguousArrayTy =
+  llvm::OpenMPIRBuilder::MapNonContiguousArrayTy;
   using MapExprsArrayTy = SmallVector;
-  using MapBaseValuesArrayTy = SmallVector;
-  using MapValuesArrayTy = SmallVector;
-  using MapFlagsArrayTy = SmallVector;
+  using MapDevPtrsArrayTy = SmallVector;
   using MapMappersArrayTy = SmallVector;
-  using MapDimArrayTy = SmallVector;
-  using MapNonContiguousArrayTy = SmallVector;
 
   /// This structure contains combined information generated for mappable
   /// clauses, including base pointers, pointers, sizes, map types, user-defined
   /// mappers, and non-contiguous information.
-  struct MapCombinedInfoTy {
-struct StructNonContiguousInfo {
-  bool IsNonContiguous = false;
-  MapDimArrayTy Dims;
- 

[PATCH] D148689: [clang][Interp] Handle PredefinedExprs

2023-05-02 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/test/AST/Interp/literals.cpp:783
+
+namespace PredefinedExprs {
+  constexpr char heh(unsigned index) {

Can we add tests for each predefined expressions, it does not look like there 
are a lot of them. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148689

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


[PATCH] D148370: [Clang][Flang][OpenMP] Add loadOffloadInfoMetadata and createOffloadEntriesAndInfoMetadata into OMPIRBuilder's finalize and initialize

2023-05-02 Thread Andrew Gozillon via Phabricator via cfe-commits
agozillon added a comment.

Small ping to ask for some reviewer attention on this patch if at all possible!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148370

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


[PATCH] D148982: [clang][Interp] Fix ignoring conditional operators

2023-05-02 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148982

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


  1   2   3   >