Commit 2a81a516 authored by pugixml Upstream's avatar pugixml Upstream Committed by Atkins, Charles Vernon
Browse files

pugixml 2018-03-16 (cec32da2)

Code extracted from:

    https://github.com/zeux/pugixml.git

at commit cec32da2b5ea03066baff55810f7e8f30960b10d (master).

Upstream Shortlog
-----------------

Arseny Kapoulkine (11):
      3f28a5d9 Update all copyright notices to specify year 2018
      19549418 build: Add clang/Linux builds to Travis
      2ec3579f Work around gcc issues with limits.h not defining LLONG_MIN
      b127cfb1 Fix Texas Instruments compiler warning
      655bc825 docs: Add preliminary 1.9 changelog
      951c8f15 Refactor noexcept macros
      15fdb838 ubsan: Fix type mismatch in compact mode for document data
      9540016f ubsan: Fix type mismatch for xml_extra_buffer in compact mode
      e50672cf ubsan: Fix undefined behavior for signed left shift in compact mode
      fe7b8378 tests: Fix PUGIXML_COMPACT+PUGIXML_WCHAR_MODE tests
      cec32da2 docs: Update changelog

Ben Boeckel (2):
      0df7adb6 cmake: set the minimum version before the project call
      7fcfb72d cmake: keep sources and headers separate

Brandl, Matthäus (MBR) (1):
      b8d1d07a Enables usage of override specifier for MSVC compilers (beginning with 17.0 which is the compiler of Visual Studio 2012)

Matthäus Brandl (2):
      8284dbf6 Add noexcept specifiers to move special members where possible (#183)
      9187e650 Adds noexcept specifiers to the move special members of xml_document,… (#185)
parent 7b3c2bc2
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
/**
 * pugixml parser - version 1.8
 * --------------------------------------------------------
 * Copyright (C) 2006-2017, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
 * Copyright (C) 2006-2018, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
 * Report bugs and download new versions at http://pugixml.org/
 *
 * This library is distributed under the MIT License. See notice at the end
@@ -49,7 +49,7 @@
#endif

/**
 * Copyright (c) 2006-2017 Arseny Kapoulkine
 * Copyright (c) 2006-2018 Arseny Kapoulkine
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
+32 −21
Original line number Diff line number Diff line
/**
 * pugixml parser - version 1.8
 * --------------------------------------------------------
 * Copyright (C) 2006-2017, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
 * Copyright (C) 2006-2018, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
 * Report bugs and download new versions at http://pugixml.org/
 *
 * This library is distributed under the MIT License. See notice at the end
@@ -76,6 +76,10 @@
#	pragma diag_suppress=237 // controlling expression is constant
#endif

#ifdef __TI_COMPILER_VERSION__
#	pragma diag_suppress 179 // function was declared but never referenced
#endif

// Inlining controls
#if defined(_MSC_VER) && _MSC_VER >= 1300
#	define PUGI__NO_INLINE __declspec(noinline)
@@ -120,11 +124,11 @@ using std::memmove;
using std::memset;
#endif

// Some MinGW versions have headers that erroneously omit LLONG_MIN/LLONG_MAX/ULLONG_MAX definitions in strict ANSI mode
#if defined(PUGIXML_HAS_LONG_LONG) && defined(__MINGW32__) && defined(__STRICT_ANSI__) && !defined(LLONG_MAX) && !defined(LLONG_MIN) && !defined(ULLONG_MAX)
#	define LLONG_MAX 9223372036854775807LL
#	define LLONG_MIN (-LLONG_MAX-1)
#	define ULLONG_MAX (2ULL*LLONG_MAX+1)
// Some MinGW/GCC versions have headers that erroneously omit LLONG_MIN/LLONG_MAX/ULLONG_MAX definitions from limits.h in some configurations
#if defined(PUGIXML_HAS_LONG_LONG) && defined(__GNUC__) && !defined(LLONG_MAX) && !defined(LLONG_MIN) && !defined(ULLONG_MAX)
#	define LLONG_MIN (-LLONG_MAX - 1LL)
#	define LLONG_MAX __LONG_LONG_MAX__
#	define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
#endif

// In some environments MSVC is a compiler but the CRT lacks certain MSVC-specific features
@@ -848,7 +852,7 @@ PUGI__NS_BEGIN
				{
					uintptr_t base = reinterpret_cast<uintptr_t>(this) & ~(compact_alignment - 1);

					return reinterpret_cast<T*>(base + ((_data - 1 + start) << compact_alignment_log2));
					return reinterpret_cast<T*>(base + (_data - 1 + start) * compact_alignment);
				}
				else
					return compact_get_value<header_offset, T>(this);
@@ -926,7 +930,7 @@ PUGI__NS_BEGIN
				{
					uintptr_t base = reinterpret_cast<uintptr_t>(this) & ~(compact_alignment - 1);

					return reinterpret_cast<T*>(base + ((_data - 1 - 65533) << compact_alignment_log2));
					return reinterpret_cast<T*>(base + (_data - 1 - 65533) * compact_alignment);
				}
				else if (_data == 65534)
					return static_cast<T*>(compact_get_page(this, header_offset)->compact_shared_parent);
@@ -6072,11 +6076,17 @@ namespace pugi

		// get extra buffer element (we'll store the document fragment buffer there so that we can deallocate it later)
		impl::xml_memory_page* page = 0;
		impl::xml_extra_buffer* extra = static_cast<impl::xml_extra_buffer*>(doc->allocate_memory(sizeof(impl::xml_extra_buffer), page));
		impl::xml_extra_buffer* extra = static_cast<impl::xml_extra_buffer*>(doc->allocate_memory(sizeof(impl::xml_extra_buffer) + sizeof(void*), page));
		(void)page;

		if (!extra) return impl::make_parse_result(status_out_of_memory);

	#ifdef PUGIXML_COMPACT
		// align the memory block to a pointer boundary; this is required for compact mode where memory allocations are only 4b aligned
		// note that this requires up to sizeof(void*)-1 additional memory, which the allocation above takes into account
		extra = reinterpret_cast<impl::xml_extra_buffer*>((reinterpret_cast<uintptr_t>(extra) + (sizeof(void*) - 1)) & ~(sizeof(void*) - 1));
	#endif

		// add extra buffer to the list
		extra->buffer = 0;
		extra->next = doc->extra_buffers;
@@ -6834,13 +6844,13 @@ namespace pugi
	}

#ifdef PUGIXML_HAS_MOVE
	PUGI__FN xml_document::xml_document(xml_document&& rhs): _buffer(0)
	PUGI__FN xml_document::xml_document(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT: _buffer(0)
	{
		_create();
		_move(rhs);
	}

	PUGI__FN xml_document& xml_document::operator=(xml_document&& rhs)
	PUGI__FN xml_document& xml_document::operator=(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT
	{
		if (this == &rhs) return *this;

@@ -6871,7 +6881,8 @@ namespace pugi
		assert(!_root);

	#ifdef PUGIXML_COMPACT
		const size_t page_offset = sizeof(uint32_t);
		// space for page marker for the first page (uint32_t), rounded up to pointer size; assumes pointers are at least 32-bit
		const size_t page_offset = sizeof(void*);
	#else
		const size_t page_offset = 0;
	#endif
@@ -6948,7 +6959,7 @@ namespace pugi
	}

#ifdef PUGIXML_HAS_MOVE
	PUGI__FN void xml_document::_move(xml_document& rhs)
	PUGI__FN void xml_document::_move(xml_document& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT
	{
		impl::xml_document_struct* doc = static_cast<impl::xml_document_struct*>(_root);
		impl::xml_document_struct* other = static_cast<impl::xml_document_struct*>(rhs._root);
@@ -12040,7 +12051,7 @@ namespace pugi
	}

#ifdef PUGIXML_HAS_MOVE
	PUGI__FN void xpath_node_set::_move(xpath_node_set& rhs)
	PUGI__FN void xpath_node_set::_move(xpath_node_set& rhs) PUGIXML_NOEXCEPT
	{
		_type = rhs._type;
		_storage = rhs._storage;
@@ -12083,12 +12094,12 @@ namespace pugi
	}

#ifdef PUGIXML_HAS_MOVE
	PUGI__FN xpath_node_set::xpath_node_set(xpath_node_set&& rhs): _type(type_unsorted), _begin(&_storage), _end(&_storage)
	PUGI__FN xpath_node_set::xpath_node_set(xpath_node_set&& rhs) PUGIXML_NOEXCEPT: _type(type_unsorted), _begin(&_storage), _end(&_storage)
	{
		_move(rhs);
	}

	PUGI__FN xpath_node_set& xpath_node_set::operator=(xpath_node_set&& rhs)
	PUGI__FN xpath_node_set& xpath_node_set::operator=(xpath_node_set&& rhs) PUGIXML_NOEXCEPT
	{
		if (this == &rhs) return *this;

@@ -12283,7 +12294,7 @@ namespace pugi
	}

#ifdef PUGIXML_HAS_MOVE
	PUGI__FN xpath_variable_set::xpath_variable_set(xpath_variable_set&& rhs)
	PUGI__FN xpath_variable_set::xpath_variable_set(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT
	{
		for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i)
		{
@@ -12292,7 +12303,7 @@ namespace pugi
		}
	}

	PUGI__FN xpath_variable_set& xpath_variable_set::operator=(xpath_variable_set&& rhs)
	PUGI__FN xpath_variable_set& xpath_variable_set::operator=(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT
	{
		for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i)
		{
@@ -12486,7 +12497,7 @@ namespace pugi
	}

#ifdef PUGIXML_HAS_MOVE
	PUGI__FN xpath_query::xpath_query(xpath_query&& rhs)
	PUGI__FN xpath_query::xpath_query(xpath_query&& rhs) PUGIXML_NOEXCEPT
	{
		_impl = rhs._impl;
		_result = rhs._result;
@@ -12494,7 +12505,7 @@ namespace pugi
		rhs._result = xpath_parse_result();
	}

	PUGI__FN xpath_query& xpath_query::operator=(xpath_query&& rhs)
	PUGI__FN xpath_query& xpath_query::operator=(xpath_query&& rhs) PUGIXML_NOEXCEPT
	{
		if (this == &rhs) return *this;

@@ -12759,7 +12770,7 @@ namespace pugi
#endif

/**
 * Copyright (c) 2006-2017 Arseny Kapoulkine
 * Copyright (c) 2006-2018 Arseny Kapoulkine
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
+32 −12
Original line number Diff line number Diff line
/**
 * pugixml parser - version 1.8
 * --------------------------------------------------------
 * Copyright (C) 2006-2017, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
 * Copyright (C) 2006-2018, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
 * Report bugs and download new versions at http://pugixml.org/
 *
 * This library is distributed under the MIT License. See notice at the end
@@ -81,10 +81,30 @@
#	endif
#endif

// If C++ is 2011 or higher, add 'noexcept' specifiers
#ifndef PUGIXML_NOEXCEPT
#	if __cplusplus >= 201103
#		define PUGIXML_NOEXCEPT noexcept
#	elif defined(_MSC_VER) && _MSC_VER >= 1900
#		define PUGIXML_NOEXCEPT noexcept
#	else
#		define PUGIXML_NOEXCEPT
#	endif
#endif

// Some functions can not be noexcept in compact mode
#ifdef PUGIXML_COMPACT
#	define PUGIXML_NOEXCEPT_IF_NOT_COMPACT
#else
#	define PUGIXML_NOEXCEPT_IF_NOT_COMPACT PUGIXML_NOEXCEPT
#endif

// If C++ is 2011 or higher, add 'override' qualifiers
#ifndef PUGIXML_OVERRIDE
#	if __cplusplus >= 201103
#		define PUGIXML_OVERRIDE override
#	elif defined(_MSC_VER) && _MSC_VER >= 1700
#		define PUGIXML_OVERRIDE override
#	else
#		define PUGIXML_OVERRIDE
#	endif
@@ -983,7 +1003,7 @@ namespace pugi

		void _create();
		void _destroy();
		void _move(xml_document& rhs);
		void _move(xml_document& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT;

	public:
		// Default constructor, makes empty document
@@ -994,8 +1014,8 @@ namespace pugi

	#ifdef PUGIXML_HAS_MOVE
		// Move semantics support
		xml_document(xml_document&& rhs);
		xml_document& operator=(xml_document&& rhs);
		xml_document(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT;
		xml_document& operator=(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT;
	#endif

		// Removes all nodes, leaving the empty document
@@ -1138,8 +1158,8 @@ namespace pugi

	#ifdef PUGIXML_HAS_MOVE
		// Move semantics support
		xpath_variable_set(xpath_variable_set&& rhs);
		xpath_variable_set& operator=(xpath_variable_set&& rhs);
		xpath_variable_set(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT;
		xpath_variable_set& operator=(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT;
	#endif

		// Add a new variable or get the existing one, if the types match
@@ -1182,8 +1202,8 @@ namespace pugi

	#ifdef PUGIXML_HAS_MOVE
		// Move semantics support
		xpath_query(xpath_query&& rhs);
		xpath_query& operator=(xpath_query&& rhs);
		xpath_query(xpath_query&& rhs) PUGIXML_NOEXCEPT;
		xpath_query& operator=(xpath_query&& rhs) PUGIXML_NOEXCEPT;
	#endif

		// Get query expression return type
@@ -1323,8 +1343,8 @@ namespace pugi

	#ifdef PUGIXML_HAS_MOVE
		// Move semantics support
		xpath_node_set(xpath_node_set&& rhs);
		xpath_node_set& operator=(xpath_node_set&& rhs);
		xpath_node_set(xpath_node_set&& rhs) PUGIXML_NOEXCEPT;
		xpath_node_set& operator=(xpath_node_set&& rhs) PUGIXML_NOEXCEPT;
	#endif

		// Get collection type
@@ -1358,7 +1378,7 @@ namespace pugi
		xpath_node* _end;

		void _assign(const_iterator begin, const_iterator end, type_t type);
		void _move(xpath_node_set& rhs);
		void _move(xpath_node_set& rhs) PUGIXML_NOEXCEPT;
	};
#endif

@@ -1416,7 +1436,7 @@ namespace std
#endif

/**
 * Copyright (c) 2006-2017 Arseny Kapoulkine
 * Copyright (c) 2006-2018 Arseny Kapoulkine
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation