[Lldb-commits] [lldb] 4b15c6e - [lldb/Host] Use cmakedefine01 for LLDB_ENABLE_LIBXML2
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Thu Dec 12 09:29:02 PST 2019
Author: Jonas Devlieghere
Date: 2019-12-12T09:28:56-08:00
New Revision: 4b15c6e2a15f9d1d7c2586af8a7811e7b43ac799
URL: https://github.com/llvm/llvm-project/commit/4b15c6e2a15f9d1d7c2586af8a7811e7b43ac799
DIFF: https://github.com/llvm/llvm-project/commit/4b15c6e2a15f9d1d7c2586af8a7811e7b43ac799.diff
LOG: [lldb/Host] Use cmakedefine01 for LLDB_ENABLE_LIBXML2
This keeps things consistent with out other optional dependencies. But
more importantly it won't silently fail when you forget to include
Config.h.
Added:
Modified:
lldb/include/lldb/Host/Config.h.cmake
lldb/include/lldb/Host/XML.h
lldb/source/Host/common/XML.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Host/Config.h.cmake b/lldb/include/lldb/Host/Config.h.cmake
index eaa5404ce744..7f0588a12f26 100644
--- a/lldb/include/lldb/Host/Config.h.cmake
+++ b/lldb/include/lldb/Host/Config.h.cmake
@@ -39,7 +39,7 @@
#cmakedefine01 LLDB_ENABLE_LIBEDIT
-#cmakedefine LLDB_ENABLE_LIBXML2
+#cmakedefine01 LLDB_ENABLE_LIBXML2
#cmakedefine LLDB_DISABLE_PYTHON
diff --git a/lldb/include/lldb/Host/XML.h b/lldb/include/lldb/Host/XML.h
index 38754539d5a4..ca51d304dc8f 100644
--- a/lldb/include/lldb/Host/XML.h
+++ b/lldb/include/lldb/Host/XML.h
@@ -11,7 +11,7 @@
#include "lldb/Host/Config.h"
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
#include <libxml/xmlreader.h>
#endif
@@ -27,7 +27,7 @@
namespace lldb_private {
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
typedef xmlNodePtr XMLNodeImpl;
typedef xmlDocPtr XMLDocumentImpl;
#else
diff --git a/lldb/source/Host/common/XML.cpp b/lldb/source/Host/common/XML.cpp
index 4289117ff932..28d1f5a8eaf4 100644
--- a/lldb/source/Host/common/XML.cpp
+++ b/lldb/source/Host/common/XML.cpp
@@ -22,7 +22,7 @@ XMLDocument::XMLDocument() : m_document(nullptr) {}
XMLDocument::~XMLDocument() { Clear(); }
void XMLDocument::Clear() {
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
if (m_document) {
xmlDocPtr doc = m_document;
m_document = nullptr;
@@ -43,7 +43,7 @@ void XMLDocument::ErrorCallback(void *ctx, const char *format, ...) {
}
bool XMLDocument::ParseFile(const char *path) {
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
Clear();
xmlSetGenericErrorFunc((void *)this, XMLDocument::ErrorCallback);
m_document = xmlParseFile(path);
@@ -54,7 +54,7 @@ bool XMLDocument::ParseFile(const char *path) {
bool XMLDocument::ParseMemory(const char *xml, size_t xml_length,
const char *url) {
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
Clear();
xmlSetGenericErrorFunc((void *)this, XMLDocument::ErrorCallback);
m_document = xmlReadMemory(xml, (int)xml_length, url, nullptr, 0);
@@ -64,7 +64,7 @@ bool XMLDocument::ParseMemory(const char *xml, size_t xml_length,
}
XMLNode XMLDocument::GetRootElement(const char *required_name) {
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
if (IsValid()) {
XMLNode root_node(xmlDocGetRootElement(m_document));
if (required_name) {
@@ -82,7 +82,7 @@ XMLNode XMLDocument::GetRootElement(const char *required_name) {
llvm::StringRef XMLDocument::GetErrors() const { return m_errors.GetString(); }
bool XMLDocument::XMLEnabled() {
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
return true;
#else
return false;
@@ -100,7 +100,7 @@ XMLNode::~XMLNode() {}
void XMLNode::Clear() { m_node = nullptr; }
XMLNode XMLNode::GetParent() const {
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
if (IsValid())
return XMLNode(m_node->parent);
else
@@ -111,7 +111,7 @@ XMLNode XMLNode::GetParent() const {
}
XMLNode XMLNode::GetSibling() const {
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
if (IsValid())
return XMLNode(m_node->next);
else
@@ -122,7 +122,7 @@ XMLNode XMLNode::GetSibling() const {
}
XMLNode XMLNode::GetChild() const {
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
if (IsValid())
return XMLNode(m_node->children);
@@ -136,7 +136,7 @@ XMLNode XMLNode::GetChild() const {
llvm::StringRef XMLNode::GetAttributeValue(const char *name,
const char *fail_value) const {
const char *attr_value = nullptr;
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
if (IsValid())
attr_value = (const char *)xmlGetProp(m_node, (const xmlChar *)name);
@@ -153,7 +153,7 @@ llvm::StringRef XMLNode::GetAttributeValue(const char *name,
bool XMLNode::GetAttributeValueAsUnsigned(const char *name, uint64_t &value,
uint64_t fail_value, int base) const {
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
llvm::StringRef str_value = GetAttributeValue(name, "");
#else
llvm::StringRef str_value;
@@ -164,14 +164,14 @@ bool XMLNode::GetAttributeValueAsUnsigned(const char *name, uint64_t &value,
}
void XMLNode::ForEachChildNode(NodeCallback const &callback) const {
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
if (IsValid())
GetChild().ForEachSiblingNode(callback);
#endif
}
void XMLNode::ForEachChildElement(NodeCallback const &callback) const {
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
XMLNode child = GetChild();
if (child)
child.ForEachSiblingElement(callback);
@@ -180,7 +180,7 @@ void XMLNode::ForEachChildElement(NodeCallback const &callback) const {
void XMLNode::ForEachChildElementWithName(const char *name,
NodeCallback const &callback) const {
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
XMLNode child = GetChild();
if (child)
child.ForEachSiblingElementWithName(name, callback);
@@ -188,7 +188,7 @@ void XMLNode::ForEachChildElementWithName(const char *name,
}
void XMLNode::ForEachAttribute(AttributeCallback const &callback) const {
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
if (IsValid()) {
for (xmlAttrPtr attr = m_node->properties; attr != nullptr;
@@ -211,7 +211,7 @@ void XMLNode::ForEachAttribute(AttributeCallback const &callback) const {
}
void XMLNode::ForEachSiblingNode(NodeCallback const &callback) const {
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
if (IsValid()) {
// iterate through all siblings
@@ -224,7 +224,7 @@ void XMLNode::ForEachSiblingNode(NodeCallback const &callback) const {
}
void XMLNode::ForEachSiblingElement(NodeCallback const &callback) const {
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
if (IsValid()) {
// iterate through all siblings
@@ -242,7 +242,7 @@ void XMLNode::ForEachSiblingElement(NodeCallback const &callback) const {
void XMLNode::ForEachSiblingElementWithName(
const char *name, NodeCallback const &callback) const {
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
if (IsValid()) {
// iterate through all siblings
@@ -270,7 +270,7 @@ void XMLNode::ForEachSiblingElementWithName(
}
llvm::StringRef XMLNode::GetName() const {
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
if (IsValid()) {
if (m_node->name)
return llvm::StringRef((const char *)m_node->name);
@@ -281,7 +281,7 @@ llvm::StringRef XMLNode::GetName() const {
bool XMLNode::GetElementText(std::string &text) const {
text.clear();
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
if (IsValid()) {
bool success = false;
if (m_node->type == XML_ELEMENT_NODE) {
@@ -303,7 +303,7 @@ bool XMLNode::GetElementText(std::string &text) const {
bool XMLNode::GetElementTextAsUnsigned(uint64_t &value, uint64_t fail_value,
int base) const {
bool success = false;
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
if (IsValid()) {
std::string text;
if (GetElementText(text))
@@ -317,7 +317,7 @@ bool XMLNode::GetElementTextAsUnsigned(uint64_t &value, uint64_t fail_value,
bool XMLNode::GetElementTextAsFloat(double &value, double fail_value) const {
bool success = false;
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
if (IsValid()) {
std::string text;
if (GetElementText(text)) {
@@ -332,7 +332,7 @@ bool XMLNode::GetElementTextAsFloat(double &value, double fail_value) const {
}
bool XMLNode::NameIs(const char *name) const {
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
if (IsValid()) {
// In case we are looking for a nullptr name or an exact pointer match
@@ -348,7 +348,7 @@ bool XMLNode::NameIs(const char *name) const {
XMLNode XMLNode::FindFirstChildElementWithName(const char *name) const {
XMLNode result_node;
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
ForEachChildElementWithName(
name, [&result_node](const XMLNode &node) -> bool {
result_node = node;
@@ -363,7 +363,7 @@ XMLNode XMLNode::FindFirstChildElementWithName(const char *name) const {
bool XMLNode::IsValid() const { return m_node != nullptr; }
bool XMLNode::IsElement() const {
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
if (IsValid())
return m_node->type == XML_ELEMENT_NODE;
#endif
@@ -371,7 +371,7 @@ bool XMLNode::IsElement() const {
}
XMLNode XMLNode::GetElementForPath(const NamePath &path) {
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
if (IsValid()) {
if (path.empty())
@@ -431,7 +431,7 @@ bool ApplePropertyList::GetValueAsString(const char *key,
XMLNode ApplePropertyList::GetValueNode(const char *key) const {
XMLNode value_node;
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
if (IsValid()) {
m_dict_node.ForEachChildElementWithName(
@@ -455,7 +455,7 @@ XMLNode ApplePropertyList::GetValueNode(const char *key) const {
bool ApplePropertyList::ExtractStringFromValueNode(const XMLNode &node,
std::string &value) {
value.clear();
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
if (node.IsValid()) {
llvm::StringRef element_name = node.GetName();
if (element_name == "true" || element_name == "false") {
@@ -471,7 +471,7 @@ bool ApplePropertyList::ExtractStringFromValueNode(const XMLNode &node,
return false;
}
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
namespace {
@@ -533,7 +533,7 @@ StructuredData::ObjectSP CreatePlistValue(XMLNode node) {
StructuredData::ObjectSP ApplePropertyList::GetStructuredData() {
StructuredData::ObjectSP root_sp;
-#if defined(LLDB_ENABLE_LIBXML2)
+#if LLDB_ENABLE_LIBXML2
if (IsValid()) {
return CreatePlistValue(m_dict_node);
}
More information about the lldb-commits
mailing list