Skip to content

Commit 76221c7

Browse files
committed
Remove llvm::Error include form Diagnostic.h
Saves ~400 related LLVM ADT. llvm/ADT/Error.h takes 90ms to parse. $ diff -u <(sort thedeps-before.txt) <(sort thedeps-after.txt) \ | grep '^[-+] ' | sort | uniq -c | sort -nr 403 - /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/Error.h 403 - /usr/local/google/home/rnk/llvm-project/llvm/include/llvm-c/Error.h 397 - /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/Format.h 397 - /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/Debug.h 377 - /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/ADT/StringExtras.h 158 - /usr/local/google/home/rnk/llvm-project/llvm/include/llvm-c/ExternC.h 138 - /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/ErrorOr.h 13 - /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/raw_ostream.h 13 - /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/ADT/SmallString.h 5 - /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/ADT/Twine.h
1 parent d3df2da commit 76221c7

File tree

14 files changed

+24
-6
lines changed

14 files changed

+24
-6
lines changed

clang-tools-extra/clang-include-fixer/find-all-symbols/PathConfig.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//===----------------------------------------------------------------------===//
99

1010
#include "PathConfig.h"
11+
#include "llvm/ADT/SmallString.h"
1112
#include "llvm/Support/Path.h"
1213

1314
namespace clang {

clang/include/clang/Basic/Diagnostic.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "llvm/ADT/StringRef.h"
2727
#include "llvm/ADT/iterator_range.h"
2828
#include "llvm/Support/Compiler.h"
29-
#include "llvm/Support/Error.h"
3029
#include <cassert>
3130
#include <cstdint>
3231
#include <limits>
@@ -38,6 +37,10 @@
3837
#include <utility>
3938
#include <vector>
4039

40+
namespace llvm {
41+
class Error;
42+
}
43+
4144
namespace clang {
4245

4346
class DeclContext;
@@ -1329,11 +1332,8 @@ inline DiagnosticBuilder DiagnosticsEngine::Report(SourceLocation Loc,
13291332
return DiagnosticBuilder(this);
13301333
}
13311334

1332-
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
1333-
llvm::Error &&E) {
1334-
DB.AddString(toString(std::move(E)));
1335-
return DB;
1336-
}
1335+
const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
1336+
llvm::Error &&E);
13371337

13381338
inline DiagnosticBuilder DiagnosticsEngine::Report(unsigned DiagID) {
13391339
return Report(SourceLocation(), DiagID);

clang/include/clang/Tooling/Refactoring/ASTSelection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "clang/AST/Stmt.h"
1414
#include "clang/Basic/LLVM.h"
1515
#include "clang/Basic/SourceLocation.h"
16+
#include "llvm/Support/raw_ostream.h"
1617
#include <vector>
1718

1819
namespace clang {

clang/lib/AST/ExprConstant.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#include "clang/Basic/TargetInfo.h"
5555
#include "llvm/ADT/Optional.h"
5656
#include "llvm/ADT/SmallBitVector.h"
57+
#include "llvm/Support/Debug.h"
5758
#include "llvm/Support/SaveAndRestore.h"
5859
#include "llvm/Support/raw_ostream.h"
5960
#include <cstring>

clang/lib/AST/Interp/Disasm.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "Program.h"
1717
#include "clang/AST/DeclCXX.h"
1818
#include "llvm/Support/Compiler.h"
19+
#include "llvm/Support/Format.h"
1920

2021
using namespace clang;
2122
using namespace clang::interp;

clang/lib/Basic/Diagnostic.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB,
6161
return DB;
6262
}
6363

64+
const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB,
65+
llvm::Error &&E) {
66+
DB.AddString(toString(std::move(E)));
67+
return DB;
68+
}
69+
6470
static void DummyArgToStringFn(DiagnosticsEngine::ArgumentKind AK, intptr_t QT,
6571
StringRef Modifier, StringRef Argument,
6672
ArrayRef<DiagnosticsEngine::ArgumentValue> PrevArgs,

clang/lib/Lex/LiteralSupport.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "llvm/ADT/StringExtras.h"
2626
#include "llvm/ADT/StringSwitch.h"
2727
#include "llvm/Support/ConvertUTF.h"
28+
#include "llvm/Support/Error.h"
2829
#include "llvm/Support/ErrorHandling.h"
2930
#include <algorithm>
3031
#include <cassert>

clang/lib/Sema/CodeCompleteConsumer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "clang/Sema/Sema.h"
2424
#include "llvm/ADT/SmallString.h"
2525
#include "llvm/ADT/SmallVector.h"
26+
#include "llvm/ADT/StringExtras.h"
2627
#include "llvm/ADT/StringRef.h"
2728
#include "llvm/ADT/Twine.h"
2829
#include "llvm/Support/Casting.h"

clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
2424
#include "llvm/ADT/STLExtras.h"
2525
#include "llvm/ADT/SmallString.h"
26+
#include "llvm/ADT/StringExtras.h"
2627
#include "llvm/Support/raw_ostream.h"
2728

2829
using namespace clang;

clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
9191
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
9292
#include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
93+
#include "llvm/ADT/StringExtras.h"
9394

9495
using namespace clang;
9596
using namespace ento;

0 commit comments

Comments
 (0)