[Lldb-commits] [lldb] r286088 - Convert some helper functions to use StringRef.

2016-11-06 Thread Zachary Turner via lldb-commits
Author: zturner
Date: Sun Nov  6 18:07:25 2016
New Revision: 286088

URL: http://llvm.org/viewvc/llvm-project?rev=286088&view=rev
Log:
Convert some helper functions to use StringRef.

I will probably submit a lot of small trivial changes
like this over the coming weeks.  The end goal is to
convert Options::SetOptionValue to take the option arg
as a StringRef, but doing so in one pass would be a huge
mess of disparate changes just to satisfy the compiler,
and with a high risk of breaking.  So I'm going to do
this in small pieces, changing seemingly random things
here and there until the final change to the signature
of Options::SetOptionValue() can be done trivially.

Modified:

lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp

Modified: 
lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp?rev=286088&r1=286087&r2=286088&view=diff
==
--- 
lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp 
(original)
+++ 
lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp 
Sun Nov  6 18:07:25 2016
@@ -562,7 +562,7 @@ public:
   break;
 
 case 'f':
-  return ParseFilterRule(option_arg);
+  return ParseFilterRule(option_strref);
 
 case 'i':
   m_include_info_level = true;
@@ -664,10 +664,10 @@ public:
   bool GetBroadcastEvents() const { return m_broadcast_events; }
 
 private:
-  Error ParseFilterRule(const char *rule_text_cstr) {
+  Error ParseFilterRule(llvm::StringRef rule_text) {
 Error error;
 
-if (!rule_text_cstr || !rule_text_cstr[0]) {
+if (rule_text.empty()) {
   error.SetErrorString("invalid rule_text");
   return error;
 }
@@ -692,14 +692,12 @@ private:
 //   match {exact-match-text} |
 //   regex {search-regex}
 
-const std::string rule_text(rule_text_cstr);
-
 // Parse action.
 auto action_end_pos = rule_text.find(" ");
 if (action_end_pos == std::string::npos) {
   error.SetErrorStringWithFormat("could not parse filter rule "
  "action from \"%s\"",
- rule_text_cstr);
+ rule_text.str().c_str());
   return error;
 }
 auto action = rule_text.substr(0, action_end_pos);
@@ -709,8 +707,7 @@ private:
 else if (action == "reject")
   accept = false;
 else {
-  error.SetErrorString("filter action must be \"accept\" or "
-   "\"deny\"");
+  error.SetErrorString("filter action must be \"accept\" or \"deny\"");
   return error;
 }
 
@@ -719,7 +716,7 @@ private:
 if (attribute_end_pos == std::string::npos) {
   error.SetErrorStringWithFormat("could not parse filter rule "
  "attribute from \"%s\"",
- rule_text_cstr);
+ rule_text.str().c_str());
   return error;
 }
 auto attribute = rule_text.substr(action_end_pos + 1,
@@ -728,7 +725,7 @@ private:
 if (attribute_index < 0) {
   error.SetErrorStringWithFormat("filter rule attribute unknown: "
  "%s",
- attribute.c_str());
+ attribute.str().c_str());
   return error;
 }
 
@@ -748,12 +745,10 @@ private:
 return error;
   }
 
