[Lldb-commits] [PATCH] debugserver: Remove an infinitely recursive operator=

2016-10-17 Thread Justin Bogner via lldb-commits
Today I checked out lldb to check that r284364 wouldn't cause any
trouble, but there were a few warnings that fired when I tried to build
it, breaking my -Werror build.

This deletes an unused operator= that would infinitely recurse if it
were called (caught by -Winfinite-recursion). It would also probably be
reasonable to `= default` this or do a memberwise assignment, if you
prefer.

commit 5522eaf39ab8ed9f44c62c212b71cd37582e1668
Author: Justin Bogner 
Date:   Sun Oct 16 21:39:48 2016 -0700

debugserver: Remove an infinitely recursive operator=

diff --git a/tools/debugserver/source/MacOSX/CFBundle.cpp b/tools/debugserver/source/MacOSX/CFBundle.cpp
index 7b080e6..060b3c7 100644
--- a/tools/debugserver/source/MacOSX/CFBundle.cpp
+++ b/tools/debugserver/source/MacOSX/CFBundle.cpp
@@ -30,14 +30,6 @@ CFBundle::CFBundle(const CFBundle &rhs)
 : CFReleaser(rhs), m_bundle_url(rhs.m_bundle_url) {}

 //--
-// CFBundle copy constructor
-//--
-CFBundle &CFBundle::operator=(const CFBundle &rhs) {
-  *this = rhs;
-  return *this;
-}
-
-//--
 // Destructor
 //--
 CFBundle::~CFBundle() {}
diff --git a/tools/debugserver/source/MacOSX/CFBundle.h b/tools/debugserver/source/MacOSX/CFBundle.h
index 09957af..c0aa35a 100644
--- a/tools/debugserver/source/MacOSX/CFBundle.h
+++ b/tools/debugserver/source/MacOSX/CFBundle.h
@@ -23,7 +23,7 @@ public:
   //--
   CFBundle(const char *path = NULL);
   CFBundle(const CFBundle &rhs);
-  CFBundle &operator=(const CFBundle &rhs);
+  CFBundle &operator=(const CFBundle &rhs) = delete;
   virtual ~CFBundle();
   bool SetPath(const char *path);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] unittests: Specify types in a bunch of unittest EXPECT's

2016-10-17 Thread Justin Bogner via lldb-commits
Today I checked out lldb to check that r284364 wouldn't cause any
trouble, but there were a few warnings that fired when I tried to build
it, breaking my -Werror build.

The EXPECT and ASSERT macros in gtest don't do the usual arithmetic
conversions, so there are a number of warnings where we compare
differently sized ints. This fixes the places that warn to be more
specific. Okay to commit?

commit d64b335a2ffcf48f98c0267f890630ace2b454ea
Author: Justin Bogner 
Date:   Sun Oct 16 22:47:17 2016 -0700

unittests: Specify types in a bunch of unittest EXPECT's

The EXPECT and ASSERT macros in gtest don't do the usual arithmetic
conversions. Specify types in several of them to fix -Werror.

diff --git a/unittests/Core/ArchSpecTest.cpp b/unittests/Core/ArchSpecTest.cpp
index 03a0637..32b3636 100644
--- a/unittests/Core/ArchSpecTest.cpp
+++ b/unittests/Core/ArchSpecTest.cpp
@@ -21,26 +21,26 @@ TEST(ArchSpecTest, TestParseMachCPUDashSubtypeTripleSimple) {
   // Success conditions.  Valid cpu/subtype combinations using both - and .
   ArchSpec AS;
   EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("12-10", AS));
-  EXPECT_EQ(12, AS.GetMachOCPUType());
-  EXPECT_EQ(10, AS.GetMachOCPUSubType());
+  EXPECT_EQ(12u, AS.GetMachOCPUType());
+  EXPECT_EQ(10u, AS.GetMachOCPUSubType());
 
   AS = ArchSpec();
   EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("12-15", AS));
-  EXPECT_EQ(12, AS.GetMachOCPUType());
-  EXPECT_EQ(15, AS.GetMachOCPUSubType());
+  EXPECT_EQ(12u, AS.GetMachOCPUType());
+  EXPECT_EQ(15u, AS.GetMachOCPUSubType());
 
   AS = ArchSpec();
   EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("12.15", AS));
-  EXPECT_EQ(12, AS.GetMachOCPUType());
-  EXPECT_EQ(15, AS.GetMachOCPUSubType());
+  EXPECT_EQ(12u, AS.GetMachOCPUType());
+  EXPECT_EQ(15u, AS.GetMachOCPUSubType());
 
   // Failure conditions.
 
   // Valid string, unknown cpu/subtype.
   AS = ArchSpec();
   EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("13.11", AS));
-  EXPECT_EQ(0, AS.GetMachOCPUType());
-  EXPECT_EQ(0, AS.GetMachOCPUSubType());
+  EXPECT_EQ(0u, AS.GetMachOCPUType());
+  EXPECT_EQ(0u, AS.GetMachOCPUSubType());
 
   // Missing / invalid cpu or subtype
   AS = ArchSpec();
@@ -60,22 +60,22 @@ TEST(ArchSpecTest, TestParseMachCPUDashSubtypeTripleSimple) {
 TEST(ArchSpecTest, TestParseMachCPUDashSubtypeTripleExtra) {
   ArchSpec AS;
   EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("12-15-vendor-os", AS));
-  EXPECT_EQ(12, AS.GetMachOCPUType());
-  EXPECT_EQ(15, AS.GetMachOCPUSubType());
+  EXPECT_EQ(12u, AS.GetMachOCPUType());
+  EXPECT_EQ(15u, AS.GetMachOCPUSubType());
   EXPECT_EQ("vendor", AS.GetTriple().getVendorName());
   EXPECT_EQ("os", AS.GetTriple().getOSName());
 
   AS = ArchSpec();
   EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("12-10-vendor-os-name", AS));
-  EXPECT_EQ(12, AS.GetMachOCPUType());
-  EXPECT_EQ(10, AS.GetMachOCPUSubType());
+  EXPECT_EQ(12u, AS.GetMachOCPUType());
+  EXPECT_EQ(10u, AS.GetMachOCPUSubType());
   EXPECT_EQ("vendor", AS.GetTriple().getVendorName());
   EXPECT_EQ("os", AS.GetTriple().getOSName());
 
   AS = ArchSpec();
   EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("12-15-vendor.os-name", AS));
