summaryrefslogtreecommitdiff
path: root/gnu/llvm/clang/tools/diagtool
diff options
context:
space:
mode:
authorRobert Nagy <robert@cvs.openbsd.org>2023-11-11 18:17:06 +0000
committerRobert Nagy <robert@cvs.openbsd.org>2023-11-11 18:17:06 +0000
commita388acc7d111eece16e7c46f357872ec47588443 (patch)
treea636add3cb3f4afb8c45bb8302545f79f9e37d37 /gnu/llvm/clang/tools/diagtool
parent77976eff798a4c323c3194ff91190574c44d047d (diff)
import of clang from LLVM-16.0.6
Diffstat (limited to 'gnu/llvm/clang/tools/diagtool')
-rw-r--r--gnu/llvm/clang/tools/diagtool/DiagTool.cpp1
-rw-r--r--gnu/llvm/clang/tools/diagtool/DiagnosticNames.cpp15
-rw-r--r--gnu/llvm/clang/tools/diagtool/FindDiagnosticID.cpp9
-rw-r--r--gnu/llvm/clang/tools/diagtool/ShowEnabledWarnings.cpp7
-rw-r--r--gnu/llvm/clang/tools/diagtool/TreeView.cpp6
5 files changed, 19 insertions, 19 deletions
diff --git a/gnu/llvm/clang/tools/diagtool/DiagTool.cpp b/gnu/llvm/clang/tools/diagtool/DiagTool.cpp
index 81d4e7e44cc..99abe5755f7 100644
--- a/gnu/llvm/clang/tools/diagtool/DiagTool.cpp
+++ b/gnu/llvm/clang/tools/diagtool/DiagTool.cpp
@@ -12,6 +12,7 @@
#include "DiagTool.h"
#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/STLExtras.h"
#include <vector>
using namespace diagtool;
diff --git a/gnu/llvm/clang/tools/diagtool/DiagnosticNames.cpp b/gnu/llvm/clang/tools/diagtool/DiagnosticNames.cpp
index c54f81481a2..852b8c226e8 100644
--- a/gnu/llvm/clang/tools/diagtool/DiagnosticNames.cpp
+++ b/gnu/llvm/clang/tools/diagtool/DiagnosticNames.cpp
@@ -20,16 +20,16 @@ static const DiagnosticRecord BuiltinDiagnosticsByName[] = {
};
llvm::ArrayRef<DiagnosticRecord> diagtool::getBuiltinDiagnosticsByName() {
- return llvm::makeArrayRef(BuiltinDiagnosticsByName);
+ return llvm::ArrayRef(BuiltinDiagnosticsByName);
}
// FIXME: Is it worth having two tables, especially when this one can get
// out of sync easily?
static const DiagnosticRecord BuiltinDiagnosticsByID[] = {
-#define DIAG(ENUM,CLASS,DEFAULT_MAPPING,DESC,GROUP, \
- SFINAE,NOWERROR,SHOWINSYSHEADER,DEFER,CATEGORY) \
- { #ENUM, diag::ENUM, STR_SIZE(#ENUM, uint8_t) },
+#define DIAG(ENUM, CLASS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
+ SHOWINSYSHEADER, SHOWINSYSMACRO, DEFER, CATEGORY) \
+ {#ENUM, diag::ENUM, STR_SIZE(#ENUM, uint8_t)},
#include "clang/Basic/DiagnosticCommonKinds.inc"
#include "clang/Basic/DiagnosticCrossTUKinds.inc"
#include "clang/Basic/DiagnosticDriverKinds.inc"
@@ -66,9 +66,10 @@ const DiagnosticRecord &diagtool::getDiagnosticForID(short DiagID) {
// Second the table of options, sorted by name for fast binary lookup.
static const GroupRecord OptionTable[] = {
-#define GET_DIAG_TABLE
+#define DIAG_ENTRY(GroupName, FlagNameOffset, Members, SubGroups, Docs) \
+ {FlagNameOffset, Members, SubGroups},
#include "clang/Basic/DiagnosticGroups.inc"
-#undef GET_DIAG_TABLE
+#undef DIAG_ENTRY
};
llvm::StringRef GroupRecord::getName() const {
@@ -102,5 +103,5 @@ GroupRecord::diagnostics() const {
}
llvm::ArrayRef<GroupRecord> diagtool::getDiagnosticGroups() {
- return llvm::makeArrayRef(OptionTable);
+ return llvm::ArrayRef(OptionTable);
}
diff --git a/gnu/llvm/clang/tools/diagtool/FindDiagnosticID.cpp b/gnu/llvm/clang/tools/diagtool/FindDiagnosticID.cpp
index 2a08814478f..6ced701f563 100644
--- a/gnu/llvm/clang/tools/diagtool/FindDiagnosticID.cpp
+++ b/gnu/llvm/clang/tools/diagtool/FindDiagnosticID.cpp
@@ -10,6 +10,7 @@
#include "DiagnosticNames.h"
#include "clang/Basic/AllDiagnostics.h"
#include "llvm/Support/CommandLine.h"
+#include <optional>
DEF_DIAGTOOL("find-diagnostic-id", "Print the id of the given diagnostic",
FindDiagnosticID)
@@ -26,14 +27,14 @@ static StringRef getNameFromID(StringRef Name) {
return StringRef();
}
-static Optional<DiagnosticRecord>
+static std::optional<DiagnosticRecord>
findDiagnostic(ArrayRef<DiagnosticRecord> Diagnostics, StringRef Name) {
for (const auto &Diag : Diagnostics) {
StringRef DiagName = Diag.getName();
if (DiagName == Name)
return Diag;
}
- return None;
+ return std::nullopt;
}
int FindDiagnosticID::run(unsigned int argc, char **argv,
@@ -47,7 +48,7 @@ int FindDiagnosticID::run(unsigned int argc, char **argv,
std::vector<const char *> Args;
Args.push_back("diagtool find-diagnostic-id");
- for (const char *A : llvm::makeArrayRef(argv, argc))
+ for (const char *A : llvm::ArrayRef(argv, argc))
Args.push_back(A);
llvm::cl::HideUnrelatedOptions(FindDiagnosticIDOptions);
@@ -55,7 +56,7 @@ int FindDiagnosticID::run(unsigned int argc, char **argv,
"Diagnostic ID mapping utility");
ArrayRef<DiagnosticRecord> AllDiagnostics = getBuiltinDiagnosticsByName();
- Optional<DiagnosticRecord> Diag =
+ std::optional<DiagnosticRecord> Diag =
findDiagnostic(AllDiagnostics, DiagnosticName);
if (!Diag) {
// Name to id failed, so try id to name.
diff --git a/gnu/llvm/clang/tools/diagtool/ShowEnabledWarnings.cpp b/gnu/llvm/clang/tools/diagtool/ShowEnabledWarnings.cpp
index ae2d3e37e84..285efe6ae05 100644
--- a/gnu/llvm/clang/tools/diagtool/ShowEnabledWarnings.cpp
+++ b/gnu/llvm/clang/tools/diagtool/ShowEnabledWarnings.cpp
@@ -59,15 +59,16 @@ createDiagnostics(unsigned int argc, char **argv) {
// Buffer diagnostics from argument parsing so that we can output them using a
// well formed diagnostic object.
TextDiagnosticBuffer *DiagsBuffer = new TextDiagnosticBuffer;
- IntrusiveRefCntPtr<DiagnosticsEngine> InterimDiags(
- new DiagnosticsEngine(DiagIDs, new DiagnosticOptions(), DiagsBuffer));
// Try to build a CompilerInvocation.
SmallVector<const char *, 4> Args;
Args.push_back("diagtool");
Args.append(argv, argv + argc);
+ CreateInvocationOptions CIOpts;
+ CIOpts.Diags =
+ new DiagnosticsEngine(DiagIDs, new DiagnosticOptions(), DiagsBuffer);
std::unique_ptr<CompilerInvocation> Invocation =
- createInvocationFromCommandLine(Args, InterimDiags);
+ createInvocation(Args, CIOpts);
if (!Invocation)
return nullptr;
diff --git a/gnu/llvm/clang/tools/diagtool/TreeView.cpp b/gnu/llvm/clang/tools/diagtool/TreeView.cpp
index 843bd377e57..92d92aa9069 100644
--- a/gnu/llvm/clang/tools/diagtool/TreeView.cpp
+++ b/gnu/llvm/clang/tools/diagtool/TreeView.cpp
@@ -40,11 +40,7 @@ public:
if (!Group.diagnostics().empty())
return false;
- for (const GroupRecord &GR : Group.subgroups())
- if (!unimplemented(GR))
- return false;
-
- return true;
+ return llvm::all_of(Group.subgroups(), unimplemented);
}
static bool enabledByDefault(const GroupRecord &Group) {