forked from OSchip/llvm-project
[AST, ASTMatchers, Basic] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 289160
This commit is contained in:
parent
08da283295
commit
a0da28fef0
|
@ -19,73 +19,107 @@
|
|||
#include "clang/AST/CanonicalType.h"
|
||||
#include "clang/AST/CommentCommandTraits.h"
|
||||
#include "clang/AST/Decl.h"
|
||||
#include "clang/AST/DeclarationName.h"
|
||||
#include "clang/AST/DeclBase.h"
|
||||
#include "clang/AST/ExternalASTSource.h"
|
||||
#include "clang/AST/NestedNameSpecifier.h"
|
||||
#include "clang/AST/PrettyPrinter.h"
|
||||
#include "clang/AST/RawCommentList.h"
|
||||
#include "clang/AST/TemplateBase.h"
|
||||
#include "clang/AST/TemplateName.h"
|
||||
#include "clang/AST/Type.h"
|
||||
#include "clang/Basic/AddressSpaces.h"
|
||||
#include "clang/Basic/IdentifierTable.h"
|
||||
#include "clang/Basic/LangOptions.h"
|
||||
#include "clang/Basic/Linkage.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "clang/Basic/Module.h"
|
||||
#include "clang/Basic/OperatorKinds.h"
|
||||
#include "clang/Basic/PartialDiagnostic.h"
|
||||
#include "clang/Basic/SanitizerBlacklist.h"
|
||||
#include "clang/Basic/VersionTuple.h"
|
||||
#include "clang/Basic/SourceLocation.h"
|
||||
#include "clang/Basic/Specifiers.h"
|
||||
#include "llvm/ADT/APSInt.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/FoldingSet.h"
|
||||
#include "llvm/ADT/IntrusiveRefCntPtr.h"
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include "llvm/ADT/MapVector.h"
|
||||
#include "llvm/ADT/None.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/PointerIntPair.h"
|
||||
#include "llvm/ADT/PointerUnion.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/TinyPtrVector.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/AlignOf.h"
|
||||
#include "llvm/Support/Allocator.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <new>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
struct fltSemantics;
|
||||
}
|
||||
|
||||
struct fltSemantics;
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
namespace clang {
|
||||
class FileManager;
|
||||
class AtomicExpr;
|
||||
class ASTRecordLayout;
|
||||
class BlockExpr;
|
||||
class CharUnits;
|
||||
class DiagnosticsEngine;
|
||||
class Expr;
|
||||
class ASTMutationListener;
|
||||
class IdentifierTable;
|
||||
class MaterializeTemporaryExpr;
|
||||
class SelectorTable;
|
||||
class TargetInfo;
|
||||
class CXXABI;
|
||||
class MangleNumberingContext;
|
||||
// Decls
|
||||
class MangleContext;
|
||||
class ObjCIvarDecl;
|
||||
class ObjCPropertyDecl;
|
||||
class UnresolvedSetIterator;
|
||||
class UsingDecl;
|
||||
class UsingShadowDecl;
|
||||
class VTableContextBase;
|
||||
|
||||
namespace Builtin { class Context; }
|
||||
enum BuiltinTemplateKind : int;
|
||||
class ASTMutationListener;
|
||||
class ASTRecordLayout;
|
||||
class AtomicExpr;
|
||||
class BlockExpr;
|
||||
class CharUnits;
|
||||
class CXXABI;
|
||||
class DiagnosticsEngine;
|
||||
class Expr;
|
||||
class MangleNumberingContext;
|
||||
class MaterializeTemporaryExpr;
|
||||
class TargetInfo;
|
||||
// Decls
|
||||
class MangleContext;
|
||||
class ObjCIvarDecl;
|
||||
class ObjCPropertyDecl;
|
||||
class UnresolvedSetIterator;
|
||||
class UsingDecl;
|
||||
class UsingShadowDecl;
|
||||
class VTableContextBase;
|
||||
|
||||
namespace comments {
|
||||
class FullComment;
|
||||
}
|
||||
namespace Builtin {
|
||||
|
||||
struct TypeInfo {
|
||||
uint64_t Width;
|
||||
unsigned Align;
|
||||
bool AlignIsRequired : 1;
|
||||
TypeInfo() : Width(0), Align(0), AlignIsRequired(false) {}
|
||||
TypeInfo(uint64_t Width, unsigned Align, bool AlignIsRequired)
|
||||
: Width(Width), Align(Align), AlignIsRequired(AlignIsRequired) {}
|
||||
};
|
||||
class Context;
|
||||
|
||||
} // end namespace Builtin
|
||||
|
||||
enum BuiltinTemplateKind : int;
|
||||
|
||||
namespace comments {
|
||||
|
||||
class FullComment;
|
||||
|
||||
} // end namespace comments
|
||||
|
||||
struct TypeInfo {
|
||||
uint64_t Width;
|
||||
unsigned Align;
|
||||
bool AlignIsRequired : 1;
|
||||
|
||||
TypeInfo() : Width(0), Align(0), AlignIsRequired(false) {}
|
||||
TypeInfo(uint64_t Width, unsigned Align, bool AlignIsRequired)
|
||||
: Width(Width), Align(Align), AlignIsRequired(AlignIsRequired) {}
|
||||
};
|
||||
|
||||
/// \brief Holds long-lived AST nodes (such as types and decls) that can be
|
||||
/// referred to throughout the semantic analysis of a file.
|
||||
|
@ -331,7 +365,6 @@ public:
|
|||
TemplateOrSpecializationInfo;
|
||||
|
||||
private:
|
||||
|
||||
/// \brief A mapping to contain the template or declaration that
|
||||
/// a variable declaration describes or was instantiated from,
|
||||
/// respectively.
|
||||
|
@ -527,6 +560,7 @@ public:
|
|||
|
||||
size_t size() const { return end() - begin(); }
|
||||
bool empty() const { return begin() == end(); }
|
||||
|
||||
const DynTypedNode &operator[](size_t N) const {
|
||||
assert(N < size() && "Out of bounds!");
|
||||
return *(begin() + N);
|
||||
|
@ -952,7 +986,8 @@ public:
|
|||
|
||||
ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents,
|
||||
SelectorTable &sels, Builtin::Context &builtins);
|
||||
|
||||
ASTContext(const ASTContext &) = delete;
|
||||
ASTContext &operator=(const ASTContext &) = delete;
|
||||
~ASTContext();
|
||||
|
||||
/// \brief Attach an external AST source to the AST context.
|
||||
|
@ -1489,7 +1524,6 @@ public:
|
|||
return getObjCSelType();
|
||||
return ObjCSelRedefinitionType;
|
||||
}
|
||||
|
||||
|
||||
/// \brief Set the user-written type that redefines 'SEL'.
|
||||
void setObjCSelRedefinitionType(QualType RedefType) {
|
||||
|
@ -1909,7 +1943,7 @@ public:
|
|||
|
||||
/// \brief Return the default alignment for __attribute__((aligned)) on
|
||||
/// this target, to be used if no alignment value is specified.
|
||||
unsigned getTargetDefaultAlignForAttributeAligned(void) const;
|
||||
unsigned getTargetDefaultAlignForAttributeAligned() const;
|
||||
|
||||
/// \brief Return the alignment in bits that should be given to a
|
||||
/// global variable with type \p T.
|
||||
|
@ -2272,7 +2306,6 @@ private:
|
|||
unsigned getIntegerRank(const Type *T) const;
|
||||
|
||||
public:
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Type Compatibility Predicates
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
@ -2527,10 +2560,6 @@ public:
|
|||
/// declarations were built.
|
||||
static unsigned NumImplicitDestructorsDeclared;
|
||||
|
||||
private:
|
||||
ASTContext(const ASTContext &) = delete;
|
||||
void operator=(const ASTContext &) = delete;
|
||||
|
||||
public:
|
||||
/// \brief Initialize built-in types.
|
||||
///
|
||||
|
@ -2610,6 +2639,7 @@ private:
|
|||
|
||||
friend class DeclContext;
|
||||
friend class DeclarationNameTable;
|
||||
|
||||
void ReleaseDeclContextMaps();
|
||||
void ReleaseParentMapEntries();
|
||||
|
||||
|
@ -2632,7 +2662,8 @@ public:
|
|||
DeclaratorDecl *Decl;
|
||||
SourceLocation PragmaSectionLocation;
|
||||
int SectionFlags;
|
||||
SectionInfo() {}
|
||||
|
||||
SectionInfo() = default;
|
||||
SectionInfo(DeclaratorDecl *Decl,
|
||||
SourceLocation PragmaSectionLocation,
|
||||
int SectionFlags)
|
||||
|
@ -2754,4 +2785,4 @@ typename clang::LazyGenerationalUpdatePtr<Owner, T, Update>::ValueType
|
|||
return Value;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // LLVM_CLANG_AST_ASTCONTEXT_H
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
#ifndef LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
|
||||
#define LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "clang/AST/Attr.h"
|
||||
#include "clang/AST/Decl.h"
|
||||
#include "clang/AST/DeclarationName.h"
|
||||
#include "clang/AST/DeclBase.h"
|
||||
#include "clang/AST/DeclCXX.h"
|
||||
#include "clang/AST/DeclFriend.h"
|
||||
#include "clang/AST/DeclObjC.h"
|
||||
|
@ -27,7 +27,9 @@
|
|||
#include "clang/AST/ExprCXX.h"
|
||||
#include "clang/AST/ExprObjC.h"
|
||||
#include "clang/AST/ExprOpenMP.h"
|
||||
#include "clang/AST/LambdaCapture.h"
|
||||
#include "clang/AST/NestedNameSpecifier.h"
|
||||
#include "clang/AST/OpenMPClause.h"
|
||||
#include "clang/AST/Stmt.h"
|
||||
#include "clang/AST/StmtCXX.h"
|
||||
#include "clang/AST/StmtObjC.h"
|
||||
|
@ -36,6 +38,15 @@
|
|||
#include "clang/AST/TemplateName.h"
|
||||
#include "clang/AST/Type.h"
|
||||
#include "clang/AST/TypeLoc.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "clang/Basic/OpenMPKinds.h"
|
||||
#include "clang/Basic/Specifiers.h"
|
||||
#include "llvm/ADT/PointerIntPair.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
// The following three macros are used for meta programming. The code
|
||||
// using them is responsible for defining macro OPERATOR().
|
||||
|
@ -70,7 +81,7 @@ namespace clang {
|
|||
do { \
|
||||
if (!getDerived().CALL_EXPR) \
|
||||
return false; \
|
||||
} while (0)
|
||||
} while (false)
|
||||
|
||||
/// \brief A class that does preordor or postorder
|
||||
/// depth-first traversal on the entire Clang AST and visits each node.
|
||||
|
@ -329,7 +340,7 @@ private:
|
|||
do { \
|
||||
if (!TRAVERSE_STMT_BASE(Stmt, Stmt, S, Queue)) \
|
||||
return false; \
|
||||
} while (0)
|
||||
} while (false)
|
||||
|
||||
public:
|
||||
// Declare Traverse*() for all concrete Stmt classes.
|
||||
|
@ -573,7 +584,6 @@ bool RecursiveASTVisitor<Derived>::dataTraverseNode(Stmt *S,
|
|||
|
||||
#undef DISPATCH_STMT
|
||||
|
||||
|
||||
template <typename Derived>
|
||||
bool RecursiveASTVisitor<Derived>::PostVisitStmt(Stmt *S) {
|
||||
switch (S->getStmtClass()) {
|
||||
|
@ -762,7 +772,6 @@ bool RecursiveASTVisitor<Derived>::TraverseDeclarationNameInfo(
|
|||
case DeclarationName::CXXConversionFunctionName:
|
||||
if (TypeSourceInfo *TSInfo = NameInfo.getNamedTypeInfo())
|
||||
TRY_TO(TraverseTypeLoc(TSInfo->getTypeLoc()));
|
||||
|
||||
break;
|
||||
|
||||
case DeclarationName::Identifier:
|
||||
|
@ -2085,6 +2094,7 @@ DEF_TRAVERSE_STMT(ObjCAtThrowStmt, {})
|
|||
DEF_TRAVERSE_STMT(ObjCAtTryStmt, {})
|
||||
DEF_TRAVERSE_STMT(ObjCForCollectionStmt, {})
|
||||
DEF_TRAVERSE_STMT(ObjCAutoreleasePoolStmt, {})
|
||||
|
||||
DEF_TRAVERSE_STMT(CXXForRangeStmt, {
|
||||
if (!getDerived().shouldVisitImplicitCode()) {
|
||||
TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLoopVarStmt());
|
||||
|
@ -2094,10 +2104,12 @@ DEF_TRAVERSE_STMT(CXXForRangeStmt, {
|
|||
ShouldVisitChildren = false;
|
||||
}
|
||||
})
|
||||
|
||||
DEF_TRAVERSE_STMT(MSDependentExistsStmt, {
|
||||
TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
|
||||
TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
|
||||
})
|
||||
|
||||
DEF_TRAVERSE_STMT(ReturnStmt, {})
|
||||
DEF_TRAVERSE_STMT(SwitchStmt, {})
|
||||
DEF_TRAVERSE_STMT(WhileStmt, {})
|
||||
|
@ -2345,26 +2357,31 @@ DEF_TRAVERSE_STMT(CXXMemberCallExpr, {})
|
|||
DEF_TRAVERSE_STMT(AddrLabelExpr, {})
|
||||
DEF_TRAVERSE_STMT(ArraySubscriptExpr, {})
|
||||
DEF_TRAVERSE_STMT(OMPArraySectionExpr, {})
|
||||
|
||||
DEF_TRAVERSE_STMT(BlockExpr, {
|
||||
TRY_TO(TraverseDecl(S->getBlockDecl()));
|
||||
return true; // no child statements to loop through.
|
||||
})
|
||||
|
||||
DEF_TRAVERSE_STMT(ChooseExpr, {})
|
||||
DEF_TRAVERSE_STMT(CompoundLiteralExpr, {
|
||||
TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc()));
|
||||
})
|
||||
DEF_TRAVERSE_STMT(CXXBindTemporaryExpr, {})
|
||||
DEF_TRAVERSE_STMT(CXXBoolLiteralExpr, {})
|
||||
|
||||
DEF_TRAVERSE_STMT(CXXDefaultArgExpr, {
|
||||
if (getDerived().shouldVisitImplicitCode())
|
||||
TRY_TO(TraverseStmt(S->getExpr()));
|
||||
})
|
||||
|
||||
DEF_TRAVERSE_STMT(CXXDefaultInitExpr, {})
|
||||
DEF_TRAVERSE_STMT(CXXDeleteExpr, {})
|
||||
DEF_TRAVERSE_STMT(ExprWithCleanups, {})
|
||||
DEF_TRAVERSE_STMT(CXXInheritedCtorInitExpr, {})
|
||||
DEF_TRAVERSE_STMT(CXXNullPtrLiteralExpr, {})
|
||||
DEF_TRAVERSE_STMT(CXXStdInitializerListExpr, {})
|
||||
|
||||
DEF_TRAVERSE_STMT(CXXPseudoDestructorExpr, {
|
||||
TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
|
||||
if (TypeSourceInfo *ScopeInfo = S->getScopeTypeInfo())
|
||||
|
@ -2372,6 +2389,7 @@ DEF_TRAVERSE_STMT(CXXPseudoDestructorExpr, {
|
|||
if (TypeSourceInfo *DestroyedTypeInfo = S->getDestroyedTypeInfo())
|
||||
TRY_TO(TraverseTypeLoc(DestroyedTypeInfo->getTypeLoc()));
|
||||
})
|
||||
|
||||
DEF_TRAVERSE_STMT(CXXThisExpr, {})
|
||||
DEF_TRAVERSE_STMT(CXXThrowExpr, {})
|
||||
DEF_TRAVERSE_STMT(UserDefinedLiteral, {})
|
||||
|
@ -2382,24 +2400,30 @@ DEF_TRAVERSE_STMT(GNUNullExpr, {})
|
|||
DEF_TRAVERSE_STMT(ImplicitValueInitExpr, {})
|
||||
DEF_TRAVERSE_STMT(NoInitExpr, {})
|
||||
DEF_TRAVERSE_STMT(ObjCBoolLiteralExpr, {})
|
||||
|
||||
DEF_TRAVERSE_STMT(ObjCEncodeExpr, {
|
||||
if (TypeSourceInfo *TInfo = S->getEncodedTypeSourceInfo())
|
||||
TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
|
||||
})
|
||||
|
||||
DEF_TRAVERSE_STMT(ObjCIsaExpr, {})
|
||||
DEF_TRAVERSE_STMT(ObjCIvarRefExpr, {})
|
||||
|
||||
DEF_TRAVERSE_STMT(ObjCMessageExpr, {
|
||||
if (TypeSourceInfo *TInfo = S->getClassReceiverTypeInfo())
|
||||
TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc()));
|
||||
})
|
||||
|
||||
DEF_TRAVERSE_STMT(ObjCPropertyRefExpr, {})
|
||||
DEF_TRAVERSE_STMT(ObjCSubscriptRefExpr, {})
|
||||
DEF_TRAVERSE_STMT(ObjCProtocolExpr, {})
|
||||
DEF_TRAVERSE_STMT(ObjCSelectorExpr, {})
|
||||
DEF_TRAVERSE_STMT(ObjCIndirectCopyRestoreExpr, {})
|
||||
|
||||
DEF_TRAVERSE_STMT(ObjCBridgedCastExpr, {
|
||||
TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc()));
|
||||
})
|
||||
|
||||
DEF_TRAVERSE_STMT(ObjCAvailabilityCheckExpr, {})
|
||||
DEF_TRAVERSE_STMT(ParenExpr, {})
|
||||
DEF_TRAVERSE_STMT(ParenListExpr, {})
|
||||
|
|
|
@ -97,7 +97,7 @@
|
|||
class matcher_##DefineMatcher##Matcher \
|
||||
: public ::clang::ast_matchers::internal::MatcherInterface<Type> { \
|
||||
public: \
|
||||
explicit matcher_##DefineMatcher##Matcher() {} \
|
||||
explicit matcher_##DefineMatcher##Matcher() = default; \
|
||||
bool matches(const Type &Node, \
|
||||
::clang::ast_matchers::internal::ASTMatchFinder *Finder, \
|
||||
::clang::ast_matchers::internal::BoundNodesTreeBuilder \
|
||||
|
@ -401,4 +401,4 @@
|
|||
ReturnTypesF>::Func MatcherName##Loc; \
|
||||
AST_TYPE_TRAVERSE_MATCHER(MatcherName, FunctionName##Type, ReturnTypesF)
|
||||
|
||||
#endif
|
||||
#endif // LLVM_CLANG_ASTMATCHERS_ASTMATCHERSMACROS_H
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- Registry.h - Matcher registry -----*- C++ -*-===//
|
||||
//===--- Registry.h - Matcher registry --------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -19,28 +19,36 @@
|
|||
|
||||
#include "clang/ASTMatchers/Dynamic/Diagnostics.h"
|
||||
#include "clang/ASTMatchers/Dynamic/VariantValue.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace clang {
|
||||
namespace ast_matchers {
|
||||
namespace dynamic {
|
||||
|
||||
namespace internal {
|
||||
|
||||
class MatcherDescriptor;
|
||||
}
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
typedef const internal::MatcherDescriptor *MatcherCtor;
|
||||
|
||||
struct MatcherCompletion {
|
||||
MatcherCompletion() {}
|
||||
MatcherCompletion() = default;
|
||||
MatcherCompletion(StringRef TypedText, StringRef MatcherDecl,
|
||||
unsigned Specificity)
|
||||
: TypedText(TypedText), MatcherDecl(MatcherDecl),
|
||||
Specificity(Specificity) {}
|
||||
|
||||
bool operator==(const MatcherCompletion &Other) const {
|
||||
return TypedText == Other.TypedText && MatcherDecl == Other.MatcherDecl;
|
||||
}
|
||||
|
||||
/// \brief The text to type to select this matcher.
|
||||
std::string TypedText;
|
||||
|
||||
|
@ -53,14 +61,12 @@ struct MatcherCompletion {
|
|||
/// matcher that will either always or never match.
|
||||
/// Such matchers are excluded from code completion results.
|
||||
unsigned Specificity;
|
||||
|
||||
bool operator==(const MatcherCompletion &Other) const {
|
||||
return TypedText == Other.TypedText && MatcherDecl == Other.MatcherDecl;
|
||||
}
|
||||
};
|
||||
|
||||
class Registry {
|
||||
public:
|
||||
Registry() = delete;
|
||||
|
||||
/// \brief Look up a matcher in the registry by name,
|
||||
///
|
||||
/// \return An opaque value which may be used to refer to the matcher
|
||||
|
@ -121,13 +127,10 @@ public:
|
|||
StringRef BindID,
|
||||
ArrayRef<ParserValue> Args,
|
||||
Diagnostics *Error);
|
||||
|
||||
private:
|
||||
Registry() = delete;
|
||||
};
|
||||
|
||||
} // namespace dynamic
|
||||
} // namespace ast_matchers
|
||||
} // namespace clang
|
||||
} // end namespace dynamic
|
||||
} // end namespace ast_matchers
|
||||
} // end namespace clang
|
||||
|
||||
#endif // LLVM_CLANG_AST_MATCHERS_DYNAMIC_REGISTRY_H
|
||||
#endif // LLVM_CLANG_AST_MATCHERS_DYNAMIC_REGISTRY_H
|
||||
|
|
|
@ -23,22 +23,33 @@
|
|||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/IntrusiveRefCntPtr.h"
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace clang {
|
||||
class DeclContext;
|
||||
class DiagnosticBuilder;
|
||||
class DiagnosticConsumer;
|
||||
class DiagnosticErrorTrap;
|
||||
class DiagnosticOptions;
|
||||
class IdentifierInfo;
|
||||
class LangOptions;
|
||||
class Preprocessor;
|
||||
class StoredDiagnostic;
|
||||
namespace tok {
|
||||
|
||||
class DeclContext;
|
||||
class DiagnosticBuilder;
|
||||
class DiagnosticConsumer;
|
||||
class IdentifierInfo;
|
||||
class LangOptions;
|
||||
class Preprocessor;
|
||||
class StoredDiagnostic;
|
||||
|
||||
namespace tok {
|
||||
|
||||
enum TokenKind : unsigned short;
|
||||
}
|
||||
|
||||
} // end namespace tok
|
||||
|
||||
/// \brief Annotates a diagnostic with some code that should be
|
||||
/// inserted, removed, or replaced to fix the problem.
|
||||
|
@ -133,9 +144,6 @@ public:
|
|||
/// the user. DiagnosticsEngine is tied to one translation unit and one
|
||||
/// SourceManager.
|
||||
class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
|
||||
DiagnosticsEngine(const DiagnosticsEngine &) = delete;
|
||||
void operator=(const DiagnosticsEngine &) = delete;
|
||||
|
||||
public:
|
||||
/// \brief The level of the diagnostic, after it has been through mapping.
|
||||
enum Level {
|
||||
|
@ -348,6 +356,8 @@ public:
|
|||
DiagnosticOptions *DiagOpts,
|
||||
DiagnosticConsumer *client = nullptr,
|
||||
bool ShouldOwnClient = true);
|
||||
DiagnosticsEngine(const DiagnosticsEngine &) = delete;
|
||||
DiagnosticsEngine &operator=(const DiagnosticsEngine &) = delete;
|
||||
~DiagnosticsEngine();
|
||||
|
||||
const IntrusiveRefCntPtr<DiagnosticIDs> &getDiagnosticIDs() const {
|
||||
|
@ -884,7 +894,6 @@ class DiagnosticBuilder {
|
|||
/// call to ForceEmit.
|
||||
mutable bool IsForceEmit = false;
|
||||
|
||||
void operator=(const DiagnosticBuilder &) = delete;
|
||||
friend class DiagnosticsEngine;
|
||||
|
||||
DiagnosticBuilder() = default;
|
||||
|
@ -949,16 +958,18 @@ public:
|
|||
NumArgs = D.NumArgs;
|
||||
}
|
||||
|
||||
/// \brief Retrieve an empty diagnostic builder.
|
||||
static DiagnosticBuilder getEmpty() {
|
||||
return DiagnosticBuilder();
|
||||
}
|
||||
DiagnosticBuilder &operator=(const DiagnosticBuilder &) = delete;
|
||||
|
||||
/// \brief Emits the diagnostic.
|
||||
~DiagnosticBuilder() {
|
||||
Emit();
|
||||
}
|
||||
|
||||
|
||||
/// \brief Retrieve an empty diagnostic builder.
|
||||
static DiagnosticBuilder getEmpty() {
|
||||
return DiagnosticBuilder();
|
||||
}
|
||||
|
||||
/// \brief Forces the diagnostic to be emitted.
|
||||
const DiagnosticBuilder &setForceEmit() const {
|
||||
IsForceEmit = true;
|
||||
|
@ -1143,6 +1154,7 @@ inline DiagnosticBuilder DiagnosticsEngine::Report(unsigned DiagID) {
|
|||
class Diagnostic {
|
||||
const DiagnosticsEngine *DiagObj;
|
||||
StringRef StoredDiagMessage;
|
||||
|
||||
public:
|
||||
explicit Diagnostic(const DiagnosticsEngine *DO) : DiagObj(DO) {}
|
||||
Diagnostic(const DiagnosticsEngine *DO, StringRef storedDiagMessage)
|
||||
|
@ -1279,7 +1291,7 @@ public:
|
|||
ArrayRef<FixItHint> Fixits);
|
||||
|
||||
/// \brief Evaluates true when this object stores a diagnostic.
|
||||
explicit operator bool() const { return Message.size() > 0; }
|
||||
explicit operator bool() const { return !Message.empty(); }
|
||||
|
||||
unsigned getID() const { return ID; }
|
||||
DiagnosticsEngine::Level getLevel() const { return Level; }
|
||||
|
@ -1297,7 +1309,6 @@ public:
|
|||
return llvm::makeArrayRef(Ranges);
|
||||
}
|
||||
|
||||
|
||||
typedef std::vector<FixItHint>::const_iterator fixit_iterator;
|
||||
fixit_iterator fixit_begin() const { return FixIts.begin(); }
|
||||
fixit_iterator fixit_end() const { return FixIts.end(); }
|
||||
|
@ -1312,18 +1323,18 @@ public:
|
|||
/// formats and prints fully processed diagnostics.
|
||||
class DiagnosticConsumer {
|
||||
protected:
|
||||
unsigned NumWarnings; ///< Number of warnings reported
|
||||
unsigned NumErrors; ///< Number of errors reported
|
||||
unsigned NumWarnings = 0; ///< Number of warnings reported
|
||||
unsigned NumErrors = 0; ///< Number of errors reported
|
||||
|
||||
public:
|
||||
DiagnosticConsumer() : NumWarnings(0), NumErrors(0) { }
|
||||
DiagnosticConsumer() = default;
|
||||
|
||||
virtual ~DiagnosticConsumer();
|
||||
|
||||
unsigned getNumErrors() const { return NumErrors; }
|
||||
unsigned getNumWarnings() const { return NumWarnings; }
|
||||
virtual void clear() { NumWarnings = NumErrors = 0; }
|
||||
|
||||
virtual ~DiagnosticConsumer();
|
||||
|
||||
/// \brief Callback to inform the diagnostic client that processing
|
||||
/// of a source file is beginning.
|
||||
///
|
||||
|
@ -1368,6 +1379,7 @@ public:
|
|||
/// \brief A diagnostic client that ignores all diagnostics.
|
||||
class IgnoringDiagConsumer : public DiagnosticConsumer {
|
||||
virtual void anchor();
|
||||
|
||||
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
|
||||
const Diagnostic &Info) override {
|
||||
// Just ignore it.
|
||||
|
@ -1415,6 +1427,6 @@ void ProcessWarningOptions(DiagnosticsEngine &Diags,
|
|||
const DiagnosticOptions &Opts,
|
||||
bool ReportDiags = true);
|
||||
|
||||
} // end namespace clang
|
||||
} // end namespace clang
|
||||
|
||||
#endif
|
||||
#endif // LLVM_CLANG_BASIC_DIAGNOSTIC_H
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#define LLVM_CLANG_BASIC_FILEMANAGER_H
|
||||
|
||||
#include "clang/Basic/FileSystemOptions.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "clang/Basic/VirtualFileSystem.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/IntrusiveRefCntPtr.h"
|
||||
|
@ -24,22 +23,30 @@
|
|||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Allocator.h"
|
||||
#include "llvm/Support/ErrorOr.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
#include <ctime>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class MemoryBuffer;
|
||||
}
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
namespace clang {
|
||||
class FileManager;
|
||||
|
||||
class FileSystemStatCache;
|
||||
|
||||
/// \brief Cached information about one directory (either on disk or in
|
||||
/// the virtual file system).
|
||||
class DirectoryEntry {
|
||||
StringRef Name; // Name of the directory.
|
||||
friend class FileManager;
|
||||
|
||||
StringRef Name; // Name of the directory.
|
||||
|
||||
public:
|
||||
StringRef getName() const { return Name; }
|
||||
};
|
||||
|
@ -50,6 +57,8 @@ public:
|
|||
/// If the 'File' member is valid, then this FileEntry has an open file
|
||||
/// descriptor for the file.
|
||||
class FileEntry {
|
||||
friend class FileManager;
|
||||
|
||||
StringRef Name; // Name of the file.
|
||||
std::string RealPathName; // Real path to the file; could be empty.
|
||||
off_t Size; // File size in bytes.
|
||||
|
@ -63,16 +72,15 @@ class FileEntry {
|
|||
|
||||
/// \brief The open file, if it is owned by the \p FileEntry.
|
||||
mutable std::unique_ptr<vfs::File> File;
|
||||
friend class FileManager;
|
||||
|
||||
FileEntry(const FileEntry &) = delete;
|
||||
void operator=(const FileEntry &) = delete;
|
||||
|
||||
public:
|
||||
FileEntry()
|
||||
: UniqueID(0, 0), IsNamedPipe(false), InPCH(false), IsValid(false)
|
||||
{}
|
||||
|
||||
FileEntry(const FileEntry &) = delete;
|
||||
FileEntry &operator=(const FileEntry &) = delete;
|
||||
|
||||
StringRef getName() const { return Name; }
|
||||
StringRef tryGetRealPathName() const { return RealPathName; }
|
||||
bool isValid() const { return IsValid; }
|
||||
|
@ -276,6 +284,6 @@ public:
|
|||
void PrintStats() const;
|
||||
};
|
||||
|
||||
} // end namespace clang
|
||||
} // end namespace clang
|
||||
|
||||
#endif
|
||||
#endif // LLVM_CLANG_BASIC_FILEMANAGER_H
|
||||
|
|
|
@ -18,16 +18,26 @@
|
|||
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "clang/Basic/TokenKinds.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Allocator.h"
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <new>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
template <typename T> struct DenseMapInfo;
|
||||
}
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
namespace clang {
|
||||
|
||||
class LangOptions;
|
||||
class IdentifierInfo;
|
||||
class IdentifierTable;
|
||||
|
@ -38,13 +48,14 @@ namespace clang {
|
|||
/// \brief A simple pair of identifier info and location.
|
||||
typedef std::pair<IdentifierInfo*, SourceLocation> IdentifierLocPair;
|
||||
|
||||
|
||||
/// One of these records is kept for each identifier that
|
||||
/// is lexed. This contains information about whether the token was \#define'd,
|
||||
/// is a language keyword, or if it is a front-end token of some sort (e.g. a
|
||||
/// variable or function name). The preprocessor keeps this information in a
|
||||
/// set, and all tok::identifier tokens have a pointer to one of these.
|
||||
class IdentifierInfo {
|
||||
friend class IdentifierTable;
|
||||
|
||||
unsigned TokenID : 9; // Front-end token ID or tok::identifier.
|
||||
// Objective-C keyword ('protocol' in '@protocol') or builtin (__builtin_inf).
|
||||
// First NUM_OBJC_KEYWORDS values are for Objective-C, the remaining values
|
||||
|
@ -77,21 +88,18 @@ class IdentifierInfo {
|
|||
void *FETokenInfo; // Managed by the language front-end.
|
||||
llvm::StringMapEntry<IdentifierInfo*> *Entry;
|
||||
|
||||
IdentifierInfo(const IdentifierInfo&) = delete;
|
||||
void operator=(const IdentifierInfo&) = delete;
|
||||
|
||||
friend class IdentifierTable;
|
||||
|
||||
public:
|
||||
IdentifierInfo();
|
||||
|
||||
IdentifierInfo(const IdentifierInfo &) = delete;
|
||||
IdentifierInfo &operator=(const IdentifierInfo &) = delete;
|
||||
|
||||
/// \brief Return true if this is the identifier for the specified string.
|
||||
///
|
||||
/// This is intended to be used for string literals only: II->isStr("foo").
|
||||
template <std::size_t StrLen>
|
||||
bool isStr(const char (&Str)[StrLen]) const {
|
||||
return getLength() == StrLen-1 && !memcmp(getNameStart(), Str, StrLen-1);
|
||||
return getLength() == StrLen-1 &&
|
||||
memcmp(getNameStart(), Str, StrLen-1) == 0;
|
||||
}
|
||||
|
||||
/// \brief Return the beginning of the actual null-terminated string for this
|
||||
|
@ -137,7 +145,7 @@ public:
|
|||
|
||||
HasMacro = Val;
|
||||
if (Val) {
|
||||
NeedsHandleIdentifier = 1;
|
||||
NeedsHandleIdentifier = true;
|
||||
HadMacro = true;
|
||||
} else {
|
||||
RecomputeNeedsHandleIdentifier();
|
||||
|
@ -228,7 +236,7 @@ public:
|
|||
void setIsExtensionToken(bool Val) {
|
||||
IsExtension = Val;
|
||||
if (Val)
|
||||
NeedsHandleIdentifier = 1;
|
||||
NeedsHandleIdentifier = true;
|
||||
else
|
||||
RecomputeNeedsHandleIdentifier();
|
||||
}
|
||||
|
@ -242,7 +250,7 @@ public:
|
|||
void setIsFutureCompatKeyword(bool Val) {
|
||||
IsFutureCompatKeyword = Val;
|
||||
if (Val)
|
||||
NeedsHandleIdentifier = 1;
|
||||
NeedsHandleIdentifier = true;
|
||||
else
|
||||
RecomputeNeedsHandleIdentifier();
|
||||
}
|
||||
|
@ -252,7 +260,7 @@ public:
|
|||
void setIsPoisoned(bool Value = true) {
|
||||
IsPoisoned = Value;
|
||||
if (Value)
|
||||
NeedsHandleIdentifier = 1;
|
||||
NeedsHandleIdentifier = true;
|
||||
else
|
||||
RecomputeNeedsHandleIdentifier();
|
||||
}
|
||||
|
@ -265,7 +273,7 @@ public:
|
|||
void setIsCPlusPlusOperatorKeyword(bool Val = true) {
|
||||
IsCPPOperatorKeyword = Val;
|
||||
if (Val)
|
||||
NeedsHandleIdentifier = 1;
|
||||
NeedsHandleIdentifier = true;
|
||||
else
|
||||
RecomputeNeedsHandleIdentifier();
|
||||
}
|
||||
|
@ -370,6 +378,7 @@ private:
|
|||
class PoisonIdentifierRAIIObject {
|
||||
IdentifierInfo *const II;
|
||||
const bool OldValue;
|
||||
|
||||
public:
|
||||
PoisonIdentifierRAIIObject(IdentifierInfo *II, bool NewValue)
|
||||
: II(II), OldValue(II ? II->isPoisoned() : false) {
|
||||
|
@ -394,14 +403,13 @@ public:
|
|||
/// operation. Subclasses of this iterator type will provide the
|
||||
/// actual functionality.
|
||||
class IdentifierIterator {
|
||||
private:
|
||||
IdentifierIterator(const IdentifierIterator &) = delete;
|
||||
void operator=(const IdentifierIterator &) = delete;
|
||||
|
||||
protected:
|
||||
IdentifierIterator() { }
|
||||
IdentifierIterator() = default;
|
||||
|
||||
public:
|
||||
IdentifierIterator(const IdentifierIterator &) = delete;
|
||||
IdentifierIterator &operator=(const IdentifierIterator &) = delete;
|
||||
|
||||
virtual ~IdentifierIterator();
|
||||
|
||||
/// \brief Retrieve the next string in the identifier table and
|
||||
|
@ -536,7 +544,7 @@ public:
|
|||
|
||||
iterator begin() const { return HashTable.begin(); }
|
||||
iterator end() const { return HashTable.end(); }
|
||||
unsigned size() const { return HashTable.size(); }
|
||||
unsigned size() const { return HashTable.size(); }
|
||||
|
||||
/// \brief Print some statistics to stderr that indicate how well the
|
||||
/// hashing is doing.
|
||||
|
@ -653,6 +661,7 @@ class Selector {
|
|||
return reinterpret_cast<IdentifierInfo *>(InfoPtr & ~ArgFlags);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MultiKeywordSelector *getMultiKeywordSelector() const {
|
||||
return reinterpret_cast<MultiKeywordSelector *>(InfoPtr & ~ArgFlags);
|
||||
}
|
||||
|
@ -681,6 +690,7 @@ public:
|
|||
bool operator!=(Selector RHS) const {
|
||||
return InfoPtr != RHS.InfoPtr;
|
||||
}
|
||||
|
||||
void *getAsOpaquePtr() const {
|
||||
return reinterpret_cast<void*>(InfoPtr);
|
||||
}
|
||||
|
@ -692,12 +702,13 @@ public:
|
|||
bool isKeywordSelector() const {
|
||||
return getIdentifierInfoFlag() != ZeroArg;
|
||||
}
|
||||
|
||||
bool isUnarySelector() const {
|
||||
return getIdentifierInfoFlag() == ZeroArg;
|
||||
}
|
||||
|
||||
unsigned getNumArgs() const;
|
||||
|
||||
|
||||
/// \brief Retrieve the identifier at a given position in the selector.
|
||||
///
|
||||
/// Note that the identifier pointer returned may be NULL. Clients that only
|
||||
|
@ -742,6 +753,7 @@ public:
|
|||
static Selector getEmptyMarker() {
|
||||
return Selector(uintptr_t(-1));
|
||||
}
|
||||
|
||||
static Selector getTombstoneMarker() {
|
||||
return Selector(uintptr_t(-2));
|
||||
}
|
||||
|
@ -753,10 +765,11 @@ public:
|
|||
/// multi-keyword caching.
|
||||
class SelectorTable {
|
||||
void *Impl; // Actually a SelectorTableImpl
|
||||
SelectorTable(const SelectorTable &) = delete;
|
||||
void operator=(const SelectorTable &) = delete;
|
||||
|
||||
public:
|
||||
SelectorTable();
|
||||
SelectorTable(const SelectorTable &) = delete;
|
||||
SelectorTable &operator=(const SelectorTable &) = delete;
|
||||
~SelectorTable();
|
||||
|
||||
/// \brief Can create any sort of selector.
|
||||
|
@ -825,6 +838,7 @@ public:
|
|||
} // end namespace clang
|
||||
|
||||
namespace llvm {
|
||||
|
||||
/// Define DenseMapInfo so that Selectors can be used as keys in DenseMap and
|
||||
/// DenseSets.
|
||||
template <>
|
||||
|
@ -832,6 +846,7 @@ struct DenseMapInfo<clang::Selector> {
|
|||
static inline clang::Selector getEmptyKey() {
|
||||
return clang::Selector::getEmptyMarker();
|
||||
}
|
||||
|
||||
static inline clang::Selector getTombstoneKey() {
|
||||
return clang::Selector::getTombstoneMarker();
|
||||
}
|
||||
|
@ -854,9 +869,11 @@ public:
|
|||
static inline const void *getAsVoidPointer(clang::Selector P) {
|
||||
return P.getAsOpaquePtr();
|
||||
}
|
||||
|
||||
static inline clang::Selector getFromVoidPointer(const void *P) {
|
||||
return clang::Selector(reinterpret_cast<uintptr_t>(P));
|
||||
}
|
||||
|
||||
enum { NumLowBitsAvailable = 0 };
|
||||
};
|
||||
|
||||
|
@ -868,9 +885,11 @@ public:
|
|||
static inline void *getAsVoidPointer(clang::IdentifierInfo* P) {
|
||||
return P;
|
||||
}
|
||||
|
||||
static inline clang::IdentifierInfo *getFromVoidPointer(void *P) {
|
||||
return static_cast<clang::IdentifierInfo*>(P);
|
||||
}
|
||||
|
||||
enum { NumLowBitsAvailable = 1 };
|
||||
};
|
||||
|
||||
|
@ -880,11 +899,14 @@ public:
|
|||
static inline const void *getAsVoidPointer(const clang::IdentifierInfo* P) {
|
||||
return P;
|
||||
}
|
||||
|
||||
static inline const clang::IdentifierInfo *getFromVoidPointer(const void *P) {
|
||||
return static_cast<const clang::IdentifierInfo*>(P);
|
||||
}
|
||||
|
||||
enum { NumLowBitsAvailable = 1 };
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
#endif
|
||||
} // end namespace llvm
|
||||
|
||||
#endif // LLVM_CLANG_BASIC_IDENTIFIERTABLE_H
|
||||
|
|
|
@ -44,28 +44,34 @@
|
|||
#include "llvm/ADT/DenseSet.h"
|
||||
#include "llvm/ADT/IntrusiveRefCntPtr.h"
|
||||
#include "llvm/ADT/PointerIntPair.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Allocator.h"
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace clang {
|
||||
|
||||
class DiagnosticsEngine;
|
||||
class SourceManager;
|
||||
class FileManager;
|
||||
class FileEntry;
|
||||
class LineTableInfo;
|
||||
class ASTWriter;
|
||||
class ASTReader;
|
||||
class ASTWriter;
|
||||
class DiagnosticsEngine;
|
||||
class LineTableInfo;
|
||||
class SourceManager;
|
||||
|
||||
/// \brief Public enums and private classes that are part of the
|
||||
/// SourceManager implementation.
|
||||
///
|
||||
namespace SrcMgr {
|
||||
|
||||
/// \brief Indicates whether a file or directory holds normal user code,
|
||||
/// system code, or system code which is implicitly 'extern "C"' in C++ mode.
|
||||
///
|
||||
|
@ -144,8 +150,6 @@ namespace SrcMgr {
|
|||
SourceLineCache(nullptr), NumLines(0), BufferOverridden(false),
|
||||
IsSystemFile(false), IsTransient(false) {}
|
||||
|
||||
~ContentCache();
|
||||
|
||||
/// The copy ctor does not allow copies where source object has either
|
||||
/// a non-NULL Buffer or SourceLineCache. Ownership of allocated memory
|
||||
/// is not transferred, so this is a logical error.
|
||||
|
@ -162,6 +166,10 @@ namespace SrcMgr {
|
|||
NumLines = RHS.NumLines;
|
||||
}
|
||||
|
||||
ContentCache &operator=(const ContentCache& RHS) = delete;
|
||||
|
||||
~ContentCache();
|
||||
|
||||
/// \brief Returns the memory buffer for the associated content.
|
||||
///
|
||||
/// \param Diag Object through which diagnostics will be emitted if the
|
||||
|
@ -217,10 +225,6 @@ namespace SrcMgr {
|
|||
bool shouldFreeBuffer() const {
|
||||
return (Buffer.getInt() & DoNotFreeFlag) == 0;
|
||||
}
|
||||
|
||||
private:
|
||||
// Disable assignments.
|
||||
ContentCache &operator=(const ContentCache& RHS) = delete;
|
||||
};
|
||||
|
||||
// Assert that the \c ContentCache objects will always be 8-byte aligned so
|
||||
|
@ -257,6 +261,7 @@ namespace SrcMgr {
|
|||
friend class clang::SourceManager;
|
||||
friend class clang::ASTWriter;
|
||||
friend class clang::ASTReader;
|
||||
|
||||
public:
|
||||
/// \brief Return a FileInfo object.
|
||||
static FileInfo get(SourceLocation IL, const ContentCache *Con,
|
||||
|
@ -274,6 +279,7 @@ namespace SrcMgr {
|
|||
SourceLocation getIncludeLoc() const {
|
||||
return SourceLocation::getFromRawEncoding(IncludeLoc);
|
||||
}
|
||||
|
||||
const ContentCache* getContentCache() const {
|
||||
return reinterpret_cast<const ContentCache*>(Data & ~uintptr_t(7));
|
||||
}
|
||||
|
@ -314,9 +320,11 @@ namespace SrcMgr {
|
|||
SourceLocation getSpellingLoc() const {
|
||||
return SourceLocation::getFromRawEncoding(SpellingLoc);
|
||||
}
|
||||
|
||||
SourceLocation getExpansionLocStart() const {
|
||||
return SourceLocation::getFromRawEncoding(ExpansionLocStart);
|
||||
}
|
||||
|
||||
SourceLocation getExpansionLocEnd() const {
|
||||
SourceLocation EndLoc =
|
||||
SourceLocation::getFromRawEncoding(ExpansionLocEnd);
|
||||
|
@ -397,6 +405,7 @@ namespace SrcMgr {
|
|||
FileInfo File;
|
||||
ExpansionInfo Expansion;
|
||||
};
|
||||
|
||||
public:
|
||||
unsigned getOffset() const { return Offset; }
|
||||
|
||||
|
@ -431,6 +440,7 @@ namespace SrcMgr {
|
|||
return E;
|
||||
}
|
||||
};
|
||||
|
||||
} // end SrcMgr namespace.
|
||||
|
||||
/// \brief External source of source location entries.
|
||||
|
@ -451,7 +461,6 @@ public:
|
|||
virtual std::pair<SourceLocation, StringRef> getModuleImportLoc(int ID) = 0;
|
||||
};
|
||||
|
||||
|
||||
/// \brief Holds the cache used by isBeforeInTranslationUnit.
|
||||
///
|
||||
/// The cache structure is complex enough to be worth breaking out of
|
||||
|
@ -477,6 +486,7 @@ class InBeforeInTUCacheEntry {
|
|||
/// if LQueryFID is a parent of RQueryFID (or vice versa) then these can be a
|
||||
/// random token in the parent.
|
||||
unsigned LCommonOffset, RCommonOffset;
|
||||
|
||||
public:
|
||||
/// \brief Return true if the currently cached values match up with
|
||||
/// the specified LHS/RHS query.
|
||||
|
@ -524,13 +534,12 @@ public:
|
|||
LCommonOffset = lCommonOffset;
|
||||
RCommonOffset = rCommonOffset;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/// \brief The stack used when building modules on demand, which is used
|
||||
/// to provide a link between the source managers of the different compiler
|
||||
/// instances.
|
||||
typedef ArrayRef<std::pair<std::string, FullSourceLoc> > ModuleBuildStack;
|
||||
typedef ArrayRef<std::pair<std::string, FullSourceLoc>> ModuleBuildStack;
|
||||
|
||||
/// \brief This class handles loading and caching of source files into memory.
|
||||
///
|
||||
|
@ -665,7 +674,7 @@ class SourceManager : public RefCountedBase<SourceManager> {
|
|||
///
|
||||
/// Used to cache results from and speed-up \c getDecomposedIncludedLoc
|
||||
/// function.
|
||||
mutable llvm::DenseMap<FileID, std::pair<FileID, unsigned> > IncludedLocMap;
|
||||
mutable llvm::DenseMap<FileID, std::pair<FileID, unsigned>> IncludedLocMap;
|
||||
|
||||
/// The key value into the IsBeforeInTUCache table.
|
||||
typedef std::pair<FileID, FileID> IsBeforeInTUCacheKey;
|
||||
|
@ -704,12 +713,11 @@ class SourceManager : public RefCountedBase<SourceManager> {
|
|||
/// we can add a cc1-level option to do so.
|
||||
SmallVector<std::pair<std::string, FullSourceLoc>, 2> StoredModuleBuildStack;
|
||||
|
||||
// SourceManager doesn't support copy construction.
|
||||
explicit SourceManager(const SourceManager&) = delete;
|
||||
void operator=(const SourceManager&) = delete;
|
||||
public:
|
||||
SourceManager(DiagnosticsEngine &Diag, FileManager &FileMgr,
|
||||
bool UserFilesAreVolatile = false);
|
||||
explicit SourceManager(const SourceManager &) = delete;
|
||||
SourceManager &operator=(const SourceManager &) = delete;
|
||||
~SourceManager();
|
||||
|
||||
void clearIDTables();
|
||||
|
@ -1712,7 +1720,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
} // end namespace clang
|
||||
} // end namespace clang
|
||||
|
||||
|
||||
#endif
|
||||
#endif // LLVM_CLANG_BASIC_SOURCEMANAGER_H
|
||||
|
|
|
@ -16,16 +16,30 @@
|
|||
#include "clang/Basic/LLVM.h"
|
||||
#include "llvm/ADT/IntrusiveRefCntPtr.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/Twine.h"
|
||||
#include "llvm/Support/Chrono.h"
|
||||
#include "llvm/Support/ErrorOr.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
#include "llvm/Support/SourceMgr.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
#include <memory>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class MemoryBuffer;
|
||||
}
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
namespace clang {
|
||||
namespace vfs {
|
||||
|
@ -90,8 +104,10 @@ public:
|
|||
/// Sub-classes should generally call close() inside their destructors. We
|
||||
/// cannot do that from the base class, since close is virtual.
|
||||
virtual ~File();
|
||||
|
||||
/// \brief Get the status of the file.
|
||||
virtual llvm::ErrorOr<Status> status() = 0;
|
||||
|
||||
/// \brief Get the name of the file
|
||||
virtual llvm::ErrorOr<std::string> getName() {
|
||||
if (auto Status = status())
|
||||
|
@ -99,24 +115,30 @@ public:
|
|||
else
|
||||
return Status.getError();
|
||||
}
|
||||
|
||||
/// \brief Get the contents of the file as a \p MemoryBuffer.
|
||||
virtual llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
|
||||
getBuffer(const Twine &Name, int64_t FileSize = -1,
|
||||
bool RequiresNullTerminator = true, bool IsVolatile = false) = 0;
|
||||
|
||||
/// \brief Closes the file.
|
||||
virtual std::error_code close() = 0;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
/// \brief An interface for virtual file systems to provide an iterator over the
|
||||
/// (non-recursive) contents of a directory.
|
||||
struct DirIterImpl {
|
||||
virtual ~DirIterImpl();
|
||||
|
||||
/// \brief Sets \c CurrentEntry to the next entry in the directory on success,
|
||||
/// or returns a system-defined \c error_code.
|
||||
virtual std::error_code increment() = 0;
|
||||
|
||||
Status CurrentEntry;
|
||||
};
|
||||
|
||||
} // end namespace detail
|
||||
|
||||
/// \brief An input iterator over the entries in a virtual path, similar to
|
||||
|
@ -133,7 +155,7 @@ public:
|
|||
}
|
||||
|
||||
/// \brief Construct an 'end' iterator.
|
||||
directory_iterator() { }
|
||||
directory_iterator() = default;
|
||||
|
||||
/// \brief Equivalent to operator++, with an error code.
|
||||
directory_iterator &increment(std::error_code &EC) {
|
||||
|
@ -172,7 +194,7 @@ public:
|
|||
recursive_directory_iterator(FileSystem &FS, const Twine &Path,
|
||||
std::error_code &EC);
|
||||
/// \brief Construct an 'end' iterator.
|
||||
recursive_directory_iterator() { }
|
||||
recursive_directory_iterator() = default;
|
||||
|
||||
/// \brief Equivalent to operator++, with an error code.
|
||||
recursive_directory_iterator &increment(std::error_code &EC);
|
||||
|
@ -186,6 +208,7 @@ public:
|
|||
bool operator!=(const recursive_directory_iterator &RHS) const {
|
||||
return !(*this == RHS);
|
||||
}
|
||||
|
||||
/// \brief Gets the current level. Starting path is at level 0.
|
||||
int level() const {
|
||||
assert(State->size() && "Cannot get level without any iteration state");
|
||||
|
@ -281,7 +304,9 @@ public:
|
|||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
class InMemoryDirectory;
|
||||
|
||||
} // end namespace detail
|
||||
|
||||
/// An in-memory file system.
|
||||
|
@ -293,6 +318,7 @@ class InMemoryFileSystem : public FileSystem {
|
|||
public:
|
||||
explicit InMemoryFileSystem(bool UseNormalizedPaths = true);
|
||||
~InMemoryFileSystem() override;
|
||||
|
||||
/// Add a buffer to the VFS with a path. The VFS owns the buffer.
|
||||
/// \return true if the file was successfully added, false if the file already
|
||||
/// exists in the file system with different contents.
|
||||
|
@ -345,17 +371,22 @@ class YAMLVFSWriter {
|
|||
std::string OverlayDir;
|
||||
|
||||
public:
|
||||
YAMLVFSWriter() {}
|
||||
YAMLVFSWriter() = default;
|
||||
|
||||
void addFileMapping(StringRef VirtualPath, StringRef RealPath);
|
||||
|
||||
void setCaseSensitivity(bool CaseSensitive) {
|
||||
IsCaseSensitive = CaseSensitive;
|
||||
}
|
||||
|
||||
void setUseExternalNames(bool UseExtNames) {
|
||||
UseExternalNames = UseExtNames;
|
||||
}
|
||||
|
||||
void setIgnoreNonExistentContents(bool IgnoreContents) {
|
||||
IgnoreNonExistentContents = IgnoreContents;
|
||||
}
|
||||
|
||||
void setOverlayDir(StringRef OverlayDirectory) {
|
||||
IsOverlayRelative = true;
|
||||
OverlayDir.assign(OverlayDirectory.str());
|
||||
|
@ -366,4 +397,5 @@ public:
|
|||
|
||||
} // end namespace vfs
|
||||
} // end namespace clang
|
||||
#endif
|
||||
|
||||
#endif // LLVM_CLANG_BASIC_VIRTUALFILESYSTEM_H
|
||||
|
|
Loading…
Reference in New Issue