-  EXPECT_EQ(12, AS.GetMachOCPUType());
-  EXPECT_EQ(15, AS.GetMachOCPUSubType());
+  EXPECT_EQ(12u, AS.GetMachOCPUType());
+  EXPECT_EQ(15u, AS.GetMachOCPUSubType());
   EXPECT_EQ("vendor.os", AS.GetTriple().getVendorName());
   EXPECT_EQ("name", AS.GetTriple().getOSName());
 
@@ -83,8 +83,8 @@ TEST(ArchSpecTest, TestParseMachCPUDashSubtypeTripleExtra) {
   // since they are unrecognized.
   AS = ArchSpec();
   EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("12-10-vendor", AS));
-  EXPECT_EQ(12, AS.GetMachOCPUType());
-  EXPECT_EQ(10, AS.GetMachOCPUSubType());
+  EXPECT_EQ(12u, AS.GetMachOCPUType());
+  EXPECT_EQ(10u, AS.GetMachOCPUSubType());
   EXPECT_EQ("apple", AS.GetTriple().getVendorName());
   EXPECT_EQ("", AS.GetTriple().getOSName());
 
@@ -100,16 +100,16 @@ TEST(ArchSpecTest, TestSetTriple) {
 
   // Various flavors of valid triples.
   EXPECT_TRUE(AS.SetTriple("12-10-apple-darwin"));
-  EXPECT_EQ(llvm::MachO::CPU_TYPE_ARM, AS.GetMachOCPUType());
-  EXPECT_EQ(10, AS.GetMachOCPUSubType());
+  EXPECT_EQ(uint32_t(llvm::MachO::CPU_TYPE_ARM), AS.GetMachOCPUType());
+  EXPECT_EQ(10u, AS.GetMachOCPUSubType());
   EXPECT_TRUE(llvm::StringRef(AS.GetTriple().str())
   .consume_front("armv7f-apple-darwin"));
   EXPECT_EQ(ArchSpec::eCore_arm_armv7f, AS.GetCore());
 
   AS = ArchSpec();
   EXPECT_TRUE(AS.SetTriple("18.100-apple-darwin"));
-  EXPECT_EQ(llvm::MachO::CPU_TYPE_POWERPC, AS.GetMachOCPUType());
-  EXPECT_EQ(100, AS.GetMachOCPUSubType());
+  EXPECT_EQ(uint32_t(llvm::MachO::CPU_TYPE_POWERPC), AS.GetMachOCPUType());
+  EXPECT_EQ(100u, AS.GetMachOCPUSubType());
   EXPECT_TRUE(llvm::StringRef(AS.GetTriple().str())
   .consume_front("powerpc-apple-darwin"));
   EXPECT_EQ(ArchSpec::eCore_ppc_ppc970, AS.GetCore());
@@ -133,4 +133,4 @@ TEST(ArchSpecTest, TestSetTriple) {
 
   AS = ArchSpec();
   EXP

[Lldb-commits] [lldb] r284362 - Interpreter: Don't return StringRef from functions whose return value is never used

2016-10-17 Thread Justin Bogner via lldb-commits
Author: bogner
Date: Mon Oct 17 01:17:56 2016
New Revision: 284362

URL: http://llvm.org/viewvc/llvm-project?rev=284362&view=rev
Log:
Interpreter: Don't return StringRef from functions whose return value is never 
used

StringRef is passed through all of these APIs but never actually
used. Just remove it from the API for now and if people want to use it
they can add it back.

Modified:
lldb/trunk/include/lldb/Interpreter/Args.h
lldb/trunk/source/Interpreter/Args.cpp

Modified: lldb/trunk/include/lldb/Interpreter/Args.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Args.h?rev=284362&r1=284361&r2=284362&view=diff
==
--- lldb/trunk/include/lldb/Interpreter/Args.h (original)
+++ lldb/trunk/include/lldb/Interpreter/Args.h Mon Oct 17 01:17:56 2016
@@ -193,12 +193,8 @@ public:
   ///
   /// @param[in] quote_char
   /// If the argument was originally quoted, put in the quote char here.
-  ///
-  /// @return
-  /// The NULL terminated C string of the copy of \a arg_cstr.
   //--
-  llvm::StringRef AppendArgument(llvm::StringRef arg_str,
- char quote_char = '\0');
+  void AppendArgument(llvm::StringRef arg_str, char quote_char = '\0');
 
   void AppendArguments(const Args &rhs);
 
@@ -219,8 +215,8 @@ public:
   /// @return
   /// The NULL terminated C string of the copy of \a arg_cstr.
   //--
-  llvm::StringRef InsertArgumentAtIndex(size_t idx, llvm::StringRef arg_str,
-char quote_char = '\0');
+  void InsertArgumentAtIndex(size_t idx, llvm::StringRef arg_str,
+ char quote_char = '\0');
 
   //--
   /// Replaces the argument value at index \a idx to \a arg_cstr
@@ -234,13 +230,9 @@ public:
   ///
   /// @param[in] quote_char
   /// If the argument was originally quoted, put in the quote char here.
-  ///
-  /// @return
-  /// The NULL terminated C string of the copy of \a arg_cstr if
-  /// \a idx was a valid index, NULL otherwise.
   //--
-  llvm::StringRef ReplaceArgumentAtIndex(size_t idx, llvm::StringRef arg_str,
- char quote_char = '\0');
+  void ReplaceArgumentAtIndex(size_t idx, llvm::StringRef arg_str,
+  char quote_char = '\0');
 
   //--
   /// Deletes the argument value at index
@@ -289,11 +281,8 @@ public:
   ///
   /// @param[in] quote_char
   /// If the argument was originally quoted, put in the quote char here.
-  ///
-  /// @return
-  /// A pointer to the copy of \a arg_cstr that was made.
   //--
-  llvm::StringRef Unshift(llvm::StringRef arg_str, char quote_char = '\0');
+  void Unshift(llvm::StringRef arg_str, char quote_char = '\0');
 
   //--
   /// Parse the arguments in the contained arguments.

Modified: lldb/trunk/source/Interpreter/Args.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=284362&r1=284361&r2=284362&view=diff
==
--- lldb/trunk/source/Interpreter/Args.cpp (original)
+++ lldb/trunk/source/Interpreter/Args.cpp Mon Oct 17 01:17:56 2016
@@ -332,8 +332,8 @@ void Args::Shift() {
   m_entries.erase(m_entries.begin());
 }
 
-llvm::StringRef Args::Unshift(llvm::StringRef arg_str, char quote_char) {
-  return InsertArgumentAtIndex(0, arg_str, quote_char);
+void Args::Unshift(llvm::StringRef arg_str, char quote_char) {
+  InsertArgumentAtIndex(0, arg_str, quote_char);
 }
 
 void Args::AppendArguments(const Args &rhs) {
@@ -361,30 +361,28 @@ void Args::AppendArguments(const char **
   m_argv.push_back(nullptr);
 }
 
-llvm::StringRef Args::AppendArgument(llvm::StringRef arg_str, char quote_char) 
{
-  return InsertArgumentAtIndex(GetArgumentCount(), arg_str, quote_char);
+void Args::AppendArgument(llvm::StringRef arg_str, char quote_char) {
+  InsertArgumentAtIndex(GetArgumentCount(), arg_str, quote_char);
 }
 
-llvm::StringRef Args::InsertArgumentAtIndex(size_t idx, llvm::StringRef 
arg_str,
-char quote_char) {
+void Args::InsertArgumentAtIndex(size_t idx, llvm::StringRef arg_str,
+ char quote_char) {
   assert(m_argv.size() == m_entries.size() + 1);
   assert(m_argv.back() == nullptr);
 
   if (idx > m_entries.size())
-return llvm::StringRef();
+return;
   m_entries.emplace(m_entries.begin() + idx, arg_str, quote_char);
   m_argv.insert(m_argv.

[Lldb-commits] [PATCH] debugserver: Disable four-char-constants and format-pedantic warnings

2016-10-17 Thread Justin Bogner via lldb-commits
Today I checked out lldb to check that r284364 wouldn't cause any
trouble, but there were a few warnings that fired when I tried to build
it, breaking my -Werror build.

This disables four character literal warnings (so that 'FDSC' in
debugserver.cpp is allowed) and pedantic formatting warnings, so that
printf-like functions can pass typed pointers to "%p" in format strings.

Okay to commit?

commit c45c40c7fb8d6cff3234dc557376b513293d59cf
Author: Justin Bogner 
Date:   Sun Oct 16 21:38:58 2016 -0700

debugserver: Disable four-char-constants and format-pedantic warnings

diff --git a/tools/debugserver/source/CMakeLists.txt b/tools/debugserver/source/CMakeLists.txt
index 43479bd..621d64d 100644
--- a/tools/debugserver/source/CMakeLists.txt
+++ b/tools/debugserver/source/CMakeLists.txt
@@ -27,6 +27,18 @@ if (CXX_SUPPORTS_NO_EXTENDED_OFFSETOF)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-extended-offsetof")
 endif ()
 
+check_cxx_compiler_flag("-Wno-four-char-constants"
+CXX_SUPPORTS_NO_FOUR_CHAR_CONSTANTS)
+if (CXX_SUPPORTS_NO_FOUR_CHAR_CONSTANTS)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-four-char-constants")
+endif ()
+
+check_cxx_compiler_flag("-Wno-format-pedantic"
+CXX_SUPPORTS_NO_FORMAT_PEDANTIC)
+if (CXX_SUPPORTS_NO_FORMAT_PEDANTIC)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-format-pedantic")
+endif ()
+
 if (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
   add_definitions(
 -DDEBUGSERVER_VERSION_STR="${LLDB_VERSION}"
@@ -65,4 +77,3 @@ if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
   target_link_libraries(lldbDebugserverCommon ${COCOA_LIBRARY})
   add_subdirectory(MacOSX)
 endif()
-
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r284405 - unittests: Specify types in a bunch of unittest EXPECT's

2016-10-17 Thread Justin Bogner via lldb-commits
Author: bogner
Date: Mon Oct 17 13:22:03 2016
New Revision: 284405

URL: http://llvm.org/viewvc/llvm-project?rev=284405&view=rev
Log:
unittests: Specify types in a bunch of unittest EXPECT's

The EXPECT and ASSERT macros in gtest don't do the usual arithmetic
conversions. Specify types in several of them to fix -Werror.

Modified:
lldb/trunk/unittests/Core/ArchSpecTest.cpp
lldb/trunk/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp
lldb/trunk/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
lldb/trunk/unittests/UnwindAssembly/InstEmulation/TestArm64InstEmulation.cpp
lldb/trunk/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp
lldb/trunk/unittests/Utility/StringExtractorTest.cpp

Modified: lldb/trunk/unittests/Core/ArchSpecTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Core/ArchSpecTest.cpp?rev=284405&r1=284404&r2=284405&view=diff
==
--- lldb/trunk/unittests/Core/ArchSpecTest.cpp (original)
+++ lldb/trunk/unittests/Core/ArchSpecTest.cpp Mon Oct 17 13:22:03 2016
@@ -21,26 +21,26 @@ TEST(ArchSpecTest, TestParseMachCPUDashS
   // Success conditions.  Valid cpu/subtype combinations using both - and .
   ArchSpec AS;
   EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("12-10", AS));
-  EXPECT_EQ(12, AS.GetMachOCPUType());
-  EXPECT_EQ(10, AS.GetMachOCPUSubType());
+  EXPECT_EQ(12u, AS.GetMachOCPUType());
+  EXPECT_EQ(10u, AS.GetMachOCPUSubType());
 
   AS = ArchSpec();
   EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("12-15", AS));
-  EXPECT_EQ(12, AS.GetMachOCPUType());
-  EXPECT_EQ(15, AS.GetMachOCPUSubType());
+  EXPECT_EQ(12u, AS.GetMachOCPUType());
+  EXPECT_EQ(15u, AS.GetMachOCPUSubType());
 
   AS = ArchSpec();
   EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("12.15", AS));
-  EXPECT_EQ(12, AS.GetMachOCPUType());
-  EXPECT_EQ(15, AS.GetMachOCPUSubType());
+  EXPECT_EQ(12u, AS.GetMachOCPUType());
+  EXPECT_EQ(15u, AS.GetMachOCPUSubType());
 
   // Failure conditions.
 
   // Valid string, unknown cpu/subtype.
   AS = ArchSpec();
   EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("13.11", AS));
-  EXPECT_EQ(0, AS.GetMachOCPUType());
-  EXPECT_EQ(0, AS.GetMachOCPUSubType());
+  EXPECT_EQ(0u, AS.GetMachOCPUType());
+  EXPECT_EQ(0u, AS.GetMachOCPUSubType());
 
   // Missing / invalid cpu or subtype
   AS = ArchSpec();
@@ -60,22 +60,22 @@ TEST(ArchSpecTest, TestParseMachCPUDashS
 TEST(ArchSpecTest, TestParseMachCPUDashSubtypeTripleExtra) {
   ArchSpec AS;
   EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("12-15-vendor-os", AS));
-  EXPECT_EQ(12, AS.GetMachOCPUType());
-  EXPECT_EQ(15, AS.GetMachOCPUSubType());
+  EXPECT_EQ(12u, AS.GetMachOCPUType());
+  EXPECT_EQ(15u, AS.GetMachOCPUSubType());
   EXPECT_EQ("vendor", AS.GetTriple().getVendorName());
   EXPECT_EQ("os", AS.GetTriple().getOSName());
 
   AS = ArchSpec();
   EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("12-10-vendor-os-name", AS));
-  EXPECT_EQ(12, AS.GetMachOCPUType());
-  EXPECT_EQ(10, AS.GetMachOCPUSubType());
+  EXPECT_EQ(12u, AS.GetMachOCPUType());
+  EXPECT_EQ(10u, AS.GetMachOCPUSubType());
   EXPECT_EQ("vendor", AS.GetTriple().getVendorName());
   EXPECT_EQ("os", AS.GetTriple().getOSName());
 
   AS = ArchSpec();
   EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("12-15-vendor.os-name", AS));
-  EXPECT_EQ(12, AS.GetMachOCPUType());
-  EXPECT_EQ(15, AS.GetMachOCPUSubType());
+  EXPECT_EQ(12u, AS.GetMachOCPUType());
+  EXPECT_EQ(15u, AS.GetMachOCPUSubType());
   EXPECT_EQ("vendor.os", AS.GetTriple().getVendorName());
   EXPECT_EQ("name", AS.GetTriple().getOSName());
 
@@ -83,8 +83,8 @@ TEST(ArchSpecTest, TestParseMachCPUDashS
   // since they are unrecognized.
   AS = ArchSpec();
   EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("12-10-vendor", AS));
-  EXPECT_EQ(12, AS.GetMachOCPUType());
-  EXPECT_EQ(10, AS.GetMachOCPUSubType());
+  EXPECT_EQ(12u, AS.GetMachOCPUType());
+  EXPECT_EQ(10u, AS.GetMachOCPUSubType());
   EXPECT_EQ("apple", AS.GetTriple().getVendorName());
   EXPECT_EQ("", AS.GetTriple().getOSName());
 
@@ -100,16 +100,16 @@ TEST(ArchSpecTest, TestSetTriple) {
 
   // Various flavors of valid triples.
   EXPECT_TRUE(AS.SetTriple("12-10-apple-darwin"));
-  EXPECT_EQ(llvm::MachO::CPU_TYPE_ARM, AS.GetMachOCPUType());
-  EXPECT_EQ(10, AS.GetMachOCPUSubType());
+  EXPECT_EQ(uint32_t(llvm::MachO::CPU_TYPE_ARM), AS.GetMachOCPUType());
+  EXPECT_EQ(10u, AS.GetMachOCPUSubType());
   EXPECT_TRUE(llvm::StringRef(AS.GetTriple().str())
   .consume_front("armv7f-apple-darwin"));
   EXPECT_EQ(ArchSpec::eCore_arm_armv7f, AS.GetCore());
 
   AS = ArchSpec();
   EXPECT_TRUE(AS.SetTriple("18.100-apple-darwin"));
-  EXPECT_EQ(llvm::MachO::CPU_TYPE_POWERPC, AS.GetMachOCPUType());
-  EXPECT_EQ(100, AS.GetMachOCPUSubType());
+  EXPECT_EQ(uint32_t(llvm::MachO::CPU_TYPE_POWERPC), AS.GetMachOCPUType());
+  EXPECT_EQ(100u, AS.GetMachOCPUSubType());
   EXPECT_TRUE(llvm::StringRef(AS.GetTriple().str())
   .consume_front("po

Re: [Lldb-commits] [PATCH] unittests: Specify types in a bunch of unittest EXPECT's

2016-10-17 Thread Justin Bogner via lldb-commits
Zachary Turner  writes:
> looks fine, thanks

Thanks! r284405.

> On Mon, Oct 17, 2016 at 10:37 AM Justin Bogner via lldb-commits <
> lldb-commits@lists.llvm.org> wrote:
>
>> Today I checked out lldb to check that r284364 wouldn't cause any
>> trouble, but there were a few warnings that fired when I tried to build
>> it, breaking my -Werror build.
>>
>> The EXPECT and ASSERT macros in gtest don't do the usual arithmetic
>> conversions, so there are a number of warnings where we compare
>> differently sized ints. This fixes the places that warn to be more
>> specific. Okay to commit?
>>
>> ___
>> lldb-commits mailing list
>> lldb-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] debugserver: Disable four-char-constants and format-pedantic warnings

2016-10-18 Thread Justin Bogner via lldb-commits
Pavel Labath  writes:
> Thanks for the patch. Could you submit the patch through phabricator
> <https://reviews.llvm.org> and add Greg Clayton as a reviewer.

Maybe later. I don't have time to fight with phabricator today.

> That said, my preference would be to actually fix those warnings
> instead of silencing them.

If you think that's best, but do note that neither of these warnings is
flagging much of a problem:

- The four-character-literal warning is flagging implementation defined
  behaviour four spelling a 32 bit hex constant in ascii instead of
  something like 0x46445343. This is a portability vs readability thing,
  and pretty minor.

- The format-pedantic is warning about passing typed pointers to a %p
  format specifier. The "fix" is to cast these arguments to `void *`,
  which IMO hurts readability for no gain. I'm pretty sure this warning
  only exists to preserve portability to some hypothetical ABI whose
  calling convention depends on the type of the pointer.

> pl
>
> On 17 October 2016 at 08:24, Justin Bogner via lldb-commits
>  wrote:
>> Today I checked out lldb to check that r284364 wouldn't cause any
>> trouble, but there were a few warnings that fired when I tried to build
>> it, breaking my -Werror build.
>>
>> This disables four character literal warnings (so that 'FDSC' in
>> debugserver.cpp is allowed) and pedantic formatting warnings, so that
>> printf-like functions can pass typed pointers to "%p" in format strings.
>>
>> Okay to commit?
>>
>>
>> ___
>> lldb-commits mailing list
>> lldb-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] debugserver: Disable four-char-constants and format-pedantic warnings

2016-10-27 Thread Justin Bogner via lldb-commits
Pavel Labath  writes:
> On 19 October 2016 at 00:20, Justin Bogner  wrote:
>> Pavel Labath  writes:
>>> Thanks for the patch. Could you submit the patch through phabricator
>>>  and add Greg Clayton as a reviewer.
>>
>> Maybe later. I don't have time to fight with phabricator today.
>>
>>> That said, my preference would be to actually fix those warnings
>>> instead of silencing them.
>>
>> If you think that's best, but do note that neither of these warnings is
>> flagging much of a problem:
>>
>> - The four-character-literal warning is flagging implementation defined
>>   behaviour four spelling a 32 bit hex constant in ascii instead of
>>   something like 0x46445343. This is a portability vs readability thing,
>>   and pretty minor.
>
> Agreed, but it also is pretty easily workaroundable without hurting
> readability by defining a symbolic constant.

Sure, I'd be fine with that too.

>> - The format-pedantic is warning about passing typed pointers to a %p
>>   format specifier. The "fix" is to cast these arguments to `void *`,
>>   which IMO hurts readability for no gain. I'm pretty sure this warning
>>   only exists to preserve portability to some hypothetical ABI whose
>>   calling convention depends on the type of the pointer.
>
> This one actually annoys me as well, but if we do that, I think it
> should be done at the project level. BTW, does the flag disable
> anything else apart from the void *-cast issue. I'd hate to lose other
> checks, as it's extremely easy to write non-portable format strings.

The format-pedantic warning is specifically for %p with any pointer type
other than `void *`. It also looks like clang applies this for some sort
of freebsd kernel extension %D arg, but that doesn't seem relevant.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)

2024-07-08 Thread Justin Bogner via lldb-commits


@@ -115,6 +116,18 @@ GlobalVariable *replaceBuffer(CGHLSLRuntime::Buffer &Buf) {
 
 } // namespace
 
+llvm::Type *CGHLSLRuntime::convertHLSLSpecificType(const Type *T) {
+  assert(T->isHLSLSpecificType() && "Not an HLSL specific type!");
+
+  // Check if the target has a specific translation for this type first.
+  if (llvm::Type *TargetTy = CGM.getTargetCodeGenInfo().getHLSLType(CGM, T))
+return TargetTy;
+
+  // TODO: What do we actually want to do generically here? OpenCL uses a
+  // pointer in a particular address space.
+  llvm_unreachable("Generic handling of HLSL types is not implemented yet");

bogner wrote:

For DirectX and SPIR-V we'll implement `getHLSLType` and this should really be 
unreachable, but we may want to do something generic in the future if/when we 
want to generate code for GPU or CPU targets directly generically. Something 
like the OpenCL approach mentioned in the comment might make sense in that case.

https://github.com/llvm/llvm-project/pull/97362
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)

2024-08-02 Thread Justin Bogner via lldb-commits

https://github.com/bogner approved this pull request.

LGTM!

https://github.com/llvm/llvm-project/pull/97362
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [flang] [libcxx] [libcxxabi] [lldb] [llvm] [libunwind] [clang-tools-extra] [openmp] [clang] [lld] [Clang][Sema] Don't say "is declared here" for invalid template locations (PR #71264)

2023-11-30 Thread Justin Bogner via lldb-commits

https://github.com/bogner updated 
https://github.com/llvm/llvm-project/pull/71264

>From cab6bcd73081fcbe9807adbf60b345f8d9e654e4 Mon Sep 17 00:00:00 2001
From: Justin Bogner 
Date: Fri, 3 Nov 2023 18:59:49 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5
---
 clang/lib/Sema/SemaDecl.cpp   |   2 +-
 clang/lib/Sema/SemaDeclCXX.cpp|   3 +-
 clang/lib/Sema/SemaInit.cpp   |   3 +-
 clang/lib/Sema/SemaLambda.cpp |   3 +-
 clang/lib/Sema/SemaTemplate.cpp   | 123 --
 clang/lib/Sema/SemaType.cpp   |   3 +-
 .../test/SemaHLSL/BuiltIns/vector-errors.hlsl |   5 -
 7 files changed, 89 insertions(+), 53 deletions(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 396566a8f10a9b7..a86c428c9121abf 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -5929,7 +5929,7 @@ Sema::GetNameFromUnqualifiedId(const UnqualifiedId &Name) 
{
   Diag(Name.StartLocation,
diag::err_deduction_guide_name_not_class_template)
 << (int)getTemplateNameKindForDiagnostics(TN) << TN;
-  if (Template)
+  if (Template && Template->getLocation().isValid())
 Diag(Template->getLocation(), diag::note_template_decl_here);
   return DeclarationNameInfo();
 }
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 397b7a00e453126..de5cc07f5d42865 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -11462,7 +11462,8 @@ bool Sema::CheckDeductionGuideDeclarator(Declarator &D, 
QualType &R,
   GuidedTemplateDecl->getDeclContext()->getRedeclContext())) {
 Diag(D.getIdentifierLoc(), diag::err_deduction_guide_wrong_scope)
   << GuidedTemplateDecl;
-Diag(GuidedTemplateDecl->getLocation(), diag::note_template_decl_here);
+if (GuidedTemplateDecl->getLocation().isValid())
+  Diag(GuidedTemplateDecl->getLocation(), diag::note_template_decl_here);
   }
 
   auto &DS = D.getMutableDeclSpec();
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index ed02d3580f34f9a..0952b065d56b58e 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -10575,7 +10575,8 @@ QualType 
Sema::DeduceTemplateSpecializationFromInitializer(
  diag::err_deduced_non_class_template_specialization_type)
   << (int)getTemplateNameKindForDiagnostics(TemplateName) << TemplateName;
 if (auto *TD = TemplateName.getAsTemplateDecl())
-  Diag(TD->getLocation(), diag::note_template_decl_here);
+  if (TD->getLocation().isValid())
+Diag(TD->getLocation(), diag::note_template_decl_here);
 return QualType();
   }
 
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index ca09b0481bcac76..603b7465323e237 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -1444,7 +1444,8 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer 
&Intro,
   for (const auto &Capture : Intro.Captures) {
 if (Capture.Id == TP->getIdentifier()) {
   Diag(Capture.Loc, diag::err_template_param_shadow) << Capture.Id;
-  Diag(TP->getLocation(), diag::note_template_param_here);
+  if (TP->getLocation().isValid())
+Diag(TP->getLocation(), diag::note_template_param_here);
 }
   }
 }
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index ee354862212803f..1a6eaa196db09be 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -872,7 +872,7 @@ bool Sema::DiagnoseUninstantiableTemplate(SourceLocation 
PointOfInstantiation,
   Note = diag::note_explicit_instantiation_here;
 }
   }
-  if (Note) // Diagnostics were emitted.
+  if (Note && Pattern->getLocation().isValid()) // Diagnostics were emitted.
 Diag(Pattern->getLocation(), *Note);
 
   // In general, Instantiation isn't marked invalid to get more than one
@@ -899,7 +899,8 @@ void Sema::DiagnoseTemplateParameterShadow(SourceLocation 
Loc, Decl *PrevDecl) {
   unsigned DiagId = getLangOpts().MSVCCompat ? diag::ext_template_param_shadow
  : diag::err_template_param_shadow;
   Diag(Loc, DiagId) << cast(PrevDecl)->getDeclName();
-  Diag(PrevDecl->getLocation(), diag::note_template_param_here);
+  if (PrevDecl->getLocation().isValid())
+Diag(PrevDecl->getLocation(), diag::note_template_param_here);
 }
 
 /// AdjustDeclIfTemplate - If the given decl happens to be a template, reset
@@ -4434,7 +4435,8 @@ static void checkMoreSpecializedThanPrimary(Sema &S, 
PartialSpecDecl *Partial) {
   << SFINAEArgString;
   }
 
-  S.Diag(Template->getLocation(), diag::note_template_decl_here);
+  if (Template->getLocation().isValid

[Lldb-commits] [clang-tools-extra] [lld] [clang] [openmp] [mlir] [lldb] [llvm] [flang] [libunwind] [libcxx] [libc] [libcxxabi] [Clang][Sema] Don't say "is declared here" for invalid template locations

2023-11-30 Thread Justin Bogner via lldb-commits

https://github.com/bogner updated 
https://github.com/llvm/llvm-project/pull/71264

>From cab6bcd73081fcbe9807adbf60b345f8d9e654e4 Mon Sep 17 00:00:00 2001
From: Justin Bogner 
Date: Fri, 3 Nov 2023 18:59:49 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5
---
 clang/lib/Sema/SemaDecl.cpp   |   2 +-
 clang/lib/Sema/SemaDeclCXX.cpp|   3 +-
 clang/lib/Sema/SemaInit.cpp   |   3 +-
 clang/lib/Sema/SemaLambda.cpp |   3 +-
 clang/lib/Sema/SemaTemplate.cpp   | 123 --
 clang/lib/Sema/SemaType.cpp   |   3 +-
 .../test/SemaHLSL/BuiltIns/vector-errors.hlsl |   5 -
 7 files changed, 89 insertions(+), 53 deletions(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 396566a8f10a9b7..a86c428c9121abf 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -5929,7 +5929,7 @@ Sema::GetNameFromUnqualifiedId(const UnqualifiedId &Name) 
{
   Diag(Name.StartLocation,
diag::err_deduction_guide_name_not_class_template)
 << (int)getTemplateNameKindForDiagnostics(TN) << TN;
-  if (Template)
+  if (Template && Template->getLocation().isValid())
 Diag(Template->getLocation(), diag::note_template_decl_here);
   return DeclarationNameInfo();
 }
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 397b7a00e453126..de5cc07f5d42865 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -11462,7 +11462,8 @@ bool Sema::CheckDeductionGuideDeclarator(Declarator &D, 
QualType &R,
   GuidedTemplateDecl->getDeclContext()->getRedeclContext())) {
 Diag(D.getIdentifierLoc(), diag::err_deduction_guide_wrong_scope)
   << GuidedTemplateDecl;
-Diag(GuidedTemplateDecl->getLocation(), diag::note_template_decl_here);
+if (GuidedTemplateDecl->getLocation().isValid())
+  Diag(GuidedTemplateDecl->getLocation(), diag::note_template_decl_here);
   }
 
   auto &DS = D.getMutableDeclSpec();
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index ed02d3580f34f9a..0952b065d56b58e 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -10575,7 +10575,8 @@ QualType 
Sema::DeduceTemplateSpecializationFromInitializer(
  diag::err_deduced_non_class_template_specialization_type)
   << (int)getTemplateNameKindForDiagnostics(TemplateName) << TemplateName;
 if (auto *TD = TemplateName.getAsTemplateDecl())
-  Diag(TD->getLocation(), diag::note_template_decl_here);
+  if (TD->getLocation().isValid())
+Diag(TD->getLocation(), diag::note_template_decl_here);
 return QualType();
   }
 
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index ca09b0481bcac76..603b7465323e237 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -1444,7 +1444,8 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer 
&Intro,
   for (const auto &Capture : Intro.Captures) {
 if (Capture.Id == TP->getIdentifier()) {
   Diag(Capture.Loc, diag::err_template_param_shadow) << Capture.Id;
-  Diag(TP->getLocation(), diag::note_template_param_here);
+  if (TP->getLocation().isValid())
+Diag(TP->getLocation(), diag::note_template_param_here);
 }
   }
 }
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index ee354862212803f..1a6eaa196db09be 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -872,7 +872,7 @@ bool Sema::DiagnoseUninstantiableTemplate(SourceLocation 
PointOfInstantiation,
   Note = diag::note_explicit_instantiation_here;
 }
   }
-  if (Note) // Diagnostics were emitted.
+  if (Note && Pattern->getLocation().isValid()) // Diagnostics were emitted.
 Diag(Pattern->getLocation(), *Note);
 
   // In general, Instantiation isn't marked invalid to get more than one
@@ -899,7 +899,8 @@ void Sema::DiagnoseTemplateParameterShadow(SourceLocation 
Loc, Decl *PrevDecl) {
   unsigned DiagId = getLangOpts().MSVCCompat ? diag::ext_template_param_shadow
  : diag::err_template_param_shadow;
   Diag(Loc, DiagId) << cast(PrevDecl)->getDeclName();
-  Diag(PrevDecl->getLocation(), diag::note_template_param_here);
+  if (PrevDecl->getLocation().isValid())
+Diag(PrevDecl->getLocation(), diag::note_template_param_here);
 }
 
 /// AdjustDeclIfTemplate - If the given decl happens to be a template, reset
@@ -4434,7 +4435,8 @@ static void checkMoreSpecializedThanPrimary(Sema &S, 
PartialSpecDecl *Partial) {
   << SFINAEArgString;
   }
 
-  S.Diag(Template->getLocation(), diag::note_template_decl_here);
+  if (Template->getLocation().isValid

[Lldb-commits] [clang-tools-extra] [llvm] [libunwind] [mlir] [lld] [libc] [clang] [flang] [libcxx] [libcxxabi] [lldb] [openmp] [Clang][Sema] Don't say "is declared here" for invalid template locations

2023-11-30 Thread Justin Bogner via lldb-commits


@@ -7909,6 +7903,37 @@ bool 
Sema::CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param,
  Arg.getLocation());
 }
 
+static Sema::SemaDiagnosticBuilder noteLocation(Sema &S, const NamedDecl &Decl,
+unsigned HereDiagID,
+unsigned ExternalDiagID) {
+  if (Decl.getLocation().isValid())
+return S.Diag(Decl.getLocation(), HereDiagID);
+
+  SmallString<128> Str;
+  llvm::raw_svector_ostream Out(Str);
+  PrintingPolicy PP = S.getPrintingPolicy();
+  PP.TerseOutput = 1;
+  Decl.print(Out, PP);
+  return S.Diag(Decl.getLocation(), ExternalDiagID) << Out.str();

bogner wrote:

Using `<< &Decl` here just gives the name. With print we get:
```
template declaration from hidden source: template  using vector = element 
__attribute__((ext_vector_type(element_count)))
template parameter from hidden source: class element = float
```
whereas with the stream operator it's
```
note: template declaration from hidden source: 'vector'
note: template parameter from hidden source: 'element'
```

Similarly in #71265 it's the difference between printing `template  class RWBuffer final` vs just `RWBuffer`

https://github.com/llvm/llvm-project/pull/71264
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [openmp] [libcxxabi] [clang] [compiler-rt] [libc] [mlir] [flang] [libcxx] [llvm] [lldb] [lld] [clang-tools-extra] [libunwind] [Clang][Sema] Don't say "is declared here" for invalid temp

2023-12-06 Thread Justin Bogner via lldb-commits

https://github.com/bogner updated 
https://github.com/llvm/llvm-project/pull/71264

>From cab6bcd73081fcbe9807adbf60b345f8d9e654e4 Mon Sep 17 00:00:00 2001
From: Justin Bogner 
Date: Fri, 3 Nov 2023 18:59:49 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5
---
 clang/lib/Sema/SemaDecl.cpp   |   2 +-
 clang/lib/Sema/SemaDeclCXX.cpp|   3 +-
 clang/lib/Sema/SemaInit.cpp   |   3 +-
 clang/lib/Sema/SemaLambda.cpp |   3 +-
 clang/lib/Sema/SemaTemplate.cpp   | 123 --
 clang/lib/Sema/SemaType.cpp   |   3 +-
 .../test/SemaHLSL/BuiltIns/vector-errors.hlsl |   5 -
 7 files changed, 89 insertions(+), 53 deletions(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 396566a8f10a9..a86c428c9121a 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -5929,7 +5929,7 @@ Sema::GetNameFromUnqualifiedId(const UnqualifiedId &Name) 
{
   Diag(Name.StartLocation,
diag::err_deduction_guide_name_not_class_template)
 << (int)getTemplateNameKindForDiagnostics(TN) << TN;
-  if (Template)
+  if (Template && Template->getLocation().isValid())
 Diag(Template->getLocation(), diag::note_template_decl_here);
   return DeclarationNameInfo();
 }
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 397b7a00e4531..de5cc07f5d428 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -11462,7 +11462,8 @@ bool Sema::CheckDeductionGuideDeclarator(Declarator &D, 
QualType &R,
   GuidedTemplateDecl->getDeclContext()->getRedeclContext())) {
 Diag(D.getIdentifierLoc(), diag::err_deduction_guide_wrong_scope)
   << GuidedTemplateDecl;
-Diag(GuidedTemplateDecl->getLocation(), diag::note_template_decl_here);
+if (GuidedTemplateDecl->getLocation().isValid())
+  Diag(GuidedTemplateDecl->getLocation(), diag::note_template_decl_here);
   }
 
   auto &DS = D.getMutableDeclSpec();
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index ed02d3580f34f..0952b065d56b5 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -10575,7 +10575,8 @@ QualType 
Sema::DeduceTemplateSpecializationFromInitializer(
  diag::err_deduced_non_class_template_specialization_type)
   << (int)getTemplateNameKindForDiagnostics(TemplateName) << TemplateName;
 if (auto *TD = TemplateName.getAsTemplateDecl())
-  Diag(TD->getLocation(), diag::note_template_decl_here);
+  if (TD->getLocation().isValid())
+Diag(TD->getLocation(), diag::note_template_decl_here);
 return QualType();
   }
 
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index ca09b0481bcac..603b7465323e2 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -1444,7 +1444,8 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer 
&Intro,
   for (const auto &Capture : Intro.Captures) {
 if (Capture.Id == TP->getIdentifier()) {
   Diag(Capture.Loc, diag::err_template_param_shadow) << Capture.Id;
-  Diag(TP->getLocation(), diag::note_template_param_here);
+  if (TP->getLocation().isValid())
+Diag(TP->getLocation(), diag::note_template_param_here);
 }
   }
 }
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index ee35486221280..1a6eaa196db09 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -872,7 +872,7 @@ bool Sema::DiagnoseUninstantiableTemplate(SourceLocation 
PointOfInstantiation,
   Note = diag::note_explicit_instantiation_here;
 }
   }
