summaryrefslogtreecommitdiffstats
path: root/include/clang/Basic/PartialDiagnostic.h
diff options
context:
space:
mode:
authorEugene Zelenko <eugene.zelenko@gmail.com>2018-02-16 23:40:07 +0000
committerEugene Zelenko <eugene.zelenko@gmail.com>2018-02-16 23:40:07 +0000
commit53d982bea4e15405c228fd90afc486c36d71feed (patch)
tree4a4ce5ae8875d3783abf5947334045a5220be375 /include/clang/Basic/PartialDiagnostic.h
parent4735edbbaf28ced185e76223b39ab4f0141186e3 (diff)
[Basic] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325412 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/PartialDiagnostic.h')
-rw-r--r--include/clang/Basic/PartialDiagnostic.h60
1 files changed, 32 insertions, 28 deletions
diff --git a/include/clang/Basic/PartialDiagnostic.h b/include/clang/Basic/PartialDiagnostic.h
index b2f14afe56..dffeaee8e2 100644
--- a/include/clang/Basic/PartialDiagnostic.h
+++ b/include/clang/Basic/PartialDiagnostic.h
@@ -1,4 +1,4 @@
-//===--- PartialDiagnostic.h - Diagnostic "closures" ------------*- C++ -*-===//
+//===- PartialDiagnostic.h - Diagnostic "closures" --------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -6,25 +6,32 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-///
+//
/// \file
/// \brief Implements a partial diagnostic that can be emitted anwyhere
/// in a DiagnosticBuilder stream.
-///
+//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_BASIC_PARTIALDIAGNOSTIC_H
#define LLVM_CLANG_BASIC_PARTIALDIAGNOSTIC_H
#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/LLVM.h"
#include "clang/Basic/SourceLocation.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/Support/Compiler.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
#include <cassert>
+#include <cstdint>
+#include <string>
+#include <type_traits>
+#include <utility>
namespace clang {
+class DeclContext;
+class IdentifierInfo;
+
class PartialDiagnostic {
public:
enum {
@@ -36,8 +43,6 @@ public:
};
struct Storage {
- Storage() : NumDiagArgs(0) { }
-
enum {
/// \brief The maximum number of arguments we can hold. We
/// currently only support up to 10 arguments (%0-%9).
@@ -48,7 +53,7 @@ public:
};
/// \brief The number of entries in Arguments.
- unsigned char NumDiagArgs;
+ unsigned char NumDiagArgs = 0;
/// \brief Specifies for each argument whether it is in DiagArgumentsStr
/// or in DiagArguments.
@@ -71,6 +76,8 @@ public:
/// \brief If valid, provides a hint with some code to insert, remove, or
/// modify at a particular position.
SmallVector<FixItHint, 6> FixItHints;
+
+ Storage() = default;
};
/// \brief An allocator for Storage objects, which uses a small cache to
@@ -114,13 +121,13 @@ private:
// in the new location.
/// \brief The diagnostic ID.
- mutable unsigned DiagID;
+ mutable unsigned DiagID = 0;
/// \brief Storage for args and ranges.
- mutable Storage *DiagStorage;
+ mutable Storage *DiagStorage = nullptr;
/// \brief Allocator used to allocate storage for this diagnostic.
- StorageAllocator *Allocator;
+ StorageAllocator *Allocator = nullptr;
/// \brief Retrieve storage for this particular diagnostic.
Storage *getStorage() const {
@@ -176,17 +183,16 @@ private:
public:
struct NullDiagnostic {};
+
/// \brief Create a null partial diagnostic, which cannot carry a payload,
/// and only exists to be swapped with a real partial diagnostic.
- PartialDiagnostic(NullDiagnostic)
- : DiagID(0), DiagStorage(nullptr), Allocator(nullptr) { }
+ PartialDiagnostic(NullDiagnostic) {}
PartialDiagnostic(unsigned DiagID, StorageAllocator &Allocator)
- : DiagID(DiagID), DiagStorage(nullptr), Allocator(&Allocator) { }
+ : DiagID(DiagID), Allocator(&Allocator) {}
PartialDiagnostic(const PartialDiagnostic &Other)
- : DiagID(Other.DiagID), DiagStorage(nullptr), Allocator(Other.Allocator)
- {
+ : DiagID(Other.DiagID), Allocator(Other.Allocator) {
if (Other.DiagStorage) {
DiagStorage = getStorage();
*DiagStorage = *Other.DiagStorage;
@@ -194,22 +200,20 @@ public:
}
PartialDiagnostic(PartialDiagnostic &&Other)
- : DiagID(Other.DiagID), DiagStorage(Other.DiagStorage),
- Allocator(Other.Allocator) {
+ : DiagID(Other.DiagID), DiagStorage(Other.DiagStorage),
+ Allocator(Other.Allocator) {
Other.DiagStorage = nullptr;
}
PartialDiagnostic(const PartialDiagnostic &Other, Storage *DiagStorage)
- : DiagID(Other.DiagID), DiagStorage(DiagStorage),
- Allocator(reinterpret_cast<StorageAllocator *>(~uintptr_t(0)))
- {
+ : DiagID(Other.DiagID), DiagStorage(DiagStorage),
+ Allocator(reinterpret_cast<StorageAllocator *>(~uintptr_t(0))) {
if (Other.DiagStorage)
*this->DiagStorage = *Other.DiagStorage;
}
PartialDiagnostic(const Diagnostic &Other, StorageAllocator &Allocator)
- : DiagID(Other.getID()), DiagStorage(nullptr), Allocator(&Allocator)
- {
+ : DiagID(Other.getID()), Allocator(&Allocator) {
// Copy arguments.
for (unsigned I = 0, N = Other.getNumArgs(); I != N; ++I) {
if (Other.getArgKind(I) == DiagnosticsEngine::ak_std_string)
@@ -402,7 +406,6 @@ public:
PD.AddFixItHint(Hint);
return PD;
}
-
};
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
@@ -413,7 +416,8 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
/// \brief A partial diagnostic along with the source location where this
/// diagnostic occurs.
-typedef std::pair<SourceLocation, PartialDiagnostic> PartialDiagnosticAt;
+using PartialDiagnosticAt = std::pair<SourceLocation, PartialDiagnostic>;
+
+} // namespace clang
-} // end namespace clang
-#endif
+#endif // LLVM_CLANG_BASIC_PARTIALDIAGNOSTIC_H