Skip to content

Commit

Permalink
Remove llvm::Error include form Diagnostic.h
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rnk committed Apr 6, 2020
1 parent d3df2da commit 76221c7
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 6 deletions.
Expand Up @@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//

#include "PathConfig.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/Path.h"

namespace clang {
Expand Down
12 changes: 6 additions & 6 deletions clang/include/clang/Basic/Diagnostic.h
Expand Up @@ -26,7 +26,6 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"
#include <cassert>
#include <cstdint>
#include <limits>
Expand All @@ -38,6 +37,10 @@
#include <utility>
#include <vector>

namespace llvm {
class Error;
}

namespace clang {

class DeclContext;
Expand Down Expand Up @@ -1329,11 +1332,8 @@ inline DiagnosticBuilder DiagnosticsEngine::Report(SourceLocation Loc,
return DiagnosticBuilder(this);
}

inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
llvm::Error &&E) {
DB.AddString(toString(std::move(E)));
return DB;
}
const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
llvm::Error &&E);

inline DiagnosticBuilder DiagnosticsEngine::Report(unsigned DiagID) {
return Report(SourceLocation(), DiagID);
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Tooling/Refactoring/ASTSelection.h
Expand Up @@ -13,6 +13,7 @@
#include "clang/AST/Stmt.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/SourceLocation.h"
#include "llvm/Support/raw_ostream.h"
#include <vector>

namespace clang {
Expand Down
1 change: 1 addition & 0 deletions clang/lib/AST/ExprConstant.cpp
Expand Up @@ -54,6 +54,7 @@
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/SaveAndRestore.h"
#include "llvm/Support/raw_ostream.h"
#include <cstring>
Expand Down
1 change: 1 addition & 0 deletions clang/lib/AST/Interp/Disasm.cpp
Expand Up @@ -16,6 +16,7 @@
#include "Program.h"
#include "clang/AST/DeclCXX.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Format.h"

using namespace clang;
using namespace clang::interp;
Expand Down
6 changes: 6 additions & 0 deletions clang/lib/Basic/Diagnostic.cpp
Expand Up @@ -61,6 +61,12 @@ const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB,
return DB;
}

const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB,
llvm::Error &&E) {
DB.AddString(toString(std::move(E)));
return DB;
}

static void DummyArgToStringFn(DiagnosticsEngine::ArgumentKind AK, intptr_t QT,
StringRef Modifier, StringRef Argument,
ArrayRef<DiagnosticsEngine::ArgumentValue> PrevArgs,
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Lex/LiteralSupport.cpp
Expand Up @@ -25,6 +25,7 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include <algorithm>
#include <cassert>
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Sema/CodeCompleteConsumer.cpp
Expand Up @@ -23,6 +23,7 @@
#include "clang/Sema/Sema.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/Casting.h"
Expand Down
1 change: 1 addition & 0 deletions clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
Expand Up @@ -23,6 +23,7 @@
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/raw_ostream.h"

using namespace clang;
Expand Down
1 change: 1 addition & 0 deletions clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
Expand Up @@ -90,6 +90,7 @@
#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
#include "llvm/ADT/StringExtras.h"

using namespace clang;
using namespace ento;
Expand Down
1 change: 1 addition & 0 deletions clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
Expand Up @@ -21,6 +21,7 @@
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
#include "llvm/ADT/StringExtras.h"

using namespace clang;
using namespace ento;
Expand Down
1 change: 1 addition & 0 deletions clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
Expand Up @@ -20,6 +20,7 @@
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/raw_ostream.h"

using namespace clang;
Expand Down
1 change: 1 addition & 0 deletions clang/lib/StaticAnalyzer/Core/BugReporter.cpp
Expand Up @@ -51,6 +51,7 @@
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Support/Casting.h"
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Tooling/Transformer/SourceCode.cpp
Expand Up @@ -20,6 +20,7 @@
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/Lexer.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
#include <set>

using namespace clang;
Expand Down

0 comments on commit 76221c7

Please sign in to comment.