-  int MatchAttributeIndex(const std::string &attribute_name) {
-auto attribute_count =
-sizeof(s_filter_attributes) / sizeof(s_filter_attributes[0]);
-for (size_t i = 0; i < attribute_count; ++i) {
-  if (attribute_name == s_filter_attributes[i])
-return static_cast(i);
+  int MatchAttributeIndex(llvm::StringRef attribute_name) const {
+for (const auto &Item : llvm::enumerate(s_filter_attributes)) {
+  if (attribute_name == Item.Value)
+return Item.Index;
 }
 
 // We didn't match anything.


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


[Lldb-commits] [PATCH] D26338: [lldb] Don't build unit tests for unsupported targets

2016-11-06 Thread Vedant Kumar via lldb-commits
vsk created this revision.
vsk added a reviewer: jasonmolenda.
vsk added a subscriber: lldb-commits.
Herald added a subscriber: mgorny.

Should fix: https://llvm.org/bugs/show_bug.cgi?id=30928


https://reviews.llvm.org/D26338

Files:
  unittests/UnwindAssembly/CMakeLists.txt
  unittests/UnwindAssembly/InstEmulation/CMakeLists.txt


Index: unittests/UnwindAssembly/InstEmulation/CMakeLists.txt
===
--- unittests/UnwindAssembly/InstEmulation/CMakeLists.txt
+++ unittests/UnwindAssembly/InstEmulation/CMakeLists.txt
@@ -1 +1,3 @@
-add_lldb_unittest(InstEmulationTests TestArm64InstEmulation.cpp)
+if ("AArch64" IN_LIST LLVM_TARGETS_TO_BUILD)
+  add_lldb_unittest(InstEmulationTests TestArm64InstEmulation.cpp)
+endif()
Index: unittests/UnwindAssembly/CMakeLists.txt
===
--- unittests/UnwindAssembly/CMakeLists.txt
+++ unittests/UnwindAssembly/CMakeLists.txt
@@ -1,2 +1,5 @@
-add_subdirectory(x86)
+if ("X86" IN_LIST LLVM_TARGETS_TO_BUILD)
+  add_subdirectory(x86)
+endif()
+
 add_subdirectory(InstEmulation)


Index: unittests/UnwindAssembly/InstEmulation/CMakeLists.txt
===
--- unittests/UnwindAssembly/InstEmulation/CMakeLists.txt
+++ unittests/UnwindAssembly/InstEmulation/CMakeLists.txt
@@ -1 +1,3 @@
-add_lldb_unittest(InstEmulationTests TestArm64InstEmulation.cpp)
+if ("AArch64" IN_LIST LLVM_TARGETS_TO_BUILD)
+  add_lldb_unittest(InstEmulationTests TestArm64InstEmulation.cpp)
+endif()
Index: unittests/UnwindAssembly/CMakeLists.txt
===
--- unittests/UnwindAssembly/CMakeLists.txt
+++ unittests/UnwindAssembly/CMakeLists.txt
@@ -1,2 +1,5 @@
-add_subdirectory(x86)
+if ("X86" IN_LIST LLVM_TARGETS_TO_BUILD)
+  add_subdirectory(x86)
+endif()
+
 add_subdirectory(InstEmulation)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r286093 - [lldb] Fix -Waggressive-loop-optimizations warning

2016-11-06 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Sun Nov  6 20:39:37 2016
New Revision: 286093

URL: http://llvm.org/viewvc/llvm-project?rev=286093&view=rev
Log:
[lldb] Fix -Waggressive-loop-optimizations warning

We shouldn't access past the end of an array, even if we think that the
layout of the struct containing the array is always what we expect. The
compiler is free to optimize away the stores as undefined behavior, and
in fact, GCC 6.2.1 claims it will do exactly this.

Modified:
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=286093&r1=286092&r2=286093&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Sun Nov  6 
20:39:37 2016
@@ -667,8 +667,12 @@ public:
 // x0-x29 + fp + lr + sp + pc (== 33 64-bit registers) plus cpsr (1
 // 32-bit register)
 if (count >= (33 * 2) + 1) {
-  for (uint32_t i = 0; i < 33; ++i)
+  for (uint32_t i = 0; i < 29; ++i)
 gpr.x[i] = data.GetU64(&offset);
+  gpr.fp = data.GetU64(&offset);
+  gpr.lr = data.GetU64(&offset);
+  gpr.sp = data.GetU64(&offset);
+  gpr.pc = data.GetU64(&offset);
   gpr.cpsr = data.GetU32(&offset);
   SetError(GPRRegSet, Read, 0);
 }


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