Skip to content

Commit 37b0f58

Browse files
committed
[Diagnostics] Rely on clang headers for .dia block and record IDs
1 parent 7d2f944 commit 37b0f58

File tree

1 file changed

+5
-37
lines changed

1 file changed

+5
-37
lines changed

lib/Frontend/SerializedDiagnosticConsumer.cpp

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -14,6 +14,8 @@
1414
//
1515
//===----------------------------------------------------------------------===//
1616

17+
#include "clang/Frontend/SerializedDiagnostics.h"
18+
1719
#include "swift/Frontend/SerializedDiagnosticConsumer.h"
1820
#include "swift/AST/DiagnosticConsumer.h"
1921
#include "swift/AST/DiagnosticsFrontend.h"
@@ -30,39 +32,8 @@
3032
#include "llvm/ADT/SmallString.h"
3133
#include "llvm/Bitstream/BitstreamWriter.h"
3234

33-
// For constant values only.
34-
#include "clang/Frontend/SerializedDiagnosticPrinter.h"
35-
3635
using namespace swift;
37-
38-
//===----------------------------------------------------------------------===//
39-
// These must match Clang's diagnostic IDs. We can consider sharing the
40-
// header files to avoid this copy-paste.
41-
//===----------------------------------------------------------------------===//
42-
43-
enum BlockIDs {
44-
/// A top-level block which represents any meta data associated
45-
/// with the diagnostics, including versioning of the format.
46-
BLOCK_META = llvm::bitc::FIRST_APPLICATION_BLOCKID,
47-
48-
/// The this block acts as a container for all the information
49-
/// for a specific diagnostic.
50-
BLOCK_DIAG
51-
};
52-
53-
enum RecordIDs {
54-
RECORD_VERSION = 1,
55-
RECORD_DIAG,
56-
RECORD_SOURCE_RANGE,
57-
RECORD_DIAG_FLAG,
58-
RECORD_CATEGORY,
59-
RECORD_FILENAME,
60-
RECORD_FIXIT,
61-
RECORD_FIRST = RECORD_VERSION,
62-
RECORD_LAST = RECORD_FIXIT
63-
};
64-
65-
//===----------------------------------------------------------------------===//
36+
using namespace clang::serialized_diags;
6637

6738
namespace {
6839
class AbbreviationMap {
@@ -193,9 +164,6 @@ class SerializedDiagnosticConsumer : public DiagnosticConsumer {
193164

194165
void handleDiagnostic(SourceManager &SM, const DiagnosticInfo &Info) override;
195166

196-
/// The version of the diagnostics file.
197-
enum { Version = 1 };
198-
199167
private:
200168
/// Emit bitcode for the preamble.
201169
void emitPreamble();
@@ -334,7 +302,7 @@ void SerializedDiagnosticConsumer::emitMetaBlock() {
334302
Stream.EnterSubblock(BLOCK_META, 3);
335303
Record.clear();
336304
Record.push_back(RECORD_VERSION);
337-
Record.push_back(Version);
305+
Record.push_back(clang::serialized_diags::VersionNumber);
338306
Stream.EmitRecordWithAbbrev(Abbrevs.get(RECORD_VERSION), Record);
339307
Stream.ExitBlock();
340308
}

0 commit comments

Comments
 (0)