[clang] 04da3df - Forward declare special case lists
Reid Kleckner via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 27 10:09:02 PST 2020
Author: Reid Kleckner
Date: 2020-02-27T10:05:30-08:00
New Revision: 04da3dfecc199a7fdd262b06eeb399fc8ce0d1f6
URL: https://github.com/llvm/llvm-project/commit/04da3dfecc199a7fdd262b06eeb399fc8ce0d1f6
DIFF: https://github.com/llvm/llvm-project/commit/04da3dfecc199a7fdd262b06eeb399fc8ce0d1f6.diff
LOG: Forward declare special case lists
This avoids pulling in unordered_map from TrigramIndex.h:
$ diff -u thedeps-before.txt thedeps-after.txt | \
grep '^[-+] ' | sort | uniq -c | sort -nr
976 - ../llvm/include/llvm/Support/TrigramIndex.h
976 - ../llvm/include/llvm/Support/SpecialCaseList.h
976 - ../clang/include/clang/Basic/SanitizerSpecialCaseList.h
502 - ../../../PROGRA~2/MIB055~1/2019/PROFES~1/VC/Tools/MSVC/14.24.28314/include/unordered_map
467 - ../../../PROGRA~2/MIB055~1/2019/PROFES~1/VC/Tools/MSVC/14.24.28314/include/xhash
467 - ../../../PROGRA~2/MIB055~1/2019/PROFES~1/VC/Tools/MSVC/14.24.28314/include/xbit_ops.h
212 - ../llvm/include/llvm/ADT/StringSet.h
Added:
Modified:
clang/include/clang/Basic/SanitizerBlacklist.h
clang/include/clang/Basic/SanitizerSpecialCaseList.h
clang/include/clang/Basic/XRayLists.h
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
clang/lib/Basic/SanitizerBlacklist.cpp
clang/lib/Basic/XRayLists.cpp
clang/lib/Sema/SemaDecl.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/SanitizerBlacklist.h b/clang/include/clang/Basic/SanitizerBlacklist.h
index 29af28b84365..c874ff28aacc 100644
--- a/clang/include/clang/Basic/SanitizerBlacklist.h
+++ b/clang/include/clang/Basic/SanitizerBlacklist.h
@@ -14,15 +14,17 @@
#define LLVM_CLANG_BASIC_SANITIZERBLACKLIST_H
#include "clang/Basic/LLVM.h"
-#include "clang/Basic/SanitizerSpecialCaseList.h"
-#include "clang/Basic/Sanitizers.h"
#include "clang/Basic/SourceLocation.h"
-#include "clang/Basic/SourceManager.h"
#include "llvm/ADT/StringRef.h"
#include <memory>
+#include <vector>
namespace clang {
+class SanitizerMask;
+class SourceManager;
+class SanitizerSpecialCaseList;
+
class SanitizerBlacklist {
std::unique_ptr<SanitizerSpecialCaseList> SSCL;
SourceManager &SM;
@@ -30,6 +32,7 @@ class SanitizerBlacklist {
public:
SanitizerBlacklist(const std::vector<std::string> &BlacklistPaths,
SourceManager &SM);
+ ~SanitizerBlacklist();
bool isBlacklistedGlobal(SanitizerMask Mask, StringRef GlobalName,
StringRef Category = StringRef()) const;
bool isBlacklistedType(SanitizerMask Mask, StringRef MangledTypeName,
diff --git a/clang/include/clang/Basic/SanitizerSpecialCaseList.h b/clang/include/clang/Basic/SanitizerSpecialCaseList.h
index 88d31a6cbcce..c84894dae298 100644
--- a/clang/include/clang/Basic/SanitizerSpecialCaseList.h
+++ b/clang/include/clang/Basic/SanitizerSpecialCaseList.h
@@ -10,6 +10,7 @@
// SanitizerMask.
//
//===----------------------------------------------------------------------===//
+
#ifndef LLVM_CLANG_BASIC_SANITIZERSPECIALCASELIST_H
#define LLVM_CLANG_BASIC_SANITIZERSPECIALCASELIST_H
@@ -17,8 +18,14 @@
#include "clang/Basic/Sanitizers.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/SpecialCaseList.h"
-#include "llvm/Support/VirtualFileSystem.h"
#include <memory>
+#include <vector>
+
+namespace llvm {
+namespace vfs {
+class FileSystem;
+}
+} // namespace llvm
namespace clang {
diff --git a/clang/include/clang/Basic/XRayLists.h b/clang/include/clang/Basic/XRayLists.h
index cf464f9e5478..7ea9d9789aab 100644
--- a/clang/include/clang/Basic/XRayLists.h
+++ b/clang/include/clang/Basic/XRayLists.h
@@ -14,14 +14,18 @@
#include "clang/Basic/LLVM.h"
#include "clang/Basic/SourceLocation.h"
-#include "clang/Basic/SourceManager.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/SpecialCaseList.h"
#include <memory>
+namespace llvm {
+class SpecialCaseList;
+}
+
namespace clang {
+class SourceManager;
+
class XRayFunctionFilter {
std::unique_ptr<llvm::SpecialCaseList> AlwaysInstrument;
std::unique_ptr<llvm::SpecialCaseList> NeverInstrument;
@@ -32,6 +36,7 @@ class XRayFunctionFilter {
XRayFunctionFilter(ArrayRef<std::string> AlwaysInstrumentPaths,
ArrayRef<std::string> NeverInstrumentPaths,
ArrayRef<std::string> AttrListPaths, SourceManager &SM);
+ ~XRayFunctionFilter();
enum class ImbueAttribute {
NONE,
diff --git a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
index c5d12fc73e1a..c490bb38c167 100644
--- a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -19,8 +19,8 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/raw_ostream.h"
-
#include <string>
+#include <unordered_map>
namespace clang {
namespace tooling {
diff --git a/clang/lib/Basic/SanitizerBlacklist.cpp b/clang/lib/Basic/SanitizerBlacklist.cpp
index 4f71349350fd..48cc229b867a 100644
--- a/clang/lib/Basic/SanitizerBlacklist.cpp
+++ b/clang/lib/Basic/SanitizerBlacklist.cpp
@@ -10,7 +10,11 @@
// sanitizers.
//
//===----------------------------------------------------------------------===//
+
#include "clang/Basic/SanitizerBlacklist.h"
+#include "clang/Basic/SanitizerSpecialCaseList.h"
+#include "clang/Basic/Sanitizers.h"
+#include "clang/Basic/SourceManager.h"
using namespace clang;
@@ -20,6 +24,8 @@ SanitizerBlacklist::SanitizerBlacklist(
BlacklistPaths, SM.getFileManager().getVirtualFileSystem())),
SM(SM) {}
+SanitizerBlacklist::~SanitizerBlacklist() = default;
+
bool SanitizerBlacklist::isBlacklistedGlobal(SanitizerMask Mask,
StringRef GlobalName,
StringRef Category) const {
diff --git a/clang/lib/Basic/XRayLists.cpp b/clang/lib/Basic/XRayLists.cpp
index 222a28f79cc5..f9827beccf57 100644
--- a/clang/lib/Basic/XRayLists.cpp
+++ b/clang/lib/Basic/XRayLists.cpp
@@ -9,7 +9,10 @@
// User-provided filters for always/never XRay instrumenting certain functions.
//
//===----------------------------------------------------------------------===//
+
#include "clang/Basic/XRayLists.h"
+#include "clang/Basic/SourceManager.h"
+#include "llvm/Support/SpecialCaseList.h"
using namespace clang;
@@ -25,6 +28,8 @@ XRayFunctionFilter::XRayFunctionFilter(
AttrListPaths, SM.getFileManager().getVirtualFileSystem())),
SM(SM) {}
+XRayFunctionFilter::~XRayFunctionFilter() = default;
+
XRayFunctionFilter::ImbueAttribute
XRayFunctionFilter::shouldImbueFunction(StringRef FunctionName) const {
// First apply the always instrument list, than if it isn't an "always" see
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 7fe3213e2a23..ffe620b122bd 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -47,6 +47,7 @@
#include <algorithm>
#include <cstring>
#include <functional>
+#include <unordered_map>
using namespace clang;
using namespace sema;
@@ -17570,9 +17571,11 @@ static void CheckForDuplicateEnumValues(Sema &S, ArrayRef<Decl *> Elements,
typedef SmallVector<std::unique_ptr<ECDVector>, 3> DuplicatesVector;
typedef llvm::PointerUnion<EnumConstantDecl*, ECDVector*> DeclOrVector;
+
+ // DenseMaps cannot contain the all ones int64_t value, so use unordered_map.
typedef std::unordered_map<int64_t, DeclOrVector> ValueToVectorMap;
- // Use int64_t as a key to avoid needing special handling for DenseMap keys.
+ // Use int64_t as a key to avoid needing special handling for map keys.
auto EnumConstantToKey = [](const EnumConstantDecl *D) {
llvm::APSInt Val = D->getInitVal();
return Val.isSigned() ? Val.getSExtValue() : Val.getZExtValue();
More information about the cfe-commits
mailing list