-  if (Note) // Diagnostics were emitted.
+  if (Note && Pattern->getLocation().isValid()) // Diagnostics were emitted.
 Diag(Pattern->getLocation(), *Note);
 
   // In general, Instantiation isn't marked invalid to get more than one
@@ -899,7 +899,8 @@ void Sema::DiagnoseTemplateParameterShadow(SourceLocation 
Loc, Decl *PrevDecl) {
   unsigned DiagId = getLangOpts().MSVCCompat ? diag::ext_template_param_shadow
  : diag::err_template_param_shadow;
   Diag(Loc, DiagId) << cast(PrevDecl)->getDeclName();
-  Diag(PrevDecl->getLocation(), diag::note_template_param_here);
+  if (PrevDecl->getLocation().isValid())
+Diag(PrevDecl->getLocation(), diag::note_template_param_here);
 }
 
 /// AdjustDeclIfTemplate - If the given decl happens to be a template, reset
@@ -4434,7 +4435,8 @@ static void checkMoreSpecializedThanPrimary(Sema &S, 
PartialSpecDecl *Partial) {
   << SFINAEArgString;
   }
 
-  S.Diag(Template->getLocation(), diag::note_template_decl_here);
+  if (Template->getLocation().isValid())
+S.Diag(Temp

[Lldb-commits] [compiler-rt] [llvm] [openmp] [libc] [lldb] [libcxx] [libcxxabi] [libunwind] [lld] [clang-tools-extra] [clang] [flang] [mlir] [Clang][Sema] Don't say "is declared here" for invalid temp

2023-12-06 Thread Justin Bogner via lldb-commits

https://github.com/bogner closed https://github.com/llvm/llvm-project/pull/71264
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [libcxx] [flang] [llvm] [lldb] [libcxxabi] [clang] [clang-tools-extra] [lld] [compiler-rt] [libc] [HLSL][DirectX] Move handling of resource element types into the frontend (PR #75674)

2023-12-18 Thread Justin Bogner via lldb-commits

https://github.com/bogner updated 
https://github.com/llvm/llvm-project/pull/75674

>From 9d6e00bd972a563daefd67b544614e2bb609cc42 Mon Sep 17 00:00:00 2001
From: Justin Bogner 
Date: Fri, 15 Dec 2023 16:29:09 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5-bogner
---
 clang/lib/CodeGen/CGHLSLRuntime.cpp   | 63 +++--
 clang/lib/CodeGen/CGHLSLRuntime.h |  2 +-
 .../builtins/RWBuffer-annotations.hlsl| 14 +--
 .../builtins/RWBuffer-elementtype.hlsl| 52 +++
 .../RasterizerOrderedBuffer-annotations.hlsl  | 12 +--
 clang/test/CodeGenHLSL/cbuf.hlsl  |  4 +-
 .../include/llvm/Frontend/HLSL/HLSLResource.h | 27 +-
 llvm/lib/Frontend/HLSL/HLSLResource.cpp   | 17 ++--
 llvm/lib/Target/DirectX/DXILResource.cpp  | 92 ++-
 llvm/lib/Target/DirectX/DXILResource.h| 37 ++--
 llvm/test/CodeGen/DirectX/UAVMetadata.ll  | 22 ++---
 11 files changed, 204 insertions(+), 138 deletions(-)
 create mode 100644 clang/test/CodeGenHLSL/builtins/RWBuffer-elementtype.hlsl

diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 3e8a40e7540bef..e887d35198b3c7 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -182,10 +182,8 @@ void CGHLSLRuntime::finishCodeGen() {
 llvm::hlsl::ResourceKind RK = Buf.IsCBuffer
   ? llvm::hlsl::ResourceKind::CBuffer
   : llvm::hlsl::ResourceKind::TBuffer;
-std::string TyName =
-Buf.Name.str() + (Buf.IsCBuffer ? ".cb." : ".tb.") + "ty";
-addBufferResourceAnnotation(GV, TyName, RC, RK, /*IsROV=*/false,
-Buf.Binding);
+addBufferResourceAnnotation(GV, RC, RK, /*IsROV=*/false,
+llvm::hlsl::ElementType::Invalid, Buf.Binding);
   }
 }
 
@@ -194,10 +192,10 @@ CGHLSLRuntime::Buffer::Buffer(const HLSLBufferDecl *D)
   Binding(D->getAttr()) {}
 
 void CGHLSLRuntime::addBufferResourceAnnotation(llvm::GlobalVariable *GV,
-llvm::StringRef TyName,
 llvm::hlsl::ResourceClass RC,
 llvm::hlsl::ResourceKind RK,
 bool IsROV,
+llvm::hlsl::ElementType ET,
 BufferResBinding &Binding) {
   llvm::Module &M = CGM.getModule();
 
@@ -216,15 +214,62 @@ void 
CGHLSLRuntime::addBufferResourceAnnotation(llvm::GlobalVariable *GV,
 assert(false && "Unsupported buffer type!");
 return;
   }
-
   assert(ResourceMD != nullptr &&
  "ResourceMD must have been set by the switch above.");
 
   llvm::hlsl::FrontendResource Res(
-  GV, TyName, RK, IsROV, Binding.Reg.value_or(UINT_MAX), Binding.Space);
+  GV, RK, ET, IsROV, Binding.Reg.value_or(UINT_MAX), Binding.Space);
   ResourceMD->addOperand(Res.getMetadata());
 }
 
+static llvm::hlsl::ElementType
+calculateElementType(const ASTContext &Context, const clang::Type *ResourceTy) 
{
+  using llvm::hlsl::ElementType;
+
+  // TODO: We may need to update this when we add things like ByteAddressBuffer
+  // that don't have a template parameter (or, indeed, an element type).
+  const auto *TST = ResourceTy->getAs();
+  assert(TST && "Resource types must be template specializations");
+  ArrayRef Args = TST->template_arguments();
+  assert(!Args.empty() && "Resource has no element type");
+
+  // At this point we have a resource with an element type, so we can assume
+  // that it's valid or we would have diagnosed the error earlier.
+  QualType ElTy = Args[0].getAsType();
+
+  // We should either have a basic type or a vector of a basic type.
+  if (const auto *VecTy = ElTy->getAs())
+ElTy = VecTy->getElementType();
+
+  if (ElTy->isSignedIntegerType()) {
+switch (Context.getTypeSize(ElTy)) {
+case 16:
+  return ElementType::I16;
+case 32:
+  return ElementType::I32;
+case 64:
+  return ElementType::I64;
+}
+  } else if (ElTy->isUnsignedIntegerType()) {
+switch (Context.getTypeSize(ElTy)) {
+case 16:
+  return ElementType::U16;
+case 32:
+  return ElementType::U32;
+case 64:
+  return ElementType::U64;
+}
+  } else if (ElTy->isSpecificBuiltinType(BuiltinType::Half))
+return ElementType::F16;
+  else if (ElTy->isSpecificBuiltinType(BuiltinType::Float))
+return ElementType::F32;
+  else if (ElTy->isSpecificBuiltinType(BuiltinType::Double))
+return ElementType::F64;
+
+  // TODO: We need to handle unorm/snorm float types here once we support them
+  llvm_unreachable("Invalid element type for resource");
+}
+

[Lldb-commits] [compiler-rt] [clang-tools-extra] [libcxx] [lldb] [clang] [libc] [llvm] [libcxxabi] [lld] [flang] [HLSL][DirectX] Move handling of resource element types into the frontend (PR #75674)

2023-12-18 Thread Justin Bogner via lldb-commits

https://github.com/bogner closed https://github.com/llvm/llvm-project/pull/75674
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits