Saves only 36 includes of ASTContext.h and related headers.
There are two deps on ASTContext.h:
- C++ method overrides iterator types (TinyPtrVector)
- getting LangOptions
For #1, duplicate the iterator type, which is
TinyPtrVector<>::const_iterator.
For #2, add an out-of-line accessor to get the language options. Getting
the ASTContext from a Decl is already an out of line method that loops
over the parent DeclContexts, so if it is ever performance critical, the
proper fix is to pass the context (or LangOpts) into the predicate in
question.
Other changes are just header fixups.
ASTContext &getASTContext() const LLVM_READONLY;
+ /// Helper to get the language options from the ASTContext.
+ /// Defined out of line to avoid depending on ASTContext.h.
+ const LangOptions &getLangOpts() const LLVM_READONLY;
+
void setAccess(AccessSpecifier AS) {
Access = AS;
assert(AccessDeclContextSanity());
#ifndef LLVM_CLANG_AST_DECLCXX_H
#define LLVM_CLANG_AST_DECLCXX_H
-#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTUnresolvedSet.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclBase.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/TinyPtrVector.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h"
namespace clang {
+class ASTContext;
class ClassTemplateDecl;
class ConstructorUsingShadowDecl;
class CXXBasePath;
bool defaultedDefaultConstructorIsConstexpr() const {
return data().DefaultedDefaultConstructorIsConstexpr &&
(!isUnion() || hasInClassInitializer() || !hasVariantMembers() ||
- getASTContext().getLangOpts().CPlusPlus2a);
+ getLangOpts().CPlusPlus2a);
}
/// Determine whether this class has a constexpr default constructor.
/// would be constexpr.
bool defaultedDestructorIsConstexpr() const {
return data().DefaultedDestructorIsConstexpr &&
- getASTContext().getLangOpts().CPlusPlus2a;
+ getLangOpts().CPlusPlus2a;
}
/// Determine whether this class has a constexpr destructor.
///
/// Only in C++17 and beyond, are lambdas literal types.
bool isLiteral() const {
- ASTContext &Ctx = getASTContext();
- return (Ctx.getLangOpts().CPlusPlus2a ? hasConstexprDestructor()
+ const LangOptions &LangOpts = getLangOpts();
+ return (LangOpts.CPlusPlus2a ? hasConstexprDestructor()
: hasTrivialDestructor()) &&
- (!isLambda() || Ctx.getLangOpts().CPlusPlus17) &&
+ (!isLambda() || LangOpts.CPlusPlus17) &&
!hasNonLiteralTypeFieldsOrBases() &&
(isAggregate() || isLambda() ||
hasConstexprNonCopyMoveConstructor() ||
method_iterator end_overridden_methods() const;
unsigned size_overridden_methods() const;
- using overridden_method_range= ASTContext::overridden_method_range;
+ using overridden_method_range = llvm::iterator_range<
+ llvm::TinyPtrVector<const CXXMethodDecl *>::const_iterator>;
overridden_method_range overridden_methods() const;
}
static KernelReferenceKind getDefaultKernelReference(const FunctionDecl *D) {
- return D->getASTContext().getLangOpts().CUDAIsDevice
- ? KernelReferenceKind::Kernel
- : KernelReferenceKind::Stub;
+ return D->getLangOpts().CUDAIsDevice ? KernelReferenceKind::Kernel
+ : KernelReferenceKind::Stub;
}
GlobalDecl getWithDecl(const Decl *D) {
#ifndef LLVM_CLANG_SERIALIZATION_ASTRECORDREADER_H
#define LLVM_CLANG_SERIALIZATION_ASTRECORDREADER_H
+#include "clang/AST/ASTContext.h"
#include "clang/AST/AbstractBasicReader.h"
#include "clang/Lex/Token.h"
#include "clang/Serialization/ASTReader.h"
FD->doesThisDeclarationHaveABody())
return;
- const LangOptions &LO = FD->getASTContext().getLangOpts();
+ const LangOptions &LO = FD->getLangOpts();
const bool DoubleSquareBracket = LO.CPlusPlus14 || LO.C2x;
StringRef AttributeSpelling =
DoubleSquareBracket ? "[[deprecated]]" : "__attribute__((deprecated))";
//===----------------------------------------------------------------------===//
#include "clang/AST/ComparisonCategories.h"
+#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/Type.h"
return getTranslationUnitDecl()->getASTContext();
}
+/// Helper to get the language options from the ASTContext.
+/// Defined out of line to avoid depending on ASTContext.h.
+const LangOptions &Decl::getLangOpts() const {
+ return getASTContext().getLangOpts();
+}
+
ASTMutationListener *Decl::getASTMutationListener() const {
return getASTContext().getASTMutationListener();
}
#include "clang/AST/ExprCXX.h"
#include "clang/AST/OperationKinds.h"
#include "clang/AST/ParentMap.h"
+#include "clang/AST/PrettyPrinter.h"
#include "clang/AST/Stmt.h"
#include "clang/AST/Type.h"
#include "clang/Analysis/AnalysisDeclContext.h"
Out << Prefix << '\'' << *D;
if (const auto T = dyn_cast<ClassTemplateSpecializationDecl>(D))
describeTemplateParameters(Out, T->getTemplateArgs().asArray(),
- D->getASTContext().getLangOpts(), "<", ">");
+ D->getLangOpts(), "<", ">");
Out << '\'';
}
if (const auto FD = dyn_cast<FunctionDecl>(D))
if (const TemplateArgumentList *TAList =
FD->getTemplateSpecializationArgs())
- describeTemplateParameters(Out, TAList->asArray(),
- FD->getASTContext().getLangOpts(), "<", ">");
+ describeTemplateParameters(Out, TAList->asArray(), FD->getLangOpts(), "<",
+ ">");
Out << '\'';
return true;
//===----------------------------------------------------------------------===//
#include "clang/Analysis/ProgramPoint.h"
+#include "clang/AST/ASTContext.h"
#include "clang/Basic/JsonSupport.h"
using namespace clang;
#include "clang/AST/DeclCXX.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExternalASTSource.h"
+#include "clang/AST/PrettyPrinter.h"
#include "clang/AST/Type.h"
#include "clang/AST/TypeOrdering.h"
#include "clang/Basic/CodeGenOptions.h"
//===----------------------------------------------------------------------===//
#include "clang/Tooling/Core/Lookup.h"
+#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclarationName.h"