Skip to content

Commit 6713652

Browse files
committed
[NFC] Cleanup some #includes in header files
Limit the #includes to the least necessary to still compile. Move the "new" function into the .cpp file to remove the need to #include ASTContext.h into ASTConcept.h. Differential Revision: https://reviews.llvm.org/D159320
1 parent 54ec8bc commit 6713652

File tree

4 files changed

+36
-25
lines changed

4 files changed

+36
-25
lines changed

clang/include/clang/AST/ASTConcept.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,21 @@
1414
#ifndef LLVM_CLANG_AST_ASTCONCEPT_H
1515
#define LLVM_CLANG_AST_ASTCONCEPT_H
1616

17-
#include "clang/AST/Decl.h"
18-
#include "clang/AST/Expr.h"
19-
#include "clang/AST/PrettyPrinter.h"
17+
#include "clang/AST/DeclarationName.h"
18+
#include "clang/AST/NestedNameSpecifier.h"
19+
#include "clang/AST/TemplateBase.h"
2020
#include "clang/Basic/SourceLocation.h"
21+
#include "llvm/ADT/FoldingSet.h"
2122
#include "llvm/ADT/PointerUnion.h"
2223
#include "llvm/ADT/SmallVector.h"
2324
#include <utility>
2425

2526
namespace clang {
27+
2628
class ConceptDecl;
29+
class Expr;
30+
class NamedDecl;
31+
struct PrintingPolicy;
2732

2833
/// The result of a constraint satisfaction check, containing the necessary
2934
/// information to diagnose an unsatisfied constraint.
@@ -157,10 +162,7 @@ class ConceptReference {
157162
Create(const ASTContext &C, NestedNameSpecifierLoc NNS,
158163
SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo,
159164
NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
160-
const ASTTemplateArgumentListInfo *ArgsAsWritten) {
161-
return new (C) ConceptReference(NNS, TemplateKWLoc, ConceptNameInfo,
162-
FoundDecl, NamedConcept, ArgsAsWritten);
163-
}
165+
const ASTTemplateArgumentListInfo *ArgsAsWritten);
164166

165167
const NestedNameSpecifierLoc &getNestedNameSpecifierLoc() const {
166168
return NestedNameSpec;

clang/include/clang/AST/ASTContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "clang/AST/Decl.h"
2222
#include "clang/AST/DeclarationName.h"
2323
#include "clang/AST/ExternalASTSource.h"
24-
#include "clang/AST/NestedNameSpecifier.h"
2524
#include "clang/AST/PrettyPrinter.h"
2625
#include "clang/AST/RawCommentList.h"
2726
#include "clang/AST/TemplateName.h"
@@ -81,6 +80,7 @@ class MangleNumberingContext;
8180
class MemberSpecializationInfo;
8281
class Module;
8382
struct MSGuidDeclParts;
83+
class NestedNameSpecifier;
8484
class ObjCCategoryDecl;
8585
class ObjCCategoryImplDecl;
8686
class ObjCContainerDecl;

clang/lib/AST/ASTConcept.cpp

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313

1414
#include "clang/AST/ASTConcept.h"
1515
#include "clang/AST/ASTContext.h"
16-
#include "clang/AST/Decl.h"
17-
#include "clang/AST/TemplateBase.h"
16+
#include "clang/AST/PrettyPrinter.h"
1817
#include "llvm/ADT/ArrayRef.h"
19-
#include "llvm/ADT/FoldingSet.h"
18+
2019
using namespace clang;
2120

2221
namespace {
@@ -89,3 +88,27 @@ void ConstraintSatisfaction::Profile(
8988
for (auto &Arg : TemplateArgs)
9089
Arg.Profile(ID, C);
9190
}
91+
92+
ConceptReference *
93+
ConceptReference::Create(const ASTContext &C, NestedNameSpecifierLoc NNS,
94+
SourceLocation TemplateKWLoc,
95+
DeclarationNameInfo ConceptNameInfo,
96+
NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
97+
const ASTTemplateArgumentListInfo *ArgsAsWritten) {
98+
return new (C) ConceptReference(NNS, TemplateKWLoc, ConceptNameInfo,
99+
FoundDecl, NamedConcept, ArgsAsWritten);
100+
}
101+
102+
void ConceptReference::print(llvm::raw_ostream &OS,
103+
const PrintingPolicy &Policy) const {
104+
if (NestedNameSpec)
105+
NestedNameSpec.getNestedNameSpecifier()->print(OS, Policy);
106+
ConceptName.printName(OS, Policy);
107+
if (hasExplicitTemplateArgs()) {
108+
OS << "<";
109+
// FIXME: Find corresponding parameter for argument
110+
for (auto &ArgLoc : ArgsAsWritten->arguments())
111+
ArgLoc.getArgument().print(Policy, OS, /*IncludeType*/ false);
112+
OS << ">";
113+
}
114+
}

clang/lib/AST/DeclTemplate.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,20 +1552,6 @@ BuiltinTemplateDecl::BuiltinTemplateDecl(const ASTContext &C, DeclContext *DC,
15521552
createBuiltinTemplateParameterList(C, DC, BTK)),
15531553
BTK(BTK) {}
15541554

1555-
void ConceptReference::print(llvm::raw_ostream &OS,
1556-
const PrintingPolicy &Policy) const {
1557-
if (NestedNameSpec)
1558-
NestedNameSpec.getNestedNameSpecifier()->print(OS, Policy);
1559-
ConceptName.printName(OS, Policy);
1560-
if (hasExplicitTemplateArgs()) {
1561-
OS << "<";
1562-
// FIXME: Find corresponding parameter for argument
1563-
for (auto &ArgLoc : ArgsAsWritten->arguments())
1564-
ArgLoc.getArgument().print(Policy, OS, /*IncludeType*/ false);
1565-
OS << ">";
1566-
}
1567-
}
1568-
15691555
TemplateParamObjectDecl *TemplateParamObjectDecl::Create(const ASTContext &C,
15701556
QualType T,
15711557
const APValue &V) {

0 commit comments

Comments
 (0)