[clang] [OpenMP 6.0] Parse/Sema support for reduction over private variable with reduction clause. (PR #129938)
CHANDRA GHALE via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 5 13:40:53 PST 2025
https://github.com/chandraghale updated https://github.com/llvm/llvm-project/pull/129938
>From ea22ec12b98e50265d122e70482ce11d06e0921f Mon Sep 17 00:00:00 2001
From: Chandra Ghale <ghale at pe31.hpc.amslabs.hpecorp.net>
Date: Wed, 5 Mar 2025 14:59:44 -0600
Subject: [PATCH 1/2] Parse/Sema support for reduction over private variable
with reduction clause
---
clang/include/clang/AST/OpenMPClause.h | 16 +-
clang/include/clang/Basic/OpenMPKinds.def | 9 +
clang/include/clang/Basic/OpenMPKinds.h | 7 +
clang/include/clang/Sema/SemaOpenMP.h | 6 +-
clang/lib/AST/OpenMPClause.cpp | 3 +-
clang/lib/Parse/ParseOpenMP.cpp | 27 +
clang/lib/Sema/SemaOpenMP.cpp | 52 +-
clang/lib/Serialization/ASTReader.cpp | 1312 +++++++++--------
clang/lib/Serialization/ASTWriter.cpp | 578 ++++----
clang/test/OpenMP/for_reduction_messages.cpp | 5 +-
.../OpenMP/for_simd_reduction_messages.cpp | 4 +
.../parallel_for_reduction_messages.cpp | 9 +-
.../OpenMP/sections_reduction_messages.cpp | 4 +
13 files changed, 1086 insertions(+), 946 deletions(-)
diff --git a/clang/include/clang/AST/OpenMPClause.h b/clang/include/clang/AST/OpenMPClause.h
index 154ecfbaa4418..51d08205850d6 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -3678,6 +3678,9 @@ class OMPReductionClause final
/// Name of custom operator.
DeclarationNameInfo NameInfo;
+ /// Private variable reduction flag
+ llvm::SmallVector<bool, 8> IsPrivateVarReductionFlags;
+
/// Build clause with number of variables \a N.
///
/// \param StartLoc Starting location of the clause.
@@ -3854,6 +3857,7 @@ class OMPReductionClause final
/// region with this clause.
/// \param PostUpdate Expression that must be executed after exit from the
/// OpenMP region with this clause.
+ /// \pram IsPrivateVarReduction array for private variable reduction flags
static OMPReductionClause *
Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
SourceLocation ModifierLoc, SourceLocation ColonLoc,
@@ -3863,7 +3867,7 @@ class OMPReductionClause final
ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
ArrayRef<Expr *> ReductionOps, ArrayRef<Expr *> CopyOps,
ArrayRef<Expr *> CopyArrayTemps, ArrayRef<Expr *> CopyArrayElems,
- Stmt *PreInit, Expr *PostUpdate);
+ Stmt *PreInit, Expr *PostUpdate, ArrayRef<bool> IsPrivateVarReduction);
/// Creates an empty clause with the place for \a N variables.
///
@@ -3889,6 +3893,16 @@ class OMPReductionClause final
/// Gets the nested name specifier.
NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
+ /// Get all private variable reduction flags
+ ArrayRef<bool> getPrivateVariableReductionFlags() const {
+ return IsPrivateVarReductionFlags;
+ }
+
+ //// Set private variable reduction flags
+ void setPrivateVariableReductionFlags(ArrayRef<bool> Flags) {
+ std::copy(Flags.begin(), Flags.end(), IsPrivateVarReductionFlags.begin());
+ }
+
using helper_expr_iterator = MutableArrayRef<Expr *>::iterator;
using helper_expr_const_iterator = ArrayRef<const Expr *>::iterator;
using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
diff --git a/clang/include/clang/Basic/OpenMPKinds.def b/clang/include/clang/Basic/OpenMPKinds.def
index 76a861f416fd5..ea01fe6386ada 100644
--- a/clang/include/clang/Basic/OpenMPKinds.def
+++ b/clang/include/clang/Basic/OpenMPKinds.def
@@ -71,6 +71,9 @@
#ifndef OPENMP_REDUCTION_MODIFIER
#define OPENMP_REDUCTION_MODIFIER(Name)
#endif
+#ifndef OPENMP_ORIGINAL_SHARING_MODIFIER
+#define OPENMP_ORIGINAL_SHARING_MODIFIER(Name)
+#endif
#ifndef OPENMP_ADJUST_ARGS_KIND
#define OPENMP_ADJUST_ARGS_KIND(Name)
#endif
@@ -202,6 +205,11 @@ OPENMP_REDUCTION_MODIFIER(default)
OPENMP_REDUCTION_MODIFIER(inscan)
OPENMP_REDUCTION_MODIFIER(task)
+// OpenMP 6.0 modifiers for 'reduction' clause.
+OPENMP_ORIGINAL_SHARING_MODIFIER(shared)
+OPENMP_ORIGINAL_SHARING_MODIFIER(private)
+OPENMP_ORIGINAL_SHARING_MODIFIER(default)
+
// Adjust-op kinds for the 'adjust_args' clause.
OPENMP_ADJUST_ARGS_KIND(nothing)
OPENMP_ADJUST_ARGS_KIND(need_device_ptr)
@@ -233,6 +241,7 @@ OPENMP_DOACROSS_MODIFIER(source_omp_cur_iteration)
#undef OPENMP_ADJUST_ARGS_KIND
#undef OPENMP_REDUCTION_MODIFIER
#undef OPENMP_DEVICE_MODIFIER
+#undef OPENMP_ORIGINAL_SHARING_MODIFIER
#undef OPENMP_ORDER_KIND
#undef OPENMP_ORDER_MODIFIER
#undef OPENMP_LASTPRIVATE_KIND
diff --git a/clang/include/clang/Basic/OpenMPKinds.h b/clang/include/clang/Basic/OpenMPKinds.h
index e80bce34a97e0..6ca9f9c550285 100644
--- a/clang/include/clang/Basic/OpenMPKinds.h
+++ b/clang/include/clang/Basic/OpenMPKinds.h
@@ -190,6 +190,13 @@ enum OpenMPReductionClauseModifier {
OMPC_REDUCTION_unknown,
};
+/// OpenMP 6.0 original sharing modifiers
+enum OpenMPOriginalSharingModifier {
+#define OPENMP_ORIGINAL_SHARING_MODIFIER(Name) OMPC_ORIGINAL_SHARING_##Name,
+#include "clang/Basic/OpenMPKinds.def"
+ OMPC_ORIGINAL_SHARING_unknown,
+};
+
/// OpenMP adjust-op kinds for 'adjust_args' clause.
enum OpenMPAdjustArgsOpKind {
#define OPENMP_ADJUST_ARGS_KIND(Name) OMPC_ADJUST_ARGS_##Name,
diff --git a/clang/include/clang/Sema/SemaOpenMP.h b/clang/include/clang/Sema/SemaOpenMP.h
index 64f0cfa0676af..90768e763894d 100644
--- a/clang/include/clang/Sema/SemaOpenMP.h
+++ b/clang/include/clang/Sema/SemaOpenMP.h
@@ -1142,6 +1142,7 @@ class SemaOpenMP : public SemaBase {
DeclarationNameInfo ReductionOrMapperId;
int ExtraModifier = -1; ///< Additional modifier for linear, map, depend or
///< lastprivate clause.
+ int OriginalSharingModifier = 0; // Default is shared
SmallVector<OpenMPMapModifierKind, NumberOfOMPMapClauseModifiers>
MapTypeModifiers;
SmallVector<SourceLocation, NumberOfOMPMapClauseModifiers>
@@ -1151,6 +1152,7 @@ class SemaOpenMP : public SemaBase {
SmallVector<SourceLocation, NumberOfOMPMotionModifiers> MotionModifiersLoc;
bool IsMapTypeImplicit = false;
SourceLocation ExtraModifierLoc;
+ SourceLocation OriginalSharingModifierLoc;
SourceLocation OmpAllMemoryLoc;
SourceLocation
StepModifierLoc; /// 'step' modifier location for linear clause
@@ -1213,7 +1215,9 @@ class SemaOpenMP : public SemaBase {
SourceLocation ModifierLoc, SourceLocation ColonLoc,
SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec,
const DeclarationNameInfo &ReductionId,
- ArrayRef<Expr *> UnresolvedReductions = {});
+ ArrayRef<Expr *> UnresolvedReductions = {},
+ OpenMPOriginalSharingModifier OriginalShareModifier =
+ OMPC_ORIGINAL_SHARING_default);
/// Called on well-formed 'task_reduction' clause.
OMPClause *ActOnOpenMPTaskReductionClause(
ArrayRef<Expr *> VarList, SourceLocation StartLoc,
diff --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp
index 424cab3a7de35..df4f0550e0a98 100644
--- a/clang/lib/AST/OpenMPClause.cpp
+++ b/clang/lib/AST/OpenMPClause.cpp
@@ -797,7 +797,7 @@ OMPReductionClause *OMPReductionClause::Create(
ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps,
ArrayRef<Expr *> CopyOps, ArrayRef<Expr *> CopyArrayTemps,
- ArrayRef<Expr *> CopyArrayElems, Stmt *PreInit, Expr *PostUpdate) {
+ ArrayRef<Expr *> CopyArrayElems, Stmt *PreInit, Expr *PostUpdate,ArrayRef<bool> IsPrivateVarReduction) {
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(
(Modifier == OMPC_REDUCTION_inscan ? 8 : 5) * VL.size()));
auto *Clause = new (Mem)
@@ -810,6 +810,7 @@ OMPReductionClause *OMPReductionClause::Create(
Clause->setReductionOps(ReductionOps);
Clause->setPreInitStmt(PreInit);
Clause->setPostUpdateExpr(PostUpdate);
+ Clause->setPrivateVariableReductionFlags(IsPrivateVarReduction);
if (Modifier == OMPC_REDUCTION_inscan) {
Clause->setInscanCopyOps(CopyOps);
Clause->setInscanCopyArrayTemps(CopyArrayTemps);
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 42e6aac681c1c..3b95eb01a06c9 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -4668,6 +4668,33 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind,
assert(Tok.is(tok::comma) && "Expected comma.");
(void)ConsumeToken();
}
+ // Handle original(private / shared) Modifier
+ if (Kind == OMPC_reduction && getLangOpts().OpenMP >= 60 &&
+ Tok.is(tok::identifier) && PP.getSpelling(Tok) == "original" &&
+ NextToken().is(tok::l_paren)) {
+ // Parse original(private) modifier.
+ ConsumeToken();
+ BalancedDelimiterTracker ParenT(*this, tok::l_paren, tok::r_paren);
+ ParenT.consumeOpen();
+ if (Tok.is(tok::kw_private)) {
+ Data.OriginalSharingModifier = OMPC_ORIGINAL_SHARING_private;
+ Data.OriginalSharingModifierLoc = Tok.getLocation();
+ ConsumeToken();
+ } else if (Tok.is(tok::identifier) && (PP.getSpelling(Tok) == "shared"
+ || PP.getSpelling(Tok) == "default")) {
+ Data.OriginalSharingModifier = OMPC_ORIGINAL_SHARING_shared;
+ Data.OriginalSharingModifierLoc = Tok.getLocation();
+ ConsumeToken();
+ } else {
+ Diag(Tok.getLocation(), diag::err_expected)
+ << "'private or shared or default'";
+ SkipUntil(tok::r_paren);
+ return false;
+ }
+ ParenT.consumeClose();
+ assert(Tok.is(tok::comma) && "Expected comma.");
+ (void)ConsumeToken();
+ }
ColonProtectionRAIIObject ColonRAII(*this);
if (getLangOpts().CPlusPlus)
ParseOptionalCXXScopeSpecifier(Data.ReductionOrMapperIdScopeSpec,
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 616296027d811..ae554299a01b1 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -17366,6 +17366,7 @@ OMPClause *SemaOpenMP::ActOnOpenMPVarListClause(OpenMPClauseKind Kind,
SourceLocation EndLoc = Locs.EndLoc;
OMPClause *Res = nullptr;
int ExtraModifier = Data.ExtraModifier;
+ int OriginalSharingModifier = Data.OriginalSharingModifier;
SourceLocation ExtraModifierLoc = Data.ExtraModifierLoc;
SourceLocation ColonLoc = Data.ColonLoc;
switch (Kind) {
@@ -17391,7 +17392,8 @@ OMPClause *SemaOpenMP::ActOnOpenMPVarListClause(OpenMPClauseKind Kind,
Res = ActOnOpenMPReductionClause(
VarList, static_cast<OpenMPReductionClauseModifier>(ExtraModifier),
StartLoc, LParenLoc, ExtraModifierLoc, ColonLoc, EndLoc,
- Data.ReductionOrMapperIdScopeSpec, Data.ReductionOrMapperId);
+ Data.ReductionOrMapperIdScopeSpec, Data.ReductionOrMapperId, {},
+ static_cast<OpenMPOriginalSharingModifier>(OriginalSharingModifier));
break;
case OMPC_task_reduction:
Res = ActOnOpenMPTaskReductionClause(
@@ -18570,14 +18572,20 @@ struct ReductionData {
SmallVector<Expr *, 4> ExprPostUpdates;
/// Reduction modifier.
unsigned RedModifier = 0;
+ /// Original modifier.
+ unsigned OrigSharingModifier = 0;
+ /// Private Variable Reduction
+ SmallVector<bool, 8> IsPrivateVarReduction;
ReductionData() = delete;
/// Reserves required memory for the reduction data.
- ReductionData(unsigned Size, unsigned Modifier = 0) : RedModifier(Modifier) {
+ ReductionData(unsigned Size, unsigned Modifier = 0, unsigned OrgModifier = 0)
+ : RedModifier(Modifier), OrigSharingModifier(OrgModifier) {
Vars.reserve(Size);
Privates.reserve(Size);
LHSs.reserve(Size);
RHSs.reserve(Size);
ReductionOps.reserve(Size);
+ IsPrivateVarReduction.reserve(Size);
if (RedModifier == OMPC_REDUCTION_inscan) {
InscanCopyOps.reserve(Size);
InscanCopyArrayTemps.reserve(Size);
@@ -18595,6 +18603,7 @@ struct ReductionData {
LHSs.emplace_back(nullptr);
RHSs.emplace_back(nullptr);
ReductionOps.emplace_back(ReductionOp);
+ IsPrivateVarReduction.emplace_back(false);
TaskgroupDescriptors.emplace_back(nullptr);
if (RedModifier == OMPC_REDUCTION_inscan) {
InscanCopyOps.push_back(nullptr);
@@ -18605,7 +18614,7 @@ struct ReductionData {
/// Stores reduction data.
void push(Expr *Item, Expr *Private, Expr *LHS, Expr *RHS, Expr *ReductionOp,
Expr *TaskgroupDescriptor, Expr *CopyOp, Expr *CopyArrayTemp,
- Expr *CopyArrayElem) {
+ Expr *CopyArrayElem, bool IsPrivate) {
Vars.emplace_back(Item);
Privates.emplace_back(Private);
LHSs.emplace_back(LHS);
@@ -18621,6 +18630,7 @@ struct ReductionData {
CopyArrayElem == nullptr &&
"Copy operation must be used for inscan reductions only.");
}
+ IsPrivateVarReduction.emplace_back(IsPrivate);
}
};
} // namespace
@@ -18834,6 +18844,7 @@ static bool actOnOMPReductionKindClause(
FirstIter = false;
SourceLocation ELoc;
SourceRange ERange;
+ bool IsPrivate = false;
Expr *SimpleRefExpr = RefExpr;
auto Res = getPrivateItem(S, SimpleRefExpr, ELoc, ERange,
/*AllowArraySection=*/true);
@@ -18933,12 +18944,35 @@ static bool actOnOMPReductionKindClause(
reportOriginalDsa(S, Stack, D, DVar);
continue;
}
+ // OpenMP 6.0 [ 7.6.10 ]
+ // Support Reduction over private variables with reduction clause.
+ // A list item in a reduction clause can now be private in the enclosing
+ // context. For orphaned constructs it is assumed to be shared unless the
+ // original(private) modifier appears in the clause.
+ DVar = Stack->getImplicitDSA(D, true);
+ bool IsOrphaned = false;
+ OpenMPDirectiveKind CurrDir = Stack->getCurrentDirective();
+ OpenMPDirectiveKind ParentDir = Stack->getParentDirective();
+ // Check if the construct is orphaned (has no enclosing OpenMP context)
+ IsOrphaned = (ParentDir == OMPD_unknown);
+ IsPrivate =
+ ((isOpenMPPrivate(DVar.CKind) && DVar.CKind != OMPC_reduction &&
+ isOpenMPWorksharingDirective(CurrDir) &&
+ !isOpenMPParallelDirective(CurrDir) &&
+ !isOpenMPTeamsDirective(CurrDir) &&
+ !isOpenMPSimdDirective(ParentDir)) ||
+ (IsOrphaned && DVar.CKind == OMPC_unknown) ||
+ RD.OrigSharingModifier != OMPC_ORIGINAL_SHARING_shared);
+ // Disable private handling for OpenMP versions <= 5.2
+ if (S.getLangOpts().OpenMP <= 52)
+ IsPrivate = false;
// OpenMP [2.14.3.6, Restrictions, p.1]
// A list item that appears in a reduction clause of a worksharing
// construct must be shared in the parallel regions to which any of the
// worksharing regions arising from the worksharing construct bind.
- if (isOpenMPWorksharingDirective(CurrDir) &&
+
+ if (!IsPrivate && isOpenMPWorksharingDirective(CurrDir) &&
!isOpenMPParallelDirective(CurrDir) &&
!isOpenMPTeamsDirective(CurrDir)) {
DVar = Stack->getImplicitDSA(D, true);
@@ -19434,7 +19468,7 @@ static bool actOnOMPReductionKindClause(
}
RD.push(VarsExpr, PrivateDRE, LHSDRE, RHSDRE, ReductionOp.get(),
TaskgroupDescriptor, CopyOpRes.get(), TempArrayRes.get(),
- TempArrayElem.get());
+ TempArrayElem.get(), IsPrivate);
}
return RD.Vars.empty();
}
@@ -19444,7 +19478,8 @@ OMPClause *SemaOpenMP::ActOnOpenMPReductionClause(
SourceLocation StartLoc, SourceLocation LParenLoc,
SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc,
CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId,
- ArrayRef<Expr *> UnresolvedReductions) {
+ ArrayRef<Expr *> UnresolvedReductions,
+ OpenMPOriginalSharingModifier OriginalSharingMod) {
if (ModifierLoc.isValid() && Modifier == OMPC_REDUCTION_unknown) {
Diag(LParenLoc, diag::err_omp_unexpected_clause_value)
<< getListOfPossibleValues(OMPC_reduction, /*First=*/0,
@@ -19466,8 +19501,7 @@ OMPClause *SemaOpenMP::ActOnOpenMPReductionClause(
Diag(ModifierLoc, diag::err_omp_wrong_inscan_reduction);
return nullptr;
}
-
- ReductionData RD(VarList.size(), Modifier);
+ ReductionData RD(VarList.size(), Modifier, OriginalSharingMod);
if (actOnOMPReductionKindClause(SemaRef, DSAStack, OMPC_reduction, VarList,
StartLoc, LParenLoc, ColonLoc, EndLoc,
ReductionIdScopeSpec, ReductionId,
@@ -19481,7 +19515,7 @@ OMPClause *SemaOpenMP::ActOnOpenMPReductionClause(
RD.Privates, RD.LHSs, RD.RHSs, RD.ReductionOps, RD.InscanCopyOps,
RD.InscanCopyArrayTemps, RD.InscanCopyArrayElems,
buildPreInits(getASTContext(), RD.ExprCaptures),
- buildPostUpdate(SemaRef, RD.ExprPostUpdates));
+ buildPostUpdate(SemaRef, RD.ExprPostUpdates), RD.IsPrivateVarReduction);
}
OMPClause *SemaOpenMP::ActOnOpenMPTaskReductionClause(
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 4a40df6399f64..fc01ac6097d8c 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -158,8 +158,8 @@ using llvm::BitstreamCursor;
// ChainedASTReaderListener implementation
//===----------------------------------------------------------------------===//
-bool
-ChainedASTReaderListener::ReadFullVersionInformation(StringRef FullVersion) {
+bool ChainedASTReaderListener::ReadFullVersionInformation(
+ StringRef FullVersion) {
return First->ReadFullVersionInformation(FullVersion) ||
Second->ReadFullVersionInformation(FullVersion);
}
@@ -199,9 +199,8 @@ bool ChainedASTReaderListener::ReadDiagnosticOptions(
Second->ReadDiagnosticOptions(DiagOpts, ModuleFilename, Complain);
}
-bool
-ChainedASTReaderListener::ReadFileSystemOptions(const FileSystemOptions &FSOpts,
- bool Complain) {
+bool ChainedASTReaderListener::ReadFileSystemOptions(
+ const FileSystemOptions &FSOpts, bool Complain) {
return First->ReadFileSystemOptions(FSOpts, Complain) ||
Second->ReadFileSystemOptions(FSOpts, Complain);
}
@@ -237,7 +236,7 @@ bool ChainedASTReaderListener::needsInputFileVisitation() {
bool ChainedASTReaderListener::needsSystemInputFileVisitation() {
return First->needsSystemInputFileVisitation() ||
- Second->needsSystemInputFileVisitation();
+ Second->needsSystemInputFileVisitation();
}
void ChainedASTReaderListener::visitModuleFile(StringRef Filename,
@@ -246,8 +245,7 @@ void ChainedASTReaderListener::visitModuleFile(StringRef Filename,
Second->visitModuleFile(Filename, Kind);
}
-bool ChainedASTReaderListener::visitInputFile(StringRef Filename,
- bool isSystem,
+bool ChainedASTReaderListener::visitInputFile(StringRef Filename, bool isSystem,
bool isOverridden,
bool isExplicitModule) {
bool Continue = false;
@@ -263,7 +261,7 @@ bool ChainedASTReaderListener::visitInputFile(StringRef Filename,
}
void ChainedASTReaderListener::readModuleFileExtension(
- const ModuleFileExtensionMetadata &Metadata) {
+ const ModuleFileExtensionMetadata &Metadata) {
First->readModuleFileExtension(Metadata);
Second->readModuleFileExtension(Metadata);
}
@@ -317,17 +315,17 @@ static bool checkLanguageOptions(const LangOptions &LangOpts,
return true; \
}
-#define COMPATIBLE_LANGOPT(Name, Bits, Default, Description) \
- if (!AllowCompatibleDifferences) \
- LANGOPT(Name, Bits, Default, Description)
+#define COMPATIBLE_LANGOPT(Name, Bits, Default, Description) \
+ if (!AllowCompatibleDifferences) \
+ LANGOPT(Name, Bits, Default, Description)
-#define COMPATIBLE_ENUM_LANGOPT(Name, Bits, Default, Description) \
- if (!AllowCompatibleDifferences) \
- ENUM_LANGOPT(Name, Bits, Default, Description)
+#define COMPATIBLE_ENUM_LANGOPT(Name, Bits, Default, Description) \
+ if (!AllowCompatibleDifferences) \
+ ENUM_LANGOPT(Name, Bits, Default, Description)
-#define COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description) \
- if (!AllowCompatibleDifferences) \
- VALUE_LANGOPT(Name, Bits, Default, Description)
+#define COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description) \
+ if (!AllowCompatibleDifferences) \
+ VALUE_LANGOPT(Name, Bits, Default, Description)
#define BENIGN_LANGOPT(Name, Bits, Default, Description)
#define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
@@ -422,8 +420,8 @@ static bool checkTargetOptions(const TargetOptions &TargetOpts,
// Compare feature sets.
SmallVector<StringRef, 4> ExistingFeatures(
- ExistingTargetOpts.FeaturesAsWritten.begin(),
- ExistingTargetOpts.FeaturesAsWritten.end());
+ ExistingTargetOpts.FeaturesAsWritten.begin(),
+ ExistingTargetOpts.FeaturesAsWritten.end());
SmallVector<StringRef, 4> ReadFeatures(TargetOpts.FeaturesAsWritten.begin(),
TargetOpts.FeaturesAsWritten.end());
llvm::sort(ExistingFeatures);
@@ -432,9 +430,9 @@ static bool checkTargetOptions(const TargetOptions &TargetOpts,
// We compute the set difference in both directions explicitly so that we can
// diagnose the differences differently.
SmallVector<StringRef, 4> UnmatchedExistingFeatures, UnmatchedReadFeatures;
- std::set_difference(
- ExistingFeatures.begin(), ExistingFeatures.end(), ReadFeatures.begin(),
- ReadFeatures.end(), std::back_inserter(UnmatchedExistingFeatures));
+ std::set_difference(ExistingFeatures.begin(), ExistingFeatures.end(),
+ ReadFeatures.begin(), ReadFeatures.end(),
+ std::back_inserter(UnmatchedExistingFeatures));
std::set_difference(ReadFeatures.begin(), ReadFeatures.end(),
ExistingFeatures.begin(), ExistingFeatures.end(),
std::back_inserter(UnmatchedReadFeatures));
@@ -491,7 +489,7 @@ static bool checkDiagnosticGroupMappings(DiagnosticsEngine &StoredDiags,
// Check current mappings for new -Werror mappings, and the stored mappings
// for cases that were explicitly mapped to *not* be errors that are now
// errors because of options like -Werror.
- DiagnosticsEngine *MappingSources[] = { &Diags, &StoredDiags };
+ DiagnosticsEngine *MappingSources[] = {&Diags, &StoredDiags};
for (DiagnosticsEngine *MappingSource : MappingSources) {
for (auto DiagIDMappingPair : MappingSource->getDiagnosticMappings()) {
@@ -974,12 +972,12 @@ LocalDeclID LocalDeclID::get(ASTReader &Reader, ModuleFile &MF,
}
std::pair<unsigned, unsigned>
-ASTSelectorLookupTrait::ReadKeyDataLength(const unsigned char*& d) {
+ASTSelectorLookupTrait::ReadKeyDataLength(const unsigned char *&d) {
return readULEBKeyDataLength(d);
}
ASTSelectorLookupTrait::internal_key_type
-ASTSelectorLookupTrait::ReadKey(const unsigned char* d, unsigned) {
+ASTSelectorLookupTrait::ReadKey(const unsigned char *d, unsigned) {
using namespace llvm::support;
SelectorTable &SelTable = Reader.getContext().Selectors;
@@ -1001,7 +999,7 @@ ASTSelectorLookupTrait::ReadKey(const unsigned char* d, unsigned) {
}
ASTSelectorLookupTrait::data_type
-ASTSelectorLookupTrait::ReadData(Selector, const unsigned char* d,
+ASTSelectorLookupTrait::ReadData(Selector, const unsigned char *d,
unsigned DataLen) {
using namespace llvm::support;
@@ -1041,19 +1039,19 @@ ASTSelectorLookupTrait::ReadData(Selector, const unsigned char* d,
return Result;
}
-unsigned ASTIdentifierLookupTraitBase::ComputeHash(const internal_key_type& a) {
+unsigned ASTIdentifierLookupTraitBase::ComputeHash(const internal_key_type &a) {
return llvm::djbHash(a);
}
std::pair<unsigned, unsigned>
-ASTIdentifierLookupTraitBase::ReadKeyDataLength(const unsigned char*& d) {
+ASTIdentifierLookupTraitBase::ReadKeyDataLength(const unsigned char *&d) {
return readULEBKeyDataLength(d);
}
ASTIdentifierLookupTraitBase::internal_key_type
-ASTIdentifierLookupTraitBase::ReadKey(const unsigned char* d, unsigned n) {
- assert(n >= 2 && d[n-1] == '\0');
- return StringRef((const char*) d, n-1);
+ASTIdentifierLookupTraitBase::ReadKey(const unsigned char *d, unsigned n) {
+ assert(n >= 2 && d[n - 1] == '\0');
+ return StringRef((const char *)d, n - 1);
}
/// Whether the given identifier is "interesting".
@@ -1075,7 +1073,8 @@ static bool readBit(unsigned &Bits) {
return Value;
}
-IdentifierID ASTIdentifierLookupTrait::ReadIdentifierID(const unsigned char *d) {
+IdentifierID
+ASTIdentifierLookupTrait::ReadIdentifierID(const unsigned char *d) {
using namespace llvm::support;
IdentifierID RawID =
@@ -1092,8 +1091,8 @@ static void markIdentifierFromAST(ASTReader &Reader, IdentifierInfo &II,
}
}
-IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k,
- const unsigned char* d,
+IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type &k,
+ const unsigned char *d,
unsigned DataLen) {
using namespace llvm::support;
@@ -1197,7 +1196,8 @@ DeclarationNameKey::DeclarationNameKey(DeclarationName Name)
break;
case DeclarationName::CXXDeductionGuideName:
Data = (uint64_t)Name.getCXXDeductionGuideTemplate()
- ->getDeclName().getAsIdentifierInfo();
+ ->getDeclName()
+ .getAsIdentifierInfo();
break;
case DeclarationName::CXXConstructorName:
case DeclarationName::CXXDestructorName:
@@ -1216,7 +1216,7 @@ unsigned DeclarationNameKey::getHash() const {
case DeclarationName::Identifier:
case DeclarationName::CXXLiteralOperatorName:
case DeclarationName::CXXDeductionGuideName:
- ID.AddString(((IdentifierInfo*)Data)->getName());
+ ID.AddString(((IdentifierInfo *)Data)->getName());
break;
case DeclarationName::ObjCZeroArgSelector:
case DeclarationName::ObjCOneArgSelector:
@@ -1476,7 +1476,7 @@ bool ASTReader::ReadVisibleDeclContextStorage(
// We can't safely determine the primary context yet, so delay attaching the
// lookup table until we're done with recursive deserialization.
- auto *Data = (const unsigned char*)Blob.data();
+ auto *Data = (const unsigned char *)Blob.data();
switch (VisibleKind) {
case VisibleDeclContextStorageKind::GenerallyVisible:
PendingVisibleUpdates[ID].push_back(UpdateData{&M, Data});
@@ -1542,7 +1542,7 @@ void ASTReader::Error(StringRef Msg) const {
if (PP.getLangOpts().Modules &&
!PP.getHeaderSearchInfo().getModuleCachePath().empty()) {
Diag(diag::note_module_cache_path)
- << PP.getHeaderSearchInfo().getModuleCachePath();
+ << PP.getHeaderSearchInfo().getModuleCachePath();
}
}
@@ -1610,11 +1610,11 @@ void ASTReader::ParseLineTable(ModuleFile &F, const RecordData &Record) {
unsigned FileOffset = Record[Idx++];
unsigned LineNo = Record[Idx++];
int FilenameID = FileIDs[Record[Idx++]];
- SrcMgr::CharacteristicKind FileKind
- = (SrcMgr::CharacteristicKind)Record[Idx++];
+ SrcMgr::CharacteristicKind FileKind =
+ (SrcMgr::CharacteristicKind)Record[Idx++];
unsigned IncludeOffset = Record[Idx++];
- Entries.push_back(LineEntry::get(FileOffset, LineNo, FilenameID,
- FileKind, IncludeOffset));
+ Entries.push_back(LineEntry::get(FileOffset, LineNo, FilenameID, FileKind,
+ IncludeOffset));
}
LineTable.AddEntry(FID, Entries);
}
@@ -1669,7 +1669,7 @@ llvm::Error ASTReader::ReadSourceManagerBlock(ModuleFile &F) {
if (!MaybeRecord)
return MaybeRecord.takeError();
switch (MaybeRecord.get()) {
- default: // Default behavior: ignore.
+ default: // Default behavior: ignore.
break;
case SM_SLOC_FILE_ENTRY:
@@ -1765,9 +1765,9 @@ bool ASTReader::ReadSLocEntry(int ID) {
// Local helper to read the (possibly-compressed) buffer data following the
// entry record.
- auto ReadBuffer = [this](
- BitstreamCursor &SLocEntryCursor,
- StringRef Name) -> std::unique_ptr<llvm::MemoryBuffer> {
+ auto ReadBuffer =
+ [this](BitstreamCursor &SLocEntryCursor,
+ StringRef Name) -> std::unique_ptr<llvm::MemoryBuffer> {
RecordData Record;
StringRef Blob;
Expected<unsigned> MaybeCode = SLocEntryCursor.ReadCode();
@@ -1869,8 +1869,8 @@ bool ASTReader::ReadSLocEntry(int ID) {
// This is the module's main file.
IncludeLoc = getImportLocation(F);
}
- SrcMgr::CharacteristicKind
- FileCharacter = (SrcMgr::CharacteristicKind)Record[2];
+ SrcMgr::CharacteristicKind FileCharacter =
+ (SrcMgr::CharacteristicKind)Record[2];
FileID FID = SourceMgr.createFileID(*File, IncludeLoc, FileCharacter, ID,
BaseOffset + Record[0]);
SrcMgr::FileInfo &FileInfo = SourceMgr.getSLocEntry(FID).getFile();
@@ -1903,8 +1903,8 @@ bool ASTReader::ReadSLocEntry(int ID) {
case SM_SLOC_BUFFER_ENTRY: {
const char *Name = Blob.data();
unsigned Offset = Record[0];
- SrcMgr::CharacteristicKind
- FileCharacter = (SrcMgr::CharacteristicKind)Record[2];
+ SrcMgr::CharacteristicKind FileCharacter =
+ (SrcMgr::CharacteristicKind)Record[2];
SourceLocation IncludeLoc = ReadSourceLocation(*F, Record[1]);
if (IncludeLoc.isInvalid() && F->isModule()) {
IncludeLoc = getImportLocation(F);
@@ -2067,7 +2067,7 @@ MacroInfo *ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset) {
return nullptr;
}
RecordData Record;
- SmallVector<IdentifierInfo*, 16> MacroParams;
+ SmallVector<IdentifierInfo *, 16> MacroParams;
MacroInfo *Macro = nullptr;
llvm::MutableArrayRef<Token> MacroTokens;
@@ -2138,9 +2138,12 @@ MacroInfo *ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset) {
// Install function-like macro info.
MI->setIsFunctionLike();
- if (isC99VarArgs) MI->setIsC99Varargs();
- if (isGNUVarArgs) MI->setIsGNUVarargs();
- if (hasCommaPasting) MI->setHasCommaPasting();
+ if (isC99VarArgs)
+ MI->setIsC99Varargs();
+ if (isGNUVarArgs)
+ MI->setIsGNUVarargs();
+ if (hasCommaPasting)
+ MI->setHasCommaPasting();
MI->setParameterList(MacroParams, PP.getPreprocessorAllocator());
}
@@ -2151,8 +2154,8 @@ MacroInfo *ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset) {
if (NextIndex + 1 == Record.size() && PP.getPreprocessingRecord() &&
Record[NextIndex]) {
// We have a macro definition. Register the association
- PreprocessedEntityID
- GlobalID = getGlobalPreprocessedEntityID(F, Record[NextIndex]);
+ PreprocessedEntityID GlobalID =
+ getGlobalPreprocessedEntityID(F, Record[NextIndex]);
PreprocessingRecord &PPRec = *PP.getPreprocessingRecord();
PreprocessingRecord::PPEntityID PPID =
PPRec.getPPEntityID(GlobalID - 1, /*isLoaded=*/true);
@@ -2169,7 +2172,8 @@ MacroInfo *ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset) {
case PP_TOKEN: {
// If we see a TOKEN before a PP_MACRO_*, then the file is
// erroneous, just pretend we didn't see this.
- if (!Macro) break;
+ if (!Macro)
+ break;
if (MacroTokens.empty()) {
Error("unexpected number of macro tokens for a macro in AST file");
return Macro;
@@ -2190,10 +2194,10 @@ ASTReader::getGlobalPreprocessedEntityID(ModuleFile &M,
if (!M.ModuleOffsetMap.empty())
ReadModuleOffsetMap(M);
- ContinuousRangeMap<uint32_t, int, 2>::const_iterator
- I = M.PreprocessedEntityRemap.find(LocalID - NUM_PREDEF_PP_ENTITY_IDS);
- assert(I != M.PreprocessedEntityRemap.end()
- && "Invalid index into preprocessed entity index remap");
+ ContinuousRangeMap<uint32_t, int, 2>::const_iterator I =
+ M.PreprocessedEntityRemap.find(LocalID - NUM_PREDEF_PP_ENTITY_IDS);
+ assert(I != M.PreprocessedEntityRemap.end() &&
+ "Invalid index into preprocessed entity index remap");
return LocalID + I->second;
}
@@ -2238,7 +2242,7 @@ bool HeaderFileInfoTrait::EqualKey(internal_key_ref a, internal_key_ref b) {
}
std::pair<unsigned, unsigned>
-HeaderFileInfoTrait::ReadKeyDataLength(const unsigned char*& d) {
+HeaderFileInfoTrait::ReadKeyDataLength(const unsigned char *&d) {
return readULEBKeyDataLength(d);
}
@@ -2310,7 +2314,8 @@ HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,
void ASTReader::addPendingMacro(IdentifierInfo *II, ModuleFile *M,
uint32_t MacroDirectivesOffset) {
- assert(NumCurrentElementsDeserializing > 0 &&"Missing deserialization guard");
+ assert(NumCurrentElementsDeserializing > 0 &&
+ "Missing deserialization guard");
PendingMacroIDs[II].push_back(PendingMacroInfo(M, MacroDirectivesOffset));
}
@@ -2356,7 +2361,7 @@ void ASTReader::ReadDefinedMacros() {
return;
}
switch (MaybeRecord.get()) {
- default: // Default behavior: ignore.
+ default: // Default behavior: ignore.
break;
case PP_MACRO_OBJECT_LIKE:
@@ -2375,60 +2380,59 @@ void ASTReader::ReadDefinedMacros() {
}
}
}
- NextCursor: ;
+ NextCursor:;
}
}
namespace {
- /// Visitor class used to look up identifirs in an AST file.
- class IdentifierLookupVisitor {
- StringRef Name;
- unsigned NameHash;
- unsigned PriorGeneration;
- unsigned &NumIdentifierLookups;
- unsigned &NumIdentifierLookupHits;
- IdentifierInfo *Found = nullptr;
-
- public:
- IdentifierLookupVisitor(StringRef Name, unsigned PriorGeneration,
- unsigned &NumIdentifierLookups,
- unsigned &NumIdentifierLookupHits)
+/// Visitor class used to look up identifirs in an AST file.
+class IdentifierLookupVisitor {
+ StringRef Name;
+ unsigned NameHash;
+ unsigned PriorGeneration;
+ unsigned &NumIdentifierLookups;
+ unsigned &NumIdentifierLookupHits;
+ IdentifierInfo *Found = nullptr;
+
+public:
+ IdentifierLookupVisitor(StringRef Name, unsigned PriorGeneration,
+ unsigned &NumIdentifierLookups,
+ unsigned &NumIdentifierLookupHits)
: Name(Name), NameHash(ASTIdentifierLookupTrait::ComputeHash(Name)),
PriorGeneration(PriorGeneration),
NumIdentifierLookups(NumIdentifierLookups),
NumIdentifierLookupHits(NumIdentifierLookupHits) {}
- bool operator()(ModuleFile &M) {
- // If we've already searched this module file, skip it now.
- if (M.Generation <= PriorGeneration)
- return true;
+ bool operator()(ModuleFile &M) {
+ // If we've already searched this module file, skip it now.
+ if (M.Generation <= PriorGeneration)
+ return true;
- ASTIdentifierLookupTable *IdTable
- = (ASTIdentifierLookupTable *)M.IdentifierLookupTable;
- if (!IdTable)
- return false;
+ ASTIdentifierLookupTable *IdTable =
+ (ASTIdentifierLookupTable *)M.IdentifierLookupTable;
+ if (!IdTable)
+ return false;
- ASTIdentifierLookupTrait Trait(IdTable->getInfoObj().getReader(), M,
- Found);
- ++NumIdentifierLookups;
- ASTIdentifierLookupTable::iterator Pos =
- IdTable->find_hashed(Name, NameHash, &Trait);
- if (Pos == IdTable->end())
- return false;
+ ASTIdentifierLookupTrait Trait(IdTable->getInfoObj().getReader(), M, Found);
+ ++NumIdentifierLookups;
+ ASTIdentifierLookupTable::iterator Pos =
+ IdTable->find_hashed(Name, NameHash, &Trait);
+ if (Pos == IdTable->end())
+ return false;
- // Dereferencing the iterator has the effect of building the
- // IdentifierInfo node and populating it with the various
- // declarations it needs.
- ++NumIdentifierLookupHits;
- Found = *Pos;
- return true;
- }
+ // Dereferencing the iterator has the effect of building the
+ // IdentifierInfo node and populating it with the various
+ // declarations it needs.
+ ++NumIdentifierLookupHits;
+ Found = *Pos;
+ return true;
+ }
- // Retrieve the identifier info found within the module
- // files.
- IdentifierInfo *getIdentifierInfo() const { return Found; }
- };
+ // Retrieve the identifier info found within the module
+ // files.
+ IdentifierInfo *getIdentifierInfo() const { return Found; }
+};
} // namespace
@@ -2538,7 +2542,7 @@ void ASTReader::resolvePendingMacro(IdentifierInfo *II,
// Module macros are listed in reverse dependency order.
{
std::reverse(ModuleMacros.begin(), ModuleMacros.end());
- llvm::SmallVector<ModuleMacro*, 8> Overrides;
+ llvm::SmallVector<ModuleMacro *, 8> Overrides;
for (auto &MMR : ModuleMacros) {
Overrides.clear();
for (unsigned ModID : MMR.Overrides) {
@@ -2694,10 +2698,10 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
return InputFile();
// If we've already loaded this input file, return it.
- if (F.InputFilesLoaded[ID-1].getFile())
- return F.InputFilesLoaded[ID-1];
+ if (F.InputFilesLoaded[ID - 1].getFile())
+ return F.InputFilesLoaded[ID - 1];
- if (F.InputFilesLoaded[ID-1].isNotFound())
+ if (F.InputFilesLoaded[ID - 1].isNotFound())
return InputFile();
// Go find this input file.
@@ -2748,7 +2752,7 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
Error(ErrorStr);
}
// Record that we didn't find the file.
- F.InputFilesLoaded[ID-1] = InputFile::getNotFound();
+ F.InputFilesLoaded[ID - 1] = InputFile::getNotFound();
return InputFile();
}
@@ -2865,7 +2869,7 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
<< *Filename << ImportStack[0]->FileName;
for (unsigned I = 1; I < ImportStack.size(); ++I)
Diag(diag::note_pch_required_by)
- << ImportStack[I-1]->FileName << ImportStack[I]->FileName;
+ << ImportStack[I - 1]->FileName << ImportStack[I]->FileName;
}
Diag(diag::note_pch_rebuild_required) << TopLevelPCHName;
@@ -2879,7 +2883,7 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
InputFile IF = InputFile(*File, Overridden || Transient, IsOutOfDate);
// Note that we've loaded this input file.
- F.InputFilesLoaded[ID-1] = IF;
+ F.InputFilesLoaded[ID - 1] = IF;
return IF;
}
@@ -2919,14 +2923,20 @@ std::string ASTReader::ResolveImportedPathAndAllocate(SmallString<0> &Buf,
static bool isDiagnosedResult(ASTReader::ASTReadResult ARR, unsigned Caps) {
switch (ARR) {
- case ASTReader::Failure: return true;
- case ASTReader::Missing: return !(Caps & ASTReader::ARR_Missing);
- case ASTReader::OutOfDate: return !(Caps & ASTReader::ARR_OutOfDate);
- case ASTReader::VersionMismatch: return !(Caps & ASTReader::ARR_VersionMismatch);
+ case ASTReader::Failure:
+ return true;
+ case ASTReader::Missing:
+ return !(Caps & ASTReader::ARR_Missing);
+ case ASTReader::OutOfDate:
+ return !(Caps & ASTReader::ARR_OutOfDate);
+ case ASTReader::VersionMismatch:
+ return !(Caps & ASTReader::ARR_VersionMismatch);
case ASTReader::ConfigurationMismatch:
return !(Caps & ASTReader::ARR_ConfigurationMismatch);
- case ASTReader::HadErrors: return true;
- case ASTReader::Success: return false;
+ case ASTReader::HadErrors:
+ return true;
+ case ASTReader::Success:
+ return false;
}
llvm_unreachable("unknown ASTReadResult");
@@ -3019,11 +3029,9 @@ ASTReader::ASTReadResult ASTReader::ReadOptionsBlock(
}
}
-ASTReader::ASTReadResult
-ASTReader::ReadControlBlock(ModuleFile &F,
- SmallVectorImpl<ImportedModule> &Loaded,
- const ModuleFile *ImportedBy,
- unsigned ClientLoadCapabilities) {
+ASTReader::ASTReadResult ASTReader::ReadControlBlock(
+ ModuleFile &F, SmallVectorImpl<ImportedModule> &Loaded,
+ const ModuleFile *ImportedBy, unsigned ClientLoadCapabilities) {
BitstreamCursor &Stream = F.Stream;
if (llvm::Error Err = Stream.EnterSubBlock(CONTROL_BLOCK_ID)) {
@@ -3095,7 +3103,7 @@ ASTReader::ReadControlBlock(ModuleFile &F,
N = NumUserInputs;
for (unsigned I = 0; I < N; ++I) {
- InputFile IF = getInputFile(F, I+1, Complain);
+ InputFile IF = getInputFile(F, I + 1, Complain);
if (!IF.getFile() || IF.isOutOfDate())
return OutOfDate;
}
@@ -3280,7 +3288,8 @@ ASTReader::ReadControlBlock(ModuleFile &F,
// explicit name to file mappings. Also, we will still verify the
// size/signature making sure it is essentially the same file but
// perhaps in a different location.
- if (ImportedKind == MK_PrebuiltModule || ImportedKind == MK_ExplicitModule)
+ if (ImportedKind == MK_PrebuiltModule ||
+ ImportedKind == MK_ExplicitModule)
ImportedFile = PP.getHeaderSearchInfo().getPrebuiltModuleFileName(
ImportedName, /*FileMapOnly*/ !IsImportingStdCXXModule);
@@ -3313,9 +3322,9 @@ ASTReader::ReadControlBlock(ModuleFile &F,
Capabilities &= ~ARR_Missing;
// Load the AST file.
- auto Result = ReadASTCore(ImportedFile, ImportedKind, ImportLoc, &F,
- Loaded, StoredSize, StoredModTime,
- StoredSignature, Capabilities);
+ auto Result =
+ ReadASTCore(ImportedFile, ImportedKind, ImportLoc, &F, Loaded,
+ StoredSize, StoredModTime, StoredSignature, Capabilities);
// If we diagnosed a problem, produce a backtrace.
bool recompilingFinalized =
@@ -3328,14 +3337,20 @@ ASTReader::ReadControlBlock(ModuleFile &F,
Diag(diag::note_module_file_conflict);
switch (Result) {
- case Failure: return Failure;
+ case Failure:
+ return Failure;
// If we have to ignore the dependency, we'll have to ignore this too.
case Missing:
- case OutOfDate: return OutOfDate;
- case VersionMismatch: return VersionMismatch;
- case ConfigurationMismatch: return ConfigurationMismatch;
- case HadErrors: return HadErrors;
- case Success: break;
+ case OutOfDate:
+ return OutOfDate;
+ case VersionMismatch:
+ return VersionMismatch;
+ case ConfigurationMismatch:
+ return ConfigurationMismatch;
+ case HadErrors:
+ return HadErrors;
+ case Success:
+ break;
}
break;
}
@@ -3401,8 +3416,8 @@ ASTReader::ReadControlBlock(ModuleFile &F,
}
case MODULE_MAP_FILE:
- if (ASTReadResult Result =
- ReadModuleMapFileBlock(Record, F, ImportedBy, ClientLoadCapabilities))
+ if (ASTReadResult Result = ReadModuleMapFileBlock(Record, F, ImportedBy,
+ ClientLoadCapabilities))
return Result;
break;
@@ -3490,8 +3505,8 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
if (llvm::Error Err = ReadBlockAbbrevs(F.PreprocessorDetailCursor,
PREPROCESSOR_DETAIL_BLOCK_ID))
return Err;
- F.PreprocessorDetailStartOffset
- = F.PreprocessorDetailCursor.GetCurrentBitNo();
+ F.PreprocessorDetailStartOffset =
+ F.PreprocessorDetailCursor.GetCurrentBitNo();
if (!PP.getPreprocessingRecord())
PP.createPreprocessingRecord();
@@ -3565,7 +3580,7 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
}
switch (RecordType) {
- default: // Default behavior: ignore.
+ default: // Default behavior: ignore.
break;
case TYPE_OFFSET: {
@@ -3611,7 +3626,7 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
case UPDATE_VISIBLE: {
unsigned Idx = 0;
GlobalDeclID ID = ReadDeclID(F, Record, Idx);
- auto *Data = (const unsigned char*)Blob.data();
+ auto *Data = (const unsigned char *)Blob.data();
PendingVisibleUpdates[ID].push_back(UpdateData{&F, Data});
// If we've already loaded the decl, perform the updates when we finish
// loading this block.
@@ -3681,8 +3696,7 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
if (Record[0]) {
F.IdentifierLookupTable = ASTIdentifierLookupTable::Create(
F.IdentifierTableData + Record[0],
- F.IdentifierTableData + sizeof(uint32_t),
- F.IdentifierTableData,
+ F.IdentifierTableData + sizeof(uint32_t), F.IdentifierTableData,
ASTIdentifierLookupTrait(*this, F));
PP.getIdentifierTable().setExternalIdentifierLookup(this);
@@ -3699,8 +3713,8 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
F.BaseIdentifierID = getTotalNumIdentifiers();
if (F.LocalNumIdentifiers > 0)
- IdentifiersLoaded.resize(IdentifiersLoaded.size()
- + F.LocalNumIdentifiers);
+ IdentifiersLoaded.resize(IdentifiersLoaded.size() +
+ F.LocalNumIdentifiers);
break;
}
@@ -3778,9 +3792,9 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
// Translate the weak, undeclared identifiers into global IDs.
for (unsigned I = 0, N = Record.size(); I < N; /* in loop */) {
WeakUndeclaredIdentifiers.push_back(
- getGlobalIdentifierID(F, Record[I++]));
+ getGlobalIdentifierID(F, Record[I++]));
WeakUndeclaredIdentifiers.push_back(
- getGlobalIdentifierID(F, Record[I++]));
+ getGlobalIdentifierID(F, Record[I++]));
WeakUndeclaredIdentifiers.push_back(
ReadSourceLocation(F, Record, I).getRawEncoding());
}
@@ -3795,13 +3809,13 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
if (F.LocalNumSelectors > 0) {
// Introduce the global -> local mapping for selectors within this
// module.
- GlobalSelectorMap.insert(std::make_pair(getTotalNumSelectors()+1, &F));
+ GlobalSelectorMap.insert(
+ std::make_pair(getTotalNumSelectors() + 1, &F));
// Introduce the local -> global mapping for selectors within this
// module.
- F.SelectorRemap.insertOrReplace(
- std::make_pair(LocalBaseSelectorID,
- F.BaseSelectorID - LocalBaseSelectorID));
+ F.SelectorRemap.insertOrReplace(std::make_pair(
+ LocalBaseSelectorID, F.BaseSelectorID - LocalBaseSelectorID));
SelectorsLoaded.resize(SelectorsLoaded.size() + F.LocalNumSelectors);
}
@@ -3811,21 +3825,19 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
case METHOD_POOL:
F.SelectorLookupTableData = (const unsigned char *)Blob.data();
if (Record[0])
- F.SelectorLookupTable
- = ASTSelectorLookupTable::Create(
- F.SelectorLookupTableData + Record[0],
- F.SelectorLookupTableData,
- ASTSelectorLookupTrait(*this, F));
+ F.SelectorLookupTable = ASTSelectorLookupTable::Create(
+ F.SelectorLookupTableData + Record[0], F.SelectorLookupTableData,
+ ASTSelectorLookupTrait(*this, F));
TotalNumMethodPoolEntries += Record[1];
break;
case REFERENCED_SELECTOR_POOL:
if (!Record.empty()) {
for (unsigned Idx = 0, N = Record.size() - 1; Idx < N; /* in loop */) {
- ReferencedSelectorsData.push_back(getGlobalSelectorID(F,
- Record[Idx++]));
- ReferencedSelectorsData.push_back(ReadSourceLocation(F, Record, Idx).
- getRawEncoding());
+ ReferencedSelectorsData.push_back(
+ getGlobalSelectorID(F, Record[Idx++]));
+ ReferencedSelectorsData.push_back(
+ ReadSourceLocation(F, Record, Idx).getRawEncoding());
}
}
break;
@@ -3910,9 +3922,10 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
// SLocEntryBaseOffset is lower than MaxLoadedOffset and decreasing.
assert((F.SLocEntryBaseOffset & SourceLocation::MacroIDBit) == 0);
- GlobalSLocOffsetMap.insert(
- std::make_pair(SourceManager::MaxLoadedOffset - F.SLocEntryBaseOffset
- - SLocSpaceSize,&F));
+ GlobalSLocOffsetMap.insert(std::make_pair(SourceManager::MaxLoadedOffset -
+ F.SLocEntryBaseOffset -
+ SLocSpaceSize,
+ &F));
TotalNumSLocEntries += F.LocalNumSLocEntries;
break;
@@ -3983,9 +3996,8 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
PP.createPreprocessingRecord();
if (!PP.getPreprocessingRecord()->getExternalSource())
PP.getPreprocessingRecord()->SetExternalSource(*this);
- StartingID
- = PP.getPreprocessingRecord()
- ->allocateLoadedEntities(F.NumPreprocessedEntities);
+ StartingID = PP.getPreprocessingRecord()->allocateLoadedEntities(
+ F.NumPreprocessedEntities);
F.BasePreprocessedEntityID = StartingID;
if (F.NumPreprocessedEntities > 0) {
@@ -3995,8 +4007,8 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
// Introduce the local -> global mapping for preprocessed entities in
// this module.
- F.PreprocessedEntityRemap.insertOrReplace(
- std::make_pair(LocalBasePreprocessedEntityID,
+ F.PreprocessedEntityRemap.insertOrReplace(std::make_pair(
+ LocalBasePreprocessedEntityID,
F.BasePreprocessedEntityID - LocalBasePreprocessedEntityID));
}
@@ -4004,7 +4016,7 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
}
case PPD_SKIPPED_RANGES: {
- F.PreprocessedSkippedRangeOffsets = (const PPSkippedRange*)Blob.data();
+ F.PreprocessedSkippedRangeOffsets = (const PPSkippedRange *)Blob.data();
assert(Blob.size() % sizeof(PPSkippedRange) == 0);
F.NumPreprocessedSkippedRanges = Blob.size() / sizeof(PPSkippedRange);
@@ -4012,8 +4024,9 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
PP.createPreprocessingRecord();
if (!PP.getPreprocessingRecord()->getExternalSource())
PP.getPreprocessingRecord()->SetExternalSource(*this);
- F.BasePreprocessedSkippedRangeID = PP.getPreprocessingRecord()
- ->allocateSkippedRanges(F.NumPreprocessedSkippedRanges);
+ F.BasePreprocessedSkippedRangeID =
+ PP.getPreprocessingRecord()->allocateSkippedRanges(
+ F.NumPreprocessedSkippedRanges);
if (F.NumPreprocessedSkippedRanges > 0)
GlobalSkippedRangeMap.insert(
@@ -4131,7 +4144,7 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
break;
case OPENCL_EXTENSIONS:
- for (unsigned I = 0, E = Record.size(); I != E; ) {
+ for (unsigned I = 0, E = Record.size(); I != E;) {
auto Name = ReadString(Record, I);
auto &OptInfo = OpenCLExtensions.OptMap[Name];
OptInfo.Supported = Record[I++] != 0;
@@ -4170,7 +4183,8 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
const uint64_t Count = Record[I++];
DelayedDeleteExprs.push_back(Count);
for (uint64_t C = 0; C < Count; ++C) {
- DelayedDeleteExprs.push_back(ReadSourceLocation(F, Record, I).getRawEncoding());
+ DelayedDeleteExprs.push_back(
+ ReadSourceLocation(F, Record, I).getRawEncoding());
bool IsArrayForm = Record[I++] == 1;
DelayedDeleteExprs.push_back(IsArrayForm);
}
@@ -4218,8 +4232,7 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
// Introduce the local -> global mapping for macros within this module.
F.MacroRemap.insertOrReplace(
- std::make_pair(LocalBaseMacroID,
- F.BaseMacroID - LocalBaseMacroID));
+ std::make_pair(LocalBaseMacroID, F.BaseMacroID - LocalBaseMacroID));
MacrosLoaded.resize(MacrosLoaded.size() + F.LocalNumMacros);
}
@@ -4323,7 +4336,7 @@ void ASTReader::ReadModuleOffsetMap(ModuleFile &F) const {
assert(!F.ModuleOffsetMap.empty() && "no module offset map to read");
// Additional remapping information.
- const unsigned char *Data = (const unsigned char*)F.ModuleOffsetMap.data();
+ const unsigned char *Data = (const unsigned char *)F.ModuleOffsetMap.data();
const unsigned char *DataEnd = Data + F.ModuleOffsetMap.size();
F.ModuleOffsetMap = StringRef();
@@ -4344,7 +4357,7 @@ void ASTReader::ReadModuleOffsetMap(ModuleFile &F) const {
ModuleKind Kind = static_cast<ModuleKind>(
endian::readNext<uint8_t, llvm::endianness::little>(Data));
uint16_t Len = endian::readNext<uint16_t, llvm::endianness::little>(Data);
- StringRef Name = StringRef((const char*)Data, Len);
+ StringRef Name = StringRef((const char *)Data, Len);
Data += Len;
ModuleFile *OM = (Kind == MK_PrebuiltModule || Kind == MK_ExplicitModule ||
Kind == MK_ImplicitModule
@@ -4372,8 +4385,8 @@ void ASTReader::ReadModuleOffsetMap(ModuleFile &F) const {
RemapBuilder &Remap) {
constexpr uint32_t None = std::numeric_limits<uint32_t>::max();
if (Offset != None)
- Remap.insert(std::make_pair(Offset,
- static_cast<int>(BaseOffset - Offset)));
+ Remap.insert(
+ std::make_pair(Offset, static_cast<int>(BaseOffset - Offset)));
};
mapOffset(MacroIDOffset, OM->BaseMacroID, MacroRemap);
@@ -4413,8 +4426,8 @@ ASTReader::ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F,
if (!canRecoverFromOutOfDate(F.FileName, ClientLoadCapabilities)) {
if (auto ASTFE = M ? M->getASTFile() : std::nullopt) {
// This module was defined by an imported (explicit) module.
- Diag(diag::err_module_file_conflict) << F.ModuleName << F.FileName
- << ASTFE->getName();
+ Diag(diag::err_module_file_conflict)
+ << F.ModuleName << F.FileName << ASTFE->getName();
} else {
// This module was built with a different module map.
Diag(diag::err_imported_module_not_found)
@@ -4455,7 +4468,8 @@ ASTReader::ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F,
auto SF = FileMgr.getOptionalFileRef(Filename, false, false);
if (!SF) {
if (!canRecoverFromOutOfDate(F.FileName, ClientLoadCapabilities))
- Error("could not find file '" + Filename +"' referenced by AST file");
+ Error("could not find file '" + Filename +
+ "' referenced by AST file");
return OutOfDate;
}
AdditionalStoredMaps.insert(*SF);
@@ -4470,7 +4484,7 @@ ASTReader::ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F,
if (!AdditionalStoredMaps.erase(ModMap)) {
if (!canRecoverFromOutOfDate(F.FileName, ClientLoadCapabilities))
Diag(diag::err_module_different_modmap)
- << F.ModuleName << /*new*/0 << ModMap.getName();
+ << F.ModuleName << /*new*/ 0 << ModMap.getName();
return OutOfDate;
}
}
@@ -4481,7 +4495,7 @@ ASTReader::ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F,
for (FileEntryRef ModMap : AdditionalStoredMaps) {
if (!canRecoverFromOutOfDate(F.FileName, ClientLoadCapabilities))
Diag(diag::err_module_different_modmap)
- << F.ModuleName << /*not new*/1 << ModMap.getName();
+ << F.ModuleName << /*not new*/ 1 << ModMap.getName();
return OutOfDate;
}
}
@@ -4500,8 +4514,8 @@ static void moveMethodToBackOfGlobalList(Sema &S, ObjCMethodDecl *Method) {
return;
// Retrieve the appropriate method list.
- ObjCMethodList &Start = Method->isInstanceMethod()? Known->second.first
- : Known->second.second;
+ ObjCMethodList &Start =
+ Method->isInstanceMethod() ? Known->second.first : Known->second.second;
bool Found = false;
for (ObjCMethodList *List = &Start; List; List = List->getNext()) {
if (!Found) {
@@ -4571,8 +4585,9 @@ void ASTReader::makeModuleVisible(Module *Mod,
// Push any exported modules onto the stack to be marked as visible.
SmallVector<Module *, 16> Exports;
Mod->getExportedModules(Exports);
- for (SmallVectorImpl<Module *>::iterator
- I = Exports.begin(), E = Exports.end(); I != E; ++I) {
+ for (SmallVectorImpl<Module *>::iterator I = Exports.begin(),
+ E = Exports.end();
+ I != E; ++I) {
Module *Exported = *I;
if (Visited.insert(Exported).second)
Stack.push_back(Exported);
@@ -4602,14 +4617,13 @@ bool ASTReader::loadGlobalIndex() {
if (GlobalIndex)
return false;
- if (TriedLoadingGlobalIndex || !UseGlobalIndex ||
- !PP.getLangOpts().Modules)
+ if (TriedLoadingGlobalIndex || !UseGlobalIndex || !PP.getLangOpts().Modules)
return true;
// Try to load the global index.
TriedLoadingGlobalIndex = true;
- StringRef ModuleCachePath
- = getPreprocessor().getHeaderSearchInfo().getModuleCachePath();
+ StringRef ModuleCachePath =
+ getPreprocessor().getHeaderSearchInfo().getModuleCachePath();
std::pair<GlobalModuleIndex *, llvm::Error> Result =
GlobalModuleIndex::readIndex(ModuleCachePath);
if (llvm::Error Err = std::move(Result.second)) {
@@ -4624,8 +4638,8 @@ bool ASTReader::loadGlobalIndex() {
}
bool ASTReader::isGlobalIndexUnavailable() const {
- return PP.getLangOpts().Modules && UseGlobalIndex &&
- !hasGlobalIndex() && TriedLoadingGlobalIndex;
+ return PP.getLangOpts().Modules && UseGlobalIndex && !hasGlobalIndex() &&
+ TriedLoadingGlobalIndex;
}
/// Given a cursor at the start of an AST file, scan ahead and drop the
@@ -4831,7 +4845,8 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName, ModuleKind Type,
// Resolve any unresolved module exports.
for (unsigned I = 0, N = UnresolvedModuleRefs.size(); I != N; ++I) {
UnresolvedModuleRef &Unresolved = UnresolvedModuleRefs[I];
- SubmoduleID GlobalID = getGlobalSubmoduleID(*Unresolved.File,Unresolved.ID);
+ SubmoduleID GlobalID =
+ getGlobalSubmoduleID(*Unresolved.File, Unresolved.ID);
Module *ResolvedMod = getSubmodule(GlobalID);
switch (Unresolved.Kind) {
@@ -4857,7 +4872,7 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName, ModuleKind Type,
case UnresolvedModuleRef::Export:
if (ResolvedMod || Unresolved.IsWildcard)
Unresolved.Mod->Exports.push_back(
- Module::ExportDecl(ResolvedMod, Unresolved.IsWildcard));
+ Module::ExportDecl(ResolvedMod, Unresolved.IsWildcard));
continue;
}
}
@@ -4949,22 +4964,16 @@ static unsigned moduleKindForDiagnostic(ModuleKind Kind) {
llvm_unreachable("unknown module kind");
}
-ASTReader::ASTReadResult
-ASTReader::ReadASTCore(StringRef FileName,
- ModuleKind Type,
- SourceLocation ImportLoc,
- ModuleFile *ImportedBy,
- SmallVectorImpl<ImportedModule> &Loaded,
- off_t ExpectedSize, time_t ExpectedModTime,
- ASTFileSignature ExpectedSignature,
- unsigned ClientLoadCapabilities) {
+ASTReader::ASTReadResult ASTReader::ReadASTCore(
+ StringRef FileName, ModuleKind Type, SourceLocation ImportLoc,
+ ModuleFile *ImportedBy, SmallVectorImpl<ImportedModule> &Loaded,
+ off_t ExpectedSize, time_t ExpectedModTime,
+ ASTFileSignature ExpectedSignature, unsigned ClientLoadCapabilities) {
ModuleFile *M;
std::string ErrorStr;
- ModuleManager::AddModuleResult AddResult
- = ModuleMgr.addModule(FileName, Type, ImportLoc, ImportedBy,
- getGeneration(), ExpectedSize, ExpectedModTime,
- ExpectedSignature, readASTFileSignature,
- M, ErrorStr);
+ ModuleManager::AddModuleResult AddResult = ModuleMgr.addModule(
+ FileName, Type, ImportLoc, ImportedBy, getGeneration(), ExpectedSize,
+ ExpectedModTime, ExpectedSignature, readASTFileSignature, M, ErrorStr);
switch (AddResult) {
case ModuleManager::AlreadyLoaded:
@@ -5065,12 +5074,18 @@ ASTReader::ReadASTCore(StringRef FileName,
}
break;
- case Failure: return Failure;
- case Missing: return Missing;
- case OutOfDate: return OutOfDate;
- case VersionMismatch: return VersionMismatch;
- case ConfigurationMismatch: return ConfigurationMismatch;
- case HadErrors: return HadErrors;
+ case Failure:
+ return Failure;
+ case Missing:
+ return Missing;
+ case OutOfDate:
+ return OutOfDate;
+ case VersionMismatch:
+ return VersionMismatch;
+ case ConfigurationMismatch:
+ return ConfigurationMismatch;
+ case HadErrors:
+ return HadErrors;
}
break;
@@ -5256,11 +5271,12 @@ ASTReader::ASTReadResult ASTReader::readUnhashedControlBlockImpl(
}
/// Parse a record and blob containing module file extension metadata.
-static bool parseModuleFileExtensionMetadata(
- const SmallVectorImpl<uint64_t> &Record,
- StringRef Blob,
- ModuleFileExtensionMetadata &Metadata) {
- if (Record.size() < 4) return true;
+static bool
+parseModuleFileExtensionMetadata(const SmallVectorImpl<uint64_t> &Record,
+ StringRef Blob,
+ ModuleFileExtensionMetadata &Metadata) {
+ if (Record.size() < 4)
+ return true;
Metadata.MajorVersion = Record[0];
Metadata.MinorVersion = Record[1];
@@ -5268,7 +5284,8 @@ static bool parseModuleFileExtensionMetadata(
unsigned BlockNameLen = Record[2];
unsigned UserInfoLen = Record[3];
- if (BlockNameLen + UserInfoLen > Blob.size()) return true;
+ if (BlockNameLen + UserInfoLen > Blob.size())
+ return true;
Metadata.BlockName = std::string(Blob.data(), Blob.data() + BlockNameLen);
Metadata.UserInfo = std::string(Blob.data() + BlockNameLen,
@@ -5316,11 +5333,12 @@ llvm::Error ASTReader::ReadExtensionBlock(ModuleFile &F) {
// Find a module file extension with this block name.
auto Known = ModuleFileExtensions.find(Metadata.BlockName);
- if (Known == ModuleFileExtensions.end()) break;
+ if (Known == ModuleFileExtensions.end())
+ break;
// Form a reader.
- if (auto Reader = Known->second->createExtensionReader(Metadata, *this,
- F, Stream)) {
+ if (auto Reader = Known->second->createExtensionReader(Metadata, *this, F,
+ Stream)) {
F.ExtensionReaders.push_back(std::move(Reader));
}
@@ -5454,7 +5472,7 @@ void ASTReader::InitializeContext() {
if (!CUDASpecialDeclRefs.empty()) {
assert(CUDASpecialDeclRefs.size() == 1 && "More decl refs than expected!");
Context.setcudaConfigureCallDecl(
- cast<FunctionDecl>(GetDecl(CUDASpecialDeclRefs[0])));
+ cast<FunctionDecl>(GetDecl(CUDASpecialDeclRefs[0])));
}
// Re-export any modules that were imported by a non-module AST file.
@@ -5592,61 +5610,60 @@ std::string ASTReader::getOriginalSourceFile(
namespace {
- class SimplePCHValidator : public ASTReaderListener {
- const LangOptions &ExistingLangOpts;
- const TargetOptions &ExistingTargetOpts;
- const PreprocessorOptions &ExistingPPOpts;
- std::string ExistingModuleCachePath;
- FileManager &FileMgr;
- bool StrictOptionMatches;
-
- public:
- SimplePCHValidator(const LangOptions &ExistingLangOpts,
- const TargetOptions &ExistingTargetOpts,
- const PreprocessorOptions &ExistingPPOpts,
- StringRef ExistingModuleCachePath, FileManager &FileMgr,
- bool StrictOptionMatches)
- : ExistingLangOpts(ExistingLangOpts),
- ExistingTargetOpts(ExistingTargetOpts),
- ExistingPPOpts(ExistingPPOpts),
- ExistingModuleCachePath(ExistingModuleCachePath), FileMgr(FileMgr),
- StrictOptionMatches(StrictOptionMatches) {}
-
- bool ReadLanguageOptions(const LangOptions &LangOpts,
- StringRef ModuleFilename, bool Complain,
- bool AllowCompatibleDifferences) override {
- return checkLanguageOptions(ExistingLangOpts, LangOpts, ModuleFilename,
- nullptr, AllowCompatibleDifferences);
- }
-
- bool ReadTargetOptions(const TargetOptions &TargetOpts,
+class SimplePCHValidator : public ASTReaderListener {
+ const LangOptions &ExistingLangOpts;
+ const TargetOptions &ExistingTargetOpts;
+ const PreprocessorOptions &ExistingPPOpts;
+ std::string ExistingModuleCachePath;
+ FileManager &FileMgr;
+ bool StrictOptionMatches;
+
+public:
+ SimplePCHValidator(const LangOptions &ExistingLangOpts,
+ const TargetOptions &ExistingTargetOpts,
+ const PreprocessorOptions &ExistingPPOpts,
+ StringRef ExistingModuleCachePath, FileManager &FileMgr,
+ bool StrictOptionMatches)
+ : ExistingLangOpts(ExistingLangOpts),
+ ExistingTargetOpts(ExistingTargetOpts), ExistingPPOpts(ExistingPPOpts),
+ ExistingModuleCachePath(ExistingModuleCachePath), FileMgr(FileMgr),
+ StrictOptionMatches(StrictOptionMatches) {}
+
+ bool ReadLanguageOptions(const LangOptions &LangOpts,
StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) override {
- return checkTargetOptions(ExistingTargetOpts, TargetOpts, ModuleFilename,
+ return checkLanguageOptions(ExistingLangOpts, LangOpts, ModuleFilename,
nullptr, AllowCompatibleDifferences);
- }
+ }
- bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
- StringRef ModuleFilename,
- StringRef SpecificModuleCachePath,
- bool Complain) override {
- return checkModuleCachePath(FileMgr.getVirtualFileSystem(),
- SpecificModuleCachePath,
- ExistingModuleCachePath, ModuleFilename,
- nullptr, ExistingLangOpts, ExistingPPOpts);
- }
-
- bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
- StringRef ModuleFilename, bool ReadMacros,
- bool Complain,
- std::string &SuggestedPredefines) override {
- return checkPreprocessorOptions(
- PPOpts, ExistingPPOpts, ModuleFilename, ReadMacros, /*Diags=*/nullptr,
- FileMgr, SuggestedPredefines, ExistingLangOpts,
- StrictOptionMatches ? OptionValidateStrictMatches
- : OptionValidateContradictions);
- }
- };
+ bool ReadTargetOptions(const TargetOptions &TargetOpts,
+ StringRef ModuleFilename, bool Complain,
+ bool AllowCompatibleDifferences) override {
+ return checkTargetOptions(ExistingTargetOpts, TargetOpts, ModuleFilename,
+ nullptr, AllowCompatibleDifferences);
+ }
+
+ bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
+ StringRef ModuleFilename,
+ StringRef SpecificModuleCachePath,
+ bool Complain) override {
+ return checkModuleCachePath(FileMgr.getVirtualFileSystem(),
+ SpecificModuleCachePath,
+ ExistingModuleCachePath, ModuleFilename,
+ nullptr, ExistingLangOpts, ExistingPPOpts);
+ }
+
+ bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
+ StringRef ModuleFilename, bool ReadMacros,
+ bool Complain,
+ std::string &SuggestedPredefines) override {
+ return checkPreprocessorOptions(
+ PPOpts, ExistingPPOpts, ModuleFilename, ReadMacros, /*Diags=*/nullptr,
+ FileMgr, SuggestedPredefines, ExistingLangOpts,
+ StrictOptionMatches ? OptionValidateStrictMatches
+ : OptionValidateContradictions);
+ }
+};
} // namespace
@@ -5755,7 +5772,8 @@ bool ASTReader::readASTFileControlBlock(
break;
}
- if (DoneWithControlBlock) break;
+ if (DoneWithControlBlock)
+ break;
Record.clear();
StringRef Blob;
@@ -5914,24 +5932,24 @@ bool ASTReader::readASTFileControlBlock(
break;
}
- Record.clear();
- StringRef Blob;
- Expected<unsigned> MaybeRecCode =
- Stream.readRecord(Entry.ID, Record, &Blob);
- if (!MaybeRecCode) {
- // FIXME this drops the error.
- return true;
- }
- switch (MaybeRecCode.get()) {
- case EXTENSION_METADATA: {
- ModuleFileExtensionMetadata Metadata;
- if (parseModuleFileExtensionMetadata(Record, Blob, Metadata))
- return true;
-
- Listener.readModuleFileExtension(Metadata);
- break;
- }
- }
+ Record.clear();
+ StringRef Blob;
+ Expected<unsigned> MaybeRecCode =
+ Stream.readRecord(Entry.ID, Record, &Blob);
+ if (!MaybeRecCode) {
+ // FIXME this drops the error.
+ return true;
+ }
+ switch (MaybeRecCode.get()) {
+ case EXTENSION_METADATA: {
+ ModuleFileExtensionMetadata Metadata;
+ if (parseModuleFileExtensionMetadata(Record, Blob, Metadata))
+ return true;
+
+ Listener.readModuleFileExtension(Metadata);
+ break;
+ }
+ }
}
}
Stream = SavedStream;
@@ -6022,7 +6040,7 @@ llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile &F,
continue;
switch (Kind) {
- default: // Default behavior: ignore.
+ default: // Default behavior: ignore.
break;
case SUBMODULE_DEFINITION: {
@@ -6146,7 +6164,8 @@ llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile &F,
case SUBMODULE_HEADER:
case SUBMODULE_EXCLUDED_HEADER:
case SUBMODULE_PRIVATE_HEADER:
- // We lazily associate headers with their modules via the HeaderInfo table.
+ // We lazily associate headers with their modules via the HeaderInfo
+ // table.
// FIXME: Re-evaluate this section; maybe only store InputFile IDs instead
// of complete filenames or remove it entirely.
break;
@@ -6183,13 +6202,13 @@ llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile &F,
if (F.LocalNumSubmodules > 0) {
// Introduce the global -> local mapping for submodules within this
// module.
- GlobalSubmoduleMap.insert(std::make_pair(getTotalNumSubmodules()+1,&F));
+ GlobalSubmoduleMap.insert(
+ std::make_pair(getTotalNumSubmodules() + 1, &F));
// Introduce the local -> global mapping for submodules within this
// module.
- F.SubmoduleRemap.insertOrReplace(
- std::make_pair(LocalBaseSubmoduleID,
- F.BaseSubmoduleID - LocalBaseSubmoduleID));
+ F.SubmoduleRemap.insertOrReplace(std::make_pair(
+ LocalBaseSubmoduleID, F.BaseSubmoduleID - LocalBaseSubmoduleID));
SubmodulesLoaded.resize(SubmodulesLoaded.size() + F.LocalNumSubmodules);
}
@@ -6294,9 +6313,8 @@ bool ASTReader::ParseLanguageOptions(const RecordData &Record,
bool AllowCompatibleDifferences) {
LangOptions LangOpts;
unsigned Idx = 0;
-#define LANGOPT(Name, Bits, Default, Description) \
- LangOpts.Name = Record[Idx++];
-#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
+#define LANGOPT(Name, Bits, Default, Description) LangOpts.Name = Record[Idx++];
+#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
LangOpts.set##Name(static_cast<LangOptions::Type>(Record[Idx++]));
#include "clang/Basic/LangOptions.def"
#define SANITIZER(NAME, ID) \
@@ -6306,7 +6324,7 @@ bool ASTReader::ParseLanguageOptions(const RecordData &Record,
for (unsigned N = Record[Idx++]; N; --N)
LangOpts.ModuleFeatures.push_back(ReadString(Record, Idx));
- ObjCRuntime::Kind runtimeKind = (ObjCRuntime::Kind) Record[Idx++];
+ ObjCRuntime::Kind runtimeKind = (ObjCRuntime::Kind)Record[Idx++];
VersionTuple runtimeVersion = ReadVersionTuple(Record, Idx);
LangOpts.ObjCRuntime = ObjCRuntime(runtimeKind, runtimeVersion);
@@ -6314,8 +6332,7 @@ bool ASTReader::ParseLanguageOptions(const RecordData &Record,
// Comment options.
for (unsigned N = Record[Idx++]; N; --N) {
- LangOpts.CommentOpts.BlockCommandNames.push_back(
- ReadString(Record, Idx));
+ LangOpts.CommentOpts.BlockCommandNames.push_back(ReadString(Record, Idx));
}
LangOpts.CommentOpts.ParseAllComments = Record[Idx++];
@@ -6357,7 +6374,7 @@ bool ASTReader::ParseDiagnosticOptions(const RecordData &Record,
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts(new DiagnosticOptions);
unsigned Idx = 0;
#define DIAGOPT(Name, Bits, Default) DiagOpts->Name = Record[Idx++];
-#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
+#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
DiagOpts->set##Name(static_cast<Type>(Record[Idx++]));
#include "clang/Basic/DiagnosticOptions.def"
@@ -6410,8 +6427,8 @@ bool ASTReader::ParseHeaderSearchPaths(const RecordData &Record, bool Complain,
// Include entries.
for (unsigned N = Record[Idx++]; N; --N) {
std::string Path = ReadString(Record, Idx);
- frontend::IncludeDirGroup Group
- = static_cast<frontend::IncludeDirGroup>(Record[Idx++]);
+ frontend::IncludeDirGroup Group =
+ static_cast<frontend::IncludeDirGroup>(Record[Idx++]);
bool IsFramework = Record[Idx++];
bool IgnoreSysRoot = Record[Idx++];
HSOpts.UserEntries.emplace_back(std::move(Path), Group, IsFramework,
@@ -6466,7 +6483,7 @@ bool ASTReader::ParsePreprocessorOptions(const RecordData &Record,
PPOpts.DetailedRecord = Record[Idx++];
PPOpts.ImplicitPCHInclude = ReadString(Record, Idx);
PPOpts.ObjCXXARCStandardLibrary =
- static_cast<ObjCXXARCStandardLibraryKind>(Record[Idx++]);
+ static_cast<ObjCXXARCStandardLibraryKind>(Record[Idx++]);
SuggestedPredefines.clear();
return Listener.ReadPreprocessorOptions(PPOpts, ModuleFilename, ReadMacros,
Complain, SuggestedPredefines);
@@ -6474,8 +6491,8 @@ bool ASTReader::ParsePreprocessorOptions(const RecordData &Record,
std::pair<ModuleFile *, unsigned>
ASTReader::getModulePreprocessedEntity(unsigned GlobalIndex) {
- GlobalPreprocessedEntityMapType::iterator
- I = GlobalPreprocessedEntityMap.find(GlobalIndex);
+ GlobalPreprocessedEntityMapType::iterator I =
+ GlobalPreprocessedEntityMap.find(GlobalIndex);
assert(I != GlobalPreprocessedEntityMap.end() &&
"Corrupted global preprocessed entity map");
ModuleFile *M = I->second;
@@ -6510,7 +6527,7 @@ ASTReader::getModuleFileLevelDecls(ModuleFile &Mod) {
SourceRange ASTReader::ReadSkippedRange(unsigned GlobalIndex) {
auto I = GlobalSkippedRangeMap.find(GlobalIndex);
assert(I != GlobalSkippedRangeMap.end() &&
- "Corrupted global skipped range map");
+ "Corrupted global skipped range map");
ModuleFile *M = I->second;
unsigned LocalIndex = GlobalIndex - M->BasePreprocessedSkippedRangeID;
assert(LocalIndex < M->NumPreprocessedSkippedRanges);
@@ -6522,7 +6539,7 @@ SourceRange ASTReader::ReadSkippedRange(unsigned GlobalIndex) {
}
PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
- PreprocessedEntityID PPID = Index+1;
+ PreprocessedEntityID PPID = Index + 1;
std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
ModuleFile &M = *PPInfo.first;
unsigned LocalIndex = PPInfo.second;
@@ -6606,14 +6623,11 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
File = PP.getFileManager().getOptionalFileRef(FullFileName);
// FIXME: Stable encoding
- InclusionDirective::InclusionKind Kind
- = static_cast<InclusionDirective::InclusionKind>(Record[2]);
- InclusionDirective *ID
- = new (PPRec) InclusionDirective(PPRec, Kind,
- StringRef(Blob.data(), Record[0]),
- Record[1], Record[3],
- File,
- Range);
+ InclusionDirective::InclusionKind Kind =
+ static_cast<InclusionDirective::InclusionKind>(Record[2]);
+ InclusionDirective *ID = new (PPRec)
+ InclusionDirective(PPRec, Kind, StringRef(Blob.data(), Record[0]),
+ Record[1], Record[3], File, Range);
return ID;
}
}
@@ -6628,10 +6642,10 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
/// preprocessed entities or the entities it contains are not the ones we are
/// looking for.
PreprocessedEntityID ASTReader::findNextPreprocessedEntity(
- GlobalSLocOffsetMapType::const_iterator SLocMapI) const {
+ GlobalSLocOffsetMapType::const_iterator SLocMapI) const {
++SLocMapI;
- for (GlobalSLocOffsetMapType::const_iterator
- EndI = GlobalSLocOffsetMap.end(); SLocMapI != EndI; ++SLocMapI) {
+ for (GlobalSLocOffsetMapType::const_iterator EndI = GlobalSLocOffsetMap.end();
+ SLocMapI != EndI; ++SLocMapI) {
ModuleFile &M = *SLocMapI->second;
if (M.NumPreprocessedEntities)
return M.BasePreprocessedEntityID;
@@ -6697,8 +6711,7 @@ PreprocessedEntityID ASTReader::findPreprocessedEntity(SourceLocation Loc,
pp_iterator PPI;
if (EndsAfter) {
- PPI = std::upper_bound(pp_begin, pp_end, Loc,
- PPEntityComp(*this, M));
+ PPI = std::upper_bound(pp_begin, pp_end, Loc, PPEntityComp(*this, M));
} else {
// Do a binary search manually instead of using std::lower_bound because
// The end locations of entities may be unordered (when a macro expansion
@@ -6727,10 +6740,11 @@ PreprocessedEntityID ASTReader::findPreprocessedEntity(SourceLocation Loc,
/// Returns a pair of [Begin, End) indices of preallocated
/// preprocessed entities that \arg Range encompasses.
std::pair<unsigned, unsigned>
- ASTReader::findPreprocessedEntitiesInRange(SourceRange Range) {
+ASTReader::findPreprocessedEntitiesInRange(SourceRange Range) {
if (Range.isInvalid())
- return std::make_pair(0,0);
- assert(!SourceMgr.isBeforeInTranslationUnit(Range.getEnd(),Range.getBegin()));
+ return std::make_pair(0, 0);
+ assert(
+ !SourceMgr.isBeforeInTranslationUnit(Range.getEnd(), Range.getBegin()));
PreprocessedEntityID BeginID =
findPreprocessedEntity(Range.getBegin(), false);
@@ -6762,31 +6776,31 @@ std::optional<bool> ASTReader::isPreprocessedEntityInFileID(unsigned Index,
namespace {
- /// Visitor used to search for information about a header file.
- class HeaderFileInfoVisitor {
+/// Visitor used to search for information about a header file.
+class HeaderFileInfoVisitor {
FileEntryRef FE;
- std::optional<HeaderFileInfo> HFI;
+ std::optional<HeaderFileInfo> HFI;
- public:
- explicit HeaderFileInfoVisitor(FileEntryRef FE) : FE(FE) {}
+public:
+ explicit HeaderFileInfoVisitor(FileEntryRef FE) : FE(FE) {}
- bool operator()(ModuleFile &M) {
- HeaderFileInfoLookupTable *Table
- = static_cast<HeaderFileInfoLookupTable *>(M.HeaderFileInfoTable);
- if (!Table)
- return false;
+ bool operator()(ModuleFile &M) {
+ HeaderFileInfoLookupTable *Table =
+ static_cast<HeaderFileInfoLookupTable *>(M.HeaderFileInfoTable);
+ if (!Table)
+ return false;
- // Look in the on-disk hash table for an entry for this file name.
- HeaderFileInfoLookupTable::iterator Pos = Table->find(FE);
- if (Pos == Table->end())
- return false;
+ // Look in the on-disk hash table for an entry for this file name.
+ HeaderFileInfoLookupTable::iterator Pos = Table->find(FE);
+ if (Pos == Table->end())
+ return false;
- HFI = *Pos;
- return true;
- }
+ HFI = *Pos;
+ return true;
+ }
- std::optional<HeaderFileInfo> getHeaderFileInfo() const { return HFI; }
- };
+ std::optional<HeaderFileInfo> getHeaderFileInfo() const { return HFI; }
+};
} // namespace
@@ -6794,7 +6808,7 @@ HeaderFileInfo ASTReader::GetHeaderFileInfo(FileEntryRef FE) {
HeaderFileInfoVisitor Visitor(FE);
ModuleMgr.visit(Visitor);
if (std::optional<HeaderFileInfo> HFI = Visitor.getHeaderFileInfo())
- return *HFI;
+ return *HFI;
return HeaderFileInfo();
}
@@ -6867,11 +6881,16 @@ void ASTReader::ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag) {
// -Wblah flags.
unsigned Flags = Record[Idx++];
DiagState Initial(*Diag.getDiagnosticIDs());
- Initial.SuppressSystemWarnings = Flags & 1; Flags >>= 1;
- Initial.ErrorsAsFatal = Flags & 1; Flags >>= 1;
- Initial.WarningsAsErrors = Flags & 1; Flags >>= 1;
- Initial.EnableAllWarnings = Flags & 1; Flags >>= 1;
- Initial.IgnoreAllWarnings = Flags & 1; Flags >>= 1;
+ Initial.SuppressSystemWarnings = Flags & 1;
+ Flags >>= 1;
+ Initial.ErrorsAsFatal = Flags & 1;
+ Flags >>= 1;
+ Initial.WarningsAsErrors = Flags & 1;
+ Flags >>= 1;
+ Initial.EnableAllWarnings = Flags & 1;
+ Flags >>= 1;
+ Initial.IgnoreAllWarnings = Flags & 1;
+ Flags >>= 1;
Initial.ExtBehavior = (diag::Severity)Flags;
FirstState = ReadDiagState(Initial, true);
@@ -6945,8 +6964,9 @@ ASTReader::RecordLocation ASTReader::TypeCursorForIndex(TypeID ID) {
static std::optional<Type::TypeClass> getTypeClassForCode(TypeCode code) {
switch (code) {
-#define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \
- case TYPE_##CODE_ID: return Type::CLASS_ID;
+#define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \
+ case TYPE_##CODE_ID: \
+ return Type::CLASS_ID;
#include "clang/Serialization/TypeBitCodes.def"
default:
return std::nullopt;
@@ -6996,7 +7016,7 @@ QualType ASTReader::readTypeRecord(TypeID ID) {
return Context.getQualifiedType(baseType, quals);
}
- auto maybeClass = getTypeClassForCode((TypeCode) Code.get());
+ auto maybeClass = getTypeClassForCode((TypeCode)Code.get());
if (!maybeClass) {
Error("Unexpected code for type");
return QualType();
@@ -7017,17 +7037,13 @@ class TypeLocReader : public TypeLocVisitor<TypeLocReader> {
SourceLocation readSourceLocation() { return Reader.readSourceLocation(Seq); }
SourceRange readSourceRange() { return Reader.readSourceRange(Seq); }
- TypeSourceInfo *GetTypeSourceInfo() {
- return Reader.readTypeSourceInfo();
- }
+ TypeSourceInfo *GetTypeSourceInfo() { return Reader.readTypeSourceInfo(); }
NestedNameSpecifierLoc ReadNestedNameSpecifierLoc() {
return Reader.readNestedNameSpecifierLoc();
}
- Attr *ReadAttr() {
- return Reader.readAttr();
- }
+ Attr *ReadAttr() { return Reader.readAttr(); }
public:
TypeLocReader(ASTRecordReader &Reader, LocSeq *Seq)
@@ -7037,8 +7053,7 @@ class TypeLocReader : public TypeLocVisitor<TypeLocReader> {
// these, so unfortunately we have to declare them first, then
// define them out-of-line.
#define ABSTRACT_TYPELOC(CLASS, PARENT)
-#define TYPELOC(CLASS, PARENT) \
- void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
+#define TYPELOC(CLASS, PARENT) void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
#include "clang/AST/TypeLocNodes.def"
void VisitFunctionTypeLoc(FunctionTypeLoc);
@@ -7124,20 +7139,20 @@ void TypeLocReader::VisitVariableArrayTypeLoc(VariableArrayTypeLoc TL) {
}
void TypeLocReader::VisitDependentSizedArrayTypeLoc(
- DependentSizedArrayTypeLoc TL) {
+ DependentSizedArrayTypeLoc TL) {
VisitArrayTypeLoc(TL);
}
void TypeLocReader::VisitDependentAddressSpaceTypeLoc(
DependentAddressSpaceTypeLoc TL) {
- TL.setAttrNameLoc(readSourceLocation());
- TL.setAttrOperandParensRange(readSourceRange());
- TL.setAttrExprOperand(Reader.readExpr());
+ TL.setAttrNameLoc(readSourceLocation());
+ TL.setAttrOperandParensRange(readSourceRange());
+ TL.setAttrExprOperand(Reader.readExpr());
}
void TypeLocReader::VisitDependentSizedExtVectorTypeLoc(
- DependentSizedExtVectorTypeLoc TL) {
+ DependentSizedExtVectorTypeLoc TL) {
TL.setNameLoc(readSourceLocation());
}
@@ -7145,8 +7160,7 @@ void TypeLocReader::VisitVectorTypeLoc(VectorTypeLoc TL) {
TL.setNameLoc(readSourceLocation());
}
-void TypeLocReader::VisitDependentVectorTypeLoc(
- DependentVectorTypeLoc TL) {
+void TypeLocReader::VisitDependentVectorTypeLoc(DependentVectorTypeLoc TL) {
TL.setNameLoc(readSourceLocation());
}
@@ -7284,17 +7298,17 @@ void TypeLocReader::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
}
void TypeLocReader::VisitSubstTemplateTypeParmTypeLoc(
- SubstTemplateTypeParmTypeLoc TL) {
+ SubstTemplateTypeParmTypeLoc TL) {
TL.setNameLoc(readSourceLocation());
}
void TypeLocReader::VisitSubstTemplateTypeParmPackTypeLoc(
- SubstTemplateTypeParmPackTypeLoc TL) {
+ SubstTemplateTypeParmPackTypeLoc TL) {
TL.setNameLoc(readSourceLocation());
}
void TypeLocReader::VisitTemplateSpecializationTypeLoc(
- TemplateSpecializationTypeLoc TL) {
+ TemplateSpecializationTypeLoc TL) {
TL.setTemplateKeywordLoc(readSourceLocation());
TL.setTemplateNameLoc(readSourceLocation());
TL.setLAngleLoc(readSourceLocation());
@@ -7326,7 +7340,7 @@ void TypeLocReader::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
}
void TypeLocReader::VisitDependentTemplateSpecializationTypeLoc(
- DependentTemplateSpecializationTypeLoc TL) {
+ DependentTemplateSpecializationTypeLoc TL) {
TL.setElaboratedKeywordLoc(readSourceLocation());
TL.setQualifierLoc(ReadNestedNameSpecifierLoc());
TL.setTemplateKeywordLoc(readSourceLocation());
@@ -7638,15 +7652,15 @@ QualType ASTReader::GetType(TypeID ID) {
case PREDEF_TYPE_OBJC_SEL:
T = Context.ObjCBuiltinSelTy;
break;
-#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
- case PREDEF_TYPE_##Id##_ID: \
- T = Context.SingletonId; \
- break;
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
+ case PREDEF_TYPE_##Id##_ID: \
+ T = Context.SingletonId; \
+ break;
#include "clang/Basic/OpenCLImageTypes.def"
-#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
- case PREDEF_TYPE_##Id##_ID: \
- T = Context.Id##Ty; \
- break;
+#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
+ case PREDEF_TYPE_##Id##_ID: \
+ T = Context.Id##Ty; \
+ break;
#include "clang/Basic/OpenCLExtensionTypes.def"
case PREDEF_TYPE_SAMPLER_ID:
T = Context.OCLSamplerTy;
@@ -7687,20 +7701,20 @@ QualType ASTReader::GetType(TypeID ID) {
case PREDEF_TYPE_OMP_ITERATOR:
T = Context.OMPIteratorTy;
break;
-#define SVE_TYPE(Name, Id, SingletonId) \
- case PREDEF_TYPE_##Id##_ID: \
- T = Context.SingletonId; \
- break;
+#define SVE_TYPE(Name, Id, SingletonId) \
+ case PREDEF_TYPE_##Id##_ID: \
+ T = Context.SingletonId; \
+ break;
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_VECTOR_TYPE(Name, Id, Size) \
- case PREDEF_TYPE_##Id##_ID: \
- T = Context.Id##Ty; \
- break;
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
+ case PREDEF_TYPE_##Id##_ID: \
+ T = Context.Id##Ty; \
+ break;
#include "clang/Basic/PPCTypes.def"
-#define RVV_TYPE(Name, Id, SingletonId) \
- case PREDEF_TYPE_##Id##_ID: \
- T = Context.SingletonId; \
- break;
+#define RVV_TYPE(Name, Id, SingletonId) \
+ case PREDEF_TYPE_##Id##_ID: \
+ T = Context.SingletonId; \
+ break;
#include "clang/Basic/RISCVVTypes.def"
#define WASM_TYPE(Name, Id, SingletonId) \
case PREDEF_TYPE_##Id##_ID: \
@@ -7772,8 +7786,7 @@ ASTRecordReader::readTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind) {
case TemplateArgument::Type:
return readTypeSourceInfo();
case TemplateArgument::Template: {
- NestedNameSpecifierLoc QualifierLoc =
- readNestedNameSpecifierLoc();
+ NestedNameSpecifierLoc QualifierLoc = readNestedNameSpecifierLoc();
SourceLocation TemplateNameLoc = readSourceLocation();
return TemplateArgumentLocInfo(getASTContext(), QualifierLoc,
TemplateNameLoc, SourceLocation());
@@ -7831,7 +7844,7 @@ void ASTReader::CompleteRedeclChain(const Decl *D) {
// deserializing. Just remember that the AST has marked this one as complete
// but that it's not actually complete yet, so we know we still need to
// complete it later.
- PendingIncompleteDeclChains.push_back(const_cast<Decl*>(D));
+ PendingIncompleteDeclChains.push_back(const_cast<Decl *>(D));
return;
}
@@ -7864,7 +7877,7 @@ void ASTReader::CompleteRedeclChain(const Decl *D) {
// Find all declarations of this kind from the relevant context.
for (auto *DCDecl : cast<Decl>(D->getLexicalDeclContext())->redecls()) {
auto *DC = cast<DeclContext>(DCDecl);
- SmallVector<Decl*, 8> Decls;
+ SmallVector<Decl *, 8> Decls;
FindExternalLexicalDecls(
DC, [&](Decl::Kind K) { return K == D->getKind(); }, Decls);
}
@@ -7965,7 +7978,7 @@ CXXBaseSpecifier *ASTReader::GetExternalCXXBaseSpecifiers(uint64_t Offset) {
unsigned NumBases = Record.readInt();
void *Mem = Context.Allocate(sizeof(CXXBaseSpecifier) * NumBases);
- CXXBaseSpecifier *Bases = new (Mem) CXXBaseSpecifier [NumBases];
+ CXXBaseSpecifier *Bases = new (Mem) CXXBaseSpecifier[NumBases];
for (unsigned I = 0; I != NumBases; ++I)
Bases[I] = Record.readCXXBaseSpecifier();
return Bases;
@@ -8359,10 +8372,11 @@ void ASTReader::FindExternalLexicalDecls(
SmallVectorImpl<Decl *> &Decls) {
bool PredefsVisited[NUM_PREDEF_DECL_IDS] = {};
- auto Visit = [&] (ModuleFile *M, LexicalContents LexicalDecls) {
- assert(LexicalDecls.size() % 2 == 0 && "expected an even number of entries");
+ auto Visit = [&](ModuleFile *M, LexicalContents LexicalDecls) {
+ assert(LexicalDecls.size() % 2 == 0 &&
+ "expected an even number of entries");
for (int I = 0, N = LexicalDecls.size(); I != N; I += 2) {
- auto K = (Decl::Kind)+LexicalDecls[I];
+ auto K = (Decl::Kind) + LexicalDecls[I];
if (!IsKindWeWant(K))
continue;
@@ -8432,8 +8446,8 @@ class UnalignedDeclIDComp {
} // namespace
-void ASTReader::FindFileRegionDecls(FileID File,
- unsigned Offset, unsigned Length,
+void ASTReader::FindFileRegionDecls(FileID File, unsigned Offset,
+ unsigned Length,
SmallVectorImpl<Decl *> &Decls) {
SourceManager &SM = getSourceManager();
@@ -8445,8 +8459,8 @@ void ASTReader::FindFileRegionDecls(FileID File,
if (DInfo.Decls.empty())
return;
- SourceLocation
- BeginLoc = SM.getLocForStartOfFile(File).getLocWithOffset(Offset);
+ SourceLocation BeginLoc =
+ SM.getLocForStartOfFile(File).getLocWithOffset(Offset);
SourceLocation EndLoc = BeginLoc.getLocWithOffset(Length);
UnalignedDeclIDComp DIDComp(*this, *DInfo.Mod);
@@ -8645,45 +8659,45 @@ void ASTReader::PrintStats() {
if (unsigned TotalNumSLocEntries = getTotalNumSLocs())
std::fprintf(stderr, " %u/%u source location entries read (%f%%)\n",
NumSLocEntriesRead, TotalNumSLocEntries,
- ((float)NumSLocEntriesRead/TotalNumSLocEntries * 100));
+ ((float)NumSLocEntriesRead / TotalNumSLocEntries * 100));
if (!TypesLoaded.empty())
- std::fprintf(stderr, " %u/%u types read (%f%%)\n",
- NumTypesLoaded, (unsigned)TypesLoaded.size(),
- ((float)NumTypesLoaded/TypesLoaded.size() * 100));
+ std::fprintf(stderr, " %u/%u types read (%f%%)\n", NumTypesLoaded,
+ (unsigned)TypesLoaded.size(),
+ ((float)NumTypesLoaded / TypesLoaded.size() * 100));
if (!DeclsLoaded.empty())
- std::fprintf(stderr, " %u/%u declarations read (%f%%)\n",
- NumDeclsLoaded, (unsigned)DeclsLoaded.size(),
- ((float)NumDeclsLoaded/DeclsLoaded.size() * 100));
+ std::fprintf(stderr, " %u/%u declarations read (%f%%)\n", NumDeclsLoaded,
+ (unsigned)DeclsLoaded.size(),
+ ((float)NumDeclsLoaded / DeclsLoaded.size() * 100));
if (!IdentifiersLoaded.empty())
- std::fprintf(stderr, " %u/%u identifiers read (%f%%)\n",
- NumIdentifiersLoaded, (unsigned)IdentifiersLoaded.size(),
- ((float)NumIdentifiersLoaded/IdentifiersLoaded.size() * 100));
+ std::fprintf(
+ stderr, " %u/%u identifiers read (%f%%)\n", NumIdentifiersLoaded,
+ (unsigned)IdentifiersLoaded.size(),
+ ((float)NumIdentifiersLoaded / IdentifiersLoaded.size() * 100));
if (!MacrosLoaded.empty())
- std::fprintf(stderr, " %u/%u macros read (%f%%)\n",
- NumMacrosLoaded, (unsigned)MacrosLoaded.size(),
- ((float)NumMacrosLoaded/MacrosLoaded.size() * 100));
+ std::fprintf(stderr, " %u/%u macros read (%f%%)\n", NumMacrosLoaded,
+ (unsigned)MacrosLoaded.size(),
+ ((float)NumMacrosLoaded / MacrosLoaded.size() * 100));
if (!SelectorsLoaded.empty())
- std::fprintf(stderr, " %u/%u selectors read (%f%%)\n",
- NumSelectorsLoaded, (unsigned)SelectorsLoaded.size(),
- ((float)NumSelectorsLoaded/SelectorsLoaded.size() * 100));
+ std::fprintf(stderr, " %u/%u selectors read (%f%%)\n", NumSelectorsLoaded,
+ (unsigned)SelectorsLoaded.size(),
+ ((float)NumSelectorsLoaded / SelectorsLoaded.size() * 100));
if (TotalNumStatements)
- std::fprintf(stderr, " %u/%u statements read (%f%%)\n",
- NumStatementsRead, TotalNumStatements,
- ((float)NumStatementsRead/TotalNumStatements * 100));
+ std::fprintf(stderr, " %u/%u statements read (%f%%)\n", NumStatementsRead,
+ TotalNumStatements,
+ ((float)NumStatementsRead / TotalNumStatements * 100));
if (TotalNumMacros)
- std::fprintf(stderr, " %u/%u macros read (%f%%)\n",
- NumMacrosRead, TotalNumMacros,
- ((float)NumMacrosRead/TotalNumMacros * 100));
+ std::fprintf(stderr, " %u/%u macros read (%f%%)\n", NumMacrosRead,
+ TotalNumMacros, ((float)NumMacrosRead / TotalNumMacros * 100));
if (TotalLexicalDeclContexts)
- std::fprintf(stderr, " %u/%u lexical declcontexts read (%f%%)\n",
- NumLexicalDeclContextsRead, TotalLexicalDeclContexts,
- ((float)NumLexicalDeclContextsRead/TotalLexicalDeclContexts
- * 100));
+ std::fprintf(
+ stderr, " %u/%u lexical declcontexts read (%f%%)\n",
+ NumLexicalDeclContextsRead, TotalLexicalDeclContexts,
+ ((float)NumLexicalDeclContextsRead / TotalLexicalDeclContexts * 100));
if (TotalVisibleDeclContexts)
- std::fprintf(stderr, " %u/%u visible declcontexts read (%f%%)\n",
- NumVisibleDeclContextsRead, TotalVisibleDeclContexts,
- ((float)NumVisibleDeclContextsRead/TotalVisibleDeclContexts
- * 100));
+ std::fprintf(
+ stderr, " %u/%u visible declcontexts read (%f%%)\n",
+ NumVisibleDeclContextsRead, TotalVisibleDeclContexts,
+ ((float)NumVisibleDeclContextsRead / TotalVisibleDeclContexts * 100));
if (TotalModuleLocalVisibleDeclContexts)
std::fprintf(
stderr, " %u/%u module local visible declcontexts read (%f%%)\n",
@@ -8696,24 +8710,24 @@ void ASTReader::PrintStats() {
((float)NumTULocalVisibleDeclContexts /
TotalTULocalVisibleDeclContexts * 100));
if (TotalNumMethodPoolEntries)
- std::fprintf(stderr, " %u/%u method pool entries read (%f%%)\n",
- NumMethodPoolEntriesRead, TotalNumMethodPoolEntries,
- ((float)NumMethodPoolEntriesRead/TotalNumMethodPoolEntries
- * 100));
+ std::fprintf(
+ stderr, " %u/%u method pool entries read (%f%%)\n",
+ NumMethodPoolEntriesRead, TotalNumMethodPoolEntries,
+ ((float)NumMethodPoolEntriesRead / TotalNumMethodPoolEntries * 100));
if (NumMethodPoolLookups)
std::fprintf(stderr, " %u/%u method pool lookups succeeded (%f%%)\n",
NumMethodPoolHits, NumMethodPoolLookups,
- ((float)NumMethodPoolHits/NumMethodPoolLookups * 100.0));
+ ((float)NumMethodPoolHits / NumMethodPoolLookups * 100.0));
if (NumMethodPoolTableLookups)
- std::fprintf(stderr, " %u/%u method pool table lookups succeeded (%f%%)\n",
- NumMethodPoolTableHits, NumMethodPoolTableLookups,
- ((float)NumMethodPoolTableHits/NumMethodPoolTableLookups
- * 100.0));
+ std::fprintf(
+ stderr, " %u/%u method pool table lookups succeeded (%f%%)\n",
+ NumMethodPoolTableHits, NumMethodPoolTableLookups,
+ ((float)NumMethodPoolTableHits / NumMethodPoolTableLookups * 100.0));
if (NumIdentifierLookupHits)
- std::fprintf(stderr,
- " %u / %u identifier table lookups succeeded (%f%%)\n",
- NumIdentifierLookupHits, NumIdentifierLookups,
- (double)NumIdentifierLookupHits*100.0/NumIdentifierLookups);
+ std::fprintf(
+ stderr, " %u / %u identifier table lookups succeeded (%f%%)\n",
+ NumIdentifierLookupHits, NumIdentifierLookups,
+ (double)NumIdentifierLookupHits * 100.0 / NumIdentifierLookups);
if (GlobalIndex) {
std::fprintf(stderr, "\n");
@@ -8725,11 +8739,10 @@ void ASTReader::PrintStats() {
std::fprintf(stderr, "\n");
}
-template<typename Key, typename ModuleFile, unsigned InitialCapacity>
-LLVM_DUMP_METHOD static void
-dumpModuleIDMap(StringRef Name,
- const ContinuousRangeMap<Key, ModuleFile *,
- InitialCapacity> &Map) {
+template <typename Key, typename ModuleFile, unsigned InitialCapacity>
+LLVM_DUMP_METHOD static void dumpModuleIDMap(
+ StringRef Name,
+ const ContinuousRangeMap<Key, ModuleFile *, InitialCapacity> &Map) {
if (Map.begin() == Map.end())
return;
@@ -8764,12 +8777,12 @@ void ASTReader::getMemoryBufferSizes(MemoryBufferSizes &sizes) const {
if (llvm::MemoryBuffer *buf = I.Buffer) {
size_t bytes = buf->getBufferSize();
switch (buf->getBufferKind()) {
- case llvm::MemoryBuffer::MemoryBuffer_Malloc:
- sizes.malloc_bytes += bytes;
- break;
- case llvm::MemoryBuffer::MemoryBuffer_MMap:
- sizes.mmap_bytes += bytes;
- break;
+ case llvm::MemoryBuffer::MemoryBuffer_Malloc:
+ sizes.malloc_bytes += bytes;
+ break;
+ case llvm::MemoryBuffer::MemoryBuffer_MMap:
+ sizes.mmap_bytes += bytes;
+ break;
}
}
}
@@ -8832,7 +8845,7 @@ void ASTReader::UpdateSema() {
// Update the state of pragmas. Use the same API as if we had encountered the
// pragma in the source.
- if(OptimizeOffPragmaLocation.isValid())
+ if (OptimizeOffPragmaLocation.isValid())
SemaObj->ActOnPragmaOptimize(/* On = */ false, OptimizeOffPragmaLocation);
if (PragmaMSStructState != -1)
SemaObj->ActOnPragmaMSStruct((PragmaMSStructKind)PragmaMSStructState);
@@ -8954,33 +8967,33 @@ IdentifierInfo *ASTReader::get(StringRef Name) {
namespace clang {
- /// An identifier-lookup iterator that enumerates all of the
- /// identifiers stored within a set of AST files.
- class ASTIdentifierIterator : public IdentifierIterator {
- /// The AST reader whose identifiers are being enumerated.
- const ASTReader &Reader;
+/// An identifier-lookup iterator that enumerates all of the
+/// identifiers stored within a set of AST files.
+class ASTIdentifierIterator : public IdentifierIterator {
+ /// The AST reader whose identifiers are being enumerated.
+ const ASTReader &Reader;
- /// The current index into the chain of AST files stored in
- /// the AST reader.
- unsigned Index;
+ /// The current index into the chain of AST files stored in
+ /// the AST reader.
+ unsigned Index;
- /// The current position within the identifier lookup table
- /// of the current AST file.
- ASTIdentifierLookupTable::key_iterator Current;
+ /// The current position within the identifier lookup table
+ /// of the current AST file.
+ ASTIdentifierLookupTable::key_iterator Current;
- /// The end position within the identifier lookup table of
- /// the current AST file.
- ASTIdentifierLookupTable::key_iterator End;
+ /// The end position within the identifier lookup table of
+ /// the current AST file.
+ ASTIdentifierLookupTable::key_iterator End;
- /// Whether to skip any modules in the ASTReader.
- bool SkipModules;
+ /// Whether to skip any modules in the ASTReader.
+ bool SkipModules;
- public:
- explicit ASTIdentifierIterator(const ASTReader &Reader,
- bool SkipModules = false);
+public:
+ explicit ASTIdentifierIterator(const ASTReader &Reader,
+ bool SkipModules = false);
- StringRef Next() override;
- };
+ StringRef Next() override;
+};
} // namespace clang
@@ -9058,78 +9071,76 @@ IdentifierIterator *ASTReader::getIdentifiers() {
namespace clang {
namespace serialization {
- class ReadMethodPoolVisitor {
- ASTReader &Reader;
- Selector Sel;
- unsigned PriorGeneration;
- unsigned InstanceBits = 0;
- unsigned FactoryBits = 0;
- bool InstanceHasMoreThanOneDecl = false;
- bool FactoryHasMoreThanOneDecl = false;
- SmallVector<ObjCMethodDecl *, 4> InstanceMethods;
- SmallVector<ObjCMethodDecl *, 4> FactoryMethods;
-
- public:
- ReadMethodPoolVisitor(ASTReader &Reader, Selector Sel,
- unsigned PriorGeneration)
- : Reader(Reader), Sel(Sel), PriorGeneration(PriorGeneration) {}
-
- bool operator()(ModuleFile &M) {
- if (!M.SelectorLookupTable)
- return false;
+class ReadMethodPoolVisitor {
+ ASTReader &Reader;
+ Selector Sel;
+ unsigned PriorGeneration;
+ unsigned InstanceBits = 0;
+ unsigned FactoryBits = 0;
+ bool InstanceHasMoreThanOneDecl = false;
+ bool FactoryHasMoreThanOneDecl = false;
+ SmallVector<ObjCMethodDecl *, 4> InstanceMethods;
+ SmallVector<ObjCMethodDecl *, 4> FactoryMethods;
- // If we've already searched this module file, skip it now.
- if (M.Generation <= PriorGeneration)
- return true;
+public:
+ ReadMethodPoolVisitor(ASTReader &Reader, Selector Sel,
+ unsigned PriorGeneration)
+ : Reader(Reader), Sel(Sel), PriorGeneration(PriorGeneration) {}
- ++Reader.NumMethodPoolTableLookups;
- ASTSelectorLookupTable *PoolTable
- = (ASTSelectorLookupTable*)M.SelectorLookupTable;
- ASTSelectorLookupTable::iterator Pos = PoolTable->find(Sel);
- if (Pos == PoolTable->end())
- return false;
+ bool operator()(ModuleFile &M) {
+ if (!M.SelectorLookupTable)
+ return false;
- ++Reader.NumMethodPoolTableHits;
- ++Reader.NumSelectorsRead;
- // FIXME: Not quite happy with the statistics here. We probably should
- // disable this tracking when called via LoadSelector.
- // Also, should entries without methods count as misses?
- ++Reader.NumMethodPoolEntriesRead;
- ASTSelectorLookupTrait::data_type Data = *Pos;
- if (Reader.DeserializationListener)
- Reader.DeserializationListener->SelectorRead(Data.ID, Sel);
-
- // Append methods in the reverse order, so that later we can process them
- // in the order they appear in the source code by iterating through
- // the vector in the reverse order.
- InstanceMethods.append(Data.Instance.rbegin(), Data.Instance.rend());
- FactoryMethods.append(Data.Factory.rbegin(), Data.Factory.rend());
- InstanceBits = Data.InstanceBits;
- FactoryBits = Data.FactoryBits;
- InstanceHasMoreThanOneDecl = Data.InstanceHasMoreThanOneDecl;
- FactoryHasMoreThanOneDecl = Data.FactoryHasMoreThanOneDecl;
+ // If we've already searched this module file, skip it now.
+ if (M.Generation <= PriorGeneration)
+ return true;
+
+ ++Reader.NumMethodPoolTableLookups;
+ ASTSelectorLookupTable *PoolTable =
+ (ASTSelectorLookupTable *)M.SelectorLookupTable;
+ ASTSelectorLookupTable::iterator Pos = PoolTable->find(Sel);
+ if (Pos == PoolTable->end())
return false;
- }
- /// Retrieve the instance methods found by this visitor.
- ArrayRef<ObjCMethodDecl *> getInstanceMethods() const {
- return InstanceMethods;
- }
+ ++Reader.NumMethodPoolTableHits;
+ ++Reader.NumSelectorsRead;
+ // FIXME: Not quite happy with the statistics here. We probably should
+ // disable this tracking when called via LoadSelector.
+ // Also, should entries without methods count as misses?
+ ++Reader.NumMethodPoolEntriesRead;
+ ASTSelectorLookupTrait::data_type Data = *Pos;
+ if (Reader.DeserializationListener)
+ Reader.DeserializationListener->SelectorRead(Data.ID, Sel);
+
+ // Append methods in the reverse order, so that later we can process them
+ // in the order they appear in the source code by iterating through
+ // the vector in the reverse order.
+ InstanceMethods.append(Data.Instance.rbegin(), Data.Instance.rend());
+ FactoryMethods.append(Data.Factory.rbegin(), Data.Factory.rend());
+ InstanceBits = Data.InstanceBits;
+ FactoryBits = Data.FactoryBits;
+ InstanceHasMoreThanOneDecl = Data.InstanceHasMoreThanOneDecl;
+ FactoryHasMoreThanOneDecl = Data.FactoryHasMoreThanOneDecl;
+ return false;
+ }
- /// Retrieve the instance methods found by this visitor.
- ArrayRef<ObjCMethodDecl *> getFactoryMethods() const {
- return FactoryMethods;
- }
+ /// Retrieve the instance methods found by this visitor.
+ ArrayRef<ObjCMethodDecl *> getInstanceMethods() const {
+ return InstanceMethods;
+ }
- unsigned getInstanceBits() const { return InstanceBits; }
- unsigned getFactoryBits() const { return FactoryBits; }
+ /// Retrieve the instance methods found by this visitor.
+ ArrayRef<ObjCMethodDecl *> getFactoryMethods() const {
+ return FactoryMethods;
+ }
- bool instanceHasMoreThanOneDecl() const {
- return InstanceHasMoreThanOneDecl;
- }
+ unsigned getInstanceBits() const { return InstanceBits; }
+ unsigned getFactoryBits() const { return FactoryBits; }
- bool factoryHasMoreThanOneDecl() const { return FactoryHasMoreThanOneDecl; }
- };
+ bool instanceHasMoreThanOneDecl() const { return InstanceHasMoreThanOneDecl; }
+
+ bool factoryHasMoreThanOneDecl() const { return FactoryHasMoreThanOneDecl; }
+};
} // namespace serialization
} // namespace clang
@@ -9183,12 +9194,12 @@ void ASTReader::updateOutOfDateSelector(Selector Sel) {
}
void ASTReader::ReadKnownNamespaces(
- SmallVectorImpl<NamespaceDecl *> &Namespaces) {
+ SmallVectorImpl<NamespaceDecl *> &Namespaces) {
Namespaces.clear();
for (unsigned I = 0, N = KnownNamespaces.size(); I != N; ++I) {
- if (NamespaceDecl *Namespace
- = dyn_cast_or_null<NamespaceDecl>(GetDecl(KnownNamespaces[I])))
+ if (NamespaceDecl *Namespace =
+ dyn_cast_or_null<NamespaceDecl>(GetDecl(KnownNamespaces[I])))
Namespaces.push_back(Namespace);
}
}
@@ -9204,9 +9215,10 @@ void ASTReader::ReadUndefinedButUsed(
UndefinedButUsed.clear();
}
-void ASTReader::ReadMismatchingDeleteExpressions(llvm::MapVector<
- FieldDecl *, llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &
- Exprs) {
+void ASTReader::ReadMismatchingDeleteExpressions(
+ llvm::MapVector<FieldDecl *,
+ llvm::SmallVector<std::pair<SourceLocation, bool>, 4>>
+ &Exprs) {
for (unsigned Idx = 0, N = DelayedDeleteExprs.size(); Idx != N;) {
FieldDecl *FD =
cast<FieldDecl>(GetDecl(GlobalDeclID(DelayedDeleteExprs[Idx++])));
@@ -9221,7 +9233,7 @@ void ASTReader::ReadMismatchingDeleteExpressions(llvm::MapVector<
}
void ASTReader::ReadTentativeDefinitions(
- SmallVectorImpl<VarDecl *> &TentativeDefs) {
+ SmallVectorImpl<VarDecl *> &TentativeDefs) {
for (unsigned I = 0, N = TentativeDefinitions.size(); I != N; ++I) {
VarDecl *Var = dyn_cast_or_null<VarDecl>(GetDecl(TentativeDefinitions[I]));
if (Var)
@@ -9231,10 +9243,10 @@ void ASTReader::ReadTentativeDefinitions(
}
void ASTReader::ReadUnusedFileScopedDecls(
- SmallVectorImpl<const DeclaratorDecl *> &Decls) {
+ SmallVectorImpl<const DeclaratorDecl *> &Decls) {
for (unsigned I = 0, N = UnusedFileScopedDecls.size(); I != N; ++I) {
- DeclaratorDecl *D
- = dyn_cast_or_null<DeclaratorDecl>(GetDecl(UnusedFileScopedDecls[I]));
+ DeclaratorDecl *D =
+ dyn_cast_or_null<DeclaratorDecl>(GetDecl(UnusedFileScopedDecls[I]));
if (D)
Decls.push_back(D);
}
@@ -9242,10 +9254,10 @@ void ASTReader::ReadUnusedFileScopedDecls(
}
void ASTReader::ReadDelegatingConstructors(
- SmallVectorImpl<CXXConstructorDecl *> &Decls) {
+ SmallVectorImpl<CXXConstructorDecl *> &Decls) {
for (unsigned I = 0, N = DelegatingCtorDecls.size(); I != N; ++I) {
- CXXConstructorDecl *D
- = dyn_cast_or_null<CXXConstructorDecl>(GetDecl(DelegatingCtorDecls[I]));
+ CXXConstructorDecl *D =
+ dyn_cast_or_null<CXXConstructorDecl>(GetDecl(DelegatingCtorDecls[I]));
if (D)
Decls.push_back(D);
}
@@ -9254,8 +9266,8 @@ void ASTReader::ReadDelegatingConstructors(
void ASTReader::ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls) {
for (unsigned I = 0, N = ExtVectorDecls.size(); I != N; ++I) {
- TypedefNameDecl *D
- = dyn_cast_or_null<TypedefNameDecl>(GetDecl(ExtVectorDecls[I]));
+ TypedefNameDecl *D =
+ dyn_cast_or_null<TypedefNameDecl>(GetDecl(ExtVectorDecls[I]));
if (D)
Decls.push_back(D);
}
@@ -9285,33 +9297,33 @@ void ASTReader::ReadDeclsToCheckForDeferredDiags(
}
void ASTReader::ReadReferencedSelectors(
- SmallVectorImpl<std::pair<Selector, SourceLocation>> &Sels) {
+ SmallVectorImpl<std::pair<Selector, SourceLocation>> &Sels) {
if (ReferencedSelectorsData.empty())
return;
// If there are @selector references added them to its pool. This is for
// implementation of -Wselector.
- unsigned int DataSize = ReferencedSelectorsData.size()-1;
+ unsigned int DataSize = ReferencedSelectorsData.size() - 1;
unsigned I = 0;
while (I < DataSize) {
Selector Sel = DecodeSelector(ReferencedSelectorsData[I++]);
- SourceLocation SelLoc
- = SourceLocation::getFromRawEncoding(ReferencedSelectorsData[I++]);
+ SourceLocation SelLoc =
+ SourceLocation::getFromRawEncoding(ReferencedSelectorsData[I++]);
Sels.push_back(std::make_pair(Sel, SelLoc));
}
ReferencedSelectorsData.clear();
}
void ASTReader::ReadWeakUndeclaredIdentifiers(
- SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo>> &WeakIDs) {
+ SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo>> &WeakIDs) {
if (WeakUndeclaredIdentifiers.empty())
return;
for (unsigned I = 0, N = WeakUndeclaredIdentifiers.size(); I < N; /*none*/) {
- IdentifierInfo *WeakId
- = DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
- IdentifierInfo *AliasId
- = DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
+ IdentifierInfo *WeakId =
+ DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
+ IdentifierInfo *AliasId =
+ DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
SourceLocation Loc =
SourceLocation::getFromRawEncoding(WeakUndeclaredIdentifiers[I++]);
WeakInfo WI(AliasId, Loc);
@@ -9334,7 +9346,7 @@ void ASTReader::ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) {
}
void ASTReader::ReadPendingInstantiations(
- SmallVectorImpl<std::pair<ValueDecl *, SourceLocation>> &Pending) {
+ SmallVectorImpl<std::pair<ValueDecl *, SourceLocation>> &Pending) {
for (unsigned Idx = 0, N = PendingInstantiations.size(); Idx < N;) {
PendingInstantiation &Inst = PendingInstantiations[Idx++];
ValueDecl *D = cast<ValueDecl>(GetDecl(Inst.ID));
@@ -9547,8 +9559,8 @@ MacroInfo *ASTReader::getMacro(MacroID ID) {
ID -= NUM_PREDEF_MACRO_IDS;
if (!MacrosLoaded[ID]) {
- GlobalMacroMapType::iterator I
- = GlobalMacroMap.find(ID + NUM_PREDEF_MACRO_IDS);
+ GlobalMacroMapType::iterator I =
+ GlobalMacroMap.find(ID + NUM_PREDEF_MACRO_IDS);
assert(I != GlobalMacroMap.end() && "Corrupted global macro map");
ModuleFile *M = I->second;
unsigned Index = ID - M->BaseMacroID;
@@ -9570,8 +9582,8 @@ MacroID ASTReader::getGlobalMacroID(ModuleFile &M, unsigned LocalID) {
if (!M.ModuleOffsetMap.empty())
ReadModuleOffsetMap(M);
- ContinuousRangeMap<uint32_t, int, 2>::iterator I
- = M.MacroRemap.find(LocalID - NUM_PREDEF_MACRO_IDS);
+ ContinuousRangeMap<uint32_t, int, 2>::iterator I =
+ M.MacroRemap.find(LocalID - NUM_PREDEF_MACRO_IDS);
assert(I != M.MacroRemap.end() && "Invalid index into macro index remap");
return LocalID + I->second;
@@ -9585,10 +9597,10 @@ ASTReader::getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID) const {
if (!M.ModuleOffsetMap.empty())
ReadModuleOffsetMap(M);
- ContinuousRangeMap<uint32_t, int, 2>::iterator I
- = M.SubmoduleRemap.find(LocalID - NUM_PREDEF_SUBMODULE_IDS);
- assert(I != M.SubmoduleRemap.end()
- && "Invalid index into submodule index remap");
+ ContinuousRangeMap<uint32_t, int, 2>::iterator I =
+ M.SubmoduleRemap.find(LocalID - NUM_PREDEF_SUBMODULE_IDS);
+ assert(I != M.SubmoduleRemap.end() &&
+ "Invalid index into submodule index remap");
return LocalID + I->second;
}
@@ -9607,9 +9619,7 @@ Module *ASTReader::getSubmodule(SubmoduleID GlobalID) {
return SubmodulesLoaded[GlobalID - NUM_PREDEF_SUBMODULE_IDS];
}
-Module *ASTReader::getModule(unsigned ID) {
- return getSubmodule(ID);
-}
+Module *ASTReader::getModule(unsigned ID) { return getSubmodule(ID); }
ModuleFile *ASTReader::getLocalModuleFile(ModuleFile &M, unsigned ID) const {
if (ID & 1) {
@@ -9687,7 +9697,7 @@ Selector ASTReader::DecodeSelector(serialization::SelectorID ID) {
ASTSelectorLookupTrait Trait(*this, M);
unsigned Idx = ID - M.BaseSelectorID - NUM_PREDEF_SELECTOR_IDS;
SelectorsLoaded[ID - 1] =
- Trait.ReadKey(M.SelectorLookupTableData + M.SelectorOffsets[Idx], 0);
+ Trait.ReadKey(M.SelectorLookupTableData + M.SelectorOffsets[Idx], 0);
if (DeserializationListener)
DeserializationListener->SelectorRead(ID, SelectorsLoaded[ID - 1]);
}
@@ -9712,10 +9722,10 @@ ASTReader::getGlobalSelectorID(ModuleFile &M, unsigned LocalID) const {
if (!M.ModuleOffsetMap.empty())
ReadModuleOffsetMap(M);
- ContinuousRangeMap<uint32_t, int, 2>::iterator I
- = M.SelectorRemap.find(LocalID - NUM_PREDEF_SELECTOR_IDS);
- assert(I != M.SelectorRemap.end()
- && "Invalid index into selector index remap");
+ ContinuousRangeMap<uint32_t, int, 2>::iterator I =
+ M.SelectorRemap.find(LocalID - NUM_PREDEF_SELECTOR_IDS);
+ assert(I != M.SelectorRemap.end() &&
+ "Invalid index into selector index remap");
return LocalID + I->second;
}
@@ -9770,8 +9780,7 @@ void ASTRecordReader::readQualifierInfo(QualifierInfo &Info) {
}
}
-TemplateParameterList *
-ASTRecordReader::readTemplateParameterList() {
+TemplateParameterList *ASTRecordReader::readTemplateParameterList() {
SourceLocation TemplateLoc = readSourceLocation();
SourceLocation LAngleLoc = readSourceLocation();
SourceLocation RAngleLoc = readSourceLocation();
@@ -9791,8 +9800,7 @@ ASTRecordReader::readTemplateParameterList() {
}
void ASTRecordReader::readTemplateArgumentList(
- SmallVectorImpl<TemplateArgument> &TemplArgs,
- bool Canonicalize) {
+ SmallVectorImpl<TemplateArgument> &TemplArgs, bool Canonicalize) {
unsigned NumTemplateArgs = readInt();
TemplArgs.reserve(NumTemplateArgs);
while (NumTemplateArgs--)
@@ -9805,13 +9813,12 @@ void ASTRecordReader::readUnresolvedSet(LazyASTUnresolvedSet &Set) {
Set.reserve(getContext(), NumDecls);
while (NumDecls--) {
GlobalDeclID ID = readDeclID();
- AccessSpecifier AS = (AccessSpecifier) readInt();
+ AccessSpecifier AS = (AccessSpecifier)readInt();
Set.addLazyDecl(getContext(), ID, AS);
}
}
-CXXBaseSpecifier
-ASTRecordReader::readCXXBaseSpecifier() {
+CXXBaseSpecifier ASTRecordReader::readCXXBaseSpecifier() {
bool isVirtual = readBool();
bool isBaseOfClass = readBool();
AccessSpecifier AS = static_cast<AccessSpecifier>(readInt());
@@ -9825,19 +9832,18 @@ ASTRecordReader::readCXXBaseSpecifier() {
return Result;
}
-CXXCtorInitializer **
-ASTRecordReader::readCXXCtorInitializers() {
+CXXCtorInitializer **ASTRecordReader::readCXXCtorInitializers() {
ASTContext &Context = getContext();
unsigned NumInitializers = readInt();
assert(NumInitializers && "wrote ctor initializers but have no inits");
- auto **CtorInitializers = new (Context) CXXCtorInitializer*[NumInitializers];
+ auto **CtorInitializers = new (Context) CXXCtorInitializer *[NumInitializers];
for (unsigned i = 0; i != NumInitializers; ++i) {
TypeSourceInfo *TInfo = nullptr;
bool IsBaseVirtual = false;
FieldDecl *Member = nullptr;
IndirectFieldDecl *IndirectMember = nullptr;
- CtorInitializerType Type = (CtorInitializerType) readInt();
+ CtorInitializerType Type = (CtorInitializerType)readInt();
switch (Type) {
case CTOR_INITIALIZER_BASE:
TInfo = readTypeSourceInfo();
@@ -9848,11 +9854,11 @@ ASTRecordReader::readCXXCtorInitializers() {
TInfo = readTypeSourceInfo();
break;
- case CTOR_INITIALIZER_MEMBER:
+ case CTOR_INITIALIZER_MEMBER:
Member = readDeclAs<FieldDecl>();
break;
- case CTOR_INITIALIZER_INDIRECT_MEMBER:
+ case CTOR_INITIALIZER_INDIRECT_MEMBER:
IndirectMember = readDeclAs<IndirectFieldDecl>();
break;
}
@@ -9871,15 +9877,14 @@ ASTRecordReader::readCXXCtorInitializers() {
BOMInit = new (Context)
CXXCtorInitializer(Context, TInfo, LParenLoc, Init, RParenLoc);
else if (Member)
- BOMInit = new (Context)
- CXXCtorInitializer(Context, Member, MemberOrEllipsisLoc, LParenLoc,
- Init, RParenLoc);
+ BOMInit = new (Context) CXXCtorInitializer(
+ Context, Member, MemberOrEllipsisLoc, LParenLoc, Init, RParenLoc);
else
BOMInit = new (Context)
CXXCtorInitializer(Context, IndirectMember, MemberOrEllipsisLoc,
LParenLoc, Init, RParenLoc);
- if (/*IsWritten*/readBool()) {
+ if (/*IsWritten*/ readBool()) {
unsigned SourceOrder = readInt();
BOMInit->setSourceOrder(SourceOrder);
}
@@ -9890,8 +9895,7 @@ ASTRecordReader::readCXXCtorInitializers() {
return CtorInitializers;
}
-NestedNameSpecifierLoc
-ASTRecordReader::readNestedNameSpecifierLoc() {
+NestedNameSpecifierLoc ASTRecordReader::readNestedNameSpecifierLoc() {
ASTContext &Context = getContext();
unsigned N = readInt();
NestedNameSpecifierLocBuilder Builder;
@@ -9928,9 +9932,9 @@ ASTRecordReader::readNestedNameSpecifierLoc() {
SourceLocation ColonColonLoc = readSourceLocation();
// FIXME: 'template' keyword location not saved anywhere, so we fake it.
- Builder.Extend(Context,
- Template? T->getTypeLoc().getBeginLoc() : SourceLocation(),
- T->getTypeLoc(), ColonColonLoc);
+ Builder.Extend(
+ Context, Template ? T->getTypeLoc().getBeginLoc() : SourceLocation(),
+ T->getTypeLoc(), ColonColonLoc);
break;
}
@@ -10068,17 +10072,15 @@ SwitchCase *ASTReader::getSwitchCaseWithID(unsigned ID) {
return (*CurrSwitchCaseStmts)[ID];
}
-void ASTReader::ClearSwitchCaseIDs() {
- CurrSwitchCaseStmts->clear();
-}
+void ASTReader::ClearSwitchCaseIDs() { CurrSwitchCaseStmts->clear(); }
void ASTReader::ReadComments() {
ASTContext &Context = getContext();
std::vector<RawComment *> Comments;
- for (SmallVectorImpl<std::pair<BitstreamCursor,
- serialization::ModuleFile *>>::iterator
- I = CommentsCursors.begin(),
- E = CommentsCursors.end();
+ for (SmallVectorImpl<
+ std::pair<BitstreamCursor, serialization::ModuleFile *>>::iterator
+ I = CommentsCursors.begin(),
+ E = CommentsCursors.end();
I != E; ++I) {
Comments.clear();
BitstreamCursor &Cursor = I->first;
@@ -10119,12 +10121,11 @@ void ASTReader::ReadComments() {
case COMMENTS_RAW_COMMENT: {
unsigned Idx = 0;
SourceRange SR = ReadSourceRange(F, Record, Idx);
- RawComment::CommentKind Kind =
- (RawComment::CommentKind) Record[Idx++];
+ RawComment::CommentKind Kind = (RawComment::CommentKind)Record[Idx++];
bool IsTrailingComment = Record[Idx++];
bool IsAlmostTrailingComment = Record[Idx++];
- Comments.push_back(new (Context) RawComment(
- SR, Kind, IsTrailingComment, IsAlmostTrailingComment));
+ Comments.push_back(new (Context) RawComment(SR, Kind, IsTrailingComment,
+ IsAlmostTrailingComment));
break;
}
}
@@ -10155,22 +10156,22 @@ void ASTReader::visitInputFileInfos(
unsigned N = IncludeSystem ? NumInputs : NumUserInputs;
for (unsigned I = 0; I < N; ++I) {
bool IsSystem = I >= NumUserInputs;
- InputFileInfo IFI = getInputFileInfo(MF, I+1);
+ InputFileInfo IFI = getInputFileInfo(MF, I + 1);
Visitor(IFI, IsSystem);
}
}
-void ASTReader::visitInputFiles(serialization::ModuleFile &MF,
- bool IncludeSystem, bool Complain,
- llvm::function_ref<void(const serialization::InputFile &IF,
- bool isSystem)> Visitor) {
+void ASTReader::visitInputFiles(
+ serialization::ModuleFile &MF, bool IncludeSystem, bool Complain,
+ llvm::function_ref<void(const serialization::InputFile &IF, bool isSystem)>
+ Visitor) {
unsigned NumUserInputs = MF.NumUserInputFiles;
unsigned NumInputs = MF.InputFilesLoaded.size();
assert(NumUserInputs <= NumInputs);
unsigned N = IncludeSystem ? NumInputs : NumUserInputs;
for (unsigned I = 0; I < N; ++I) {
bool IsSystem = I >= NumUserInputs;
- InputFile IF = getInputFile(MF, I+1, Complain);
+ InputFile IF = getInputFile(MF, I + 1, Complain);
Visitor(IF, IsSystem);
}
}
@@ -10256,7 +10257,8 @@ void ASTReader::finishPendingActions() {
// Make the most recent of the top-level declarations visible.
for (TopLevelDeclsMap::iterator TLD = TopLevelDecls.begin(),
- TLDEnd = TopLevelDecls.end(); TLD != TLDEnd; ++TLD) {
+ TLDEnd = TopLevelDecls.end();
+ TLD != TLDEnd; ++TLD) {
IdentifierInfo *II = TLD->first;
for (unsigned I = 0, N = TLD->second.size(); I != N; ++I) {
pushExternalDeclIntoScope(cast<NamedDecl>(TLD->second[I]), II);
@@ -10353,7 +10355,7 @@ void ASTReader::finishPendingActions() {
if (TagDecl *TD = dyn_cast<TagDecl>(D)) {
if (const TagType *TagT = dyn_cast<TagType>(TD->getTypeForDecl())) {
// Make sure that the TagType points at the definition.
- const_cast<TagType*>(TagT)->decl = TD;
+ const_cast<TagType *>(TagT)->decl = TD;
}
if (auto RD = dyn_cast<CXXRecordDecl>(D)) {
@@ -10372,7 +10374,7 @@ void ASTReader::finishPendingActions() {
if (auto ID = dyn_cast<ObjCInterfaceDecl>(D)) {
// Make sure that the ObjCInterfaceType points at the definition.
const_cast<ObjCInterfaceType *>(cast<ObjCInterfaceType>(ID->TypeForDecl))
- ->Decl = ID;
+ ->Decl = ID;
for (auto *R = getMostRecentExistingDecl(ID); R; R = R->getPreviousDecl())
cast<ObjCInterfaceDecl>(R)->Data = ID->Data;
@@ -10437,7 +10439,7 @@ void ASTReader::finishPendingActions() {
// have been fully wired up (hasBody relies on this).
// FIXME: We shouldn't require complete redeclaration chains here.
for (PendingBodiesMap::iterator PB = PendingBodies.begin(),
- PBEnd = PendingBodies.end();
+ PBEnd = PendingBodies.end();
PB != PBEnd; ++PB) {
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(PB->first)) {
// FIXME: Check for =delete/=default?
@@ -10445,7 +10447,7 @@ void ASTReader::finishPendingActions() {
if (!getContext().getLangOpts().Modules || !FD->hasBody(Defn)) {
FD->setLazyBody(PB->second);
} else {
- auto *NonConstDefn = const_cast<FunctionDecl*>(Defn);
+ auto *NonConstDefn = const_cast<FunctionDecl *>(Defn);
mergeDefinitionVisibility(NonConstDefn, FD);
if (!FD->isLateTemplateParsed() &&
@@ -10604,7 +10606,7 @@ void ASTReader::diagnoseOdrViolations() {
// replaced by a more recent declaration in the lookup table), and we
// can't necessarily find it in the redeclaration chain because it might
// be merely mergeable, not redeclarable.
- llvm::SmallVector<const NamedDecl*, 4> Candidates;
+ llvm::SmallVector<const NamedDecl *, 4> Candidates;
for (auto *CanonMember : CanonDef->decls()) {
if (CanonMember->getCanonicalDecl() == DCanon) {
// This can happen if the declaration is merely mergeable and not
@@ -10634,17 +10636,18 @@ void ASTReader::diagnoseOdrViolations() {
ODRDiagsEmitter::getOwningModuleNameForDiagnostic(
cast<Decl>(CanonDef));
Diag(D->getLocation(), diag::err_module_odr_violation_missing_decl)
- << D << ODRDiagsEmitter::getOwningModuleNameForDiagnostic(D)
- << CanonDef << CanonDefModule.empty() << CanonDefModule;
+ << D << ODRDiagsEmitter::getOwningModuleNameForDiagnostic(D)
+ << CanonDef << CanonDefModule.empty() << CanonDefModule;
if (Candidates.empty())
Diag(cast<Decl>(CanonDef)->getLocation(),
- diag::note_module_odr_violation_no_possible_decls) << D;
+ diag::note_module_odr_violation_no_possible_decls)
+ << D;
else {
for (unsigned I = 0, N = Candidates.size(); I != N; ++I)
Diag(Candidates[I]->getLocation(),
diag::note_module_odr_violation_possible_decl)
- << Candidates[I];
+ << Candidates[I];
}
DiagnosedOdrMergeFailures.insert(CanonDef);
@@ -10905,8 +10908,7 @@ ASTReader::ASTReader(Preprocessor &PP, InMemoryModuleCache &ModuleCache,
auto BlockName = Ext->getExtensionMetadata().BlockName;
auto Known = ModuleFileExtensions.find(BlockName);
if (Known != ModuleFileExtensions.end()) {
- Diags.Report(diag::warn_duplicate_module_file_extension)
- << BlockName;
+ Diags.Report(diag::warn_duplicate_module_file_extension) << BlockName;
continue;
}
@@ -11414,8 +11416,7 @@ void OMPClauseReader::VisitOMPProcBindClause(OMPProcBindClause *C) {
void OMPClauseReader::VisitOMPScheduleClause(OMPScheduleClause *C) {
VisitOMPClauseWithPreInit(C);
- C->setScheduleKind(
- static_cast<OpenMPScheduleClauseKind>(Record.readInt()));
+ C->setScheduleKind(static_cast<OpenMPScheduleClauseKind>(Record.readInt()));
C->setFirstScheduleModifier(
static_cast<OpenMPScheduleClauseModifier>(Record.readInt()));
C->setSecondScheduleModifier(
@@ -11573,9 +11574,8 @@ void OMPClauseReader::VisitOMPUnifiedSharedMemoryClause(
void OMPClauseReader::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {}
-void
-OMPClauseReader::VisitOMPDynamicAllocatorsClause(OMPDynamicAllocatorsClause *) {
-}
+void OMPClauseReader::VisitOMPDynamicAllocatorsClause(
+ OMPDynamicAllocatorsClause *) {}
void OMPClauseReader::VisitOMPAtomicDefaultMemOrderClause(
OMPAtomicDefaultMemOrderClause *C) {
@@ -11721,6 +11721,12 @@ void OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) {
Vars.push_back(Record.readSubExpr());
C->setInscanCopyArrayElems(Vars);
}
+ unsigned NumFlags = Record.readInt();
+ SmallVector<bool, 16> Flags;
+ Flags.reserve(NumFlags);
+ for (unsigned i = 0; i != NumFlags; ++i)
+ Flags.push_back(Record.readInt());
+ C->setPrivateVariableReductionFlags(Flags);
}
void OMPClauseReader::VisitOMPTaskReductionClause(OMPTaskReductionClause *C) {
@@ -11903,8 +11909,7 @@ void OMPClauseReader::VisitOMPDepobjClause(OMPDepobjClause *C) {
void OMPClauseReader::VisitOMPDependClause(OMPDependClause *C) {
C->setLParenLoc(Record.readSourceLocation());
C->setModifier(Record.readSubExpr());
- C->setDependencyKind(
- static_cast<OpenMPDependClauseKind>(Record.readInt()));
+ C->setDependencyKind(static_cast<OpenMPDependClauseKind>(Record.readInt()));
C->setDependencyLoc(Record.readSourceLocation());
C->setColonLoc(Record.readSourceLocation());
C->setOmpAllMemoryLoc(Record.readSourceLocation());
@@ -11930,16 +11935,15 @@ void OMPClauseReader::VisitOMPMapClause(OMPMapClause *C) {
C->setLParenLoc(Record.readSourceLocation());
bool HasIteratorModifier = false;
for (unsigned I = 0; I < NumberOfOMPMapClauseModifiers; ++I) {
- C->setMapTypeModifier(
- I, static_cast<OpenMPMapModifierKind>(Record.readInt()));
+ C->setMapTypeModifier(I,
+ static_cast<OpenMPMapModifierKind>(Record.readInt()));
C->setMapTypeModifierLoc(I, Record.readSourceLocation());
if (C->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_iterator)
HasIteratorModifier = true;
}
C->setMapperQualifierLoc(Record.readNestedNameSpecifierLoc());
C->setMapperIdInfo(Record.readDeclarationNameInfo());
- C->setMapType(
- static_cast<OpenMPMapClauseKind>(Record.readInt()));
+ C->setMapType(static_cast<OpenMPMapClauseKind>(Record.readInt()));
C->setMapLoc(Record.readSourceLocation());
C->setColonLoc(Record.readSourceLocation());
auto NumVars = C->varlist_size();
@@ -12067,7 +12071,7 @@ void OMPClauseReader::VisitOMPDistScheduleClause(OMPDistScheduleClause *C) {
void OMPClauseReader::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) {
C->setDefaultmapKind(
- static_cast<OpenMPDefaultmapClauseKind>(Record.readInt()));
+ static_cast<OpenMPDefaultmapClauseKind>(Record.readInt()));
C->setDefaultmapModifier(
static_cast<OpenMPDefaultmapClauseModifier>(Record.readInt()));
C->setLParenLoc(Record.readSourceLocation());
@@ -12589,7 +12593,7 @@ OpenACCClause *ASTRecordReader::readOpenACCClause() {
SourceLocation LParenLoc = readSourceLocation();
Expr *IntExpr = readSubExpr();
return OpenACCDeviceNumClause::Create(getContext(), BeginLoc, LParenLoc,
- IntExpr, EndLoc);
+ IntExpr, EndLoc);
}
case OpenACCClauseKind::DefaultAsync: {
SourceLocation LParenLoc = readSourceLocation();
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 79b777cddd0b0..e24e752bfd0b1 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -129,15 +129,14 @@ using namespace clang::serialization;
template <typename T, typename Allocator>
static StringRef bytes(const std::vector<T, Allocator> &v) {
- if (v.empty()) return StringRef();
- return StringRef(reinterpret_cast<const char*>(&v[0]),
- sizeof(T) * v.size());
+ if (v.empty())
+ return StringRef();
+ return StringRef(reinterpret_cast<const char *>(&v[0]), sizeof(T) * v.size());
}
-template <typename T>
-static StringRef bytes(const SmallVectorImpl<T> &v) {
- return StringRef(reinterpret_cast<const char*>(v.data()),
- sizeof(T) * v.size());
+template <typename T> static StringRef bytes(const SmallVectorImpl<T> &v) {
+ return StringRef(reinterpret_cast<const char *>(v.data()),
+ sizeof(T) * v.size());
}
static std::string bytes(const std::vector<bool> &V) {
@@ -158,8 +157,9 @@ static std::string bytes(const std::vector<bool> &V) {
static TypeCode getTypeCodeForTypeClass(Type::TypeClass id) {
switch (id) {
-#define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \
- case Type::CLASS_ID: return TYPE_##CODE_ID;
+#define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \
+ case Type::CLASS_ID: \
+ return TYPE_##CODE_ID;
#include "clang/Serialization/TypeBitCodes.def"
case Type::Builtin:
llvm_unreachable("shouldn't be serializing a builtin type this way");
@@ -350,8 +350,7 @@ class TypeLocWriter : public TypeLocVisitor<TypeLocWriter> {
: Record(Record), Seq(Seq) {}
#define ABSTRACT_TYPELOC(CLASS, PARENT)
-#define TYPELOC(CLASS, PARENT) \
- void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
+#define TYPELOC(CLASS, PARENT) void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
#include "clang/AST/TypeLocNodes.def"
void VisitArrayTypeLoc(ArrayTypeLoc TyLoc);
@@ -432,7 +431,7 @@ void TypeLocWriter::VisitVariableArrayTypeLoc(VariableArrayTypeLoc TL) {
}
void TypeLocWriter::VisitDependentSizedArrayTypeLoc(
- DependentSizedArrayTypeLoc TL) {
+ DependentSizedArrayTypeLoc TL) {
VisitArrayTypeLoc(TL);
}
@@ -446,7 +445,7 @@ void TypeLocWriter::VisitDependentAddressSpaceTypeLoc(
}
void TypeLocWriter::VisitDependentSizedExtVectorTypeLoc(
- DependentSizedExtVectorTypeLoc TL) {
+ DependentSizedExtVectorTypeLoc TL) {
addSourceLocation(TL.getNameLoc());
}
@@ -454,8 +453,7 @@ void TypeLocWriter::VisitVectorTypeLoc(VectorTypeLoc TL) {
addSourceLocation(TL.getNameLoc());
}
-void TypeLocWriter::VisitDependentVectorTypeLoc(
- DependentVectorTypeLoc TL) {
+void TypeLocWriter::VisitDependentVectorTypeLoc(DependentVectorTypeLoc TL) {
addSourceLocation(TL.getNameLoc());
}
@@ -608,17 +606,17 @@ void TypeLocWriter::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
}
void TypeLocWriter::VisitSubstTemplateTypeParmTypeLoc(
- SubstTemplateTypeParmTypeLoc TL) {
+ SubstTemplateTypeParmTypeLoc TL) {
addSourceLocation(TL.getNameLoc());
}
void TypeLocWriter::VisitSubstTemplateTypeParmPackTypeLoc(
- SubstTemplateTypeParmPackTypeLoc TL) {
+ SubstTemplateTypeParmPackTypeLoc TL) {
addSourceLocation(TL.getNameLoc());
}
void TypeLocWriter::VisitTemplateSpecializationTypeLoc(
- TemplateSpecializationTypeLoc TL) {
+ TemplateSpecializationTypeLoc TL) {
addSourceLocation(TL.getTemplateKeywordLoc());
addSourceLocation(TL.getTemplateNameLoc());
addSourceLocation(TL.getLAngleLoc());
@@ -653,7 +651,7 @@ void TypeLocWriter::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
}
void TypeLocWriter::VisitDependentTemplateSpecializationTypeLoc(
- DependentTemplateSpecializationTypeLoc TL) {
+ DependentTemplateSpecializationTypeLoc TL) {
addSourceLocation(TL.getElaboratedKeywordLoc());
Record.AddNestedNameSpecifierLoc(TL.getQualifierLoc());
addSourceLocation(TL.getTemplateKeywordLoc());
@@ -716,8 +714,8 @@ void ASTWriter::WriteTypeAbbrevs() {
// Abbreviation for TYPE_EXT_QUAL
Abv = std::make_shared<BitCodeAbbrev>();
Abv->Add(BitCodeAbbrevOp(serialization::TYPE_EXT_QUAL));
- Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
- Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 3)); // Quals
+ Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
+ Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 3)); // Quals
TypeExtQualAbbrev = Stream.EmitAbbrev(std::move(Abv));
}
@@ -889,7 +887,7 @@ void ASTWriter::WriteBlockInfoBlock() {
RecordData Record;
Stream.EnterBlockInfoBlock();
-#define BLOCK(X) EmitBlockID(X ## _ID, #X, Stream, Record)
+#define BLOCK(X) EmitBlockID(X##_ID, #X, Stream, Record)
#define RECORD(X) EmitRecordID(X, #X, Stream, Record)
// Control Block.
@@ -1182,8 +1180,8 @@ static bool cleanPathForOutput(FileManager &FileMgr,
///
/// \returns either the original filename (if it needs no adjustment) or the
/// adjusted filename (which points into the @p Filename parameter).
-static const char *
-adjustFilenameForRelocatableAST(const char *Filename, StringRef BaseDir) {
+static const char *adjustFilenameForRelocatableAST(const char *Filename,
+ StringRef BaseDir) {
assert(Filename && "No file name to adjust?");
if (BaseDir.empty())
@@ -1457,9 +1455,12 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
MetadataAbbrev->Add(BitCodeAbbrevOp(METADATA));
MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Major
MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Minor
- MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Clang maj.
- MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Clang min.
- MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Relocatable
+ MetadataAbbrev->Add(
+ BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Clang maj.
+ MetadataAbbrev->Add(
+ BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Clang min.
+ MetadataAbbrev->Add(
+ BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Relocatable
// Standard C++ module
MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Timestamps
@@ -1562,13 +1563,13 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
auto Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(IMPORT));
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Kind
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ImportLoc
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Module name len
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ImportLoc
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Module name len
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Standard C++ mod
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File size
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File timestamp
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File name len
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Strings
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File size
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File timestamp
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File name len
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Strings
unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
SmallString<128> Blob;
@@ -1614,9 +1615,9 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
// Language options.
Record.clear();
const LangOptions &LangOpts = PP.getLangOpts();
-#define LANGOPT(Name, Bits, Default, Description) \
+#define LANGOPT(Name, Bits, Default, Description) \
Record.push_back(LangOpts.Name);
-#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
+#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
Record.push_back(static_cast<unsigned>(LangOpts.get##Name()));
#include "clang/Basic/LangOptions.def"
#define SANITIZER(NAME, ID) \
@@ -1627,7 +1628,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
for (StringRef Feature : LangOpts.ModuleFeatures)
AddString(Feature, Record);
- Record.push_back((unsigned) LangOpts.ObjCRuntime.getKind());
+ Record.push_back((unsigned)LangOpts.ObjCRuntime.getKind());
AddVersionTuple(LangOpts.ObjCRuntime.getVersion(), Record);
AddString(LangOpts.CurrentModule, Record);
@@ -1738,7 +1739,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
FileAbbrev->Add(BitCodeAbbrevOp(ORIGINAL_FILE));
FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File ID
- FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // File name
+ FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // File name
unsigned FileAbbrevCode = Stream.EmitAbbrev(std::move(FileAbbrev));
Record.clear();
@@ -1755,7 +1756,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
Stream.ExitBlock();
}
-namespace {
+namespace {
/// An input file.
struct InputFileEntry {
@@ -1793,14 +1794,14 @@ void ASTWriter::WriteInputFiles(SourceManager &SourceMgr,
// Create input-file abbreviation.
auto IFAbbrev = std::make_shared<BitCodeAbbrev>();
IFAbbrev->Add(BitCodeAbbrevOp(INPUT_FILE));
- IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ID
+ IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ID
IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 12)); // Size
IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32)); // Modification time
IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Overridden
IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Transient
IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Top-level
IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Module map
- IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16)); // Name as req. len
+ IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16)); // Name as req. len
IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Name as req. + name
unsigned IFAbbrevCode = Stream.EmitAbbrev(std::move(IFAbbrev));
@@ -1945,15 +1946,15 @@ static unsigned CreateSLocFileAbbrev(llvm::BitstreamWriter &Stream) {
auto Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(SM_SLOC_FILE_ENTRY));
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Offset
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Include location
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Offset
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Include location
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Characteristic
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Line directives
// FileEntry fields.
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Input File ID
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // NumCreatedFIDs
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Input File ID
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // NumCreatedFIDs
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 24)); // FirstDeclIndex
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // NumDecls
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // NumDecls
return Stream.EmitAbbrev(std::move(Abbrev));
}
@@ -1964,11 +1965,11 @@ static unsigned CreateSLocBufferAbbrev(llvm::BitstreamWriter &Stream) {
auto Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(SM_SLOC_BUFFER_ENTRY));
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Offset
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Include location
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Offset
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Include location
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Characteristic
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Line directives
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Buffer name blob
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Buffer name blob
return Stream.EmitAbbrev(std::move(Abbrev));
}
@@ -1983,7 +1984,7 @@ static unsigned CreateSLocBufferBlobAbbrev(llvm::BitstreamWriter &Stream,
: SM_SLOC_BUFFER_BLOB));
if (Compressed)
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Uncompressed size
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Blob
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Blob
return Stream.EmitAbbrev(std::move(Abbrev));
}
@@ -1994,12 +1995,12 @@ static unsigned CreateSLocExpansionAbbrev(llvm::BitstreamWriter &Stream) {
auto Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(SM_SLOC_EXPANSION_ENTRY));
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Offset
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Spelling location
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Start location
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // End location
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Offset
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Spelling location
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Start location
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // End location
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Is token range
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Token length
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Token length
return Stream.EmitAbbrev(std::move(Abbrev));
}
@@ -2014,109 +2015,110 @@ emitULEBKeyDataLength(unsigned KeyLen, unsigned DataLen, raw_ostream &Out) {
namespace {
- // Trait used for the on-disk hash table of header search information.
- class HeaderFileInfoTrait {
- ASTWriter &Writer;
+// Trait used for the on-disk hash table of header search information.
+class HeaderFileInfoTrait {
+ ASTWriter &Writer;
- public:
- HeaderFileInfoTrait(ASTWriter &Writer) : Writer(Writer) {}
+public:
+ HeaderFileInfoTrait(ASTWriter &Writer) : Writer(Writer) {}
- struct key_type {
- StringRef Filename;
- off_t Size;
- time_t ModTime;
- };
- using key_type_ref = const key_type &;
-
- using UnresolvedModule =
- llvm::PointerIntPair<Module *, 2, ModuleMap::ModuleHeaderRole>;
-
- struct data_type {
- data_type(const HeaderFileInfo &HFI, bool AlreadyIncluded,
- ArrayRef<ModuleMap::KnownHeader> KnownHeaders,
- UnresolvedModule Unresolved)
- : HFI(HFI), AlreadyIncluded(AlreadyIncluded),
- KnownHeaders(KnownHeaders), Unresolved(Unresolved) {}
-
- HeaderFileInfo HFI;
- bool AlreadyIncluded;
- SmallVector<ModuleMap::KnownHeader, 1> KnownHeaders;
- UnresolvedModule Unresolved;
- };
- using data_type_ref = const data_type &;
-
- using hash_value_type = unsigned;
- using offset_type = unsigned;
-
- hash_value_type ComputeHash(key_type_ref key) {
- // The hash is based only on size/time of the file, so that the reader can
- // match even when symlinking or excess path elements ("foo/../", "../")
- // change the form of the name. However, complete path is still the key.
- uint8_t buf[sizeof(key.Size) + sizeof(key.ModTime)];
- memcpy(buf, &key.Size, sizeof(key.Size));
- memcpy(buf + sizeof(key.Size), &key.ModTime, sizeof(key.ModTime));
- return llvm::xxh3_64bits(buf);
- }
+ struct key_type {
+ StringRef Filename;
+ off_t Size;
+ time_t ModTime;
+ };
+ using key_type_ref = const key_type &;
+
+ using UnresolvedModule =
+ llvm::PointerIntPair<Module *, 2, ModuleMap::ModuleHeaderRole>;
+
+ struct data_type {
+ data_type(const HeaderFileInfo &HFI, bool AlreadyIncluded,
+ ArrayRef<ModuleMap::KnownHeader> KnownHeaders,
+ UnresolvedModule Unresolved)
+ : HFI(HFI), AlreadyIncluded(AlreadyIncluded),
+ KnownHeaders(KnownHeaders), Unresolved(Unresolved) {}
+
+ HeaderFileInfo HFI;
+ bool AlreadyIncluded;
+ SmallVector<ModuleMap::KnownHeader, 1> KnownHeaders;
+ UnresolvedModule Unresolved;
+ };
+ using data_type_ref = const data_type &;
+
+ using hash_value_type = unsigned;
+ using offset_type = unsigned;
+
+ hash_value_type ComputeHash(key_type_ref key) {
+ // The hash is based only on size/time of the file, so that the reader can
+ // match even when symlinking or excess path elements ("foo/../", "../")
+ // change the form of the name. However, complete path is still the key.
+ uint8_t buf[sizeof(key.Size) + sizeof(key.ModTime)];
+ memcpy(buf, &key.Size, sizeof(key.Size));
+ memcpy(buf + sizeof(key.Size), &key.ModTime, sizeof(key.ModTime));
+ return llvm::xxh3_64bits(buf);
+ }
- std::pair<unsigned, unsigned>
- EmitKeyDataLength(raw_ostream& Out, key_type_ref key, data_type_ref Data) {
- unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
- unsigned DataLen = 1 + sizeof(IdentifierID);
- for (auto ModInfo : Data.KnownHeaders)
- if (Writer.getLocalOrImportedSubmoduleID(ModInfo.getModule()))
- DataLen += 4;
- if (Data.Unresolved.getPointer())
+ std::pair<unsigned, unsigned>
+ EmitKeyDataLength(raw_ostream &Out, key_type_ref key, data_type_ref Data) {
+ unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
+ unsigned DataLen = 1 + sizeof(IdentifierID);
+ for (auto ModInfo : Data.KnownHeaders)
+ if (Writer.getLocalOrImportedSubmoduleID(ModInfo.getModule()))
DataLen += 4;
- return emitULEBKeyDataLength(KeyLen, DataLen, Out);
- }
+ if (Data.Unresolved.getPointer())
+ DataLen += 4;
+ return emitULEBKeyDataLength(KeyLen, DataLen, Out);
+ }
- void EmitKey(raw_ostream& Out, key_type_ref key, unsigned KeyLen) {
- using namespace llvm::support;
+ void EmitKey(raw_ostream &Out, key_type_ref key, unsigned KeyLen) {
+ using namespace llvm::support;
- endian::Writer LE(Out, llvm::endianness::little);
- LE.write<uint64_t>(key.Size);
- KeyLen -= 8;
- LE.write<uint64_t>(key.ModTime);
- KeyLen -= 8;
- Out.write(key.Filename.data(), KeyLen);
- }
+ endian::Writer LE(Out, llvm::endianness::little);
+ LE.write<uint64_t>(key.Size);
+ KeyLen -= 8;
+ LE.write<uint64_t>(key.ModTime);
+ KeyLen -= 8;
+ Out.write(key.Filename.data(), KeyLen);
+ }
- void EmitData(raw_ostream &Out, key_type_ref key,
- data_type_ref Data, unsigned DataLen) {
- using namespace llvm::support;
+ void EmitData(raw_ostream &Out, key_type_ref key, data_type_ref Data,
+ unsigned DataLen) {
+ using namespace llvm::support;
- endian::Writer LE(Out, llvm::endianness::little);
- uint64_t Start = Out.tell(); (void)Start;
+ endian::Writer LE(Out, llvm::endianness::little);
+ uint64_t Start = Out.tell();
+ (void)Start;
- unsigned char Flags = (Data.AlreadyIncluded << 6)
- | (Data.HFI.isImport << 5)
- | (Writer.isWritingStdCXXNamedModules() ? 0 :
- Data.HFI.isPragmaOnce << 4)
- | (Data.HFI.DirInfo << 1);
- LE.write<uint8_t>(Flags);
+ unsigned char Flags =
+ (Data.AlreadyIncluded << 6) | (Data.HFI.isImport << 5) |
+ (Writer.isWritingStdCXXNamedModules() ? 0
+ : Data.HFI.isPragmaOnce << 4) |
+ (Data.HFI.DirInfo << 1);
+ LE.write<uint8_t>(Flags);
- if (Data.HFI.LazyControllingMacro.isID())
- LE.write<IdentifierID>(Data.HFI.LazyControllingMacro.getID());
- else
- LE.write<IdentifierID>(
- Writer.getIdentifierRef(Data.HFI.LazyControllingMacro.getPtr()));
-
- auto EmitModule = [&](Module *M, ModuleMap::ModuleHeaderRole Role) {
- if (uint32_t ModID = Writer.getLocalOrImportedSubmoduleID(M)) {
- uint32_t Value = (ModID << 3) | (unsigned)Role;
- assert((Value >> 3) == ModID && "overflow in header module info");
- LE.write<uint32_t>(Value);
- }
- };
+ if (Data.HFI.LazyControllingMacro.isID())
+ LE.write<IdentifierID>(Data.HFI.LazyControllingMacro.getID());
+ else
+ LE.write<IdentifierID>(
+ Writer.getIdentifierRef(Data.HFI.LazyControllingMacro.getPtr()));
+
+ auto EmitModule = [&](Module *M, ModuleMap::ModuleHeaderRole Role) {
+ if (uint32_t ModID = Writer.getLocalOrImportedSubmoduleID(M)) {
+ uint32_t Value = (ModID << 3) | (unsigned)Role;
+ assert((Value >> 3) == ModID && "overflow in header module info");
+ LE.write<uint32_t>(Value);
+ }
+ };
- for (auto ModInfo : Data.KnownHeaders)
- EmitModule(ModInfo.getModule(), ModInfo.getRole());
- if (Data.Unresolved.getPointer())
- EmitModule(Data.Unresolved.getPointer(), Data.Unresolved.getInt());
+ for (auto ModInfo : Data.KnownHeaders)
+ EmitModule(ModInfo.getModule(), ModInfo.getRole());
+ if (Data.Unresolved.getPointer())
+ EmitModule(Data.Unresolved.getPointer(), Data.Unresolved.getInt());
- assert(Out.tell() - Start == DataLen && "Wrong data length");
- }
- };
+ assert(Out.tell() - Start == DataLen && "Wrong data length");
+ }
+};
} // namespace
@@ -2214,12 +2216,13 @@ void ASTWriter::WriteHeaderSearch(const HeaderSearch &HS) {
bool Included = HFI->IsLocallyIncluded || PP->alreadyIncluded(*File);
- HeaderFileInfoTrait::key_type Key = {
- Filename, File->getSize(), getTimestampForOutput(*File)
- };
+ HeaderFileInfoTrait::key_type Key = {Filename, File->getSize(),
+ getTimestampForOutput(*File)};
HeaderFileInfoTrait::data_type Data = {
- *HFI, Included, HS.getModuleMap().findResolvedModulesForHeader(*File), {}
- };
+ *HFI,
+ Included,
+ HS.getModuleMap().findResolvedModulesForHeader(*File),
+ {}};
Generator.insert(Key, Data, GeneratorTrait);
++NumHeaderSearchEntries;
}
@@ -2314,8 +2317,7 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr) {
std::vector<uint32_t> SLocEntryOffsets;
uint64_t SLocEntryOffsetsBase = Stream.GetCurrentBitNo();
SLocEntryOffsets.reserve(SourceMgr.local_sloc_entry_size() - 1);
- for (unsigned I = 1, N = SourceMgr.local_sloc_entry_size();
- I != N; ++I) {
+ for (unsigned I = 1, N = SourceMgr.local_sloc_entry_size(); I != N; ++I) {
// Get this source location entry.
const SrcMgr::SLocEntry *SLoc = &SourceMgr.getLocalSLocEntry(I);
FileID FID = FileID::get(I);
@@ -2439,7 +2441,7 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr) {
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16)); // # of slocs
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16)); // total size
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32)); // base offset
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // offsets
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // offsets
unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
{
RecordData::value_type Record[] = {
@@ -2464,8 +2466,9 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr) {
if (L.first.ID < 0)
continue;
for (auto &LE : L.second) {
- if (FilenameMap.insert(std::make_pair(LE.FilenameID,
- FilenameMap.size() - 1)).second)
+ if (FilenameMap
+ .insert(std::make_pair(LE.FilenameID, FilenameMap.size() - 1))
+ .second)
AddPath(LineTable.getFilename(LE.FilenameID), Record);
}
}
@@ -2593,7 +2596,7 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
for (auto &Id : PP.getIdentifierTable())
if (Id.second->hadMacroDefinition() &&
(!Id.second->isFromAST() ||
- Id.second->hasChangedSinceDeserialization()))
+ Id.second->hasChangedSinceDeserialization()))
MacroIdentifiers.push_back(Id.second);
// Sort the set of macro definitions that need to be serialized by the
// name of the macro, to provide a stable ordering.
@@ -2791,20 +2794,20 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec,
auto Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(PPD_INCLUSION_DIRECTIVE));
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // filename length
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // in quotes
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // kind
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // imported module
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // in quotes
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // kind
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // imported module
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
InclusionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
}
- unsigned FirstPreprocessorEntityID
- = (Chain ? PPRec.getNumLoadedPreprocessedEntities() : 0)
- + NUM_PREDEF_PP_ENTITY_IDS;
+ unsigned FirstPreprocessorEntityID =
+ (Chain ? PPRec.getNumLoadedPreprocessedEntities() : 0) +
+ NUM_PREDEF_PP_ENTITY_IDS;
unsigned NextPreprocessorEntityID = FirstPreprocessorEntityID;
RecordData Record;
for (PreprocessingRecord::iterator E = PPRec.local_begin(),
- EEnd = PPRec.local_end();
+ EEnd = PPRec.local_end();
E != EEnd;
(void)++E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) {
Record.clear();
@@ -2880,7 +2883,7 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec,
if (SkippedRanges.size() > 0) {
std::vector<PPSkippedRange> SerializedSkippedRanges;
SerializedSkippedRanges.reserve(SkippedRanges.size());
- for (auto const& Range : SkippedRanges)
+ for (auto const &Range : SkippedRanges)
SerializedSkippedRanges.emplace_back(
getRawSourceLocationEncoding(Range.getBegin()),
getRawSourceLocationEncoding(Range.getEnd()));
@@ -2937,15 +2940,15 @@ static unsigned getNumberOfModules(Module *Mod) {
void ASTWriter::WriteSubmodules(Module *WritingModule, ASTContext *Context) {
// Enter the submodule description block.
- Stream.EnterSubblock(SUBMODULE_BLOCK_ID, /*bits for abbreviations*/5);
+ Stream.EnterSubblock(SUBMODULE_BLOCK_ID, /*bits for abbreviations*/ 5);
// Write the abbreviations needed for the submodules block.
using namespace llvm;
auto Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(SUBMODULE_DEFINITION));
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ID
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Parent
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ID
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Parent
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // Kind
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Definition location
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // Inferred allowed by
@@ -2959,7 +2962,7 @@ void ASTWriter::WriteSubmodules(Module *WritingModule, ASTContext *Context) {
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ConfigMacrosExh...
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ModuleMapIsPriv...
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // NamedModuleHasN...
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Name
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Name
unsigned DefinitionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
Abbrev = std::make_shared<BitCodeAbbrev>();
@@ -3016,24 +3019,24 @@ void ASTWriter::WriteSubmodules(Module *WritingModule, ASTContext *Context) {
Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(SUBMODULE_CONFIG_MACRO));
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Macro name
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Macro name
unsigned ConfigMacroAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(SUBMODULE_CONFLICT));
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Other module
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Message
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Other module
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Message
unsigned ConflictAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(SUBMODULE_EXPORT_AS));
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Macro name
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Macro name
unsigned ExportAsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
// Write the submodule metadata block.
- RecordData::value_type Record[] = {
- getNumberOfModules(WritingModule),
- FirstSubmoduleID - NUM_PREDEF_SUBMODULE_IDS};
+ RecordData::value_type Record[] = {getNumberOfModules(WritingModule),
+ FirstSubmoduleID -
+ NUM_PREDEF_SUBMODULE_IDS};
Stream.EmitRecord(SUBMODULE_METADATA, Record);
// Write all of the submodules.
@@ -3105,13 +3108,12 @@ void ASTWriter::WriteSubmodules(Module *WritingModule, ASTContext *Context) {
unsigned Abbrev;
Module::HeaderKind HeaderKind;
} HeaderLists[] = {
- {SUBMODULE_HEADER, HeaderAbbrev, Module::HK_Normal},
- {SUBMODULE_TEXTUAL_HEADER, TextualHeaderAbbrev, Module::HK_Textual},
- {SUBMODULE_PRIVATE_HEADER, PrivateHeaderAbbrev, Module::HK_Private},
- {SUBMODULE_PRIVATE_TEXTUAL_HEADER, PrivateTextualHeaderAbbrev,
- Module::HK_PrivateTextual},
- {SUBMODULE_EXCLUDED_HEADER, ExcludedHeaderAbbrev, Module::HK_Excluded}
- };
+ {SUBMODULE_HEADER, HeaderAbbrev, Module::HK_Normal},
+ {SUBMODULE_TEXTUAL_HEADER, TextualHeaderAbbrev, Module::HK_Textual},
+ {SUBMODULE_PRIVATE_HEADER, PrivateHeaderAbbrev, Module::HK_Private},
+ {SUBMODULE_PRIVATE_TEXTUAL_HEADER, PrivateTextualHeaderAbbrev,
+ Module::HK_PrivateTextual},
+ {SUBMODULE_EXCLUDED_HEADER, ExcludedHeaderAbbrev, Module::HK_Excluded}};
for (const auto &HL : HeaderLists) {
RecordData::value_type Record[] = {HL.RecordKind};
for (const auto &H : Mod->getHeaders(HL.HeaderKind))
@@ -3156,9 +3158,9 @@ void ASTWriter::WriteSubmodules(Module *WritingModule, ASTContext *Context) {
Stream.EmitRecord(SUBMODULE_EXPORTS, Record);
}
- //FIXME: How do we emit the 'use'd modules? They may not be submodules.
- // Might be unnecessary as use declarations are only used to build the
- // module itself.
+ // FIXME: How do we emit the 'use'd modules? They may not be submodules.
+ // Might be unnecessary as use declarations are only used to build the
+ // module itself.
// TODO: Consider serializing undeclared uses of modules.
@@ -3411,7 +3413,7 @@ void ASTWriter::WriteTypeDeclOffsets() {
auto Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(TYPE_OFFSET));
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // # of types
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // types block
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // types block
unsigned TypeOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
{
RecordData::value_type Record[] = {TYPE_OFFSET, TypeOffsets.size()};
@@ -3515,8 +3517,7 @@ class ASTMethodPoolTrait {
}
std::pair<unsigned, unsigned>
- EmitKeyDataLength(raw_ostream& Out, Selector Sel,
- data_type_ref Methods) {
+ EmitKeyDataLength(raw_ostream &Out, Selector Sel, data_type_ref Methods) {
unsigned KeyLen =
2 + (Sel.getNumArgs() ? Sel.getNumArgs() * sizeof(IdentifierID)
: sizeof(IdentifierID));
@@ -3532,7 +3533,7 @@ class ASTMethodPoolTrait {
return emitULEBKeyDataLength(KeyLen, DataLen, Out);
}
- void EmitKey(raw_ostream& Out, Selector Sel, unsigned) {
+ void EmitKey(raw_ostream &Out, Selector Sel, unsigned) {
using namespace llvm::support;
endian::Writer LE(Out, llvm::endianness::little);
@@ -3548,12 +3549,13 @@ class ASTMethodPoolTrait {
Writer.getIdentifierRef(Sel.getIdentifierInfoForSlot(I)));
}
- void EmitData(raw_ostream& Out, key_type_ref,
- data_type_ref Methods, unsigned DataLen) {
+ void EmitData(raw_ostream &Out, key_type_ref, data_type_ref Methods,
+ unsigned DataLen) {
using namespace llvm::support;
endian::Writer LE(Out, llvm::endianness::little);
- uint64_t Start = Out.tell(); (void)Start;
+ uint64_t Start = Out.tell();
+ (void)Start;
LE.write<uint32_t>(Methods.ID);
unsigned NumInstanceMethods = 0;
for (const ObjCMethodList *Method = &Methods.Instance; Method;
@@ -3628,11 +3630,8 @@ void ASTWriter::WriteSelectors(Sema &SemaRef) {
SelectorID ID = SelectorAndID.second;
SemaObjC::GlobalMethodPool::iterator F =
SemaRef.ObjC().MethodPool.find(S);
- ASTMethodPoolTrait::data_type Data = {
- ID,
- ObjCMethodList(),
- ObjCMethodList()
- };
+ ASTMethodPoolTrait::data_type Data = {ID, ObjCMethodList(),
+ ObjCMethodList()};
if (F != SemaRef.ObjC().MethodPool.end()) {
Data.Instance = F->second.first;
Data.Factory = F->second.second;
@@ -3841,7 +3840,7 @@ class ASTIdentifierTableTrait {
bool needDecls() const { return NeedDecls; }
- static hash_value_type ComputeHash(const IdentifierInfo* II) {
+ static hash_value_type ComputeHash(const IdentifierInfo *II) {
return llvm::djbHash(II->getName());
}
@@ -3850,8 +3849,9 @@ class ASTIdentifierTableTrait {
return isInterestingIdentifier(II, MacroOffset);
}
- std::pair<unsigned, unsigned>
- EmitKeyDataLength(raw_ostream &Out, const IdentifierInfo *II, IdentifierID ID) {
+ std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
+ const IdentifierInfo *II,
+ IdentifierID ID) {
// Record the location of the identifier data. This is used when generating
// the mapping from persistent IDs to strings.
Writer.SetIdentifierOffset(II, Out.tell());
@@ -4053,7 +4053,8 @@ class ASTDeclContextNameLookupTraitBase {
return std::make_pair(Start, DeclIDs.size());
}
- data_type ImportData(const reader::ASTDeclContextNameLookupTrait::data_type &FromReader) {
+ data_type ImportData(
+ const reader::ASTDeclContextNameLookupTrait::data_type &FromReader) {
unsigned Start = DeclIDs.size();
DeclIDs.insert(
DeclIDs.end(),
@@ -4138,7 +4139,8 @@ class ASTDeclContextNameLookupTraitBase {
using namespace llvm::support;
endian::Writer LE(Out, llvm::endianness::little);
- uint64_t Start = Out.tell(); (void)Start;
+ uint64_t Start = Out.tell();
+ (void)Start;
for (unsigned I = Lookup.first, N = Lookup.second; I != N; ++I)
LE.write<DeclID>((DeclID)DeclIDs[I]);
assert(Out.tell() - Start == DataLen && "Data length is wrong");
@@ -4535,7 +4537,7 @@ void ASTWriter::GenerateNameLookupTable(
"must call buildLookups first");
// FIXME: We need to build the lookups table, which is logically const.
- auto *DC = const_cast<DeclContext*>(ConstDC);
+ auto *DC = const_cast<DeclContext *>(ConstDC);
assert(DC == DC->getPrimaryContext() && "only primary DC has lookup table");
// Create the on-disk hash table representation.
@@ -4946,7 +4948,7 @@ void ASTWriter::WriteOpenCLExtensions(Sema &SemaRef) {
const OpenCLOptions &Opts = SemaRef.getOpenCLOptions();
RecordData Record;
- for (const auto &I:Opts.OptMap) {
+ for (const auto &I : Opts.OptMap) {
AddString(I.getKey(), Record);
auto V = I.getValue();
Record.push_back(V.Supported ? 1 : 0);
@@ -4980,8 +4982,8 @@ void ASTWriter::WriteObjCCategories() {
// Add the categories.
for (ObjCInterfaceDecl::known_categories_iterator
- Cat = Class->known_categories_begin(),
- CatEnd = Class->known_categories_end();
+ Cat = Class->known_categories_begin(),
+ CatEnd = Class->known_categories_end();
Cat != CatEnd; ++Cat, ++Size) {
assert(getDeclID(*Cat).isValid() && "Bogus category");
AddDeclRef(*Cat, Categories);
@@ -4991,7 +4993,7 @@ void ASTWriter::WriteObjCCategories() {
Categories[StartIndex] = Size;
// Record this interface -> category map.
- ObjCCategoriesInfo CatInfo = { getDeclID(Class), StartIndex };
+ ObjCCategoriesInfo CatInfo = {getDeclID(Class), StartIndex};
CategoriesMap.push_back(CatInfo);
}
@@ -5055,7 +5057,7 @@ void ASTWriter::WriteMSStructPragmaOptions(Sema &SemaRef) {
}
/// Write the state of 'pragma pointers_to_members' at the end of the
-//module.
+// module.
void ASTWriter::WriteMSPointersToMembersPragmaOptions(Sema &SemaRef) {
RecordData Record;
Record.push_back(SemaRef.MSPointerToMemberRepresentationMethod);
@@ -5158,8 +5160,8 @@ void ASTRecordWriter::AddAttr(const Attr *A) {
// FIXME: Clang can't handle the serialization/deserialization of
// preferred_name properly now. See
// https://github.com/llvm/llvm-project/issues/56490 for example.
- if (!A || (isa<PreferredNameAttr>(A) &&
- Writer->isWritingStdCXXNamedModules()))
+ if (!A ||
+ (isa<PreferredNameAttr>(A) && Writer->isWritingStdCXXNamedModules()))
return Record.push_back(0);
Record.push_back(A->getKind() + 1); // FIXME: stable encoding, target attrs
@@ -5395,7 +5397,7 @@ ASTWriter::WriteAST(llvm::PointerUnion<Sema *, Preprocessor *> Subject,
return Signature;
}
-template<typename Vector>
+template <typename Vector>
static void AddLazyVectorDecls(ASTWriter &Writer, Vector &Vec) {
for (typename Vector::iterator I = Vec.begin(nullptr, true), E = Vec.end();
I != E; ++I) {
@@ -5514,7 +5516,7 @@ void ASTWriter::PrepareWritingSpecialDecls(Sema &SemaRef) {
bool isModule = WritingModule != nullptr;
// Set up predefined declaration IDs.
- auto RegisterPredefDecl = [&] (Decl *D, PredefinedDeclIDs ID) {
+ auto RegisterPredefDecl = [&](Decl *D, PredefinedDeclIDs ID) {
if (D) {
assert(D->isCanonicalDecl() && "predefined decl is not canonical");
DeclIDs[D] = ID;
@@ -5536,8 +5538,7 @@ void ASTWriter::PrepareWritingSpecialDecls(Sema &SemaRef) {
RegisterPredefDecl(Context.VaListTagDecl, PREDEF_DECL_VA_LIST_TAG);
RegisterPredefDecl(Context.BuiltinMSVaListDecl,
PREDEF_DECL_BUILTIN_MS_VA_LIST_ID);
- RegisterPredefDecl(Context.MSGuidTagDecl,
- PREDEF_DECL_BUILTIN_MS_GUID_ID);
+ RegisterPredefDecl(Context.MSGuidTagDecl, PREDEF_DECL_BUILTIN_MS_GUID_ID);
RegisterPredefDecl(Context.ExternCContext, PREDEF_DECL_EXTERN_C_CONTEXT_ID);
RegisterPredefDecl(Context.MakeIntegerSeqDecl,
PREDEF_DECL_MAKE_INTEGER_SEQ_ID);
@@ -5659,7 +5660,7 @@ void ASTWriter::PrepareWritingSpecialDecls(Sema &SemaRef) {
// Make sure all decls associated with an identifier are registered for
// serialization, if we're storing decls with identifiers.
if (!WritingModule || !getLangOpts().CPlusPlus) {
- llvm::SmallVector<const IdentifierInfo*, 256> IIs;
+ llvm::SmallVector<const IdentifierInfo *, 256> IIs;
for (const auto &ID : SemaRef.PP.getIdentifierTable()) {
const IdentifierInfo *II = ID.second;
if (!Chain || !II->isFromAST() || II->hasChangedSinceDeserialization())
@@ -5776,7 +5777,7 @@ void ASTWriter::WriteSpecialDeclRecords(Sema &SemaRef) {
AddDeclRef(D, DeclsToCheckForDeferredDiags);
if (!DeclsToCheckForDeferredDiags.empty())
Stream.EmitRecord(DECLS_TO_CHECK_FOR_DEFERRED_DIAGS,
- DeclsToCheckForDeferredDiags);
+ DeclsToCheckForDeferredDiags);
// Write the record containing CUDA-specific declaration references.
RecordData CUDASpecialDeclRefs;
@@ -6002,7 +6003,8 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema *SemaPtr, StringRef isysroot,
uint32_t None = std::numeric_limits<uint32_t>::max();
auto writeBaseIDOrNone = [&](auto BaseID, bool ShouldWrite) {
- assert(BaseID < std::numeric_limits<uint32_t>::max() && "base id too high");
+ assert(BaseID < std::numeric_limits<uint32_t>::max() &&
+ "base id too high");
if (ShouldWrite)
LE.write<uint32_t>(BaseID);
else
@@ -6019,8 +6021,8 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema *SemaPtr, StringRef isysroot,
}
}
RecordData::value_type Record[] = {MODULE_OFFSET_MAP};
- Stream.EmitRecordWithBlob(ModuleOffsetMapAbbrev, Record,
- Buffer.data(), Buffer.size());
+ Stream.EmitRecordWithBlob(ModuleOffsetMapAbbrev, Record, Buffer.data(),
+ Buffer.size());
}
if (SemaPtr)
@@ -6055,8 +6057,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema *SemaPtr, StringRef isysroot,
// Write the record containing weak undeclared identifiers.
if (!WeakUndeclaredIdentifiers.empty())
- Stream.EmitRecord(WEAK_UNDECLARED_IDENTIFIERS,
- WeakUndeclaredIdentifiers);
+ Stream.EmitRecord(WEAK_UNDECLARED_IDENTIFIERS, WeakUndeclaredIdentifiers);
if (!WritingModule) {
// Write the submodules that were imported, if any.
@@ -6424,7 +6425,7 @@ void ASTWriter::WriteDeclUpdatesBlocks(ASTContext &Context,
// specialization. If so, record which one.
auto From = Spec->getInstantiatedFrom();
if (auto PartialSpec =
- From.dyn_cast<ClassTemplatePartialSpecializationDecl*>()) {
+ From.dyn_cast<ClassTemplatePartialSpecializationDecl *>()) {
Record.push_back(true);
Record.AddDeclRef(PartialSpec);
Record.AddTemplateArgumentList(
@@ -6454,7 +6455,7 @@ void ASTWriter::WriteDeclUpdatesBlocks(ASTContext &Context,
case UPD_CXX_RESOLVED_EXCEPTION_SPEC: {
auto prototype =
- cast<FunctionDecl>(D)->getType()->castAs<FunctionProtoType>();
+ cast<FunctionDecl>(D)->getType()->castAs<FunctionProtoType>();
Record.writeExceptionSpecInfo(prototype->getExceptionSpecInfo());
break;
}
@@ -6541,10 +6542,8 @@ FileID ASTWriter::getAdjustedFileID(FileID FID) const {
}
unsigned ASTWriter::getAdjustedNumCreatedFIDs(FileID FID) const {
- unsigned NumCreatedFIDs = PP->getSourceManager()
- .getLocalSLocEntry(FID.ID)
- .getFile()
- .NumCreatedFIDs;
+ unsigned NumCreatedFIDs =
+ PP->getSourceManager().getLocalSLocEntry(FID.ID).getFile().NumCreatedFIDs;
unsigned AdjustedNumCreatedFIDs = 0;
for (unsigned I = FID.ID, N = I + NumCreatedFIDs; I != N; ++I)
@@ -6635,7 +6634,8 @@ void ASTRecordWriter::AddAPFloat(const llvm::APFloat &Value) {
AddAPInt(Value.bitcastToAPInt());
}
-void ASTWriter::AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record) {
+void ASTWriter::AddIdentifierRef(const IdentifierInfo *II,
+ RecordDataImpl &Record) {
Record.push_back(getIdentifierRef(II));
}
@@ -6659,7 +6659,7 @@ MacroID ASTWriter::getMacroRef(MacroInfo *MI, const IdentifierInfo *Name) {
MacroID &ID = MacroIDs[MI];
if (ID == 0) {
ID = NextMacroID++;
- MacroInfoToEmitData Info = { Name, MI, ID };
+ MacroInfoToEmitData Info = {Name, MI, ID};
MacroInfosToEmit.push_back(Info);
}
return ID;
@@ -6729,8 +6729,8 @@ void ASTRecordWriter::AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg) {
AddTemplateArgument(Arg.getArgument());
if (Arg.getArgument().getKind() == TemplateArgument::Expression) {
- bool InfoHasSameExpr
- = Arg.getArgument().getAsExpr() == Arg.getLocInfo().getAsExpr();
+ bool InfoHasSameExpr =
+ Arg.getArgument().getAsExpr() == Arg.getLocInfo().getAsExpr();
Record->push_back(InfoHasSameExpr);
if (InfoHasSameExpr)
return; // Avoid storing the same expr twice.
@@ -6991,7 +6991,7 @@ void ASTRecordWriter::AddQualifierInfo(const QualifierInfo &Info) {
void ASTRecordWriter::AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS) {
// Nested name specifiers usually aren't too long. I think that 8 would
// typically accommodate the vast majority.
- SmallVector<NestedNameSpecifierLoc , 8> NestedNames;
+ SmallVector<NestedNameSpecifierLoc, 8> NestedNames;
// Push each of the nested-name-specifiers's onto a stack for
// serialization in reverse order.
@@ -7001,10 +7001,10 @@ void ASTRecordWriter::AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS) {
}
Record->push_back(NestedNames.size());
- while(!NestedNames.empty()) {
+ while (!NestedNames.empty()) {
NNS = NestedNames.pop_back_val();
- NestedNameSpecifier::SpecifierKind Kind
- = NNS.getNestedNameSpecifier()->getKind();
+ NestedNameSpecifier::SpecifierKind Kind =
+ NNS.getNestedNameSpecifier()->getKind();
Record->push_back(Kind);
switch (Kind) {
case NestedNameSpecifier::Identifier:
@@ -7082,8 +7082,8 @@ void ASTRecordWriter::AddASTTemplateArgumentListInfo(
void ASTRecordWriter::AddUnresolvedSet(const ASTUnresolvedSet &Set) {
Record->push_back(Set.size());
- for (ASTUnresolvedSet::const_iterator
- I = Set.begin(), E = Set.end(); I != E; ++I) {
+ for (ASTUnresolvedSet::const_iterator I = Set.begin(), E = Set.end(); I != E;
+ ++I) {
AddDeclRef(I.getDecl());
Record->push_back(I.getAccess());
}
@@ -7097,8 +7097,8 @@ void ASTRecordWriter::AddCXXBaseSpecifier(const CXXBaseSpecifier &Base) {
Record->push_back(Base.getInheritConstructors());
AddTypeSourceInfo(Base.getTypeSourceInfo());
AddSourceRange(Base.getSourceRange());
- AddSourceLocation(Base.isPackExpansion()? Base.getEllipsisLoc()
- : SourceLocation());
+ AddSourceLocation(Base.isPackExpansion() ? Base.getEllipsisLoc()
+ : SourceLocation());
}
static uint64_t EmitCXXBaseSpecifiers(ASTContext &Context, ASTWriter &W,
@@ -7133,7 +7133,7 @@ EmitCXXCtorInitializers(ASTContext &Context, ASTWriter &W,
} else if (Init->isDelegatingInitializer()) {
Writer.push_back(CTOR_INITIALIZER_DELEGATING);
Writer.AddTypeSourceInfo(Init->getTypeSourceInfo());
- } else if (Init->isMemberInitializer()){
+ } else if (Init->isMemberInitializer()) {
Writer.push_back(CTOR_INITIALIZER_MEMBER);
Writer.AddDeclRef(Init->getMember());
} else {
@@ -7281,10 +7281,8 @@ void ASTRecordWriter::AddVarDeclInit(const VarDecl *VD) {
void ASTWriter::ReaderInitialized(ASTReader *Reader) {
assert(Reader && "Cannot remove chain");
assert((!Chain || Chain == Reader) && "Cannot replace chain");
- assert(FirstDeclID == NextDeclID &&
- FirstTypeID == NextTypeID &&
- FirstIdentID == NextIdentID &&
- FirstMacroID == NextMacroID &&
+ assert(FirstDeclID == NextDeclID && FirstTypeID == NextTypeID &&
+ FirstIdentID == NextIdentID && FirstMacroID == NextMacroID &&
FirstSubmoduleID == NextSubmoduleID &&
FirstSelectorID == NextSelectorID &&
"Setting chain after writing has started.");
@@ -7380,7 +7378,8 @@ void ASTWriter::ModuleRead(serialization::SubmoduleID ID, Module *Mod) {
}
void ASTWriter::CompletedTagDefinition(const TagDecl *D) {
- if (Chain && Chain->isProcessingUpdateRecords()) return;
+ if (Chain && Chain->isProcessingUpdateRecords())
+ return;
assert(D->isCompleteDefinition());
assert(!WritingAST && "Already writing the AST!");
if (auto *RD = dyn_cast<CXXRecordDecl>(D)) {
@@ -7407,9 +7406,10 @@ static bool isImportedDeclContext(ASTReader *Chain, const Decl *D) {
}
void ASTWriter::AddedVisibleDecl(const DeclContext *DC, const Decl *D) {
- if (Chain && Chain->isProcessingUpdateRecords()) return;
+ if (Chain && Chain->isProcessingUpdateRecords())
+ return;
assert(DC->isLookupContext() &&
- "Should not add lookup results to non-lookup contexts!");
+ "Should not add lookup results to non-lookup contexts!");
// TU is handled elsewhere.
if (isa<TranslationUnitDecl>(DC))
@@ -7441,7 +7441,8 @@ void ASTWriter::AddedVisibleDecl(const DeclContext *DC, const Decl *D) {
}
void ASTWriter::AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) {
- if (Chain && Chain->isProcessingUpdateRecords()) return;
+ if (Chain && Chain->isProcessingUpdateRecords())
+ return;
assert(D->isImplicit());
// We're only interested in cases where a local declaration is added to an
@@ -7459,9 +7460,11 @@ void ASTWriter::AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) {
}
void ASTWriter::ResolvedExceptionSpec(const FunctionDecl *FD) {
- if (Chain && Chain->isProcessingUpdateRecords()) return;
+ if (Chain && Chain->isProcessingUpdateRecords())
+ return;
assert(!DoneWritingDeclsAndTypes && "Already done writing updates!");
- if (!Chain) return;
+ if (!Chain)
+ return;
Chain->forEachImportedKeyDecl(FD, [&](const Decl *D) {
// If we don't already know the exception specification for this redecl
// chain, add an update record for it.
@@ -7474,9 +7477,11 @@ void ASTWriter::ResolvedExceptionSpec(const FunctionDecl *FD) {
}
void ASTWriter::DeducedReturnType(const FunctionDecl *FD, QualType ReturnType) {
- if (Chain && Chain->isProcessingUpdateRecords()) return;
+ if (Chain && Chain->isProcessingUpdateRecords())
+ return;
assert(!WritingAST && "Already writing the AST!");
- if (!Chain) return;
+ if (!Chain)
+ return;
Chain->forEachImportedKeyDecl(FD, [&](const Decl *D) {
DeclUpdates[D].push_back(
DeclUpdate(UPD_CXX_DEDUCED_RETURN_TYPE, ReturnType));
@@ -7486,17 +7491,20 @@ void ASTWriter::DeducedReturnType(const FunctionDecl *FD, QualType ReturnType) {
void ASTWriter::ResolvedOperatorDelete(const CXXDestructorDecl *DD,
const FunctionDecl *Delete,
Expr *ThisArg) {
- if (Chain && Chain->isProcessingUpdateRecords()) return;
+ if (Chain && Chain->isProcessingUpdateRecords())
+ return;
assert(!WritingAST && "Already writing the AST!");
assert(Delete && "Not given an operator delete");
- if (!Chain) return;
+ if (!Chain)
+ return;
Chain->forEachImportedKeyDecl(DD, [&](const Decl *D) {
DeclUpdates[D].push_back(DeclUpdate(UPD_CXX_RESOLVED_DTOR_DELETE, Delete));
});
}
void ASTWriter::CompletedImplicitDefinition(const FunctionDecl *D) {
- if (Chain && Chain->isProcessingUpdateRecords()) return;
+ if (Chain && Chain->isProcessingUpdateRecords())
+ return;
assert(!WritingAST && "Already writing the AST!");
if (!D->isFromASTFile())
return; // Declaration not imported from PCH.
@@ -7510,7 +7518,8 @@ void ASTWriter::CompletedImplicitDefinition(const FunctionDecl *D) {
}
void ASTWriter::VariableDefinitionInstantiated(const VarDecl *D) {
- if (Chain && Chain->isProcessingUpdateRecords()) return;
+ if (Chain && Chain->isProcessingUpdateRecords())
+ return;
assert(!WritingAST && "Already writing the AST!");
if (!D->isFromASTFile())
return;
@@ -7519,7 +7528,8 @@ void ASTWriter::VariableDefinitionInstantiated(const VarDecl *D) {
}
void ASTWriter::FunctionDefinitionInstantiated(const FunctionDecl *D) {
- if (Chain && Chain->isProcessingUpdateRecords()) return;
+ if (Chain && Chain->isProcessingUpdateRecords())
+ return;
assert(!WritingAST && "Already writing the AST!");
if (!D->isFromASTFile())
return;
@@ -7532,7 +7542,8 @@ void ASTWriter::FunctionDefinitionInstantiated(const FunctionDecl *D) {
}
void ASTWriter::InstantiationRequested(const ValueDecl *D) {
- if (Chain && Chain->isProcessingUpdateRecords()) return;
+ if (Chain && Chain->isProcessingUpdateRecords())
+ return;
assert(!WritingAST && "Already writing the AST!");
if (!D->isFromASTFile())
return;
@@ -7548,7 +7559,8 @@ void ASTWriter::InstantiationRequested(const ValueDecl *D) {
}
void ASTWriter::DefaultArgumentInstantiated(const ParmVarDecl *D) {
- if (Chain && Chain->isProcessingUpdateRecords()) return;
+ if (Chain && Chain->isProcessingUpdateRecords())
+ return;
assert(!WritingAST && "Already writing the AST!");
if (!D->isFromASTFile())
return;
@@ -7568,18 +7580,20 @@ void ASTWriter::DefaultMemberInitializerInstantiated(const FieldDecl *D) {
void ASTWriter::AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD,
const ObjCInterfaceDecl *IFD) {
- if (Chain && Chain->isProcessingUpdateRecords()) return;
+ if (Chain && Chain->isProcessingUpdateRecords())
+ return;
assert(!WritingAST && "Already writing the AST!");
if (!IFD->isFromASTFile())
return; // Declaration not imported from PCH.
assert(IFD->getDefinition() && "Category on a class without a definition?");
ObjCClassesWithCategories.insert(
- const_cast<ObjCInterfaceDecl *>(IFD->getDefinition()));
+ const_cast<ObjCInterfaceDecl *>(IFD->getDefinition()));
}
void ASTWriter::DeclarationMarkedUsed(const Decl *D) {
- if (Chain && Chain->isProcessingUpdateRecords()) return;
+ if (Chain && Chain->isProcessingUpdateRecords())
+ return;
assert(!WritingAST && "Already writing the AST!");
// If there is *any* declaration of the entity that's not from an AST file,
@@ -7593,7 +7607,8 @@ void ASTWriter::DeclarationMarkedUsed(const Decl *D) {
}
void ASTWriter::DeclarationMarkedOpenMPThreadPrivate(const Decl *D) {
- if (Chain && Chain->isProcessingUpdateRecords()) return;
+ if (Chain && Chain->isProcessingUpdateRecords())
+ return;
assert(!WritingAST && "Already writing the AST!");
if (!D->isFromASTFile())
return;
@@ -7602,7 +7617,8 @@ void ASTWriter::DeclarationMarkedOpenMPThreadPrivate(const Decl *D) {
}
void ASTWriter::DeclarationMarkedOpenMPAllocate(const Decl *D, const Attr *A) {
- if (Chain && Chain->isProcessingUpdateRecords()) return;
+ if (Chain && Chain->isProcessingUpdateRecords())
+ return;
assert(!WritingAST && "Already writing the AST!");
if (!D->isFromASTFile())
return;
@@ -7612,7 +7628,8 @@ void ASTWriter::DeclarationMarkedOpenMPAllocate(const Decl *D, const Attr *A) {
void ASTWriter::DeclarationMarkedOpenMPDeclareTarget(const Decl *D,
const Attr *Attr) {
- if (Chain && Chain->isProcessingUpdateRecords()) return;
+ if (Chain && Chain->isProcessingUpdateRecords())
+ return;
assert(!WritingAST && "Already writing the AST!");
if (!D->isFromASTFile())
return;
@@ -7622,7 +7639,8 @@ void ASTWriter::DeclarationMarkedOpenMPDeclareTarget(const Decl *D,
}
void ASTWriter::RedefinedHiddenDefinition(const NamedDecl *D, Module *M) {
- if (Chain && Chain->isProcessingUpdateRecords()) return;
+ if (Chain && Chain->isProcessingUpdateRecords())
+ return;
assert(!WritingAST && "Already writing the AST!");
assert(!D->isUnconditionallyVisible() && "expected a hidden declaration");
DeclUpdates[D].push_back(DeclUpdate(UPD_DECL_EXPORTED, M));
@@ -7630,7 +7648,8 @@ void ASTWriter::RedefinedHiddenDefinition(const NamedDecl *D, Module *M) {
void ASTWriter::AddedAttributeToRecord(const Attr *Attr,
const RecordDecl *Record) {
- if (Chain && Chain->isProcessingUpdateRecords()) return;
+ if (Chain && Chain->isProcessingUpdateRecords())
+ return;
assert(!WritingAST && "Already writing the AST!");
if (!Record->isFromASTFile())
return;
@@ -7692,7 +7711,7 @@ class OMPClauseWriter : public OMPClauseVisitor<OMPClauseWriter> {
void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C);
};
-}
+} // namespace
void ASTRecordWriter::writeOMPClause(OMPClause *C) {
OMPClauseWriter(*this).writeClause(C);
@@ -7812,7 +7831,7 @@ void OMPClauseWriter::VisitOMPOrderedClause(OMPOrderedClause *C) {
Record.AddStmt(C->getNumForLoops());
for (Expr *NumIter : C->getLoopNumIterations())
Record.AddStmt(NumIter);
- for (unsigned I = 0, E = C->getLoopNumIterations().size(); I <E; ++I)
+ for (unsigned I = 0, E = C->getLoopNumIterations().size(); I < E; ++I)
Record.AddStmt(C->getLoopCounter(I));
Record.AddSourceLocation(C->getLParenLoc());
}
@@ -8020,7 +8039,11 @@ void OMPClauseWriter::VisitOMPReductionClause(OMPReductionClause *C) {
for (auto *E : C->copy_array_elems())
Record.AddStmt(E);
}
-}
+ ArrayRef<bool> PrivateFlags = C->getPrivateVariableReductionFlags();
+ Record.push_back(PrivateFlags.size());
+ for (bool Flag : PrivateFlags)
+ Record.push_back(Flag);
+ }
void OMPClauseWriter::VisitOMPTaskReductionClause(OMPTaskReductionClause *C) {
Record.push_back(C->varlist_size());
@@ -8419,9 +8442,8 @@ void OMPClauseWriter::VisitOMPUnifiedSharedMemoryClause(
void OMPClauseWriter::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {}
-void
-OMPClauseWriter::VisitOMPDynamicAllocatorsClause(OMPDynamicAllocatorsClause *) {
-}
+void OMPClauseWriter::VisitOMPDynamicAllocatorsClause(
+ OMPDynamicAllocatorsClause *) {}
void OMPClauseWriter::VisitOMPAtomicDefaultMemOrderClause(
OMPAtomicDefaultMemOrderClause *C) {
@@ -8591,7 +8613,7 @@ void ASTRecordWriter::writeOpenACCClause(const OpenACCClause *C) {
case OpenACCClauseKind::If: {
const auto *IC = cast<OpenACCIfClause>(C);
writeSourceLocation(IC->getLParenLoc());
- AddStmt(const_cast<Expr*>(IC->getConditionExpr()));
+ AddStmt(const_cast<Expr *>(IC->getConditionExpr()));
return;
}
case OpenACCClauseKind::Self: {
@@ -8620,7 +8642,7 @@ void ASTRecordWriter::writeOpenACCClause(const OpenACCClause *C) {
case OpenACCClauseKind::DeviceNum: {
const auto *DNC = cast<OpenACCDeviceNumClause>(C);
writeSourceLocation(DNC->getLParenLoc());
- AddStmt(const_cast<Expr*>(DNC->getIntExpr()));
+ AddStmt(const_cast<Expr *>(DNC->getIntExpr()));
return;
}
case OpenACCClauseKind::DefaultAsync: {
@@ -8632,13 +8654,13 @@ void ASTRecordWriter::writeOpenACCClause(const OpenACCClause *C) {
case OpenACCClauseKind::NumWorkers: {
const auto *NWC = cast<OpenACCNumWorkersClause>(C);
writeSourceLocation(NWC->getLParenLoc());
- AddStmt(const_cast<Expr*>(NWC->getIntExpr()));
+ AddStmt(const_cast<Expr *>(NWC->getIntExpr()));
return;
}
case OpenACCClauseKind::VectorLength: {
const auto *NWC = cast<OpenACCVectorLengthClause>(C);
writeSourceLocation(NWC->getLParenLoc());
- AddStmt(const_cast<Expr*>(NWC->getIntExpr()));
+ AddStmt(const_cast<Expr *>(NWC->getIntExpr()));
return;
}
case OpenACCClauseKind::Private: {
@@ -8747,7 +8769,7 @@ void ASTRecordWriter::writeOpenACCClause(const OpenACCClause *C) {
writeSourceLocation(AC->getLParenLoc());
writeBool(AC->hasIntExpr());
if (AC->hasIntExpr())
- AddStmt(const_cast<Expr*>(AC->getIntExpr()));
+ AddStmt(const_cast<Expr *>(AC->getIntExpr()));
return;
}
case OpenACCClauseKind::Wait: {
diff --git a/clang/test/OpenMP/for_reduction_messages.cpp b/clang/test/OpenMP/for_reduction_messages.cpp
index 1ef9726205abb..de28ba2c3be02 100644
--- a/clang/test/OpenMP/for_reduction_messages.cpp
+++ b/clang/test/OpenMP/for_reduction_messages.cpp
@@ -237,6 +237,7 @@ T tmain(T argc) {
#pragma omp for reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
for (int i = 0; i < 10; ++i)
foo();
+#if defined(_OPENMP) && (_OPENMP <= 202111)
#pragma omp parallel private(fl) // expected-note 2 {{defined as private}}
#pragma omp for reduction(+ : fl) // expected-error 2 {{reduction variable must be shared}}
for (int i = 0; i < 10; ++i)
@@ -253,7 +254,7 @@ T tmain(T argc) {
#pragma omp for reduction(+ : fl) // expected-error 2 {{reduction variable must be shared}}
for (int i = 0; i < 10; ++i)
foo();
-
+#endif
return T();
}
@@ -402,10 +403,12 @@ int main(int argc, char **argv) {
#pragma omp for reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
for (int i = 0; i < 10; ++i)
foo();
+#if defined(_OPENMP) && (_OPENMP <= 202111)
#pragma omp parallel private(fl) // expected-note {{defined as private}}
#pragma omp for reduction(+ : fl) // expected-error {{reduction variable must be shared}}
for (int i = 0; i < 10; ++i)
foo();
+#endif
#pragma omp parallel private(argv)
#pragma omp for reduction(+ : argv[1], get()[0]) // expected-error {{expected variable name as a base of the array subscript}} expected-error {{invalid operands to binary expression ('char *' and 'char *')}}
for (int i = 0; i < 10; ++i)
diff --git a/clang/test/OpenMP/for_simd_reduction_messages.cpp b/clang/test/OpenMP/for_simd_reduction_messages.cpp
index 2550cf481265f..96b3805b10a86 100644
--- a/clang/test/OpenMP/for_simd_reduction_messages.cpp
+++ b/clang/test/OpenMP/for_simd_reduction_messages.cpp
@@ -236,6 +236,7 @@ T tmain(T argc) {
#pragma omp for simd reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
for (int i = 0; i < 10; ++i)
foo();
+#if defined(_OPENMP) && (_OPENMP <= 202111)
#pragma omp parallel private(fl) // expected-note 2 {{defined as private}}
#pragma omp for simd reduction(+ : fl) // expected-error 2 {{reduction variable must be shared}}
for (int i = 0; i < 10; ++i)
@@ -244,6 +245,7 @@ T tmain(T argc) {
#pragma omp for simd reduction(+ : fl) // expected-error 2 {{reduction variable must be shared}}
for (int i = 0; i < 10; ++i)
foo();
+#endif
return T();
}
@@ -389,10 +391,12 @@ int main(int argc, char **argv) {
#pragma omp for simd reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
for (int i = 0; i < 10; ++i)
foo();
+#if defined(_OPENMP) && (_OPENMP <= 202111)
#pragma omp parallel private(fl) // expected-note {{defined as private}}
#pragma omp for simd reduction(+ : fl) // expected-error {{reduction variable must be shared}}
for (int i = 0; i < 10; ++i)
foo();
+#endif
#pragma omp parallel reduction(* : fl) // expected-note {{defined as reduction}}
#pragma omp for simd reduction(+ : fl) // expected-error {{reduction variable must be shared}}
for (int i = 0; i < 10; ++i)
diff --git a/clang/test/OpenMP/parallel_for_reduction_messages.cpp b/clang/test/OpenMP/parallel_for_reduction_messages.cpp
index d4660ae43acf8..5e4e3c18039fd 100644
--- a/clang/test/OpenMP/parallel_for_reduction_messages.cpp
+++ b/clang/test/OpenMP/parallel_for_reduction_messages.cpp
@@ -89,10 +89,12 @@ class S5 {
public:
S5(int v) : a(v) {}
void foo() {
+#if defined(_OPENMP) && (_OPENMP <= 202111)
#pragma omp parallel private(a) // expected-note {{defined as private}}
#pragma omp for reduction(+:a) // expected-error {{reduction variable must be shared}}
for (int i = 0; i < 10; ++i)
::foo();
+#endif
#pragma omp parallel for reduction(inscan, +:a)
for (int i = 0; i < 10; ++i) {
#pragma omp scan inclusive(a)
@@ -226,7 +228,12 @@ T tmain(T argc) {
#pragma omp parallel for reduction(+ : fl)
for (int i = 0; i < 10; ++i)
foo();
-
+#if defined(_OPENMP) && (_OPENMP >= 202411)
+#pragma omp parallel private(fl)
+#pragma omp for reduction(original(abcxx),+:fl) // expected-error {{private or shared or default}} expected-warning {{extra tokens at the end of '#pragma omp for'}}
+for (int i = 1; i <= 10; i++)
+ foo();
+#endif
return T();
}
diff --git a/clang/test/OpenMP/sections_reduction_messages.cpp b/clang/test/OpenMP/sections_reduction_messages.cpp
index f93b4dd016308..42ec3ed6d58e8 100644
--- a/clang/test/OpenMP/sections_reduction_messages.cpp
+++ b/clang/test/OpenMP/sections_reduction_messages.cpp
@@ -268,6 +268,7 @@ T tmain(T argc) {
{
foo();
}
+#if defined(_OPENMP) && (_OPENMP <= 202111)
#pragma omp parallel private(fl) // expected-note 2 {{defined as private}}
#pragma omp sections reduction(+ : fl) // expected-error 2 {{reduction variable must be shared}}
{
@@ -278,6 +279,7 @@ T tmain(T argc) {
{
foo();
}
+#endif
return T();
}
@@ -453,11 +455,13 @@ int main(int argc, char **argv) {
{
foo();
}
+#if defined(_OPENMP) && (_OPENMP <= 202111)
#pragma omp parallel private(fl) // expected-note {{defined as private}}
#pragma omp sections reduction(+ : fl) // expected-error {{reduction variable must be shared}}
{
foo();
}
+#endif
#pragma omp parallel reduction(* : fl) // expected-note {{defined as reduction}}
#pragma omp sections reduction(+ : fl) // expected-error {{reduction variable must be shared}}
{
>From 48e456417179c517565d5cf2e2fd0b3a5c0a758b Mon Sep 17 00:00:00 2001
From: Chandra Ghale <ghale at pe31.hpc.amslabs.hpecorp.net>
Date: Wed, 5 Mar 2025 15:40:16 -0600
Subject: [PATCH 2/2] formating fix
---
clang/lib/AST/OpenMPClause.cpp | 3 +-
clang/lib/Parse/ParseOpenMP.cpp | 5 +-
clang/lib/Serialization/ASTReader.cpp | 1306 +++++++++++++------------
clang/lib/Serialization/ASTWriter.cpp | 574 ++++++-----
4 files changed, 937 insertions(+), 951 deletions(-)
diff --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp
index df4f0550e0a98..dbd774681becb 100644
--- a/clang/lib/AST/OpenMPClause.cpp
+++ b/clang/lib/AST/OpenMPClause.cpp
@@ -797,7 +797,8 @@ OMPReductionClause *OMPReductionClause::Create(
ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps,
ArrayRef<Expr *> CopyOps, ArrayRef<Expr *> CopyArrayTemps,
- ArrayRef<Expr *> CopyArrayElems, Stmt *PreInit, Expr *PostUpdate,ArrayRef<bool> IsPrivateVarReduction) {
+ ArrayRef<Expr *> CopyArrayElems, Stmt *PreInit, Expr *PostUpdate,
+ ArrayRef<bool> IsPrivateVarReduction) {
void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(
(Modifier == OMPC_REDUCTION_inscan ? 8 : 5) * VL.size()));
auto *Clause = new (Mem)
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 3b95eb01a06c9..ecc00d332571f 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -4680,8 +4680,9 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind,
Data.OriginalSharingModifier = OMPC_ORIGINAL_SHARING_private;
Data.OriginalSharingModifierLoc = Tok.getLocation();
ConsumeToken();
- } else if (Tok.is(tok::identifier) && (PP.getSpelling(Tok) == "shared"
- || PP.getSpelling(Tok) == "default")) {
+ } else if (Tok.is(tok::identifier) &&
+ (PP.getSpelling(Tok) == "shared" ||
+ PP.getSpelling(Tok) == "default")) {
Data.OriginalSharingModifier = OMPC_ORIGINAL_SHARING_shared;
Data.OriginalSharingModifierLoc = Tok.getLocation();
ConsumeToken();
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index fc01ac6097d8c..fd17e26ffb080 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -158,8 +158,8 @@ using llvm::BitstreamCursor;
// ChainedASTReaderListener implementation
//===----------------------------------------------------------------------===//
-bool ChainedASTReaderListener::ReadFullVersionInformation(
- StringRef FullVersion) {
+bool
+ChainedASTReaderListener::ReadFullVersionInformation(StringRef FullVersion) {
return First->ReadFullVersionInformation(FullVersion) ||
Second->ReadFullVersionInformation(FullVersion);
}
@@ -199,8 +199,9 @@ bool ChainedASTReaderListener::ReadDiagnosticOptions(
Second->ReadDiagnosticOptions(DiagOpts, ModuleFilename, Complain);
}
-bool ChainedASTReaderListener::ReadFileSystemOptions(
- const FileSystemOptions &FSOpts, bool Complain) {
+bool
+ChainedASTReaderListener::ReadFileSystemOptions(const FileSystemOptions &FSOpts,
+ bool Complain) {
return First->ReadFileSystemOptions(FSOpts, Complain) ||
Second->ReadFileSystemOptions(FSOpts, Complain);
}
@@ -236,7 +237,7 @@ bool ChainedASTReaderListener::needsInputFileVisitation() {
bool ChainedASTReaderListener::needsSystemInputFileVisitation() {
return First->needsSystemInputFileVisitation() ||
- Second->needsSystemInputFileVisitation();
+ Second->needsSystemInputFileVisitation();
}
void ChainedASTReaderListener::visitModuleFile(StringRef Filename,
@@ -245,7 +246,8 @@ void ChainedASTReaderListener::visitModuleFile(StringRef Filename,
Second->visitModuleFile(Filename, Kind);
}
-bool ChainedASTReaderListener::visitInputFile(StringRef Filename, bool isSystem,
+bool ChainedASTReaderListener::visitInputFile(StringRef Filename,
+ bool isSystem,
bool isOverridden,
bool isExplicitModule) {
bool Continue = false;
@@ -261,7 +263,7 @@ bool ChainedASTReaderListener::visitInputFile(StringRef Filename, bool isSystem,
}
void ChainedASTReaderListener::readModuleFileExtension(
- const ModuleFileExtensionMetadata &Metadata) {
+ const ModuleFileExtensionMetadata &Metadata) {
First->readModuleFileExtension(Metadata);
Second->readModuleFileExtension(Metadata);
}
@@ -315,17 +317,17 @@ static bool checkLanguageOptions(const LangOptions &LangOpts,
return true; \
}
-#define COMPATIBLE_LANGOPT(Name, Bits, Default, Description) \
- if (!AllowCompatibleDifferences) \
- LANGOPT(Name, Bits, Default, Description)
+#define COMPATIBLE_LANGOPT(Name, Bits, Default, Description) \
+ if (!AllowCompatibleDifferences) \
+ LANGOPT(Name, Bits, Default, Description)
-#define COMPATIBLE_ENUM_LANGOPT(Name, Bits, Default, Description) \
- if (!AllowCompatibleDifferences) \
- ENUM_LANGOPT(Name, Bits, Default, Description)
+#define COMPATIBLE_ENUM_LANGOPT(Name, Bits, Default, Description) \
+ if (!AllowCompatibleDifferences) \
+ ENUM_LANGOPT(Name, Bits, Default, Description)
-#define COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description) \
- if (!AllowCompatibleDifferences) \
- VALUE_LANGOPT(Name, Bits, Default, Description)
+#define COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description) \
+ if (!AllowCompatibleDifferences) \
+ VALUE_LANGOPT(Name, Bits, Default, Description)
#define BENIGN_LANGOPT(Name, Bits, Default, Description)
#define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
@@ -420,8 +422,8 @@ static bool checkTargetOptions(const TargetOptions &TargetOpts,
// Compare feature sets.
SmallVector<StringRef, 4> ExistingFeatures(
- ExistingTargetOpts.FeaturesAsWritten.begin(),
- ExistingTargetOpts.FeaturesAsWritten.end());
+ ExistingTargetOpts.FeaturesAsWritten.begin(),
+ ExistingTargetOpts.FeaturesAsWritten.end());
SmallVector<StringRef, 4> ReadFeatures(TargetOpts.FeaturesAsWritten.begin(),
TargetOpts.FeaturesAsWritten.end());
llvm::sort(ExistingFeatures);
@@ -430,9 +432,9 @@ static bool checkTargetOptions(const TargetOptions &TargetOpts,
// We compute the set difference in both directions explicitly so that we can
// diagnose the differences differently.
SmallVector<StringRef, 4> UnmatchedExistingFeatures, UnmatchedReadFeatures;
- std::set_difference(ExistingFeatures.begin(), ExistingFeatures.end(),
- ReadFeatures.begin(), ReadFeatures.end(),
- std::back_inserter(UnmatchedExistingFeatures));
+ std::set_difference(
+ ExistingFeatures.begin(), ExistingFeatures.end(), ReadFeatures.begin(),
+ ReadFeatures.end(), std::back_inserter(UnmatchedExistingFeatures));
std::set_difference(ReadFeatures.begin(), ReadFeatures.end(),
ExistingFeatures.begin(), ExistingFeatures.end(),
std::back_inserter(UnmatchedReadFeatures));
@@ -489,7 +491,7 @@ static bool checkDiagnosticGroupMappings(DiagnosticsEngine &StoredDiags,
// Check current mappings for new -Werror mappings, and the stored mappings
// for cases that were explicitly mapped to *not* be errors that are now
// errors because of options like -Werror.
- DiagnosticsEngine *MappingSources[] = {&Diags, &StoredDiags};
+ DiagnosticsEngine *MappingSources[] = { &Diags, &StoredDiags };
for (DiagnosticsEngine *MappingSource : MappingSources) {
for (auto DiagIDMappingPair : MappingSource->getDiagnosticMappings()) {
@@ -972,12 +974,12 @@ LocalDeclID LocalDeclID::get(ASTReader &Reader, ModuleFile &MF,
}
std::pair<unsigned, unsigned>
-ASTSelectorLookupTrait::ReadKeyDataLength(const unsigned char *&d) {
+ASTSelectorLookupTrait::ReadKeyDataLength(const unsigned char*& d) {
return readULEBKeyDataLength(d);
}
ASTSelectorLookupTrait::internal_key_type
-ASTSelectorLookupTrait::ReadKey(const unsigned char *d, unsigned) {
+ASTSelectorLookupTrait::ReadKey(const unsigned char* d, unsigned) {
using namespace llvm::support;
SelectorTable &SelTable = Reader.getContext().Selectors;
@@ -999,7 +1001,7 @@ ASTSelectorLookupTrait::ReadKey(const unsigned char *d, unsigned) {
}
ASTSelectorLookupTrait::data_type
-ASTSelectorLookupTrait::ReadData(Selector, const unsigned char *d,
+ASTSelectorLookupTrait::ReadData(Selector, const unsigned char* d,
unsigned DataLen) {
using namespace llvm::support;
@@ -1039,19 +1041,19 @@ ASTSelectorLookupTrait::ReadData(Selector, const unsigned char *d,
return Result;
}
-unsigned ASTIdentifierLookupTraitBase::ComputeHash(const internal_key_type &a) {
+unsigned ASTIdentifierLookupTraitBase::ComputeHash(const internal_key_type& a) {
return llvm::djbHash(a);
}
std::pair<unsigned, unsigned>
-ASTIdentifierLookupTraitBase::ReadKeyDataLength(const unsigned char *&d) {
+ASTIdentifierLookupTraitBase::ReadKeyDataLength(const unsigned char*& d) {
return readULEBKeyDataLength(d);
}
ASTIdentifierLookupTraitBase::internal_key_type
-ASTIdentifierLookupTraitBase::ReadKey(const unsigned char *d, unsigned n) {
- assert(n >= 2 && d[n - 1] == '\0');
- return StringRef((const char *)d, n - 1);
+ASTIdentifierLookupTraitBase::ReadKey(const unsigned char* d, unsigned n) {
+ assert(n >= 2 && d[n-1] == '\0');
+ return StringRef((const char*) d, n-1);
}
/// Whether the given identifier is "interesting".
@@ -1073,8 +1075,7 @@ static bool readBit(unsigned &Bits) {
return Value;
}
-IdentifierID
-ASTIdentifierLookupTrait::ReadIdentifierID(const unsigned char *d) {
+IdentifierID ASTIdentifierLookupTrait::ReadIdentifierID(const unsigned char *d) {
using namespace llvm::support;
IdentifierID RawID =
@@ -1091,8 +1092,8 @@ static void markIdentifierFromAST(ASTReader &Reader, IdentifierInfo &II,
}
}
-IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type &k,
- const unsigned char *d,
+IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k,
+ const unsigned char* d,
unsigned DataLen) {
using namespace llvm::support;
@@ -1196,8 +1197,7 @@ DeclarationNameKey::DeclarationNameKey(DeclarationName Name)
break;
case DeclarationName::CXXDeductionGuideName:
Data = (uint64_t)Name.getCXXDeductionGuideTemplate()
- ->getDeclName()
- .getAsIdentifierInfo();
+ ->getDeclName().getAsIdentifierInfo();
break;
case DeclarationName::CXXConstructorName:
case DeclarationName::CXXDestructorName:
@@ -1216,7 +1216,7 @@ unsigned DeclarationNameKey::getHash() const {
case DeclarationName::Identifier:
case DeclarationName::CXXLiteralOperatorName:
case DeclarationName::CXXDeductionGuideName:
- ID.AddString(((IdentifierInfo *)Data)->getName());
+ ID.AddString(((IdentifierInfo*)Data)->getName());
break;
case DeclarationName::ObjCZeroArgSelector:
case DeclarationName::ObjCOneArgSelector:
@@ -1476,7 +1476,7 @@ bool ASTReader::ReadVisibleDeclContextStorage(
// We can't safely determine the primary context yet, so delay attaching the
// lookup table until we're done with recursive deserialization.
- auto *Data = (const unsigned char *)Blob.data();
+ auto *Data = (const unsigned char*)Blob.data();
switch (VisibleKind) {
case VisibleDeclContextStorageKind::GenerallyVisible:
PendingVisibleUpdates[ID].push_back(UpdateData{&M, Data});
@@ -1542,7 +1542,7 @@ void ASTReader::Error(StringRef Msg) const {
if (PP.getLangOpts().Modules &&
!PP.getHeaderSearchInfo().getModuleCachePath().empty()) {
Diag(diag::note_module_cache_path)
- << PP.getHeaderSearchInfo().getModuleCachePath();
+ << PP.getHeaderSearchInfo().getModuleCachePath();
}
}
@@ -1610,11 +1610,11 @@ void ASTReader::ParseLineTable(ModuleFile &F, const RecordData &Record) {
unsigned FileOffset = Record[Idx++];
unsigned LineNo = Record[Idx++];
int FilenameID = FileIDs[Record[Idx++]];
- SrcMgr::CharacteristicKind FileKind =
- (SrcMgr::CharacteristicKind)Record[Idx++];
+ SrcMgr::CharacteristicKind FileKind
+ = (SrcMgr::CharacteristicKind)Record[Idx++];
unsigned IncludeOffset = Record[Idx++];
- Entries.push_back(LineEntry::get(FileOffset, LineNo, FilenameID, FileKind,
- IncludeOffset));
+ Entries.push_back(LineEntry::get(FileOffset, LineNo, FilenameID,
+ FileKind, IncludeOffset));
}
LineTable.AddEntry(FID, Entries);
}
@@ -1669,7 +1669,7 @@ llvm::Error ASTReader::ReadSourceManagerBlock(ModuleFile &F) {
if (!MaybeRecord)
return MaybeRecord.takeError();
switch (MaybeRecord.get()) {
- default: // Default behavior: ignore.
+ default: // Default behavior: ignore.
break;
case SM_SLOC_FILE_ENTRY:
@@ -1765,9 +1765,9 @@ bool ASTReader::ReadSLocEntry(int ID) {
// Local helper to read the (possibly-compressed) buffer data following the
// entry record.
- auto ReadBuffer =
- [this](BitstreamCursor &SLocEntryCursor,
- StringRef Name) -> std::unique_ptr<llvm::MemoryBuffer> {
+ auto ReadBuffer = [this](
+ BitstreamCursor &SLocEntryCursor,
+ StringRef Name) -> std::unique_ptr<llvm::MemoryBuffer> {
RecordData Record;
StringRef Blob;
Expected<unsigned> MaybeCode = SLocEntryCursor.ReadCode();
@@ -1869,8 +1869,8 @@ bool ASTReader::ReadSLocEntry(int ID) {
// This is the module's main file.
IncludeLoc = getImportLocation(F);
}
- SrcMgr::CharacteristicKind FileCharacter =
- (SrcMgr::CharacteristicKind)Record[2];
+ SrcMgr::CharacteristicKind
+ FileCharacter = (SrcMgr::CharacteristicKind)Record[2];
FileID FID = SourceMgr.createFileID(*File, IncludeLoc, FileCharacter, ID,
BaseOffset + Record[0]);
SrcMgr::FileInfo &FileInfo = SourceMgr.getSLocEntry(FID).getFile();
@@ -1903,8 +1903,8 @@ bool ASTReader::ReadSLocEntry(int ID) {
case SM_SLOC_BUFFER_ENTRY: {
const char *Name = Blob.data();
unsigned Offset = Record[0];
- SrcMgr::CharacteristicKind FileCharacter =
- (SrcMgr::CharacteristicKind)Record[2];
+ SrcMgr::CharacteristicKind
+ FileCharacter = (SrcMgr::CharacteristicKind)Record[2];
SourceLocation IncludeLoc = ReadSourceLocation(*F, Record[1]);
if (IncludeLoc.isInvalid() && F->isModule()) {
IncludeLoc = getImportLocation(F);
@@ -2067,7 +2067,7 @@ MacroInfo *ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset) {
return nullptr;
}
RecordData Record;
- SmallVector<IdentifierInfo *, 16> MacroParams;
+ SmallVector<IdentifierInfo*, 16> MacroParams;
MacroInfo *Macro = nullptr;
llvm::MutableArrayRef<Token> MacroTokens;
@@ -2138,12 +2138,9 @@ MacroInfo *ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset) {
// Install function-like macro info.
MI->setIsFunctionLike();
- if (isC99VarArgs)
- MI->setIsC99Varargs();
- if (isGNUVarArgs)
- MI->setIsGNUVarargs();
- if (hasCommaPasting)
- MI->setHasCommaPasting();
+ if (isC99VarArgs) MI->setIsC99Varargs();
+ if (isGNUVarArgs) MI->setIsGNUVarargs();
+ if (hasCommaPasting) MI->setHasCommaPasting();
MI->setParameterList(MacroParams, PP.getPreprocessorAllocator());
}
@@ -2154,8 +2151,8 @@ MacroInfo *ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset) {
if (NextIndex + 1 == Record.size() && PP.getPreprocessingRecord() &&
Record[NextIndex]) {
// We have a macro definition. Register the association
- PreprocessedEntityID GlobalID =
- getGlobalPreprocessedEntityID(F, Record[NextIndex]);
+ PreprocessedEntityID
+ GlobalID = getGlobalPreprocessedEntityID(F, Record[NextIndex]);
PreprocessingRecord &PPRec = *PP.getPreprocessingRecord();
PreprocessingRecord::PPEntityID PPID =
PPRec.getPPEntityID(GlobalID - 1, /*isLoaded=*/true);
@@ -2172,8 +2169,7 @@ MacroInfo *ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset) {
case PP_TOKEN: {
// If we see a TOKEN before a PP_MACRO_*, then the file is
// erroneous, just pretend we didn't see this.
- if (!Macro)
- break;
+ if (!Macro) break;
if (MacroTokens.empty()) {
Error("unexpected number of macro tokens for a macro in AST file");
return Macro;
@@ -2194,10 +2190,10 @@ ASTReader::getGlobalPreprocessedEntityID(ModuleFile &M,
if (!M.ModuleOffsetMap.empty())
ReadModuleOffsetMap(M);
- ContinuousRangeMap<uint32_t, int, 2>::const_iterator I =
- M.PreprocessedEntityRemap.find(LocalID - NUM_PREDEF_PP_ENTITY_IDS);
- assert(I != M.PreprocessedEntityRemap.end() &&
- "Invalid index into preprocessed entity index remap");
+ ContinuousRangeMap<uint32_t, int, 2>::const_iterator
+ I = M.PreprocessedEntityRemap.find(LocalID - NUM_PREDEF_PP_ENTITY_IDS);
+ assert(I != M.PreprocessedEntityRemap.end()
+ && "Invalid index into preprocessed entity index remap");
return LocalID + I->second;
}
@@ -2242,7 +2238,7 @@ bool HeaderFileInfoTrait::EqualKey(internal_key_ref a, internal_key_ref b) {
}
std::pair<unsigned, unsigned>
-HeaderFileInfoTrait::ReadKeyDataLength(const unsigned char *&d) {
+HeaderFileInfoTrait::ReadKeyDataLength(const unsigned char*& d) {
return readULEBKeyDataLength(d);
}
@@ -2314,8 +2310,7 @@ HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,
void ASTReader::addPendingMacro(IdentifierInfo *II, ModuleFile *M,
uint32_t MacroDirectivesOffset) {
- assert(NumCurrentElementsDeserializing > 0 &&
- "Missing deserialization guard");
+ assert(NumCurrentElementsDeserializing > 0 &&"Missing deserialization guard");
PendingMacroIDs[II].push_back(PendingMacroInfo(M, MacroDirectivesOffset));
}
@@ -2361,7 +2356,7 @@ void ASTReader::ReadDefinedMacros() {
return;
}
switch (MaybeRecord.get()) {
- default: // Default behavior: ignore.
+ default: // Default behavior: ignore.
break;
case PP_MACRO_OBJECT_LIKE:
@@ -2380,59 +2375,60 @@ void ASTReader::ReadDefinedMacros() {
}
}
}
- NextCursor:;
+ NextCursor: ;
}
}
namespace {
-/// Visitor class used to look up identifirs in an AST file.
-class IdentifierLookupVisitor {
- StringRef Name;
- unsigned NameHash;
- unsigned PriorGeneration;
- unsigned &NumIdentifierLookups;
- unsigned &NumIdentifierLookupHits;
- IdentifierInfo *Found = nullptr;
-
-public:
- IdentifierLookupVisitor(StringRef Name, unsigned PriorGeneration,
- unsigned &NumIdentifierLookups,
- unsigned &NumIdentifierLookupHits)
+ /// Visitor class used to look up identifirs in an AST file.
+ class IdentifierLookupVisitor {
+ StringRef Name;
+ unsigned NameHash;
+ unsigned PriorGeneration;
+ unsigned &NumIdentifierLookups;
+ unsigned &NumIdentifierLookupHits;
+ IdentifierInfo *Found = nullptr;
+
+ public:
+ IdentifierLookupVisitor(StringRef Name, unsigned PriorGeneration,
+ unsigned &NumIdentifierLookups,
+ unsigned &NumIdentifierLookupHits)
: Name(Name), NameHash(ASTIdentifierLookupTrait::ComputeHash(Name)),
PriorGeneration(PriorGeneration),
NumIdentifierLookups(NumIdentifierLookups),
NumIdentifierLookupHits(NumIdentifierLookupHits) {}
- bool operator()(ModuleFile &M) {
- // If we've already searched this module file, skip it now.
- if (M.Generation <= PriorGeneration)
- return true;
+ bool operator()(ModuleFile &M) {
+ // If we've already searched this module file, skip it now.
+ if (M.Generation <= PriorGeneration)
+ return true;
- ASTIdentifierLookupTable *IdTable =
- (ASTIdentifierLookupTable *)M.IdentifierLookupTable;
- if (!IdTable)
- return false;
+ ASTIdentifierLookupTable *IdTable
+ = (ASTIdentifierLookupTable *)M.IdentifierLookupTable;
+ if (!IdTable)
+ return false;
- ASTIdentifierLookupTrait Trait(IdTable->getInfoObj().getReader(), M, Found);
- ++NumIdentifierLookups;
- ASTIdentifierLookupTable::iterator Pos =
- IdTable->find_hashed(Name, NameHash, &Trait);
- if (Pos == IdTable->end())
- return false;
+ ASTIdentifierLookupTrait Trait(IdTable->getInfoObj().getReader(), M,
+ Found);
+ ++NumIdentifierLookups;
+ ASTIdentifierLookupTable::iterator Pos =
+ IdTable->find_hashed(Name, NameHash, &Trait);
+ if (Pos == IdTable->end())
+ return false;
- // Dereferencing the iterator has the effect of building the
- // IdentifierInfo node and populating it with the various
- // declarations it needs.
- ++NumIdentifierLookupHits;
- Found = *Pos;
- return true;
- }
+ // Dereferencing the iterator has the effect of building the
+ // IdentifierInfo node and populating it with the various
+ // declarations it needs.
+ ++NumIdentifierLookupHits;
+ Found = *Pos;
+ return true;
+ }
- // Retrieve the identifier info found within the module
- // files.
- IdentifierInfo *getIdentifierInfo() const { return Found; }
-};
+ // Retrieve the identifier info found within the module
+ // files.
+ IdentifierInfo *getIdentifierInfo() const { return Found; }
+ };
} // namespace
@@ -2542,7 +2538,7 @@ void ASTReader::resolvePendingMacro(IdentifierInfo *II,
// Module macros are listed in reverse dependency order.
{
std::reverse(ModuleMacros.begin(), ModuleMacros.end());
- llvm::SmallVector<ModuleMacro *, 8> Overrides;
+ llvm::SmallVector<ModuleMacro*, 8> Overrides;
for (auto &MMR : ModuleMacros) {
Overrides.clear();
for (unsigned ModID : MMR.Overrides) {
@@ -2698,10 +2694,10 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
return InputFile();
// If we've already loaded this input file, return it.
- if (F.InputFilesLoaded[ID - 1].getFile())
- return F.InputFilesLoaded[ID - 1];
+ if (F.InputFilesLoaded[ID-1].getFile())
+ return F.InputFilesLoaded[ID-1];
- if (F.InputFilesLoaded[ID - 1].isNotFound())
+ if (F.InputFilesLoaded[ID-1].isNotFound())
return InputFile();
// Go find this input file.
@@ -2752,7 +2748,7 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
Error(ErrorStr);
}
// Record that we didn't find the file.
- F.InputFilesLoaded[ID - 1] = InputFile::getNotFound();
+ F.InputFilesLoaded[ID-1] = InputFile::getNotFound();
return InputFile();
}
@@ -2869,7 +2865,7 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
<< *Filename << ImportStack[0]->FileName;
for (unsigned I = 1; I < ImportStack.size(); ++I)
Diag(diag::note_pch_required_by)
- << ImportStack[I - 1]->FileName << ImportStack[I]->FileName;
+ << ImportStack[I-1]->FileName << ImportStack[I]->FileName;
}
Diag(diag::note_pch_rebuild_required) << TopLevelPCHName;
@@ -2883,7 +2879,7 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
InputFile IF = InputFile(*File, Overridden || Transient, IsOutOfDate);
// Note that we've loaded this input file.
- F.InputFilesLoaded[ID - 1] = IF;
+ F.InputFilesLoaded[ID-1] = IF;
return IF;
}
@@ -2923,20 +2919,14 @@ std::string ASTReader::ResolveImportedPathAndAllocate(SmallString<0> &Buf,
static bool isDiagnosedResult(ASTReader::ASTReadResult ARR, unsigned Caps) {
switch (ARR) {
- case ASTReader::Failure:
- return true;
- case ASTReader::Missing:
- return !(Caps & ASTReader::ARR_Missing);
- case ASTReader::OutOfDate:
- return !(Caps & ASTReader::ARR_OutOfDate);
- case ASTReader::VersionMismatch:
- return !(Caps & ASTReader::ARR_VersionMismatch);
+ case ASTReader::Failure: return true;
+ case ASTReader::Missing: return !(Caps & ASTReader::ARR_Missing);
+ case ASTReader::OutOfDate: return !(Caps & ASTReader::ARR_OutOfDate);
+ case ASTReader::VersionMismatch: return !(Caps & ASTReader::ARR_VersionMismatch);
case ASTReader::ConfigurationMismatch:
return !(Caps & ASTReader::ARR_ConfigurationMismatch);
- case ASTReader::HadErrors:
- return true;
- case ASTReader::Success:
- return false;
+ case ASTReader::HadErrors: return true;
+ case ASTReader::Success: return false;
}
llvm_unreachable("unknown ASTReadResult");
@@ -3029,9 +3019,11 @@ ASTReader::ASTReadResult ASTReader::ReadOptionsBlock(
}
}
-ASTReader::ASTReadResult ASTReader::ReadControlBlock(
- ModuleFile &F, SmallVectorImpl<ImportedModule> &Loaded,
- const ModuleFile *ImportedBy, unsigned ClientLoadCapabilities) {
+ASTReader::ASTReadResult
+ASTReader::ReadControlBlock(ModuleFile &F,
+ SmallVectorImpl<ImportedModule> &Loaded,
+ const ModuleFile *ImportedBy,
+ unsigned ClientLoadCapabilities) {
BitstreamCursor &Stream = F.Stream;
if (llvm::Error Err = Stream.EnterSubBlock(CONTROL_BLOCK_ID)) {
@@ -3103,7 +3095,7 @@ ASTReader::ASTReadResult ASTReader::ReadControlBlock(
N = NumUserInputs;
for (unsigned I = 0; I < N; ++I) {
- InputFile IF = getInputFile(F, I + 1, Complain);
+ InputFile IF = getInputFile(F, I+1, Complain);
if (!IF.getFile() || IF.isOutOfDate())
return OutOfDate;
}
@@ -3288,8 +3280,7 @@ ASTReader::ASTReadResult ASTReader::ReadControlBlock(
// explicit name to file mappings. Also, we will still verify the
// size/signature making sure it is essentially the same file but
// perhaps in a different location.
- if (ImportedKind == MK_PrebuiltModule ||
- ImportedKind == MK_ExplicitModule)
+ if (ImportedKind == MK_PrebuiltModule || ImportedKind == MK_ExplicitModule)
ImportedFile = PP.getHeaderSearchInfo().getPrebuiltModuleFileName(
ImportedName, /*FileMapOnly*/ !IsImportingStdCXXModule);
@@ -3322,9 +3313,9 @@ ASTReader::ASTReadResult ASTReader::ReadControlBlock(
Capabilities &= ~ARR_Missing;
// Load the AST file.
- auto Result =
- ReadASTCore(ImportedFile, ImportedKind, ImportLoc, &F, Loaded,
- StoredSize, StoredModTime, StoredSignature, Capabilities);
+ auto Result = ReadASTCore(ImportedFile, ImportedKind, ImportLoc, &F,
+ Loaded, StoredSize, StoredModTime,
+ StoredSignature, Capabilities);
// If we diagnosed a problem, produce a backtrace.
bool recompilingFinalized =
@@ -3337,20 +3328,14 @@ ASTReader::ASTReadResult ASTReader::ReadControlBlock(
Diag(diag::note_module_file_conflict);
switch (Result) {
- case Failure:
- return Failure;
+ case Failure: return Failure;
// If we have to ignore the dependency, we'll have to ignore this too.
case Missing:
- case OutOfDate:
- return OutOfDate;
- case VersionMismatch:
- return VersionMismatch;
- case ConfigurationMismatch:
- return ConfigurationMismatch;
- case HadErrors:
- return HadErrors;
- case Success:
- break;
+ case OutOfDate: return OutOfDate;
+ case VersionMismatch: return VersionMismatch;
+ case ConfigurationMismatch: return ConfigurationMismatch;
+ case HadErrors: return HadErrors;
+ case Success: break;
}
break;
}
@@ -3416,8 +3401,8 @@ ASTReader::ASTReadResult ASTReader::ReadControlBlock(
}
case MODULE_MAP_FILE:
- if (ASTReadResult Result = ReadModuleMapFileBlock(Record, F, ImportedBy,
- ClientLoadCapabilities))
+ if (ASTReadResult Result =
+ ReadModuleMapFileBlock(Record, F, ImportedBy, ClientLoadCapabilities))
return Result;
break;
@@ -3505,8 +3490,8 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
if (llvm::Error Err = ReadBlockAbbrevs(F.PreprocessorDetailCursor,
PREPROCESSOR_DETAIL_BLOCK_ID))
return Err;
- F.PreprocessorDetailStartOffset =
- F.PreprocessorDetailCursor.GetCurrentBitNo();
+ F.PreprocessorDetailStartOffset
+ = F.PreprocessorDetailCursor.GetCurrentBitNo();
if (!PP.getPreprocessingRecord())
PP.createPreprocessingRecord();
@@ -3580,7 +3565,7 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
}
switch (RecordType) {
- default: // Default behavior: ignore.
+ default: // Default behavior: ignore.
break;
case TYPE_OFFSET: {
@@ -3626,7 +3611,7 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
case UPDATE_VISIBLE: {
unsigned Idx = 0;
GlobalDeclID ID = ReadDeclID(F, Record, Idx);
- auto *Data = (const unsigned char *)Blob.data();
+ auto *Data = (const unsigned char*)Blob.data();
PendingVisibleUpdates[ID].push_back(UpdateData{&F, Data});
// If we've already loaded the decl, perform the updates when we finish
// loading this block.
@@ -3696,7 +3681,8 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
if (Record[0]) {
F.IdentifierLookupTable = ASTIdentifierLookupTable::Create(
F.IdentifierTableData + Record[0],
- F.IdentifierTableData + sizeof(uint32_t), F.IdentifierTableData,
+ F.IdentifierTableData + sizeof(uint32_t),
+ F.IdentifierTableData,
ASTIdentifierLookupTrait(*this, F));
PP.getIdentifierTable().setExternalIdentifierLookup(this);
@@ -3713,8 +3699,8 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
F.BaseIdentifierID = getTotalNumIdentifiers();
if (F.LocalNumIdentifiers > 0)
- IdentifiersLoaded.resize(IdentifiersLoaded.size() +
- F.LocalNumIdentifiers);
+ IdentifiersLoaded.resize(IdentifiersLoaded.size()
+ + F.LocalNumIdentifiers);
break;
}
@@ -3792,9 +3778,9 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
// Translate the weak, undeclared identifiers into global IDs.
for (unsigned I = 0, N = Record.size(); I < N; /* in loop */) {
WeakUndeclaredIdentifiers.push_back(
- getGlobalIdentifierID(F, Record[I++]));
+ getGlobalIdentifierID(F, Record[I++]));
WeakUndeclaredIdentifiers.push_back(
- getGlobalIdentifierID(F, Record[I++]));
+ getGlobalIdentifierID(F, Record[I++]));
WeakUndeclaredIdentifiers.push_back(
ReadSourceLocation(F, Record, I).getRawEncoding());
}
@@ -3809,13 +3795,13 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
if (F.LocalNumSelectors > 0) {
// Introduce the global -> local mapping for selectors within this
// module.
- GlobalSelectorMap.insert(
- std::make_pair(getTotalNumSelectors() + 1, &F));
+ GlobalSelectorMap.insert(std::make_pair(getTotalNumSelectors()+1, &F));
// Introduce the local -> global mapping for selectors within this
// module.
- F.SelectorRemap.insertOrReplace(std::make_pair(
- LocalBaseSelectorID, F.BaseSelectorID - LocalBaseSelectorID));
+ F.SelectorRemap.insertOrReplace(
+ std::make_pair(LocalBaseSelectorID,
+ F.BaseSelectorID - LocalBaseSelectorID));
SelectorsLoaded.resize(SelectorsLoaded.size() + F.LocalNumSelectors);
}
@@ -3825,19 +3811,21 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
case METHOD_POOL:
F.SelectorLookupTableData = (const unsigned char *)Blob.data();
if (Record[0])
- F.SelectorLookupTable = ASTSelectorLookupTable::Create(
- F.SelectorLookupTableData + Record[0], F.SelectorLookupTableData,
- ASTSelectorLookupTrait(*this, F));
+ F.SelectorLookupTable
+ = ASTSelectorLookupTable::Create(
+ F.SelectorLookupTableData + Record[0],
+ F.SelectorLookupTableData,
+ ASTSelectorLookupTrait(*this, F));
TotalNumMethodPoolEntries += Record[1];
break;
case REFERENCED_SELECTOR_POOL:
if (!Record.empty()) {
for (unsigned Idx = 0, N = Record.size() - 1; Idx < N; /* in loop */) {
- ReferencedSelectorsData.push_back(
- getGlobalSelectorID(F, Record[Idx++]));
- ReferencedSelectorsData.push_back(
- ReadSourceLocation(F, Record, Idx).getRawEncoding());
+ ReferencedSelectorsData.push_back(getGlobalSelectorID(F,
+ Record[Idx++]));
+ ReferencedSelectorsData.push_back(ReadSourceLocation(F, Record, Idx).
+ getRawEncoding());
}
}
break;
@@ -3922,10 +3910,9 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
// SLocEntryBaseOffset is lower than MaxLoadedOffset and decreasing.
assert((F.SLocEntryBaseOffset & SourceLocation::MacroIDBit) == 0);
- GlobalSLocOffsetMap.insert(std::make_pair(SourceManager::MaxLoadedOffset -
- F.SLocEntryBaseOffset -
- SLocSpaceSize,
- &F));
+ GlobalSLocOffsetMap.insert(
+ std::make_pair(SourceManager::MaxLoadedOffset - F.SLocEntryBaseOffset
+ - SLocSpaceSize,&F));
TotalNumSLocEntries += F.LocalNumSLocEntries;
break;
@@ -3996,8 +3983,9 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
PP.createPreprocessingRecord();
if (!PP.getPreprocessingRecord()->getExternalSource())
PP.getPreprocessingRecord()->SetExternalSource(*this);
- StartingID = PP.getPreprocessingRecord()->allocateLoadedEntities(
- F.NumPreprocessedEntities);
+ StartingID
+ = PP.getPreprocessingRecord()
+ ->allocateLoadedEntities(F.NumPreprocessedEntities);
F.BasePreprocessedEntityID = StartingID;
if (F.NumPreprocessedEntities > 0) {
@@ -4007,8 +3995,8 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
// Introduce the local -> global mapping for preprocessed entities in
// this module.
- F.PreprocessedEntityRemap.insertOrReplace(std::make_pair(
- LocalBasePreprocessedEntityID,
+ F.PreprocessedEntityRemap.insertOrReplace(
+ std::make_pair(LocalBasePreprocessedEntityID,
F.BasePreprocessedEntityID - LocalBasePreprocessedEntityID));
}
@@ -4016,7 +4004,7 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
}
case PPD_SKIPPED_RANGES: {
- F.PreprocessedSkippedRangeOffsets = (const PPSkippedRange *)Blob.data();
+ F.PreprocessedSkippedRangeOffsets = (const PPSkippedRange*)Blob.data();
assert(Blob.size() % sizeof(PPSkippedRange) == 0);
F.NumPreprocessedSkippedRanges = Blob.size() / sizeof(PPSkippedRange);
@@ -4024,9 +4012,8 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
PP.createPreprocessingRecord();
if (!PP.getPreprocessingRecord()->getExternalSource())
PP.getPreprocessingRecord()->SetExternalSource(*this);
- F.BasePreprocessedSkippedRangeID =
- PP.getPreprocessingRecord()->allocateSkippedRanges(
- F.NumPreprocessedSkippedRanges);
+ F.BasePreprocessedSkippedRangeID = PP.getPreprocessingRecord()
+ ->allocateSkippedRanges(F.NumPreprocessedSkippedRanges);
if (F.NumPreprocessedSkippedRanges > 0)
GlobalSkippedRangeMap.insert(
@@ -4144,7 +4131,7 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
break;
case OPENCL_EXTENSIONS:
- for (unsigned I = 0, E = Record.size(); I != E;) {
+ for (unsigned I = 0, E = Record.size(); I != E; ) {
auto Name = ReadString(Record, I);
auto &OptInfo = OpenCLExtensions.OptMap[Name];
OptInfo.Supported = Record[I++] != 0;
@@ -4183,8 +4170,7 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
const uint64_t Count = Record[I++];
DelayedDeleteExprs.push_back(Count);
for (uint64_t C = 0; C < Count; ++C) {
- DelayedDeleteExprs.push_back(
- ReadSourceLocation(F, Record, I).getRawEncoding());
+ DelayedDeleteExprs.push_back(ReadSourceLocation(F, Record, I).getRawEncoding());
bool IsArrayForm = Record[I++] == 1;
DelayedDeleteExprs.push_back(IsArrayForm);
}
@@ -4232,7 +4218,8 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
// Introduce the local -> global mapping for macros within this module.
F.MacroRemap.insertOrReplace(
- std::make_pair(LocalBaseMacroID, F.BaseMacroID - LocalBaseMacroID));
+ std::make_pair(LocalBaseMacroID,
+ F.BaseMacroID - LocalBaseMacroID));
MacrosLoaded.resize(MacrosLoaded.size() + F.LocalNumMacros);
}
@@ -4336,7 +4323,7 @@ void ASTReader::ReadModuleOffsetMap(ModuleFile &F) const {
assert(!F.ModuleOffsetMap.empty() && "no module offset map to read");
// Additional remapping information.
- const unsigned char *Data = (const unsigned char *)F.ModuleOffsetMap.data();
+ const unsigned char *Data = (const unsigned char*)F.ModuleOffsetMap.data();
const unsigned char *DataEnd = Data + F.ModuleOffsetMap.size();
F.ModuleOffsetMap = StringRef();
@@ -4357,7 +4344,7 @@ void ASTReader::ReadModuleOffsetMap(ModuleFile &F) const {
ModuleKind Kind = static_cast<ModuleKind>(
endian::readNext<uint8_t, llvm::endianness::little>(Data));
uint16_t Len = endian::readNext<uint16_t, llvm::endianness::little>(Data);
- StringRef Name = StringRef((const char *)Data, Len);
+ StringRef Name = StringRef((const char*)Data, Len);
Data += Len;
ModuleFile *OM = (Kind == MK_PrebuiltModule || Kind == MK_ExplicitModule ||
Kind == MK_ImplicitModule
@@ -4385,8 +4372,8 @@ void ASTReader::ReadModuleOffsetMap(ModuleFile &F) const {
RemapBuilder &Remap) {
constexpr uint32_t None = std::numeric_limits<uint32_t>::max();
if (Offset != None)
- Remap.insert(
- std::make_pair(Offset, static_cast<int>(BaseOffset - Offset)));
+ Remap.insert(std::make_pair(Offset,
+ static_cast<int>(BaseOffset - Offset)));
};
mapOffset(MacroIDOffset, OM->BaseMacroID, MacroRemap);
@@ -4426,8 +4413,8 @@ ASTReader::ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F,
if (!canRecoverFromOutOfDate(F.FileName, ClientLoadCapabilities)) {
if (auto ASTFE = M ? M->getASTFile() : std::nullopt) {
// This module was defined by an imported (explicit) module.
- Diag(diag::err_module_file_conflict)
- << F.ModuleName << F.FileName << ASTFE->getName();
+ Diag(diag::err_module_file_conflict) << F.ModuleName << F.FileName
+ << ASTFE->getName();
} else {
// This module was built with a different module map.
Diag(diag::err_imported_module_not_found)
@@ -4468,8 +4455,7 @@ ASTReader::ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F,
auto SF = FileMgr.getOptionalFileRef(Filename, false, false);
if (!SF) {
if (!canRecoverFromOutOfDate(F.FileName, ClientLoadCapabilities))
- Error("could not find file '" + Filename +
- "' referenced by AST file");
+ Error("could not find file '" + Filename +"' referenced by AST file");
return OutOfDate;
}
AdditionalStoredMaps.insert(*SF);
@@ -4484,7 +4470,7 @@ ASTReader::ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F,
if (!AdditionalStoredMaps.erase(ModMap)) {
if (!canRecoverFromOutOfDate(F.FileName, ClientLoadCapabilities))
Diag(diag::err_module_different_modmap)
- << F.ModuleName << /*new*/ 0 << ModMap.getName();
+ << F.ModuleName << /*new*/0 << ModMap.getName();
return OutOfDate;
}
}
@@ -4495,7 +4481,7 @@ ASTReader::ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F,
for (FileEntryRef ModMap : AdditionalStoredMaps) {
if (!canRecoverFromOutOfDate(F.FileName, ClientLoadCapabilities))
Diag(diag::err_module_different_modmap)
- << F.ModuleName << /*not new*/ 1 << ModMap.getName();
+ << F.ModuleName << /*not new*/1 << ModMap.getName();
return OutOfDate;
}
}
@@ -4514,8 +4500,8 @@ static void moveMethodToBackOfGlobalList(Sema &S, ObjCMethodDecl *Method) {
return;
// Retrieve the appropriate method list.
- ObjCMethodList &Start =
- Method->isInstanceMethod() ? Known->second.first : Known->second.second;
+ ObjCMethodList &Start = Method->isInstanceMethod()? Known->second.first
+ : Known->second.second;
bool Found = false;
for (ObjCMethodList *List = &Start; List; List = List->getNext()) {
if (!Found) {
@@ -4585,9 +4571,8 @@ void ASTReader::makeModuleVisible(Module *Mod,
// Push any exported modules onto the stack to be marked as visible.
SmallVector<Module *, 16> Exports;
Mod->getExportedModules(Exports);
- for (SmallVectorImpl<Module *>::iterator I = Exports.begin(),
- E = Exports.end();
- I != E; ++I) {
+ for (SmallVectorImpl<Module *>::iterator
+ I = Exports.begin(), E = Exports.end(); I != E; ++I) {
Module *Exported = *I;
if (Visited.insert(Exported).second)
Stack.push_back(Exported);
@@ -4617,13 +4602,14 @@ bool ASTReader::loadGlobalIndex() {
if (GlobalIndex)
return false;
- if (TriedLoadingGlobalIndex || !UseGlobalIndex || !PP.getLangOpts().Modules)
+ if (TriedLoadingGlobalIndex || !UseGlobalIndex ||
+ !PP.getLangOpts().Modules)
return true;
// Try to load the global index.
TriedLoadingGlobalIndex = true;
- StringRef ModuleCachePath =
- getPreprocessor().getHeaderSearchInfo().getModuleCachePath();
+ StringRef ModuleCachePath
+ = getPreprocessor().getHeaderSearchInfo().getModuleCachePath();
std::pair<GlobalModuleIndex *, llvm::Error> Result =
GlobalModuleIndex::readIndex(ModuleCachePath);
if (llvm::Error Err = std::move(Result.second)) {
@@ -4638,8 +4624,8 @@ bool ASTReader::loadGlobalIndex() {
}
bool ASTReader::isGlobalIndexUnavailable() const {
- return PP.getLangOpts().Modules && UseGlobalIndex && !hasGlobalIndex() &&
- TriedLoadingGlobalIndex;
+ return PP.getLangOpts().Modules && UseGlobalIndex &&
+ !hasGlobalIndex() && TriedLoadingGlobalIndex;
}
/// Given a cursor at the start of an AST file, scan ahead and drop the
@@ -4845,8 +4831,7 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName, ModuleKind Type,
// Resolve any unresolved module exports.
for (unsigned I = 0, N = UnresolvedModuleRefs.size(); I != N; ++I) {
UnresolvedModuleRef &Unresolved = UnresolvedModuleRefs[I];
- SubmoduleID GlobalID =
- getGlobalSubmoduleID(*Unresolved.File, Unresolved.ID);
+ SubmoduleID GlobalID = getGlobalSubmoduleID(*Unresolved.File,Unresolved.ID);
Module *ResolvedMod = getSubmodule(GlobalID);
switch (Unresolved.Kind) {
@@ -4872,7 +4857,7 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName, ModuleKind Type,
case UnresolvedModuleRef::Export:
if (ResolvedMod || Unresolved.IsWildcard)
Unresolved.Mod->Exports.push_back(
- Module::ExportDecl(ResolvedMod, Unresolved.IsWildcard));
+ Module::ExportDecl(ResolvedMod, Unresolved.IsWildcard));
continue;
}
}
@@ -4964,16 +4949,22 @@ static unsigned moduleKindForDiagnostic(ModuleKind Kind) {
llvm_unreachable("unknown module kind");
}
-ASTReader::ASTReadResult ASTReader::ReadASTCore(
- StringRef FileName, ModuleKind Type, SourceLocation ImportLoc,
- ModuleFile *ImportedBy, SmallVectorImpl<ImportedModule> &Loaded,
- off_t ExpectedSize, time_t ExpectedModTime,
- ASTFileSignature ExpectedSignature, unsigned ClientLoadCapabilities) {
+ASTReader::ASTReadResult
+ASTReader::ReadASTCore(StringRef FileName,
+ ModuleKind Type,
+ SourceLocation ImportLoc,
+ ModuleFile *ImportedBy,
+ SmallVectorImpl<ImportedModule> &Loaded,
+ off_t ExpectedSize, time_t ExpectedModTime,
+ ASTFileSignature ExpectedSignature,
+ unsigned ClientLoadCapabilities) {
ModuleFile *M;
std::string ErrorStr;
- ModuleManager::AddModuleResult AddResult = ModuleMgr.addModule(
- FileName, Type, ImportLoc, ImportedBy, getGeneration(), ExpectedSize,
- ExpectedModTime, ExpectedSignature, readASTFileSignature, M, ErrorStr);
+ ModuleManager::AddModuleResult AddResult
+ = ModuleMgr.addModule(FileName, Type, ImportLoc, ImportedBy,
+ getGeneration(), ExpectedSize, ExpectedModTime,
+ ExpectedSignature, readASTFileSignature,
+ M, ErrorStr);
switch (AddResult) {
case ModuleManager::AlreadyLoaded:
@@ -5074,18 +5065,12 @@ ASTReader::ASTReadResult ASTReader::ReadASTCore(
}
break;
- case Failure:
- return Failure;
- case Missing:
- return Missing;
- case OutOfDate:
- return OutOfDate;
- case VersionMismatch:
- return VersionMismatch;
- case ConfigurationMismatch:
- return ConfigurationMismatch;
- case HadErrors:
- return HadErrors;
+ case Failure: return Failure;
+ case Missing: return Missing;
+ case OutOfDate: return OutOfDate;
+ case VersionMismatch: return VersionMismatch;
+ case ConfigurationMismatch: return ConfigurationMismatch;
+ case HadErrors: return HadErrors;
}
break;
@@ -5271,12 +5256,11 @@ ASTReader::ASTReadResult ASTReader::readUnhashedControlBlockImpl(
}
/// Parse a record and blob containing module file extension metadata.
-static bool
-parseModuleFileExtensionMetadata(const SmallVectorImpl<uint64_t> &Record,
- StringRef Blob,
- ModuleFileExtensionMetadata &Metadata) {
- if (Record.size() < 4)
- return true;
+static bool parseModuleFileExtensionMetadata(
+ const SmallVectorImpl<uint64_t> &Record,
+ StringRef Blob,
+ ModuleFileExtensionMetadata &Metadata) {
+ if (Record.size() < 4) return true;
Metadata.MajorVersion = Record[0];
Metadata.MinorVersion = Record[1];
@@ -5284,8 +5268,7 @@ parseModuleFileExtensionMetadata(const SmallVectorImpl<uint64_t> &Record,
unsigned BlockNameLen = Record[2];
unsigned UserInfoLen = Record[3];
- if (BlockNameLen + UserInfoLen > Blob.size())
- return true;
+ if (BlockNameLen + UserInfoLen > Blob.size()) return true;
Metadata.BlockName = std::string(Blob.data(), Blob.data() + BlockNameLen);
Metadata.UserInfo = std::string(Blob.data() + BlockNameLen,
@@ -5333,12 +5316,11 @@ llvm::Error ASTReader::ReadExtensionBlock(ModuleFile &F) {
// Find a module file extension with this block name.
auto Known = ModuleFileExtensions.find(Metadata.BlockName);
- if (Known == ModuleFileExtensions.end())
- break;
+ if (Known == ModuleFileExtensions.end()) break;
// Form a reader.
- if (auto Reader = Known->second->createExtensionReader(Metadata, *this, F,
- Stream)) {
+ if (auto Reader = Known->second->createExtensionReader(Metadata, *this,
+ F, Stream)) {
F.ExtensionReaders.push_back(std::move(Reader));
}
@@ -5472,7 +5454,7 @@ void ASTReader::InitializeContext() {
if (!CUDASpecialDeclRefs.empty()) {
assert(CUDASpecialDeclRefs.size() == 1 && "More decl refs than expected!");
Context.setcudaConfigureCallDecl(
- cast<FunctionDecl>(GetDecl(CUDASpecialDeclRefs[0])));
+ cast<FunctionDecl>(GetDecl(CUDASpecialDeclRefs[0])));
}
// Re-export any modules that were imported by a non-module AST file.
@@ -5610,60 +5592,61 @@ std::string ASTReader::getOriginalSourceFile(
namespace {
-class SimplePCHValidator : public ASTReaderListener {
- const LangOptions &ExistingLangOpts;
- const TargetOptions &ExistingTargetOpts;
- const PreprocessorOptions &ExistingPPOpts;
- std::string ExistingModuleCachePath;
- FileManager &FileMgr;
- bool StrictOptionMatches;
-
-public:
- SimplePCHValidator(const LangOptions &ExistingLangOpts,
- const TargetOptions &ExistingTargetOpts,
- const PreprocessorOptions &ExistingPPOpts,
- StringRef ExistingModuleCachePath, FileManager &FileMgr,
- bool StrictOptionMatches)
- : ExistingLangOpts(ExistingLangOpts),
- ExistingTargetOpts(ExistingTargetOpts), ExistingPPOpts(ExistingPPOpts),
- ExistingModuleCachePath(ExistingModuleCachePath), FileMgr(FileMgr),
- StrictOptionMatches(StrictOptionMatches) {}
-
- bool ReadLanguageOptions(const LangOptions &LangOpts,
+ class SimplePCHValidator : public ASTReaderListener {
+ const LangOptions &ExistingLangOpts;
+ const TargetOptions &ExistingTargetOpts;
+ const PreprocessorOptions &ExistingPPOpts;
+ std::string ExistingModuleCachePath;
+ FileManager &FileMgr;
+ bool StrictOptionMatches;
+
+ public:
+ SimplePCHValidator(const LangOptions &ExistingLangOpts,
+ const TargetOptions &ExistingTargetOpts,
+ const PreprocessorOptions &ExistingPPOpts,
+ StringRef ExistingModuleCachePath, FileManager &FileMgr,
+ bool StrictOptionMatches)
+ : ExistingLangOpts(ExistingLangOpts),
+ ExistingTargetOpts(ExistingTargetOpts),
+ ExistingPPOpts(ExistingPPOpts),
+ ExistingModuleCachePath(ExistingModuleCachePath), FileMgr(FileMgr),
+ StrictOptionMatches(StrictOptionMatches) {}
+
+ bool ReadLanguageOptions(const LangOptions &LangOpts,
+ StringRef ModuleFilename, bool Complain,
+ bool AllowCompatibleDifferences) override {
+ return checkLanguageOptions(ExistingLangOpts, LangOpts, ModuleFilename,
+ nullptr, AllowCompatibleDifferences);
+ }
+
+ bool ReadTargetOptions(const TargetOptions &TargetOpts,
StringRef ModuleFilename, bool Complain,
bool AllowCompatibleDifferences) override {
- return checkLanguageOptions(ExistingLangOpts, LangOpts, ModuleFilename,
+ return checkTargetOptions(ExistingTargetOpts, TargetOpts, ModuleFilename,
nullptr, AllowCompatibleDifferences);
- }
-
- bool ReadTargetOptions(const TargetOptions &TargetOpts,
- StringRef ModuleFilename, bool Complain,
- bool AllowCompatibleDifferences) override {
- return checkTargetOptions(ExistingTargetOpts, TargetOpts, ModuleFilename,
- nullptr, AllowCompatibleDifferences);
- }
+ }
- bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
- StringRef ModuleFilename,
- StringRef SpecificModuleCachePath,
- bool Complain) override {
- return checkModuleCachePath(FileMgr.getVirtualFileSystem(),
- SpecificModuleCachePath,
- ExistingModuleCachePath, ModuleFilename,
- nullptr, ExistingLangOpts, ExistingPPOpts);
- }
-
- bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
- StringRef ModuleFilename, bool ReadMacros,
- bool Complain,
- std::string &SuggestedPredefines) override {
- return checkPreprocessorOptions(
- PPOpts, ExistingPPOpts, ModuleFilename, ReadMacros, /*Diags=*/nullptr,
- FileMgr, SuggestedPredefines, ExistingLangOpts,
- StrictOptionMatches ? OptionValidateStrictMatches
- : OptionValidateContradictions);
- }
-};
+ bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
+ StringRef ModuleFilename,
+ StringRef SpecificModuleCachePath,
+ bool Complain) override {
+ return checkModuleCachePath(FileMgr.getVirtualFileSystem(),
+ SpecificModuleCachePath,
+ ExistingModuleCachePath, ModuleFilename,
+ nullptr, ExistingLangOpts, ExistingPPOpts);
+ }
+
+ bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
+ StringRef ModuleFilename, bool ReadMacros,
+ bool Complain,
+ std::string &SuggestedPredefines) override {
+ return checkPreprocessorOptions(
+ PPOpts, ExistingPPOpts, ModuleFilename, ReadMacros, /*Diags=*/nullptr,
+ FileMgr, SuggestedPredefines, ExistingLangOpts,
+ StrictOptionMatches ? OptionValidateStrictMatches
+ : OptionValidateContradictions);
+ }
+ };
} // namespace
@@ -5772,8 +5755,7 @@ bool ASTReader::readASTFileControlBlock(
break;
}
- if (DoneWithControlBlock)
- break;
+ if (DoneWithControlBlock) break;
Record.clear();
StringRef Blob;
@@ -5932,24 +5914,24 @@ bool ASTReader::readASTFileControlBlock(
break;
}
- Record.clear();
- StringRef Blob;
- Expected<unsigned> MaybeRecCode =
- Stream.readRecord(Entry.ID, Record, &Blob);
- if (!MaybeRecCode) {
- // FIXME this drops the error.
- return true;
- }
- switch (MaybeRecCode.get()) {
- case EXTENSION_METADATA: {
- ModuleFileExtensionMetadata Metadata;
- if (parseModuleFileExtensionMetadata(Record, Blob, Metadata))
- return true;
-
- Listener.readModuleFileExtension(Metadata);
- break;
- }
- }
+ Record.clear();
+ StringRef Blob;
+ Expected<unsigned> MaybeRecCode =
+ Stream.readRecord(Entry.ID, Record, &Blob);
+ if (!MaybeRecCode) {
+ // FIXME this drops the error.
+ return true;
+ }
+ switch (MaybeRecCode.get()) {
+ case EXTENSION_METADATA: {
+ ModuleFileExtensionMetadata Metadata;
+ if (parseModuleFileExtensionMetadata(Record, Blob, Metadata))
+ return true;
+
+ Listener.readModuleFileExtension(Metadata);
+ break;
+ }
+ }
}
}
Stream = SavedStream;
@@ -6040,7 +6022,7 @@ llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile &F,
continue;
switch (Kind) {
- default: // Default behavior: ignore.
+ default: // Default behavior: ignore.
break;
case SUBMODULE_DEFINITION: {
@@ -6164,8 +6146,7 @@ llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile &F,
case SUBMODULE_HEADER:
case SUBMODULE_EXCLUDED_HEADER:
case SUBMODULE_PRIVATE_HEADER:
- // We lazily associate headers with their modules via the HeaderInfo
- // table.
+ // We lazily associate headers with their modules via the HeaderInfo table.
// FIXME: Re-evaluate this section; maybe only store InputFile IDs instead
// of complete filenames or remove it entirely.
break;
@@ -6202,13 +6183,13 @@ llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile &F,
if (F.LocalNumSubmodules > 0) {
// Introduce the global -> local mapping for submodules within this
// module.
- GlobalSubmoduleMap.insert(
- std::make_pair(getTotalNumSubmodules() + 1, &F));
+ GlobalSubmoduleMap.insert(std::make_pair(getTotalNumSubmodules()+1,&F));
// Introduce the local -> global mapping for submodules within this
// module.
- F.SubmoduleRemap.insertOrReplace(std::make_pair(
- LocalBaseSubmoduleID, F.BaseSubmoduleID - LocalBaseSubmoduleID));
+ F.SubmoduleRemap.insertOrReplace(
+ std::make_pair(LocalBaseSubmoduleID,
+ F.BaseSubmoduleID - LocalBaseSubmoduleID));
SubmodulesLoaded.resize(SubmodulesLoaded.size() + F.LocalNumSubmodules);
}
@@ -6313,8 +6294,9 @@ bool ASTReader::ParseLanguageOptions(const RecordData &Record,
bool AllowCompatibleDifferences) {
LangOptions LangOpts;
unsigned Idx = 0;
-#define LANGOPT(Name, Bits, Default, Description) LangOpts.Name = Record[Idx++];
-#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
+#define LANGOPT(Name, Bits, Default, Description) \
+ LangOpts.Name = Record[Idx++];
+#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
LangOpts.set##Name(static_cast<LangOptions::Type>(Record[Idx++]));
#include "clang/Basic/LangOptions.def"
#define SANITIZER(NAME, ID) \
@@ -6324,7 +6306,7 @@ bool ASTReader::ParseLanguageOptions(const RecordData &Record,
for (unsigned N = Record[Idx++]; N; --N)
LangOpts.ModuleFeatures.push_back(ReadString(Record, Idx));
- ObjCRuntime::Kind runtimeKind = (ObjCRuntime::Kind)Record[Idx++];
+ ObjCRuntime::Kind runtimeKind = (ObjCRuntime::Kind) Record[Idx++];
VersionTuple runtimeVersion = ReadVersionTuple(Record, Idx);
LangOpts.ObjCRuntime = ObjCRuntime(runtimeKind, runtimeVersion);
@@ -6332,7 +6314,8 @@ bool ASTReader::ParseLanguageOptions(const RecordData &Record,
// Comment options.
for (unsigned N = Record[Idx++]; N; --N) {
- LangOpts.CommentOpts.BlockCommandNames.push_back(ReadString(Record, Idx));
+ LangOpts.CommentOpts.BlockCommandNames.push_back(
+ ReadString(Record, Idx));
}
LangOpts.CommentOpts.ParseAllComments = Record[Idx++];
@@ -6374,7 +6357,7 @@ bool ASTReader::ParseDiagnosticOptions(const RecordData &Record,
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts(new DiagnosticOptions);
unsigned Idx = 0;
#define DIAGOPT(Name, Bits, Default) DiagOpts->Name = Record[Idx++];
-#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
+#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
DiagOpts->set##Name(static_cast<Type>(Record[Idx++]));
#include "clang/Basic/DiagnosticOptions.def"
@@ -6427,8 +6410,8 @@ bool ASTReader::ParseHeaderSearchPaths(const RecordData &Record, bool Complain,
// Include entries.
for (unsigned N = Record[Idx++]; N; --N) {
std::string Path = ReadString(Record, Idx);
- frontend::IncludeDirGroup Group =
- static_cast<frontend::IncludeDirGroup>(Record[Idx++]);
+ frontend::IncludeDirGroup Group
+ = static_cast<frontend::IncludeDirGroup>(Record[Idx++]);
bool IsFramework = Record[Idx++];
bool IgnoreSysRoot = Record[Idx++];
HSOpts.UserEntries.emplace_back(std::move(Path), Group, IsFramework,
@@ -6483,7 +6466,7 @@ bool ASTReader::ParsePreprocessorOptions(const RecordData &Record,
PPOpts.DetailedRecord = Record[Idx++];
PPOpts.ImplicitPCHInclude = ReadString(Record, Idx);
PPOpts.ObjCXXARCStandardLibrary =
- static_cast<ObjCXXARCStandardLibraryKind>(Record[Idx++]);
+ static_cast<ObjCXXARCStandardLibraryKind>(Record[Idx++]);
SuggestedPredefines.clear();
return Listener.ReadPreprocessorOptions(PPOpts, ModuleFilename, ReadMacros,
Complain, SuggestedPredefines);
@@ -6491,8 +6474,8 @@ bool ASTReader::ParsePreprocessorOptions(const RecordData &Record,
std::pair<ModuleFile *, unsigned>
ASTReader::getModulePreprocessedEntity(unsigned GlobalIndex) {
- GlobalPreprocessedEntityMapType::iterator I =
- GlobalPreprocessedEntityMap.find(GlobalIndex);
+ GlobalPreprocessedEntityMapType::iterator
+ I = GlobalPreprocessedEntityMap.find(GlobalIndex);
assert(I != GlobalPreprocessedEntityMap.end() &&
"Corrupted global preprocessed entity map");
ModuleFile *M = I->second;
@@ -6527,7 +6510,7 @@ ASTReader::getModuleFileLevelDecls(ModuleFile &Mod) {
SourceRange ASTReader::ReadSkippedRange(unsigned GlobalIndex) {
auto I = GlobalSkippedRangeMap.find(GlobalIndex);
assert(I != GlobalSkippedRangeMap.end() &&
- "Corrupted global skipped range map");
+ "Corrupted global skipped range map");
ModuleFile *M = I->second;
unsigned LocalIndex = GlobalIndex - M->BasePreprocessedSkippedRangeID;
assert(LocalIndex < M->NumPreprocessedSkippedRanges);
@@ -6539,7 +6522,7 @@ SourceRange ASTReader::ReadSkippedRange(unsigned GlobalIndex) {
}
PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
- PreprocessedEntityID PPID = Index + 1;
+ PreprocessedEntityID PPID = Index+1;
std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
ModuleFile &M = *PPInfo.first;
unsigned LocalIndex = PPInfo.second;
@@ -6623,11 +6606,14 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
File = PP.getFileManager().getOptionalFileRef(FullFileName);
// FIXME: Stable encoding
- InclusionDirective::InclusionKind Kind =
- static_cast<InclusionDirective::InclusionKind>(Record[2]);
- InclusionDirective *ID = new (PPRec)
- InclusionDirective(PPRec, Kind, StringRef(Blob.data(), Record[0]),
- Record[1], Record[3], File, Range);
+ InclusionDirective::InclusionKind Kind
+ = static_cast<InclusionDirective::InclusionKind>(Record[2]);
+ InclusionDirective *ID
+ = new (PPRec) InclusionDirective(PPRec, Kind,
+ StringRef(Blob.data(), Record[0]),
+ Record[1], Record[3],
+ File,
+ Range);
return ID;
}
}
@@ -6642,10 +6628,10 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
/// preprocessed entities or the entities it contains are not the ones we are
/// looking for.
PreprocessedEntityID ASTReader::findNextPreprocessedEntity(
- GlobalSLocOffsetMapType::const_iterator SLocMapI) const {
+ GlobalSLocOffsetMapType::const_iterator SLocMapI) const {
++SLocMapI;
- for (GlobalSLocOffsetMapType::const_iterator EndI = GlobalSLocOffsetMap.end();
- SLocMapI != EndI; ++SLocMapI) {
+ for (GlobalSLocOffsetMapType::const_iterator
+ EndI = GlobalSLocOffsetMap.end(); SLocMapI != EndI; ++SLocMapI) {
ModuleFile &M = *SLocMapI->second;
if (M.NumPreprocessedEntities)
return M.BasePreprocessedEntityID;
@@ -6711,7 +6697,8 @@ PreprocessedEntityID ASTReader::findPreprocessedEntity(SourceLocation Loc,
pp_iterator PPI;
if (EndsAfter) {
- PPI = std::upper_bound(pp_begin, pp_end, Loc, PPEntityComp(*this, M));
+ PPI = std::upper_bound(pp_begin, pp_end, Loc,
+ PPEntityComp(*this, M));
} else {
// Do a binary search manually instead of using std::lower_bound because
// The end locations of entities may be unordered (when a macro expansion
@@ -6740,11 +6727,10 @@ PreprocessedEntityID ASTReader::findPreprocessedEntity(SourceLocation Loc,
/// Returns a pair of [Begin, End) indices of preallocated
/// preprocessed entities that \arg Range encompasses.
std::pair<unsigned, unsigned>
-ASTReader::findPreprocessedEntitiesInRange(SourceRange Range) {
+ ASTReader::findPreprocessedEntitiesInRange(SourceRange Range) {
if (Range.isInvalid())
- return std::make_pair(0, 0);
- assert(
- !SourceMgr.isBeforeInTranslationUnit(Range.getEnd(), Range.getBegin()));
+ return std::make_pair(0,0);
+ assert(!SourceMgr.isBeforeInTranslationUnit(Range.getEnd(),Range.getBegin()));
PreprocessedEntityID BeginID =
findPreprocessedEntity(Range.getBegin(), false);
@@ -6776,31 +6762,31 @@ std::optional<bool> ASTReader::isPreprocessedEntityInFileID(unsigned Index,
namespace {
-/// Visitor used to search for information about a header file.
-class HeaderFileInfoVisitor {
+ /// Visitor used to search for information about a header file.
+ class HeaderFileInfoVisitor {
FileEntryRef FE;
- std::optional<HeaderFileInfo> HFI;
+ std::optional<HeaderFileInfo> HFI;
-public:
- explicit HeaderFileInfoVisitor(FileEntryRef FE) : FE(FE) {}
+ public:
+ explicit HeaderFileInfoVisitor(FileEntryRef FE) : FE(FE) {}
- bool operator()(ModuleFile &M) {
- HeaderFileInfoLookupTable *Table =
- static_cast<HeaderFileInfoLookupTable *>(M.HeaderFileInfoTable);
- if (!Table)
- return false;
+ bool operator()(ModuleFile &M) {
+ HeaderFileInfoLookupTable *Table
+ = static_cast<HeaderFileInfoLookupTable *>(M.HeaderFileInfoTable);
+ if (!Table)
+ return false;
- // Look in the on-disk hash table for an entry for this file name.
- HeaderFileInfoLookupTable::iterator Pos = Table->find(FE);
- if (Pos == Table->end())
- return false;
+ // Look in the on-disk hash table for an entry for this file name.
+ HeaderFileInfoLookupTable::iterator Pos = Table->find(FE);
+ if (Pos == Table->end())
+ return false;
- HFI = *Pos;
- return true;
- }
+ HFI = *Pos;
+ return true;
+ }
- std::optional<HeaderFileInfo> getHeaderFileInfo() const { return HFI; }
-};
+ std::optional<HeaderFileInfo> getHeaderFileInfo() const { return HFI; }
+ };
} // namespace
@@ -6808,7 +6794,7 @@ HeaderFileInfo ASTReader::GetHeaderFileInfo(FileEntryRef FE) {
HeaderFileInfoVisitor Visitor(FE);
ModuleMgr.visit(Visitor);
if (std::optional<HeaderFileInfo> HFI = Visitor.getHeaderFileInfo())
- return *HFI;
+ return *HFI;
return HeaderFileInfo();
}
@@ -6881,16 +6867,11 @@ void ASTReader::ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag) {
// -Wblah flags.
unsigned Flags = Record[Idx++];
DiagState Initial(*Diag.getDiagnosticIDs());
- Initial.SuppressSystemWarnings = Flags & 1;
- Flags >>= 1;
- Initial.ErrorsAsFatal = Flags & 1;
- Flags >>= 1;
- Initial.WarningsAsErrors = Flags & 1;
- Flags >>= 1;
- Initial.EnableAllWarnings = Flags & 1;
- Flags >>= 1;
- Initial.IgnoreAllWarnings = Flags & 1;
- Flags >>= 1;
+ Initial.SuppressSystemWarnings = Flags & 1; Flags >>= 1;
+ Initial.ErrorsAsFatal = Flags & 1; Flags >>= 1;
+ Initial.WarningsAsErrors = Flags & 1; Flags >>= 1;
+ Initial.EnableAllWarnings = Flags & 1; Flags >>= 1;
+ Initial.IgnoreAllWarnings = Flags & 1; Flags >>= 1;
Initial.ExtBehavior = (diag::Severity)Flags;
FirstState = ReadDiagState(Initial, true);
@@ -6964,9 +6945,8 @@ ASTReader::RecordLocation ASTReader::TypeCursorForIndex(TypeID ID) {
static std::optional<Type::TypeClass> getTypeClassForCode(TypeCode code) {
switch (code) {
-#define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \
- case TYPE_##CODE_ID: \
- return Type::CLASS_ID;
+#define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \
+ case TYPE_##CODE_ID: return Type::CLASS_ID;
#include "clang/Serialization/TypeBitCodes.def"
default:
return std::nullopt;
@@ -7016,7 +6996,7 @@ QualType ASTReader::readTypeRecord(TypeID ID) {
return Context.getQualifiedType(baseType, quals);
}
- auto maybeClass = getTypeClassForCode((TypeCode)Code.get());
+ auto maybeClass = getTypeClassForCode((TypeCode) Code.get());
if (!maybeClass) {
Error("Unexpected code for type");
return QualType();
@@ -7037,13 +7017,17 @@ class TypeLocReader : public TypeLocVisitor<TypeLocReader> {
SourceLocation readSourceLocation() { return Reader.readSourceLocation(Seq); }
SourceRange readSourceRange() { return Reader.readSourceRange(Seq); }
- TypeSourceInfo *GetTypeSourceInfo() { return Reader.readTypeSourceInfo(); }
+ TypeSourceInfo *GetTypeSourceInfo() {
+ return Reader.readTypeSourceInfo();
+ }
NestedNameSpecifierLoc ReadNestedNameSpecifierLoc() {
return Reader.readNestedNameSpecifierLoc();
}
- Attr *ReadAttr() { return Reader.readAttr(); }
+ Attr *ReadAttr() {
+ return Reader.readAttr();
+ }
public:
TypeLocReader(ASTRecordReader &Reader, LocSeq *Seq)
@@ -7053,7 +7037,8 @@ class TypeLocReader : public TypeLocVisitor<TypeLocReader> {
// these, so unfortunately we have to declare them first, then
// define them out-of-line.
#define ABSTRACT_TYPELOC(CLASS, PARENT)
-#define TYPELOC(CLASS, PARENT) void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
+#define TYPELOC(CLASS, PARENT) \
+ void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
#include "clang/AST/TypeLocNodes.def"
void VisitFunctionTypeLoc(FunctionTypeLoc);
@@ -7139,20 +7124,20 @@ void TypeLocReader::VisitVariableArrayTypeLoc(VariableArrayTypeLoc TL) {
}
void TypeLocReader::VisitDependentSizedArrayTypeLoc(
- DependentSizedArrayTypeLoc TL) {
+ DependentSizedArrayTypeLoc TL) {
VisitArrayTypeLoc(TL);
}
void TypeLocReader::VisitDependentAddressSpaceTypeLoc(
DependentAddressSpaceTypeLoc TL) {
- TL.setAttrNameLoc(readSourceLocation());
- TL.setAttrOperandParensRange(readSourceRange());
- TL.setAttrExprOperand(Reader.readExpr());
+ TL.setAttrNameLoc(readSourceLocation());
+ TL.setAttrOperandParensRange(readSourceRange());
+ TL.setAttrExprOperand(Reader.readExpr());
}
void TypeLocReader::VisitDependentSizedExtVectorTypeLoc(
- DependentSizedExtVectorTypeLoc TL) {
+ DependentSizedExtVectorTypeLoc TL) {
TL.setNameLoc(readSourceLocation());
}
@@ -7160,7 +7145,8 @@ void TypeLocReader::VisitVectorTypeLoc(VectorTypeLoc TL) {
TL.setNameLoc(readSourceLocation());
}
-void TypeLocReader::VisitDependentVectorTypeLoc(DependentVectorTypeLoc TL) {
+void TypeLocReader::VisitDependentVectorTypeLoc(
+ DependentVectorTypeLoc TL) {
TL.setNameLoc(readSourceLocation());
}
@@ -7298,17 +7284,17 @@ void TypeLocReader::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
}
void TypeLocReader::VisitSubstTemplateTypeParmTypeLoc(
- SubstTemplateTypeParmTypeLoc TL) {
+ SubstTemplateTypeParmTypeLoc TL) {
TL.setNameLoc(readSourceLocation());
}
void TypeLocReader::VisitSubstTemplateTypeParmPackTypeLoc(
- SubstTemplateTypeParmPackTypeLoc TL) {
+ SubstTemplateTypeParmPackTypeLoc TL) {
TL.setNameLoc(readSourceLocation());
}
void TypeLocReader::VisitTemplateSpecializationTypeLoc(
- TemplateSpecializationTypeLoc TL) {
+ TemplateSpecializationTypeLoc TL) {
TL.setTemplateKeywordLoc(readSourceLocation());
TL.setTemplateNameLoc(readSourceLocation());
TL.setLAngleLoc(readSourceLocation());
@@ -7340,7 +7326,7 @@ void TypeLocReader::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
}
void TypeLocReader::VisitDependentTemplateSpecializationTypeLoc(
- DependentTemplateSpecializationTypeLoc TL) {
+ DependentTemplateSpecializationTypeLoc TL) {
TL.setElaboratedKeywordLoc(readSourceLocation());
TL.setQualifierLoc(ReadNestedNameSpecifierLoc());
TL.setTemplateKeywordLoc(readSourceLocation());
@@ -7652,15 +7638,15 @@ QualType ASTReader::GetType(TypeID ID) {
case PREDEF_TYPE_OBJC_SEL:
T = Context.ObjCBuiltinSelTy;
break;
-#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
- case PREDEF_TYPE_##Id##_ID: \
- T = Context.SingletonId; \
- break;
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
+ case PREDEF_TYPE_##Id##_ID: \
+ T = Context.SingletonId; \
+ break;
#include "clang/Basic/OpenCLImageTypes.def"
-#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
- case PREDEF_TYPE_##Id##_ID: \
- T = Context.Id##Ty; \
- break;
+#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
+ case PREDEF_TYPE_##Id##_ID: \
+ T = Context.Id##Ty; \
+ break;
#include "clang/Basic/OpenCLExtensionTypes.def"
case PREDEF_TYPE_SAMPLER_ID:
T = Context.OCLSamplerTy;
@@ -7701,20 +7687,20 @@ QualType ASTReader::GetType(TypeID ID) {
case PREDEF_TYPE_OMP_ITERATOR:
T = Context.OMPIteratorTy;
break;
-#define SVE_TYPE(Name, Id, SingletonId) \
- case PREDEF_TYPE_##Id##_ID: \
- T = Context.SingletonId; \
- break;
+#define SVE_TYPE(Name, Id, SingletonId) \
+ case PREDEF_TYPE_##Id##_ID: \
+ T = Context.SingletonId; \
+ break;
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_VECTOR_TYPE(Name, Id, Size) \
- case PREDEF_TYPE_##Id##_ID: \
- T = Context.Id##Ty; \
- break;
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
+ case PREDEF_TYPE_##Id##_ID: \
+ T = Context.Id##Ty; \
+ break;
#include "clang/Basic/PPCTypes.def"
-#define RVV_TYPE(Name, Id, SingletonId) \
- case PREDEF_TYPE_##Id##_ID: \
- T = Context.SingletonId; \
- break;
+#define RVV_TYPE(Name, Id, SingletonId) \
+ case PREDEF_TYPE_##Id##_ID: \
+ T = Context.SingletonId; \
+ break;
#include "clang/Basic/RISCVVTypes.def"
#define WASM_TYPE(Name, Id, SingletonId) \
case PREDEF_TYPE_##Id##_ID: \
@@ -7786,7 +7772,8 @@ ASTRecordReader::readTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind) {
case TemplateArgument::Type:
return readTypeSourceInfo();
case TemplateArgument::Template: {
- NestedNameSpecifierLoc QualifierLoc = readNestedNameSpecifierLoc();
+ NestedNameSpecifierLoc QualifierLoc =
+ readNestedNameSpecifierLoc();
SourceLocation TemplateNameLoc = readSourceLocation();
return TemplateArgumentLocInfo(getASTContext(), QualifierLoc,
TemplateNameLoc, SourceLocation());
@@ -7844,7 +7831,7 @@ void ASTReader::CompleteRedeclChain(const Decl *D) {
// deserializing. Just remember that the AST has marked this one as complete
// but that it's not actually complete yet, so we know we still need to
// complete it later.
- PendingIncompleteDeclChains.push_back(const_cast<Decl *>(D));
+ PendingIncompleteDeclChains.push_back(const_cast<Decl*>(D));
return;
}
@@ -7877,7 +7864,7 @@ void ASTReader::CompleteRedeclChain(const Decl *D) {
// Find all declarations of this kind from the relevant context.
for (auto *DCDecl : cast<Decl>(D->getLexicalDeclContext())->redecls()) {
auto *DC = cast<DeclContext>(DCDecl);
- SmallVector<Decl *, 8> Decls;
+ SmallVector<Decl*, 8> Decls;
FindExternalLexicalDecls(
DC, [&](Decl::Kind K) { return K == D->getKind(); }, Decls);
}
@@ -7978,7 +7965,7 @@ CXXBaseSpecifier *ASTReader::GetExternalCXXBaseSpecifiers(uint64_t Offset) {
unsigned NumBases = Record.readInt();
void *Mem = Context.Allocate(sizeof(CXXBaseSpecifier) * NumBases);
- CXXBaseSpecifier *Bases = new (Mem) CXXBaseSpecifier[NumBases];
+ CXXBaseSpecifier *Bases = new (Mem) CXXBaseSpecifier [NumBases];
for (unsigned I = 0; I != NumBases; ++I)
Bases[I] = Record.readCXXBaseSpecifier();
return Bases;
@@ -8372,11 +8359,10 @@ void ASTReader::FindExternalLexicalDecls(
SmallVectorImpl<Decl *> &Decls) {
bool PredefsVisited[NUM_PREDEF_DECL_IDS] = {};
- auto Visit = [&](ModuleFile *M, LexicalContents LexicalDecls) {
- assert(LexicalDecls.size() % 2 == 0 &&
- "expected an even number of entries");
+ auto Visit = [&] (ModuleFile *M, LexicalContents LexicalDecls) {
+ assert(LexicalDecls.size() % 2 == 0 && "expected an even number of entries");
for (int I = 0, N = LexicalDecls.size(); I != N; I += 2) {
- auto K = (Decl::Kind) + LexicalDecls[I];
+ auto K = (Decl::Kind)+LexicalDecls[I];
if (!IsKindWeWant(K))
continue;
@@ -8446,8 +8432,8 @@ class UnalignedDeclIDComp {
} // namespace
-void ASTReader::FindFileRegionDecls(FileID File, unsigned Offset,
- unsigned Length,
+void ASTReader::FindFileRegionDecls(FileID File,
+ unsigned Offset, unsigned Length,
SmallVectorImpl<Decl *> &Decls) {
SourceManager &SM = getSourceManager();
@@ -8459,8 +8445,8 @@ void ASTReader::FindFileRegionDecls(FileID File, unsigned Offset,
if (DInfo.Decls.empty())
return;
- SourceLocation BeginLoc =
- SM.getLocForStartOfFile(File).getLocWithOffset(Offset);
+ SourceLocation
+ BeginLoc = SM.getLocForStartOfFile(File).getLocWithOffset(Offset);
SourceLocation EndLoc = BeginLoc.getLocWithOffset(Length);
UnalignedDeclIDComp DIDComp(*this, *DInfo.Mod);
@@ -8659,45 +8645,45 @@ void ASTReader::PrintStats() {
if (unsigned TotalNumSLocEntries = getTotalNumSLocs())
std::fprintf(stderr, " %u/%u source location entries read (%f%%)\n",
NumSLocEntriesRead, TotalNumSLocEntries,
- ((float)NumSLocEntriesRead / TotalNumSLocEntries * 100));
+ ((float)NumSLocEntriesRead/TotalNumSLocEntries * 100));
if (!TypesLoaded.empty())
- std::fprintf(stderr, " %u/%u types read (%f%%)\n", NumTypesLoaded,
- (unsigned)TypesLoaded.size(),
- ((float)NumTypesLoaded / TypesLoaded.size() * 100));
+ std::fprintf(stderr, " %u/%u types read (%f%%)\n",
+ NumTypesLoaded, (unsigned)TypesLoaded.size(),
+ ((float)NumTypesLoaded/TypesLoaded.size() * 100));
if (!DeclsLoaded.empty())
- std::fprintf(stderr, " %u/%u declarations read (%f%%)\n", NumDeclsLoaded,
- (unsigned)DeclsLoaded.size(),
- ((float)NumDeclsLoaded / DeclsLoaded.size() * 100));
+ std::fprintf(stderr, " %u/%u declarations read (%f%%)\n",
+ NumDeclsLoaded, (unsigned)DeclsLoaded.size(),
+ ((float)NumDeclsLoaded/DeclsLoaded.size() * 100));
if (!IdentifiersLoaded.empty())
- std::fprintf(
- stderr, " %u/%u identifiers read (%f%%)\n", NumIdentifiersLoaded,
- (unsigned)IdentifiersLoaded.size(),
- ((float)NumIdentifiersLoaded / IdentifiersLoaded.size() * 100));
+ std::fprintf(stderr, " %u/%u identifiers read (%f%%)\n",
+ NumIdentifiersLoaded, (unsigned)IdentifiersLoaded.size(),
+ ((float)NumIdentifiersLoaded/IdentifiersLoaded.size() * 100));
if (!MacrosLoaded.empty())
- std::fprintf(stderr, " %u/%u macros read (%f%%)\n", NumMacrosLoaded,
- (unsigned)MacrosLoaded.size(),
- ((float)NumMacrosLoaded / MacrosLoaded.size() * 100));
+ std::fprintf(stderr, " %u/%u macros read (%f%%)\n",
+ NumMacrosLoaded, (unsigned)MacrosLoaded.size(),
+ ((float)NumMacrosLoaded/MacrosLoaded.size() * 100));
if (!SelectorsLoaded.empty())
- std::fprintf(stderr, " %u/%u selectors read (%f%%)\n", NumSelectorsLoaded,
- (unsigned)SelectorsLoaded.size(),
- ((float)NumSelectorsLoaded / SelectorsLoaded.size() * 100));
+ std::fprintf(stderr, " %u/%u selectors read (%f%%)\n",
+ NumSelectorsLoaded, (unsigned)SelectorsLoaded.size(),
+ ((float)NumSelectorsLoaded/SelectorsLoaded.size() * 100));
if (TotalNumStatements)
- std::fprintf(stderr, " %u/%u statements read (%f%%)\n", NumStatementsRead,
- TotalNumStatements,
- ((float)NumStatementsRead / TotalNumStatements * 100));
+ std::fprintf(stderr, " %u/%u statements read (%f%%)\n",
+ NumStatementsRead, TotalNumStatements,
+ ((float)NumStatementsRead/TotalNumStatements * 100));
if (TotalNumMacros)
- std::fprintf(stderr, " %u/%u macros read (%f%%)\n", NumMacrosRead,
- TotalNumMacros, ((float)NumMacrosRead / TotalNumMacros * 100));
+ std::fprintf(stderr, " %u/%u macros read (%f%%)\n",
+ NumMacrosRead, TotalNumMacros,
+ ((float)NumMacrosRead/TotalNumMacros * 100));
if (TotalLexicalDeclContexts)
- std::fprintf(
- stderr, " %u/%u lexical declcontexts read (%f%%)\n",
- NumLexicalDeclContextsRead, TotalLexicalDeclContexts,
- ((float)NumLexicalDeclContextsRead / TotalLexicalDeclContexts * 100));
+ std::fprintf(stderr, " %u/%u lexical declcontexts read (%f%%)\n",
+ NumLexicalDeclContextsRead, TotalLexicalDeclContexts,
+ ((float)NumLexicalDeclContextsRead/TotalLexicalDeclContexts
+ * 100));
if (TotalVisibleDeclContexts)
- std::fprintf(
- stderr, " %u/%u visible declcontexts read (%f%%)\n",
- NumVisibleDeclContextsRead, TotalVisibleDeclContexts,
- ((float)NumVisibleDeclContextsRead / TotalVisibleDeclContexts * 100));
+ std::fprintf(stderr, " %u/%u visible declcontexts read (%f%%)\n",
+ NumVisibleDeclContextsRead, TotalVisibleDeclContexts,
+ ((float)NumVisibleDeclContextsRead/TotalVisibleDeclContexts
+ * 100));
if (TotalModuleLocalVisibleDeclContexts)
std::fprintf(
stderr, " %u/%u module local visible declcontexts read (%f%%)\n",
@@ -8710,24 +8696,24 @@ void ASTReader::PrintStats() {
((float)NumTULocalVisibleDeclContexts /
TotalTULocalVisibleDeclContexts * 100));
if (TotalNumMethodPoolEntries)
- std::fprintf(
- stderr, " %u/%u method pool entries read (%f%%)\n",
- NumMethodPoolEntriesRead, TotalNumMethodPoolEntries,
- ((float)NumMethodPoolEntriesRead / TotalNumMethodPoolEntries * 100));
+ std::fprintf(stderr, " %u/%u method pool entries read (%f%%)\n",
+ NumMethodPoolEntriesRead, TotalNumMethodPoolEntries,
+ ((float)NumMethodPoolEntriesRead/TotalNumMethodPoolEntries
+ * 100));
if (NumMethodPoolLookups)
std::fprintf(stderr, " %u/%u method pool lookups succeeded (%f%%)\n",
NumMethodPoolHits, NumMethodPoolLookups,
- ((float)NumMethodPoolHits / NumMethodPoolLookups * 100.0));
+ ((float)NumMethodPoolHits/NumMethodPoolLookups * 100.0));
if (NumMethodPoolTableLookups)
- std::fprintf(
- stderr, " %u/%u method pool table lookups succeeded (%f%%)\n",
- NumMethodPoolTableHits, NumMethodPoolTableLookups,
- ((float)NumMethodPoolTableHits / NumMethodPoolTableLookups * 100.0));
+ std::fprintf(stderr, " %u/%u method pool table lookups succeeded (%f%%)\n",
+ NumMethodPoolTableHits, NumMethodPoolTableLookups,
+ ((float)NumMethodPoolTableHits/NumMethodPoolTableLookups
+ * 100.0));
if (NumIdentifierLookupHits)
- std::fprintf(
- stderr, " %u / %u identifier table lookups succeeded (%f%%)\n",
- NumIdentifierLookupHits, NumIdentifierLookups,
- (double)NumIdentifierLookupHits * 100.0 / NumIdentifierLookups);
+ std::fprintf(stderr,
+ " %u / %u identifier table lookups succeeded (%f%%)\n",
+ NumIdentifierLookupHits, NumIdentifierLookups,
+ (double)NumIdentifierLookupHits*100.0/NumIdentifierLookups);
if (GlobalIndex) {
std::fprintf(stderr, "\n");
@@ -8739,10 +8725,11 @@ void ASTReader::PrintStats() {
std::fprintf(stderr, "\n");
}
-template <typename Key, typename ModuleFile, unsigned InitialCapacity>
-LLVM_DUMP_METHOD static void dumpModuleIDMap(
- StringRef Name,
- const ContinuousRangeMap<Key, ModuleFile *, InitialCapacity> &Map) {
+template<typename Key, typename ModuleFile, unsigned InitialCapacity>
+LLVM_DUMP_METHOD static void
+dumpModuleIDMap(StringRef Name,
+ const ContinuousRangeMap<Key, ModuleFile *,
+ InitialCapacity> &Map) {
if (Map.begin() == Map.end())
return;
@@ -8777,12 +8764,12 @@ void ASTReader::getMemoryBufferSizes(MemoryBufferSizes &sizes) const {
if (llvm::MemoryBuffer *buf = I.Buffer) {
size_t bytes = buf->getBufferSize();
switch (buf->getBufferKind()) {
- case llvm::MemoryBuffer::MemoryBuffer_Malloc:
- sizes.malloc_bytes += bytes;
- break;
- case llvm::MemoryBuffer::MemoryBuffer_MMap:
- sizes.mmap_bytes += bytes;
- break;
+ case llvm::MemoryBuffer::MemoryBuffer_Malloc:
+ sizes.malloc_bytes += bytes;
+ break;
+ case llvm::MemoryBuffer::MemoryBuffer_MMap:
+ sizes.mmap_bytes += bytes;
+ break;
}
}
}
@@ -8845,7 +8832,7 @@ void ASTReader::UpdateSema() {
// Update the state of pragmas. Use the same API as if we had encountered the
// pragma in the source.
- if (OptimizeOffPragmaLocation.isValid())
+ if(OptimizeOffPragmaLocation.isValid())
SemaObj->ActOnPragmaOptimize(/* On = */ false, OptimizeOffPragmaLocation);
if (PragmaMSStructState != -1)
SemaObj->ActOnPragmaMSStruct((PragmaMSStructKind)PragmaMSStructState);
@@ -8967,33 +8954,33 @@ IdentifierInfo *ASTReader::get(StringRef Name) {
namespace clang {
-/// An identifier-lookup iterator that enumerates all of the
-/// identifiers stored within a set of AST files.
-class ASTIdentifierIterator : public IdentifierIterator {
- /// The AST reader whose identifiers are being enumerated.
- const ASTReader &Reader;
+ /// An identifier-lookup iterator that enumerates all of the
+ /// identifiers stored within a set of AST files.
+ class ASTIdentifierIterator : public IdentifierIterator {
+ /// The AST reader whose identifiers are being enumerated.
+ const ASTReader &Reader;
- /// The current index into the chain of AST files stored in
- /// the AST reader.
- unsigned Index;
+ /// The current index into the chain of AST files stored in
+ /// the AST reader.
+ unsigned Index;
- /// The current position within the identifier lookup table
- /// of the current AST file.
- ASTIdentifierLookupTable::key_iterator Current;
+ /// The current position within the identifier lookup table
+ /// of the current AST file.
+ ASTIdentifierLookupTable::key_iterator Current;
- /// The end position within the identifier lookup table of
- /// the current AST file.
- ASTIdentifierLookupTable::key_iterator End;
+ /// The end position within the identifier lookup table of
+ /// the current AST file.
+ ASTIdentifierLookupTable::key_iterator End;
- /// Whether to skip any modules in the ASTReader.
- bool SkipModules;
+ /// Whether to skip any modules in the ASTReader.
+ bool SkipModules;
-public:
- explicit ASTIdentifierIterator(const ASTReader &Reader,
- bool SkipModules = false);
+ public:
+ explicit ASTIdentifierIterator(const ASTReader &Reader,
+ bool SkipModules = false);
- StringRef Next() override;
-};
+ StringRef Next() override;
+ };
} // namespace clang
@@ -9071,76 +9058,78 @@ IdentifierIterator *ASTReader::getIdentifiers() {
namespace clang {
namespace serialization {
-class ReadMethodPoolVisitor {
- ASTReader &Reader;
- Selector Sel;
- unsigned PriorGeneration;
- unsigned InstanceBits = 0;
- unsigned FactoryBits = 0;
- bool InstanceHasMoreThanOneDecl = false;
- bool FactoryHasMoreThanOneDecl = false;
- SmallVector<ObjCMethodDecl *, 4> InstanceMethods;
- SmallVector<ObjCMethodDecl *, 4> FactoryMethods;
-
-public:
- ReadMethodPoolVisitor(ASTReader &Reader, Selector Sel,
- unsigned PriorGeneration)
- : Reader(Reader), Sel(Sel), PriorGeneration(PriorGeneration) {}
+ class ReadMethodPoolVisitor {
+ ASTReader &Reader;
+ Selector Sel;
+ unsigned PriorGeneration;
+ unsigned InstanceBits = 0;
+ unsigned FactoryBits = 0;
+ bool InstanceHasMoreThanOneDecl = false;
+ bool FactoryHasMoreThanOneDecl = false;
+ SmallVector<ObjCMethodDecl *, 4> InstanceMethods;
+ SmallVector<ObjCMethodDecl *, 4> FactoryMethods;
+
+ public:
+ ReadMethodPoolVisitor(ASTReader &Reader, Selector Sel,
+ unsigned PriorGeneration)
+ : Reader(Reader), Sel(Sel), PriorGeneration(PriorGeneration) {}
+
+ bool operator()(ModuleFile &M) {
+ if (!M.SelectorLookupTable)
+ return false;
- bool operator()(ModuleFile &M) {
- if (!M.SelectorLookupTable)
- return false;
+ // If we've already searched this module file, skip it now.
+ if (M.Generation <= PriorGeneration)
+ return true;
- // If we've already searched this module file, skip it now.
- if (M.Generation <= PriorGeneration)
- return true;
+ ++Reader.NumMethodPoolTableLookups;
+ ASTSelectorLookupTable *PoolTable
+ = (ASTSelectorLookupTable*)M.SelectorLookupTable;
+ ASTSelectorLookupTable::iterator Pos = PoolTable->find(Sel);
+ if (Pos == PoolTable->end())
+ return false;
- ++Reader.NumMethodPoolTableLookups;
- ASTSelectorLookupTable *PoolTable =
- (ASTSelectorLookupTable *)M.SelectorLookupTable;
- ASTSelectorLookupTable::iterator Pos = PoolTable->find(Sel);
- if (Pos == PoolTable->end())
+ ++Reader.NumMethodPoolTableHits;
+ ++Reader.NumSelectorsRead;
+ // FIXME: Not quite happy with the statistics here. We probably should
+ // disable this tracking when called via LoadSelector.
+ // Also, should entries without methods count as misses?
+ ++Reader.NumMethodPoolEntriesRead;
+ ASTSelectorLookupTrait::data_type Data = *Pos;
+ if (Reader.DeserializationListener)
+ Reader.DeserializationListener->SelectorRead(Data.ID, Sel);
+
+ // Append methods in the reverse order, so that later we can process them
+ // in the order they appear in the source code by iterating through
+ // the vector in the reverse order.
+ InstanceMethods.append(Data.Instance.rbegin(), Data.Instance.rend());
+ FactoryMethods.append(Data.Factory.rbegin(), Data.Factory.rend());
+ InstanceBits = Data.InstanceBits;
+ FactoryBits = Data.FactoryBits;
+ InstanceHasMoreThanOneDecl = Data.InstanceHasMoreThanOneDecl;
+ FactoryHasMoreThanOneDecl = Data.FactoryHasMoreThanOneDecl;
return false;
+ }
- ++Reader.NumMethodPoolTableHits;
- ++Reader.NumSelectorsRead;
- // FIXME: Not quite happy with the statistics here. We probably should
- // disable this tracking when called via LoadSelector.
- // Also, should entries without methods count as misses?
- ++Reader.NumMethodPoolEntriesRead;
- ASTSelectorLookupTrait::data_type Data = *Pos;
- if (Reader.DeserializationListener)
- Reader.DeserializationListener->SelectorRead(Data.ID, Sel);
-
- // Append methods in the reverse order, so that later we can process them
- // in the order they appear in the source code by iterating through
- // the vector in the reverse order.
- InstanceMethods.append(Data.Instance.rbegin(), Data.Instance.rend());
- FactoryMethods.append(Data.Factory.rbegin(), Data.Factory.rend());
- InstanceBits = Data.InstanceBits;
- FactoryBits = Data.FactoryBits;
- InstanceHasMoreThanOneDecl = Data.InstanceHasMoreThanOneDecl;
- FactoryHasMoreThanOneDecl = Data.FactoryHasMoreThanOneDecl;
- return false;
- }
-
- /// Retrieve the instance methods found by this visitor.
- ArrayRef<ObjCMethodDecl *> getInstanceMethods() const {
- return InstanceMethods;
- }
+ /// Retrieve the instance methods found by this visitor.
+ ArrayRef<ObjCMethodDecl *> getInstanceMethods() const {
+ return InstanceMethods;
+ }
- /// Retrieve the instance methods found by this visitor.
- ArrayRef<ObjCMethodDecl *> getFactoryMethods() const {
- return FactoryMethods;
- }
+ /// Retrieve the instance methods found by this visitor.
+ ArrayRef<ObjCMethodDecl *> getFactoryMethods() const {
+ return FactoryMethods;
+ }
- unsigned getInstanceBits() const { return InstanceBits; }
- unsigned getFactoryBits() const { return FactoryBits; }
+ unsigned getInstanceBits() const { return InstanceBits; }
+ unsigned getFactoryBits() const { return FactoryBits; }
- bool instanceHasMoreThanOneDecl() const { return InstanceHasMoreThanOneDecl; }
+ bool instanceHasMoreThanOneDecl() const {
+ return InstanceHasMoreThanOneDecl;
+ }
- bool factoryHasMoreThanOneDecl() const { return FactoryHasMoreThanOneDecl; }
-};
+ bool factoryHasMoreThanOneDecl() const { return FactoryHasMoreThanOneDecl; }
+ };
} // namespace serialization
} // namespace clang
@@ -9194,12 +9183,12 @@ void ASTReader::updateOutOfDateSelector(Selector Sel) {
}
void ASTReader::ReadKnownNamespaces(
- SmallVectorImpl<NamespaceDecl *> &Namespaces) {
+ SmallVectorImpl<NamespaceDecl *> &Namespaces) {
Namespaces.clear();
for (unsigned I = 0, N = KnownNamespaces.size(); I != N; ++I) {
- if (NamespaceDecl *Namespace =
- dyn_cast_or_null<NamespaceDecl>(GetDecl(KnownNamespaces[I])))
+ if (NamespaceDecl *Namespace
+ = dyn_cast_or_null<NamespaceDecl>(GetDecl(KnownNamespaces[I])))
Namespaces.push_back(Namespace);
}
}
@@ -9215,10 +9204,9 @@ void ASTReader::ReadUndefinedButUsed(
UndefinedButUsed.clear();
}
-void ASTReader::ReadMismatchingDeleteExpressions(
- llvm::MapVector<FieldDecl *,
- llvm::SmallVector<std::pair<SourceLocation, bool>, 4>>
- &Exprs) {
+void ASTReader::ReadMismatchingDeleteExpressions(llvm::MapVector<
+ FieldDecl *, llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &
+ Exprs) {
for (unsigned Idx = 0, N = DelayedDeleteExprs.size(); Idx != N;) {
FieldDecl *FD =
cast<FieldDecl>(GetDecl(GlobalDeclID(DelayedDeleteExprs[Idx++])));
@@ -9233,7 +9221,7 @@ void ASTReader::ReadMismatchingDeleteExpressions(
}
void ASTReader::ReadTentativeDefinitions(
- SmallVectorImpl<VarDecl *> &TentativeDefs) {
+ SmallVectorImpl<VarDecl *> &TentativeDefs) {
for (unsigned I = 0, N = TentativeDefinitions.size(); I != N; ++I) {
VarDecl *Var = dyn_cast_or_null<VarDecl>(GetDecl(TentativeDefinitions[I]));
if (Var)
@@ -9243,10 +9231,10 @@ void ASTReader::ReadTentativeDefinitions(
}
void ASTReader::ReadUnusedFileScopedDecls(
- SmallVectorImpl<const DeclaratorDecl *> &Decls) {
+ SmallVectorImpl<const DeclaratorDecl *> &Decls) {
for (unsigned I = 0, N = UnusedFileScopedDecls.size(); I != N; ++I) {
- DeclaratorDecl *D =
- dyn_cast_or_null<DeclaratorDecl>(GetDecl(UnusedFileScopedDecls[I]));
+ DeclaratorDecl *D
+ = dyn_cast_or_null<DeclaratorDecl>(GetDecl(UnusedFileScopedDecls[I]));
if (D)
Decls.push_back(D);
}
@@ -9254,10 +9242,10 @@ void ASTReader::ReadUnusedFileScopedDecls(
}
void ASTReader::ReadDelegatingConstructors(
- SmallVectorImpl<CXXConstructorDecl *> &Decls) {
+ SmallVectorImpl<CXXConstructorDecl *> &Decls) {
for (unsigned I = 0, N = DelegatingCtorDecls.size(); I != N; ++I) {
- CXXConstructorDecl *D =
- dyn_cast_or_null<CXXConstructorDecl>(GetDecl(DelegatingCtorDecls[I]));
+ CXXConstructorDecl *D
+ = dyn_cast_or_null<CXXConstructorDecl>(GetDecl(DelegatingCtorDecls[I]));
if (D)
Decls.push_back(D);
}
@@ -9266,8 +9254,8 @@ void ASTReader::ReadDelegatingConstructors(
void ASTReader::ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls) {
for (unsigned I = 0, N = ExtVectorDecls.size(); I != N; ++I) {
- TypedefNameDecl *D =
- dyn_cast_or_null<TypedefNameDecl>(GetDecl(ExtVectorDecls[I]));
+ TypedefNameDecl *D
+ = dyn_cast_or_null<TypedefNameDecl>(GetDecl(ExtVectorDecls[I]));
if (D)
Decls.push_back(D);
}
@@ -9297,33 +9285,33 @@ void ASTReader::ReadDeclsToCheckForDeferredDiags(
}
void ASTReader::ReadReferencedSelectors(
- SmallVectorImpl<std::pair<Selector, SourceLocation>> &Sels) {
+ SmallVectorImpl<std::pair<Selector, SourceLocation>> &Sels) {
if (ReferencedSelectorsData.empty())
return;
// If there are @selector references added them to its pool. This is for
// implementation of -Wselector.
- unsigned int DataSize = ReferencedSelectorsData.size() - 1;
+ unsigned int DataSize = ReferencedSelectorsData.size()-1;
unsigned I = 0;
while (I < DataSize) {
Selector Sel = DecodeSelector(ReferencedSelectorsData[I++]);
- SourceLocation SelLoc =
- SourceLocation::getFromRawEncoding(ReferencedSelectorsData[I++]);
+ SourceLocation SelLoc
+ = SourceLocation::getFromRawEncoding(ReferencedSelectorsData[I++]);
Sels.push_back(std::make_pair(Sel, SelLoc));
}
ReferencedSelectorsData.clear();
}
void ASTReader::ReadWeakUndeclaredIdentifiers(
- SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo>> &WeakIDs) {
+ SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo>> &WeakIDs) {
if (WeakUndeclaredIdentifiers.empty())
return;
for (unsigned I = 0, N = WeakUndeclaredIdentifiers.size(); I < N; /*none*/) {
- IdentifierInfo *WeakId =
- DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
- IdentifierInfo *AliasId =
- DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
+ IdentifierInfo *WeakId
+ = DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
+ IdentifierInfo *AliasId
+ = DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
SourceLocation Loc =
SourceLocation::getFromRawEncoding(WeakUndeclaredIdentifiers[I++]);
WeakInfo WI(AliasId, Loc);
@@ -9346,7 +9334,7 @@ void ASTReader::ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) {
}
void ASTReader::ReadPendingInstantiations(
- SmallVectorImpl<std::pair<ValueDecl *, SourceLocation>> &Pending) {
+ SmallVectorImpl<std::pair<ValueDecl *, SourceLocation>> &Pending) {
for (unsigned Idx = 0, N = PendingInstantiations.size(); Idx < N;) {
PendingInstantiation &Inst = PendingInstantiations[Idx++];
ValueDecl *D = cast<ValueDecl>(GetDecl(Inst.ID));
@@ -9559,8 +9547,8 @@ MacroInfo *ASTReader::getMacro(MacroID ID) {
ID -= NUM_PREDEF_MACRO_IDS;
if (!MacrosLoaded[ID]) {
- GlobalMacroMapType::iterator I =
- GlobalMacroMap.find(ID + NUM_PREDEF_MACRO_IDS);
+ GlobalMacroMapType::iterator I
+ = GlobalMacroMap.find(ID + NUM_PREDEF_MACRO_IDS);
assert(I != GlobalMacroMap.end() && "Corrupted global macro map");
ModuleFile *M = I->second;
unsigned Index = ID - M->BaseMacroID;
@@ -9582,8 +9570,8 @@ MacroID ASTReader::getGlobalMacroID(ModuleFile &M, unsigned LocalID) {
if (!M.ModuleOffsetMap.empty())
ReadModuleOffsetMap(M);
- ContinuousRangeMap<uint32_t, int, 2>::iterator I =
- M.MacroRemap.find(LocalID - NUM_PREDEF_MACRO_IDS);
+ ContinuousRangeMap<uint32_t, int, 2>::iterator I
+ = M.MacroRemap.find(LocalID - NUM_PREDEF_MACRO_IDS);
assert(I != M.MacroRemap.end() && "Invalid index into macro index remap");
return LocalID + I->second;
@@ -9597,10 +9585,10 @@ ASTReader::getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID) const {
if (!M.ModuleOffsetMap.empty())
ReadModuleOffsetMap(M);
- ContinuousRangeMap<uint32_t, int, 2>::iterator I =
- M.SubmoduleRemap.find(LocalID - NUM_PREDEF_SUBMODULE_IDS);
- assert(I != M.SubmoduleRemap.end() &&
- "Invalid index into submodule index remap");
+ ContinuousRangeMap<uint32_t, int, 2>::iterator I
+ = M.SubmoduleRemap.find(LocalID - NUM_PREDEF_SUBMODULE_IDS);
+ assert(I != M.SubmoduleRemap.end()
+ && "Invalid index into submodule index remap");
return LocalID + I->second;
}
@@ -9619,7 +9607,9 @@ Module *ASTReader::getSubmodule(SubmoduleID GlobalID) {
return SubmodulesLoaded[GlobalID - NUM_PREDEF_SUBMODULE_IDS];
}
-Module *ASTReader::getModule(unsigned ID) { return getSubmodule(ID); }
+Module *ASTReader::getModule(unsigned ID) {
+ return getSubmodule(ID);
+}
ModuleFile *ASTReader::getLocalModuleFile(ModuleFile &M, unsigned ID) const {
if (ID & 1) {
@@ -9697,7 +9687,7 @@ Selector ASTReader::DecodeSelector(serialization::SelectorID ID) {
ASTSelectorLookupTrait Trait(*this, M);
unsigned Idx = ID - M.BaseSelectorID - NUM_PREDEF_SELECTOR_IDS;
SelectorsLoaded[ID - 1] =
- Trait.ReadKey(M.SelectorLookupTableData + M.SelectorOffsets[Idx], 0);
+ Trait.ReadKey(M.SelectorLookupTableData + M.SelectorOffsets[Idx], 0);
if (DeserializationListener)
DeserializationListener->SelectorRead(ID, SelectorsLoaded[ID - 1]);
}
@@ -9722,10 +9712,10 @@ ASTReader::getGlobalSelectorID(ModuleFile &M, unsigned LocalID) const {
if (!M.ModuleOffsetMap.empty())
ReadModuleOffsetMap(M);
- ContinuousRangeMap<uint32_t, int, 2>::iterator I =
- M.SelectorRemap.find(LocalID - NUM_PREDEF_SELECTOR_IDS);
- assert(I != M.SelectorRemap.end() &&
- "Invalid index into selector index remap");
+ ContinuousRangeMap<uint32_t, int, 2>::iterator I
+ = M.SelectorRemap.find(LocalID - NUM_PREDEF_SELECTOR_IDS);
+ assert(I != M.SelectorRemap.end()
+ && "Invalid index into selector index remap");
return LocalID + I->second;
}
@@ -9780,7 +9770,8 @@ void ASTRecordReader::readQualifierInfo(QualifierInfo &Info) {
}
}
-TemplateParameterList *ASTRecordReader::readTemplateParameterList() {
+TemplateParameterList *
+ASTRecordReader::readTemplateParameterList() {
SourceLocation TemplateLoc = readSourceLocation();
SourceLocation LAngleLoc = readSourceLocation();
SourceLocation RAngleLoc = readSourceLocation();
@@ -9800,7 +9791,8 @@ TemplateParameterList *ASTRecordReader::readTemplateParameterList() {
}
void ASTRecordReader::readTemplateArgumentList(
- SmallVectorImpl<TemplateArgument> &TemplArgs, bool Canonicalize) {
+ SmallVectorImpl<TemplateArgument> &TemplArgs,
+ bool Canonicalize) {
unsigned NumTemplateArgs = readInt();
TemplArgs.reserve(NumTemplateArgs);
while (NumTemplateArgs--)
@@ -9813,12 +9805,13 @@ void ASTRecordReader::readUnresolvedSet(LazyASTUnresolvedSet &Set) {
Set.reserve(getContext(), NumDecls);
while (NumDecls--) {
GlobalDeclID ID = readDeclID();
- AccessSpecifier AS = (AccessSpecifier)readInt();
+ AccessSpecifier AS = (AccessSpecifier) readInt();
Set.addLazyDecl(getContext(), ID, AS);
}
}
-CXXBaseSpecifier ASTRecordReader::readCXXBaseSpecifier() {
+CXXBaseSpecifier
+ASTRecordReader::readCXXBaseSpecifier() {
bool isVirtual = readBool();
bool isBaseOfClass = readBool();
AccessSpecifier AS = static_cast<AccessSpecifier>(readInt());
@@ -9832,18 +9825,19 @@ CXXBaseSpecifier ASTRecordReader::readCXXBaseSpecifier() {
return Result;
}
-CXXCtorInitializer **ASTRecordReader::readCXXCtorInitializers() {
+CXXCtorInitializer **
+ASTRecordReader::readCXXCtorInitializers() {
ASTContext &Context = getContext();
unsigned NumInitializers = readInt();
assert(NumInitializers && "wrote ctor initializers but have no inits");
- auto **CtorInitializers = new (Context) CXXCtorInitializer *[NumInitializers];
+ auto **CtorInitializers = new (Context) CXXCtorInitializer*[NumInitializers];
for (unsigned i = 0; i != NumInitializers; ++i) {
TypeSourceInfo *TInfo = nullptr;
bool IsBaseVirtual = false;
FieldDecl *Member = nullptr;
IndirectFieldDecl *IndirectMember = nullptr;
- CtorInitializerType Type = (CtorInitializerType)readInt();
+ CtorInitializerType Type = (CtorInitializerType) readInt();
switch (Type) {
case CTOR_INITIALIZER_BASE:
TInfo = readTypeSourceInfo();
@@ -9854,11 +9848,11 @@ CXXCtorInitializer **ASTRecordReader::readCXXCtorInitializers() {
TInfo = readTypeSourceInfo();
break;
- case CTOR_INITIALIZER_MEMBER:
+ case CTOR_INITIALIZER_MEMBER:
Member = readDeclAs<FieldDecl>();
break;
- case CTOR_INITIALIZER_INDIRECT_MEMBER:
+ case CTOR_INITIALIZER_INDIRECT_MEMBER:
IndirectMember = readDeclAs<IndirectFieldDecl>();
break;
}
@@ -9877,14 +9871,15 @@ CXXCtorInitializer **ASTRecordReader::readCXXCtorInitializers() {
BOMInit = new (Context)
CXXCtorInitializer(Context, TInfo, LParenLoc, Init, RParenLoc);
else if (Member)
- BOMInit = new (Context) CXXCtorInitializer(
- Context, Member, MemberOrEllipsisLoc, LParenLoc, Init, RParenLoc);
+ BOMInit = new (Context)
+ CXXCtorInitializer(Context, Member, MemberOrEllipsisLoc, LParenLoc,
+ Init, RParenLoc);
else
BOMInit = new (Context)
CXXCtorInitializer(Context, IndirectMember, MemberOrEllipsisLoc,
LParenLoc, Init, RParenLoc);
- if (/*IsWritten*/ readBool()) {
+ if (/*IsWritten*/readBool()) {
unsigned SourceOrder = readInt();
BOMInit->setSourceOrder(SourceOrder);
}
@@ -9895,7 +9890,8 @@ CXXCtorInitializer **ASTRecordReader::readCXXCtorInitializers() {
return CtorInitializers;
}
-NestedNameSpecifierLoc ASTRecordReader::readNestedNameSpecifierLoc() {
+NestedNameSpecifierLoc
+ASTRecordReader::readNestedNameSpecifierLoc() {
ASTContext &Context = getContext();
unsigned N = readInt();
NestedNameSpecifierLocBuilder Builder;
@@ -9932,9 +9928,9 @@ NestedNameSpecifierLoc ASTRecordReader::readNestedNameSpecifierLoc() {
SourceLocation ColonColonLoc = readSourceLocation();
// FIXME: 'template' keyword location not saved anywhere, so we fake it.
- Builder.Extend(
- Context, Template ? T->getTypeLoc().getBeginLoc() : SourceLocation(),
- T->getTypeLoc(), ColonColonLoc);
+ Builder.Extend(Context,
+ Template? T->getTypeLoc().getBeginLoc() : SourceLocation(),
+ T->getTypeLoc(), ColonColonLoc);
break;
}
@@ -10072,15 +10068,17 @@ SwitchCase *ASTReader::getSwitchCaseWithID(unsigned ID) {
return (*CurrSwitchCaseStmts)[ID];
}
-void ASTReader::ClearSwitchCaseIDs() { CurrSwitchCaseStmts->clear(); }
+void ASTReader::ClearSwitchCaseIDs() {
+ CurrSwitchCaseStmts->clear();
+}
void ASTReader::ReadComments() {
ASTContext &Context = getContext();
std::vector<RawComment *> Comments;
- for (SmallVectorImpl<
- std::pair<BitstreamCursor, serialization::ModuleFile *>>::iterator
- I = CommentsCursors.begin(),
- E = CommentsCursors.end();
+ for (SmallVectorImpl<std::pair<BitstreamCursor,
+ serialization::ModuleFile *>>::iterator
+ I = CommentsCursors.begin(),
+ E = CommentsCursors.end();
I != E; ++I) {
Comments.clear();
BitstreamCursor &Cursor = I->first;
@@ -10121,11 +10119,12 @@ void ASTReader::ReadComments() {
case COMMENTS_RAW_COMMENT: {
unsigned Idx = 0;
SourceRange SR = ReadSourceRange(F, Record, Idx);
- RawComment::CommentKind Kind = (RawComment::CommentKind)Record[Idx++];
+ RawComment::CommentKind Kind =
+ (RawComment::CommentKind) Record[Idx++];
bool IsTrailingComment = Record[Idx++];
bool IsAlmostTrailingComment = Record[Idx++];
- Comments.push_back(new (Context) RawComment(SR, Kind, IsTrailingComment,
- IsAlmostTrailingComment));
+ Comments.push_back(new (Context) RawComment(
+ SR, Kind, IsTrailingComment, IsAlmostTrailingComment));
break;
}
}
@@ -10156,22 +10155,22 @@ void ASTReader::visitInputFileInfos(
unsigned N = IncludeSystem ? NumInputs : NumUserInputs;
for (unsigned I = 0; I < N; ++I) {
bool IsSystem = I >= NumUserInputs;
- InputFileInfo IFI = getInputFileInfo(MF, I + 1);
+ InputFileInfo IFI = getInputFileInfo(MF, I+1);
Visitor(IFI, IsSystem);
}
}
-void ASTReader::visitInputFiles(
- serialization::ModuleFile &MF, bool IncludeSystem, bool Complain,
- llvm::function_ref<void(const serialization::InputFile &IF, bool isSystem)>
- Visitor) {
+void ASTReader::visitInputFiles(serialization::ModuleFile &MF,
+ bool IncludeSystem, bool Complain,
+ llvm::function_ref<void(const serialization::InputFile &IF,
+ bool isSystem)> Visitor) {
unsigned NumUserInputs = MF.NumUserInputFiles;
unsigned NumInputs = MF.InputFilesLoaded.size();
assert(NumUserInputs <= NumInputs);
unsigned N = IncludeSystem ? NumInputs : NumUserInputs;
for (unsigned I = 0; I < N; ++I) {
bool IsSystem = I >= NumUserInputs;
- InputFile IF = getInputFile(MF, I + 1, Complain);
+ InputFile IF = getInputFile(MF, I+1, Complain);
Visitor(IF, IsSystem);
}
}
@@ -10257,8 +10256,7 @@ void ASTReader::finishPendingActions() {
// Make the most recent of the top-level declarations visible.
for (TopLevelDeclsMap::iterator TLD = TopLevelDecls.begin(),
- TLDEnd = TopLevelDecls.end();
- TLD != TLDEnd; ++TLD) {
+ TLDEnd = TopLevelDecls.end(); TLD != TLDEnd; ++TLD) {
IdentifierInfo *II = TLD->first;
for (unsigned I = 0, N = TLD->second.size(); I != N; ++I) {
pushExternalDeclIntoScope(cast<NamedDecl>(TLD->second[I]), II);
@@ -10355,7 +10353,7 @@ void ASTReader::finishPendingActions() {
if (TagDecl *TD = dyn_cast<TagDecl>(D)) {
if (const TagType *TagT = dyn_cast<TagType>(TD->getTypeForDecl())) {
// Make sure that the TagType points at the definition.
- const_cast<TagType *>(TagT)->decl = TD;
+ const_cast<TagType*>(TagT)->decl = TD;
}
if (auto RD = dyn_cast<CXXRecordDecl>(D)) {
@@ -10374,7 +10372,7 @@ void ASTReader::finishPendingActions() {
if (auto ID = dyn_cast<ObjCInterfaceDecl>(D)) {
// Make sure that the ObjCInterfaceType points at the definition.
const_cast<ObjCInterfaceType *>(cast<ObjCInterfaceType>(ID->TypeForDecl))
- ->Decl = ID;
+ ->Decl = ID;
for (auto *R = getMostRecentExistingDecl(ID); R; R = R->getPreviousDecl())
cast<ObjCInterfaceDecl>(R)->Data = ID->Data;
@@ -10439,7 +10437,7 @@ void ASTReader::finishPendingActions() {
// have been fully wired up (hasBody relies on this).
// FIXME: We shouldn't require complete redeclaration chains here.
for (PendingBodiesMap::iterator PB = PendingBodies.begin(),
- PBEnd = PendingBodies.end();
+ PBEnd = PendingBodies.end();
PB != PBEnd; ++PB) {
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(PB->first)) {
// FIXME: Check for =delete/=default?
@@ -10447,7 +10445,7 @@ void ASTReader::finishPendingActions() {
if (!getContext().getLangOpts().Modules || !FD->hasBody(Defn)) {
FD->setLazyBody(PB->second);
} else {
- auto *NonConstDefn = const_cast<FunctionDecl *>(Defn);
+ auto *NonConstDefn = const_cast<FunctionDecl*>(Defn);
mergeDefinitionVisibility(NonConstDefn, FD);
if (!FD->isLateTemplateParsed() &&
@@ -10606,7 +10604,7 @@ void ASTReader::diagnoseOdrViolations() {
// replaced by a more recent declaration in the lookup table), and we
// can't necessarily find it in the redeclaration chain because it might
// be merely mergeable, not redeclarable.
- llvm::SmallVector<const NamedDecl *, 4> Candidates;
+ llvm::SmallVector<const NamedDecl*, 4> Candidates;
for (auto *CanonMember : CanonDef->decls()) {
if (CanonMember->getCanonicalDecl() == DCanon) {
// This can happen if the declaration is merely mergeable and not
@@ -10636,18 +10634,17 @@ void ASTReader::diagnoseOdrViolations() {
ODRDiagsEmitter::getOwningModuleNameForDiagnostic(
cast<Decl>(CanonDef));
Diag(D->getLocation(), diag::err_module_odr_violation_missing_decl)
- << D << ODRDiagsEmitter::getOwningModuleNameForDiagnostic(D)
- << CanonDef << CanonDefModule.empty() << CanonDefModule;
+ << D << ODRDiagsEmitter::getOwningModuleNameForDiagnostic(D)
+ << CanonDef << CanonDefModule.empty() << CanonDefModule;
if (Candidates.empty())
Diag(cast<Decl>(CanonDef)->getLocation(),
- diag::note_module_odr_violation_no_possible_decls)
- << D;
+ diag::note_module_odr_violation_no_possible_decls) << D;
else {
for (unsigned I = 0, N = Candidates.size(); I != N; ++I)
Diag(Candidates[I]->getLocation(),
diag::note_module_odr_violation_possible_decl)
- << Candidates[I];
+ << Candidates[I];
}
DiagnosedOdrMergeFailures.insert(CanonDef);
@@ -10908,7 +10905,8 @@ ASTReader::ASTReader(Preprocessor &PP, InMemoryModuleCache &ModuleCache,
auto BlockName = Ext->getExtensionMetadata().BlockName;
auto Known = ModuleFileExtensions.find(BlockName);
if (Known != ModuleFileExtensions.end()) {
- Diags.Report(diag::warn_duplicate_module_file_extension) << BlockName;
+ Diags.Report(diag::warn_duplicate_module_file_extension)
+ << BlockName;
continue;
}
@@ -11416,7 +11414,8 @@ void OMPClauseReader::VisitOMPProcBindClause(OMPProcBindClause *C) {
void OMPClauseReader::VisitOMPScheduleClause(OMPScheduleClause *C) {
VisitOMPClauseWithPreInit(C);
- C->setScheduleKind(static_cast<OpenMPScheduleClauseKind>(Record.readInt()));
+ C->setScheduleKind(
+ static_cast<OpenMPScheduleClauseKind>(Record.readInt()));
C->setFirstScheduleModifier(
static_cast<OpenMPScheduleClauseModifier>(Record.readInt()));
C->setSecondScheduleModifier(
@@ -11574,8 +11573,9 @@ void OMPClauseReader::VisitOMPUnifiedSharedMemoryClause(
void OMPClauseReader::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {}
-void OMPClauseReader::VisitOMPDynamicAllocatorsClause(
- OMPDynamicAllocatorsClause *) {}
+void
+OMPClauseReader::VisitOMPDynamicAllocatorsClause(OMPDynamicAllocatorsClause *) {
+}
void OMPClauseReader::VisitOMPAtomicDefaultMemOrderClause(
OMPAtomicDefaultMemOrderClause *C) {
@@ -11909,7 +11909,8 @@ void OMPClauseReader::VisitOMPDepobjClause(OMPDepobjClause *C) {
void OMPClauseReader::VisitOMPDependClause(OMPDependClause *C) {
C->setLParenLoc(Record.readSourceLocation());
C->setModifier(Record.readSubExpr());
- C->setDependencyKind(static_cast<OpenMPDependClauseKind>(Record.readInt()));
+ C->setDependencyKind(
+ static_cast<OpenMPDependClauseKind>(Record.readInt()));
C->setDependencyLoc(Record.readSourceLocation());
C->setColonLoc(Record.readSourceLocation());
C->setOmpAllMemoryLoc(Record.readSourceLocation());
@@ -11935,15 +11936,16 @@ void OMPClauseReader::VisitOMPMapClause(OMPMapClause *C) {
C->setLParenLoc(Record.readSourceLocation());
bool HasIteratorModifier = false;
for (unsigned I = 0; I < NumberOfOMPMapClauseModifiers; ++I) {
- C->setMapTypeModifier(I,
- static_cast<OpenMPMapModifierKind>(Record.readInt()));
+ C->setMapTypeModifier(
+ I, static_cast<OpenMPMapModifierKind>(Record.readInt()));
C->setMapTypeModifierLoc(I, Record.readSourceLocation());
if (C->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_iterator)
HasIteratorModifier = true;
}
C->setMapperQualifierLoc(Record.readNestedNameSpecifierLoc());
C->setMapperIdInfo(Record.readDeclarationNameInfo());
- C->setMapType(static_cast<OpenMPMapClauseKind>(Record.readInt()));
+ C->setMapType(
+ static_cast<OpenMPMapClauseKind>(Record.readInt()));
C->setMapLoc(Record.readSourceLocation());
C->setColonLoc(Record.readSourceLocation());
auto NumVars = C->varlist_size();
@@ -12071,7 +12073,7 @@ void OMPClauseReader::VisitOMPDistScheduleClause(OMPDistScheduleClause *C) {
void OMPClauseReader::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) {
C->setDefaultmapKind(
- static_cast<OpenMPDefaultmapClauseKind>(Record.readInt()));
+ static_cast<OpenMPDefaultmapClauseKind>(Record.readInt()));
C->setDefaultmapModifier(
static_cast<OpenMPDefaultmapClauseModifier>(Record.readInt()));
C->setLParenLoc(Record.readSourceLocation());
@@ -12593,7 +12595,7 @@ OpenACCClause *ASTRecordReader::readOpenACCClause() {
SourceLocation LParenLoc = readSourceLocation();
Expr *IntExpr = readSubExpr();
return OpenACCDeviceNumClause::Create(getContext(), BeginLoc, LParenLoc,
- IntExpr, EndLoc);
+ IntExpr, EndLoc);
}
case OpenACCClauseKind::DefaultAsync: {
SourceLocation LParenLoc = readSourceLocation();
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index e24e752bfd0b1..c84e614dbef37 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -129,14 +129,15 @@ using namespace clang::serialization;
template <typename T, typename Allocator>
static StringRef bytes(const std::vector<T, Allocator> &v) {
- if (v.empty())
- return StringRef();
- return StringRef(reinterpret_cast<const char *>(&v[0]), sizeof(T) * v.size());
+ if (v.empty()) return StringRef();
+ return StringRef(reinterpret_cast<const char*>(&v[0]),
+ sizeof(T) * v.size());
}
-template <typename T> static StringRef bytes(const SmallVectorImpl<T> &v) {
- return StringRef(reinterpret_cast<const char *>(v.data()),
- sizeof(T) * v.size());
+template <typename T>
+static StringRef bytes(const SmallVectorImpl<T> &v) {
+ return StringRef(reinterpret_cast<const char*>(v.data()),
+ sizeof(T) * v.size());
}
static std::string bytes(const std::vector<bool> &V) {
@@ -157,9 +158,8 @@ static std::string bytes(const std::vector<bool> &V) {
static TypeCode getTypeCodeForTypeClass(Type::TypeClass id) {
switch (id) {
-#define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \
- case Type::CLASS_ID: \
- return TYPE_##CODE_ID;
+#define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \
+ case Type::CLASS_ID: return TYPE_##CODE_ID;
#include "clang/Serialization/TypeBitCodes.def"
case Type::Builtin:
llvm_unreachable("shouldn't be serializing a builtin type this way");
@@ -350,7 +350,8 @@ class TypeLocWriter : public TypeLocVisitor<TypeLocWriter> {
: Record(Record), Seq(Seq) {}
#define ABSTRACT_TYPELOC(CLASS, PARENT)
-#define TYPELOC(CLASS, PARENT) void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
+#define TYPELOC(CLASS, PARENT) \
+ void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
#include "clang/AST/TypeLocNodes.def"
void VisitArrayTypeLoc(ArrayTypeLoc TyLoc);
@@ -431,7 +432,7 @@ void TypeLocWriter::VisitVariableArrayTypeLoc(VariableArrayTypeLoc TL) {
}
void TypeLocWriter::VisitDependentSizedArrayTypeLoc(
- DependentSizedArrayTypeLoc TL) {
+ DependentSizedArrayTypeLoc TL) {
VisitArrayTypeLoc(TL);
}
@@ -445,7 +446,7 @@ void TypeLocWriter::VisitDependentAddressSpaceTypeLoc(
}
void TypeLocWriter::VisitDependentSizedExtVectorTypeLoc(
- DependentSizedExtVectorTypeLoc TL) {
+ DependentSizedExtVectorTypeLoc TL) {
addSourceLocation(TL.getNameLoc());
}
@@ -453,7 +454,8 @@ void TypeLocWriter::VisitVectorTypeLoc(VectorTypeLoc TL) {
addSourceLocation(TL.getNameLoc());
}
-void TypeLocWriter::VisitDependentVectorTypeLoc(DependentVectorTypeLoc TL) {
+void TypeLocWriter::VisitDependentVectorTypeLoc(
+ DependentVectorTypeLoc TL) {
addSourceLocation(TL.getNameLoc());
}
@@ -606,17 +608,17 @@ void TypeLocWriter::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
}
void TypeLocWriter::VisitSubstTemplateTypeParmTypeLoc(
- SubstTemplateTypeParmTypeLoc TL) {
+ SubstTemplateTypeParmTypeLoc TL) {
addSourceLocation(TL.getNameLoc());
}
void TypeLocWriter::VisitSubstTemplateTypeParmPackTypeLoc(
- SubstTemplateTypeParmPackTypeLoc TL) {
+ SubstTemplateTypeParmPackTypeLoc TL) {
addSourceLocation(TL.getNameLoc());
}
void TypeLocWriter::VisitTemplateSpecializationTypeLoc(
- TemplateSpecializationTypeLoc TL) {
+ TemplateSpecializationTypeLoc TL) {
addSourceLocation(TL.getTemplateKeywordLoc());
addSourceLocation(TL.getTemplateNameLoc());
addSourceLocation(TL.getLAngleLoc());
@@ -651,7 +653,7 @@ void TypeLocWriter::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
}
void TypeLocWriter::VisitDependentTemplateSpecializationTypeLoc(
- DependentTemplateSpecializationTypeLoc TL) {
+ DependentTemplateSpecializationTypeLoc TL) {
addSourceLocation(TL.getElaboratedKeywordLoc());
Record.AddNestedNameSpecifierLoc(TL.getQualifierLoc());
addSourceLocation(TL.getTemplateKeywordLoc());
@@ -714,8 +716,8 @@ void ASTWriter::WriteTypeAbbrevs() {
// Abbreviation for TYPE_EXT_QUAL
Abv = std::make_shared<BitCodeAbbrev>();
Abv->Add(BitCodeAbbrevOp(serialization::TYPE_EXT_QUAL));
- Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
- Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 3)); // Quals
+ Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
+ Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 3)); // Quals
TypeExtQualAbbrev = Stream.EmitAbbrev(std::move(Abv));
}
@@ -887,7 +889,7 @@ void ASTWriter::WriteBlockInfoBlock() {
RecordData Record;
Stream.EnterBlockInfoBlock();
-#define BLOCK(X) EmitBlockID(X##_ID, #X, Stream, Record)
+#define BLOCK(X) EmitBlockID(X ## _ID, #X, Stream, Record)
#define RECORD(X) EmitRecordID(X, #X, Stream, Record)
// Control Block.
@@ -1180,8 +1182,8 @@ static bool cleanPathForOutput(FileManager &FileMgr,
///
/// \returns either the original filename (if it needs no adjustment) or the
/// adjusted filename (which points into the @p Filename parameter).
-static const char *adjustFilenameForRelocatableAST(const char *Filename,
- StringRef BaseDir) {
+static const char *
+adjustFilenameForRelocatableAST(const char *Filename, StringRef BaseDir) {
assert(Filename && "No file name to adjust?");
if (BaseDir.empty())
@@ -1455,12 +1457,9 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
MetadataAbbrev->Add(BitCodeAbbrevOp(METADATA));
MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Major
MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Minor
- MetadataAbbrev->Add(
- BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Clang maj.
- MetadataAbbrev->Add(
- BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Clang min.
- MetadataAbbrev->Add(
- BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Relocatable
+ MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Clang maj.
+ MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Clang min.
+ MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Relocatable
// Standard C++ module
MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Timestamps
@@ -1563,13 +1562,13 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
auto Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(IMPORT));
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Kind
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ImportLoc
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Module name len
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ImportLoc
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Module name len
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Standard C++ mod
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File size
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File timestamp
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File name len
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Strings
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File size
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File timestamp
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File name len
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Strings
unsigned AbbrevCode = Stream.EmitAbbrev(std::move(Abbrev));
SmallString<128> Blob;
@@ -1615,9 +1614,9 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
// Language options.
Record.clear();
const LangOptions &LangOpts = PP.getLangOpts();
-#define LANGOPT(Name, Bits, Default, Description) \
+#define LANGOPT(Name, Bits, Default, Description) \
Record.push_back(LangOpts.Name);
-#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
+#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
Record.push_back(static_cast<unsigned>(LangOpts.get##Name()));
#include "clang/Basic/LangOptions.def"
#define SANITIZER(NAME, ID) \
@@ -1628,7 +1627,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
for (StringRef Feature : LangOpts.ModuleFeatures)
AddString(Feature, Record);
- Record.push_back((unsigned)LangOpts.ObjCRuntime.getKind());
+ Record.push_back((unsigned) LangOpts.ObjCRuntime.getKind());
AddVersionTuple(LangOpts.ObjCRuntime.getVersion(), Record);
AddString(LangOpts.CurrentModule, Record);
@@ -1739,7 +1738,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
FileAbbrev->Add(BitCodeAbbrevOp(ORIGINAL_FILE));
FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File ID
- FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // File name
+ FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // File name
unsigned FileAbbrevCode = Stream.EmitAbbrev(std::move(FileAbbrev));
Record.clear();
@@ -1756,7 +1755,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
Stream.ExitBlock();
}
-namespace {
+namespace {
/// An input file.
struct InputFileEntry {
@@ -1794,14 +1793,14 @@ void ASTWriter::WriteInputFiles(SourceManager &SourceMgr,
// Create input-file abbreviation.
auto IFAbbrev = std::make_shared<BitCodeAbbrev>();
IFAbbrev->Add(BitCodeAbbrevOp(INPUT_FILE));
- IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ID
+ IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ID
IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 12)); // Size
IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32)); // Modification time
IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Overridden
IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Transient
IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Top-level
IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Module map
- IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16)); // Name as req. len
+ IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16)); // Name as req. len
IFAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Name as req. + name
unsigned IFAbbrevCode = Stream.EmitAbbrev(std::move(IFAbbrev));
@@ -1946,15 +1945,15 @@ static unsigned CreateSLocFileAbbrev(llvm::BitstreamWriter &Stream) {
auto Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(SM_SLOC_FILE_ENTRY));
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Offset
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Include location
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Offset
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Include location
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Characteristic
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Line directives
// FileEntry fields.
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Input File ID
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // NumCreatedFIDs
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Input File ID
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // NumCreatedFIDs
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 24)); // FirstDeclIndex
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // NumDecls
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // NumDecls
return Stream.EmitAbbrev(std::move(Abbrev));
}
@@ -1965,11 +1964,11 @@ static unsigned CreateSLocBufferAbbrev(llvm::BitstreamWriter &Stream) {
auto Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(SM_SLOC_BUFFER_ENTRY));
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Offset
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Include location
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Offset
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Include location
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Characteristic
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Line directives
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Buffer name blob
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Buffer name blob
return Stream.EmitAbbrev(std::move(Abbrev));
}
@@ -1984,7 +1983,7 @@ static unsigned CreateSLocBufferBlobAbbrev(llvm::BitstreamWriter &Stream,
: SM_SLOC_BUFFER_BLOB));
if (Compressed)
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Uncompressed size
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Blob
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Blob
return Stream.EmitAbbrev(std::move(Abbrev));
}
@@ -1995,12 +1994,12 @@ static unsigned CreateSLocExpansionAbbrev(llvm::BitstreamWriter &Stream) {
auto Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(SM_SLOC_EXPANSION_ENTRY));
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Offset
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Spelling location
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Start location
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // End location
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Offset
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Spelling location
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Start location
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // End location
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Is token range
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Token length
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Token length
return Stream.EmitAbbrev(std::move(Abbrev));
}
@@ -2015,110 +2014,109 @@ emitULEBKeyDataLength(unsigned KeyLen, unsigned DataLen, raw_ostream &Out) {
namespace {
-// Trait used for the on-disk hash table of header search information.
-class HeaderFileInfoTrait {
- ASTWriter &Writer;
-
-public:
- HeaderFileInfoTrait(ASTWriter &Writer) : Writer(Writer) {}
-
- struct key_type {
- StringRef Filename;
- off_t Size;
- time_t ModTime;
- };
- using key_type_ref = const key_type &;
-
- using UnresolvedModule =
- llvm::PointerIntPair<Module *, 2, ModuleMap::ModuleHeaderRole>;
+ // Trait used for the on-disk hash table of header search information.
+ class HeaderFileInfoTrait {
+ ASTWriter &Writer;
- struct data_type {
- data_type(const HeaderFileInfo &HFI, bool AlreadyIncluded,
- ArrayRef<ModuleMap::KnownHeader> KnownHeaders,
- UnresolvedModule Unresolved)
- : HFI(HFI), AlreadyIncluded(AlreadyIncluded),
- KnownHeaders(KnownHeaders), Unresolved(Unresolved) {}
-
- HeaderFileInfo HFI;
- bool AlreadyIncluded;
- SmallVector<ModuleMap::KnownHeader, 1> KnownHeaders;
- UnresolvedModule Unresolved;
- };
- using data_type_ref = const data_type &;
-
- using hash_value_type = unsigned;
- using offset_type = unsigned;
+ public:
+ HeaderFileInfoTrait(ASTWriter &Writer) : Writer(Writer) {}
- hash_value_type ComputeHash(key_type_ref key) {
- // The hash is based only on size/time of the file, so that the reader can
- // match even when symlinking or excess path elements ("foo/../", "../")
- // change the form of the name. However, complete path is still the key.
- uint8_t buf[sizeof(key.Size) + sizeof(key.ModTime)];
- memcpy(buf, &key.Size, sizeof(key.Size));
- memcpy(buf + sizeof(key.Size), &key.ModTime, sizeof(key.ModTime));
- return llvm::xxh3_64bits(buf);
- }
+ struct key_type {
+ StringRef Filename;
+ off_t Size;
+ time_t ModTime;
+ };
+ using key_type_ref = const key_type &;
+
+ using UnresolvedModule =
+ llvm::PointerIntPair<Module *, 2, ModuleMap::ModuleHeaderRole>;
+
+ struct data_type {
+ data_type(const HeaderFileInfo &HFI, bool AlreadyIncluded,
+ ArrayRef<ModuleMap::KnownHeader> KnownHeaders,
+ UnresolvedModule Unresolved)
+ : HFI(HFI), AlreadyIncluded(AlreadyIncluded),
+ KnownHeaders(KnownHeaders), Unresolved(Unresolved) {}
+
+ HeaderFileInfo HFI;
+ bool AlreadyIncluded;
+ SmallVector<ModuleMap::KnownHeader, 1> KnownHeaders;
+ UnresolvedModule Unresolved;
+ };
+ using data_type_ref = const data_type &;
+
+ using hash_value_type = unsigned;
+ using offset_type = unsigned;
+
+ hash_value_type ComputeHash(key_type_ref key) {
+ // The hash is based only on size/time of the file, so that the reader can
+ // match even when symlinking or excess path elements ("foo/../", "../")
+ // change the form of the name. However, complete path is still the key.
+ uint8_t buf[sizeof(key.Size) + sizeof(key.ModTime)];
+ memcpy(buf, &key.Size, sizeof(key.Size));
+ memcpy(buf + sizeof(key.Size), &key.ModTime, sizeof(key.ModTime));
+ return llvm::xxh3_64bits(buf);
+ }
- std::pair<unsigned, unsigned>
- EmitKeyDataLength(raw_ostream &Out, key_type_ref key, data_type_ref Data) {
- unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
- unsigned DataLen = 1 + sizeof(IdentifierID);
- for (auto ModInfo : Data.KnownHeaders)
- if (Writer.getLocalOrImportedSubmoduleID(ModInfo.getModule()))
+ std::pair<unsigned, unsigned>
+ EmitKeyDataLength(raw_ostream& Out, key_type_ref key, data_type_ref Data) {
+ unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
+ unsigned DataLen = 1 + sizeof(IdentifierID);
+ for (auto ModInfo : Data.KnownHeaders)
+ if (Writer.getLocalOrImportedSubmoduleID(ModInfo.getModule()))
+ DataLen += 4;
+ if (Data.Unresolved.getPointer())
DataLen += 4;
- if (Data.Unresolved.getPointer())
- DataLen += 4;
- return emitULEBKeyDataLength(KeyLen, DataLen, Out);
- }
-
- void EmitKey(raw_ostream &Out, key_type_ref key, unsigned KeyLen) {
- using namespace llvm::support;
+ return emitULEBKeyDataLength(KeyLen, DataLen, Out);
+ }
- endian::Writer LE(Out, llvm::endianness::little);
- LE.write<uint64_t>(key.Size);
- KeyLen -= 8;
- LE.write<uint64_t>(key.ModTime);
- KeyLen -= 8;
- Out.write(key.Filename.data(), KeyLen);
- }
+ void EmitKey(raw_ostream& Out, key_type_ref key, unsigned KeyLen) {
+ using namespace llvm::support;
- void EmitData(raw_ostream &Out, key_type_ref key, data_type_ref Data,
- unsigned DataLen) {
- using namespace llvm::support;
+ endian::Writer LE(Out, llvm::endianness::little);
+ LE.write<uint64_t>(key.Size);
+ KeyLen -= 8;
+ LE.write<uint64_t>(key.ModTime);
+ KeyLen -= 8;
+ Out.write(key.Filename.data(), KeyLen);
+ }
- endian::Writer LE(Out, llvm::endianness::little);
- uint64_t Start = Out.tell();
- (void)Start;
+ void EmitData(raw_ostream &Out, key_type_ref key,
+ data_type_ref Data, unsigned DataLen) {
+ using namespace llvm::support;
- unsigned char Flags =
- (Data.AlreadyIncluded << 6) | (Data.HFI.isImport << 5) |
- (Writer.isWritingStdCXXNamedModules() ? 0
- : Data.HFI.isPragmaOnce << 4) |
- (Data.HFI.DirInfo << 1);
- LE.write<uint8_t>(Flags);
+ endian::Writer LE(Out, llvm::endianness::little);
+ uint64_t Start = Out.tell(); (void)Start;
- if (Data.HFI.LazyControllingMacro.isID())
- LE.write<IdentifierID>(Data.HFI.LazyControllingMacro.getID());
- else
- LE.write<IdentifierID>(
- Writer.getIdentifierRef(Data.HFI.LazyControllingMacro.getPtr()));
+ unsigned char Flags = (Data.AlreadyIncluded << 6)
+ | (Data.HFI.isImport << 5)
+ | (Writer.isWritingStdCXXNamedModules() ? 0 :
+ Data.HFI.isPragmaOnce << 4)
+ | (Data.HFI.DirInfo << 1);
+ LE.write<uint8_t>(Flags);
- auto EmitModule = [&](Module *M, ModuleMap::ModuleHeaderRole Role) {
- if (uint32_t ModID = Writer.getLocalOrImportedSubmoduleID(M)) {
- uint32_t Value = (ModID << 3) | (unsigned)Role;
- assert((Value >> 3) == ModID && "overflow in header module info");
- LE.write<uint32_t>(Value);
- }
- };
+ if (Data.HFI.LazyControllingMacro.isID())
+ LE.write<IdentifierID>(Data.HFI.LazyControllingMacro.getID());
+ else
+ LE.write<IdentifierID>(
+ Writer.getIdentifierRef(Data.HFI.LazyControllingMacro.getPtr()));
+
+ auto EmitModule = [&](Module *M, ModuleMap::ModuleHeaderRole Role) {
+ if (uint32_t ModID = Writer.getLocalOrImportedSubmoduleID(M)) {
+ uint32_t Value = (ModID << 3) | (unsigned)Role;
+ assert((Value >> 3) == ModID && "overflow in header module info");
+ LE.write<uint32_t>(Value);
+ }
+ };
- for (auto ModInfo : Data.KnownHeaders)
- EmitModule(ModInfo.getModule(), ModInfo.getRole());
- if (Data.Unresolved.getPointer())
- EmitModule(Data.Unresolved.getPointer(), Data.Unresolved.getInt());
+ for (auto ModInfo : Data.KnownHeaders)
+ EmitModule(ModInfo.getModule(), ModInfo.getRole());
+ if (Data.Unresolved.getPointer())
+ EmitModule(Data.Unresolved.getPointer(), Data.Unresolved.getInt());
- assert(Out.tell() - Start == DataLen && "Wrong data length");
- }
-};
+ assert(Out.tell() - Start == DataLen && "Wrong data length");
+ }
+ };
} // namespace
@@ -2216,13 +2214,12 @@ void ASTWriter::WriteHeaderSearch(const HeaderSearch &HS) {
bool Included = HFI->IsLocallyIncluded || PP->alreadyIncluded(*File);
- HeaderFileInfoTrait::key_type Key = {Filename, File->getSize(),
- getTimestampForOutput(*File)};
+ HeaderFileInfoTrait::key_type Key = {
+ Filename, File->getSize(), getTimestampForOutput(*File)
+ };
HeaderFileInfoTrait::data_type Data = {
- *HFI,
- Included,
- HS.getModuleMap().findResolvedModulesForHeader(*File),
- {}};
+ *HFI, Included, HS.getModuleMap().findResolvedModulesForHeader(*File), {}
+ };
Generator.insert(Key, Data, GeneratorTrait);
++NumHeaderSearchEntries;
}
@@ -2317,7 +2314,8 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr) {
std::vector<uint32_t> SLocEntryOffsets;
uint64_t SLocEntryOffsetsBase = Stream.GetCurrentBitNo();
SLocEntryOffsets.reserve(SourceMgr.local_sloc_entry_size() - 1);
- for (unsigned I = 1, N = SourceMgr.local_sloc_entry_size(); I != N; ++I) {
+ for (unsigned I = 1, N = SourceMgr.local_sloc_entry_size();
+ I != N; ++I) {
// Get this source location entry.
const SrcMgr::SLocEntry *SLoc = &SourceMgr.getLocalSLocEntry(I);
FileID FID = FileID::get(I);
@@ -2441,7 +2439,7 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr) {
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16)); // # of slocs
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16)); // total size
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32)); // base offset
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // offsets
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // offsets
unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
{
RecordData::value_type Record[] = {
@@ -2466,9 +2464,8 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr) {
if (L.first.ID < 0)
continue;
for (auto &LE : L.second) {
- if (FilenameMap
- .insert(std::make_pair(LE.FilenameID, FilenameMap.size() - 1))
- .second)
+ if (FilenameMap.insert(std::make_pair(LE.FilenameID,
+ FilenameMap.size() - 1)).second)
AddPath(LineTable.getFilename(LE.FilenameID), Record);
}
}
@@ -2596,7 +2593,7 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
for (auto &Id : PP.getIdentifierTable())
if (Id.second->hadMacroDefinition() &&
(!Id.second->isFromAST() ||
- Id.second->hasChangedSinceDeserialization()))
+ Id.second->hasChangedSinceDeserialization()))
MacroIdentifiers.push_back(Id.second);
// Sort the set of macro definitions that need to be serialized by the
// name of the macro, to provide a stable ordering.
@@ -2794,20 +2791,20 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec,
auto Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(PPD_INCLUSION_DIRECTIVE));
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // filename length
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // in quotes
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // kind
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // imported module
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // in quotes
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // kind
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // imported module
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
InclusionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
}
- unsigned FirstPreprocessorEntityID =
- (Chain ? PPRec.getNumLoadedPreprocessedEntities() : 0) +
- NUM_PREDEF_PP_ENTITY_IDS;
+ unsigned FirstPreprocessorEntityID
+ = (Chain ? PPRec.getNumLoadedPreprocessedEntities() : 0)
+ + NUM_PREDEF_PP_ENTITY_IDS;
unsigned NextPreprocessorEntityID = FirstPreprocessorEntityID;
RecordData Record;
for (PreprocessingRecord::iterator E = PPRec.local_begin(),
- EEnd = PPRec.local_end();
+ EEnd = PPRec.local_end();
E != EEnd;
(void)++E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) {
Record.clear();
@@ -2883,7 +2880,7 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec,
if (SkippedRanges.size() > 0) {
std::vector<PPSkippedRange> SerializedSkippedRanges;
SerializedSkippedRanges.reserve(SkippedRanges.size());
- for (auto const &Range : SkippedRanges)
+ for (auto const& Range : SkippedRanges)
SerializedSkippedRanges.emplace_back(
getRawSourceLocationEncoding(Range.getBegin()),
getRawSourceLocationEncoding(Range.getEnd()));
@@ -2940,15 +2937,15 @@ static unsigned getNumberOfModules(Module *Mod) {
void ASTWriter::WriteSubmodules(Module *WritingModule, ASTContext *Context) {
// Enter the submodule description block.
- Stream.EnterSubblock(SUBMODULE_BLOCK_ID, /*bits for abbreviations*/ 5);
+ Stream.EnterSubblock(SUBMODULE_BLOCK_ID, /*bits for abbreviations*/5);
// Write the abbreviations needed for the submodules block.
using namespace llvm;
auto Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(SUBMODULE_DEFINITION));
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ID
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Parent
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ID
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Parent
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // Kind
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Definition location
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // Inferred allowed by
@@ -2962,7 +2959,7 @@ void ASTWriter::WriteSubmodules(Module *WritingModule, ASTContext *Context) {
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ConfigMacrosExh...
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ModuleMapIsPriv...
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // NamedModuleHasN...
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Name
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Name
unsigned DefinitionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
Abbrev = std::make_shared<BitCodeAbbrev>();
@@ -3019,24 +3016,24 @@ void ASTWriter::WriteSubmodules(Module *WritingModule, ASTContext *Context) {
Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(SUBMODULE_CONFIG_MACRO));
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Macro name
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Macro name
unsigned ConfigMacroAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(SUBMODULE_CONFLICT));
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Other module
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Message
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Other module
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Message
unsigned ConflictAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(SUBMODULE_EXPORT_AS));
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Macro name
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Macro name
unsigned ExportAsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
// Write the submodule metadata block.
- RecordData::value_type Record[] = {getNumberOfModules(WritingModule),
- FirstSubmoduleID -
- NUM_PREDEF_SUBMODULE_IDS};
+ RecordData::value_type Record[] = {
+ getNumberOfModules(WritingModule),
+ FirstSubmoduleID - NUM_PREDEF_SUBMODULE_IDS};
Stream.EmitRecord(SUBMODULE_METADATA, Record);
// Write all of the submodules.
@@ -3108,12 +3105,13 @@ void ASTWriter::WriteSubmodules(Module *WritingModule, ASTContext *Context) {
unsigned Abbrev;
Module::HeaderKind HeaderKind;
} HeaderLists[] = {
- {SUBMODULE_HEADER, HeaderAbbrev, Module::HK_Normal},
- {SUBMODULE_TEXTUAL_HEADER, TextualHeaderAbbrev, Module::HK_Textual},
- {SUBMODULE_PRIVATE_HEADER, PrivateHeaderAbbrev, Module::HK_Private},
- {SUBMODULE_PRIVATE_TEXTUAL_HEADER, PrivateTextualHeaderAbbrev,
- Module::HK_PrivateTextual},
- {SUBMODULE_EXCLUDED_HEADER, ExcludedHeaderAbbrev, Module::HK_Excluded}};
+ {SUBMODULE_HEADER, HeaderAbbrev, Module::HK_Normal},
+ {SUBMODULE_TEXTUAL_HEADER, TextualHeaderAbbrev, Module::HK_Textual},
+ {SUBMODULE_PRIVATE_HEADER, PrivateHeaderAbbrev, Module::HK_Private},
+ {SUBMODULE_PRIVATE_TEXTUAL_HEADER, PrivateTextualHeaderAbbrev,
+ Module::HK_PrivateTextual},
+ {SUBMODULE_EXCLUDED_HEADER, ExcludedHeaderAbbrev, Module::HK_Excluded}
+ };
for (const auto &HL : HeaderLists) {
RecordData::value_type Record[] = {HL.RecordKind};
for (const auto &H : Mod->getHeaders(HL.HeaderKind))
@@ -3158,9 +3156,9 @@ void ASTWriter::WriteSubmodules(Module *WritingModule, ASTContext *Context) {
Stream.EmitRecord(SUBMODULE_EXPORTS, Record);
}
- // FIXME: How do we emit the 'use'd modules? They may not be submodules.
- // Might be unnecessary as use declarations are only used to build the
- // module itself.
+ //FIXME: How do we emit the 'use'd modules? They may not be submodules.
+ // Might be unnecessary as use declarations are only used to build the
+ // module itself.
// TODO: Consider serializing undeclared uses of modules.
@@ -3413,7 +3411,7 @@ void ASTWriter::WriteTypeDeclOffsets() {
auto Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(TYPE_OFFSET));
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // # of types
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // types block
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // types block
unsigned TypeOffsetAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
{
RecordData::value_type Record[] = {TYPE_OFFSET, TypeOffsets.size()};
@@ -3517,7 +3515,8 @@ class ASTMethodPoolTrait {
}
std::pair<unsigned, unsigned>
- EmitKeyDataLength(raw_ostream &Out, Selector Sel, data_type_ref Methods) {
+ EmitKeyDataLength(raw_ostream& Out, Selector Sel,
+ data_type_ref Methods) {
unsigned KeyLen =
2 + (Sel.getNumArgs() ? Sel.getNumArgs() * sizeof(IdentifierID)
: sizeof(IdentifierID));
@@ -3533,7 +3532,7 @@ class ASTMethodPoolTrait {
return emitULEBKeyDataLength(KeyLen, DataLen, Out);
}
- void EmitKey(raw_ostream &Out, Selector Sel, unsigned) {
+ void EmitKey(raw_ostream& Out, Selector Sel, unsigned) {
using namespace llvm::support;
endian::Writer LE(Out, llvm::endianness::little);
@@ -3549,13 +3548,12 @@ class ASTMethodPoolTrait {
Writer.getIdentifierRef(Sel.getIdentifierInfoForSlot(I)));
}
- void EmitData(raw_ostream &Out, key_type_ref, data_type_ref Methods,
- unsigned DataLen) {
+ void EmitData(raw_ostream& Out, key_type_ref,
+ data_type_ref Methods, unsigned DataLen) {
using namespace llvm::support;
endian::Writer LE(Out, llvm::endianness::little);
- uint64_t Start = Out.tell();
- (void)Start;
+ uint64_t Start = Out.tell(); (void)Start;
LE.write<uint32_t>(Methods.ID);
unsigned NumInstanceMethods = 0;
for (const ObjCMethodList *Method = &Methods.Instance; Method;
@@ -3630,8 +3628,11 @@ void ASTWriter::WriteSelectors(Sema &SemaRef) {
SelectorID ID = SelectorAndID.second;
SemaObjC::GlobalMethodPool::iterator F =
SemaRef.ObjC().MethodPool.find(S);
- ASTMethodPoolTrait::data_type Data = {ID, ObjCMethodList(),
- ObjCMethodList()};
+ ASTMethodPoolTrait::data_type Data = {
+ ID,
+ ObjCMethodList(),
+ ObjCMethodList()
+ };
if (F != SemaRef.ObjC().MethodPool.end()) {
Data.Instance = F->second.first;
Data.Factory = F->second.second;
@@ -3840,7 +3841,7 @@ class ASTIdentifierTableTrait {
bool needDecls() const { return NeedDecls; }
- static hash_value_type ComputeHash(const IdentifierInfo *II) {
+ static hash_value_type ComputeHash(const IdentifierInfo* II) {
return llvm::djbHash(II->getName());
}
@@ -3849,9 +3850,8 @@ class ASTIdentifierTableTrait {
return isInterestingIdentifier(II, MacroOffset);
}
- std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &Out,
- const IdentifierInfo *II,
- IdentifierID ID) {
+ std::pair<unsigned, unsigned>
+ EmitKeyDataLength(raw_ostream &Out, const IdentifierInfo *II, IdentifierID ID) {
// Record the location of the identifier data. This is used when generating
// the mapping from persistent IDs to strings.
Writer.SetIdentifierOffset(II, Out.tell());
@@ -4053,8 +4053,7 @@ class ASTDeclContextNameLookupTraitBase {
return std::make_pair(Start, DeclIDs.size());
}
- data_type ImportData(
- const reader::ASTDeclContextNameLookupTrait::data_type &FromReader) {
+ data_type ImportData(const reader::ASTDeclContextNameLookupTrait::data_type &FromReader) {
unsigned Start = DeclIDs.size();
DeclIDs.insert(
DeclIDs.end(),
@@ -4139,8 +4138,7 @@ class ASTDeclContextNameLookupTraitBase {
using namespace llvm::support;
endian::Writer LE(Out, llvm::endianness::little);
- uint64_t Start = Out.tell();
- (void)Start;
+ uint64_t Start = Out.tell(); (void)Start;
for (unsigned I = Lookup.first, N = Lookup.second; I != N; ++I)
LE.write<DeclID>((DeclID)DeclIDs[I]);
assert(Out.tell() - Start == DataLen && "Data length is wrong");
@@ -4537,7 +4535,7 @@ void ASTWriter::GenerateNameLookupTable(
"must call buildLookups first");
// FIXME: We need to build the lookups table, which is logically const.
- auto *DC = const_cast<DeclContext *>(ConstDC);
+ auto *DC = const_cast<DeclContext*>(ConstDC);
assert(DC == DC->getPrimaryContext() && "only primary DC has lookup table");
// Create the on-disk hash table representation.
@@ -4948,7 +4946,7 @@ void ASTWriter::WriteOpenCLExtensions(Sema &SemaRef) {
const OpenCLOptions &Opts = SemaRef.getOpenCLOptions();
RecordData Record;
- for (const auto &I : Opts.OptMap) {
+ for (const auto &I:Opts.OptMap) {
AddString(I.getKey(), Record);
auto V = I.getValue();
Record.push_back(V.Supported ? 1 : 0);
@@ -4982,8 +4980,8 @@ void ASTWriter::WriteObjCCategories() {
// Add the categories.
for (ObjCInterfaceDecl::known_categories_iterator
- Cat = Class->known_categories_begin(),
- CatEnd = Class->known_categories_end();
+ Cat = Class->known_categories_begin(),
+ CatEnd = Class->known_categories_end();
Cat != CatEnd; ++Cat, ++Size) {
assert(getDeclID(*Cat).isValid() && "Bogus category");
AddDeclRef(*Cat, Categories);
@@ -4993,7 +4991,7 @@ void ASTWriter::WriteObjCCategories() {
Categories[StartIndex] = Size;
// Record this interface -> category map.
- ObjCCategoriesInfo CatInfo = {getDeclID(Class), StartIndex};
+ ObjCCategoriesInfo CatInfo = { getDeclID(Class), StartIndex };
CategoriesMap.push_back(CatInfo);
}
@@ -5057,7 +5055,7 @@ void ASTWriter::WriteMSStructPragmaOptions(Sema &SemaRef) {
}
/// Write the state of 'pragma pointers_to_members' at the end of the
-// module.
+//module.
void ASTWriter::WriteMSPointersToMembersPragmaOptions(Sema &SemaRef) {
RecordData Record;
Record.push_back(SemaRef.MSPointerToMemberRepresentationMethod);
@@ -5160,8 +5158,8 @@ void ASTRecordWriter::AddAttr(const Attr *A) {
// FIXME: Clang can't handle the serialization/deserialization of
// preferred_name properly now. See
// https://github.com/llvm/llvm-project/issues/56490 for example.
- if (!A ||
- (isa<PreferredNameAttr>(A) && Writer->isWritingStdCXXNamedModules()))
+ if (!A || (isa<PreferredNameAttr>(A) &&
+ Writer->isWritingStdCXXNamedModules()))
return Record.push_back(0);
Record.push_back(A->getKind() + 1); // FIXME: stable encoding, target attrs
@@ -5397,7 +5395,7 @@ ASTWriter::WriteAST(llvm::PointerUnion<Sema *, Preprocessor *> Subject,
return Signature;
}
-template <typename Vector>
+template<typename Vector>
static void AddLazyVectorDecls(ASTWriter &Writer, Vector &Vec) {
for (typename Vector::iterator I = Vec.begin(nullptr, true), E = Vec.end();
I != E; ++I) {
@@ -5516,7 +5514,7 @@ void ASTWriter::PrepareWritingSpecialDecls(Sema &SemaRef) {
bool isModule = WritingModule != nullptr;
// Set up predefined declaration IDs.
- auto RegisterPredefDecl = [&](Decl *D, PredefinedDeclIDs ID) {
+ auto RegisterPredefDecl = [&] (Decl *D, PredefinedDeclIDs ID) {
if (D) {
assert(D->isCanonicalDecl() && "predefined decl is not canonical");
DeclIDs[D] = ID;
@@ -5538,7 +5536,8 @@ void ASTWriter::PrepareWritingSpecialDecls(Sema &SemaRef) {
RegisterPredefDecl(Context.VaListTagDecl, PREDEF_DECL_VA_LIST_TAG);
RegisterPredefDecl(Context.BuiltinMSVaListDecl,
PREDEF_DECL_BUILTIN_MS_VA_LIST_ID);
- RegisterPredefDecl(Context.MSGuidTagDecl, PREDEF_DECL_BUILTIN_MS_GUID_ID);
+ RegisterPredefDecl(Context.MSGuidTagDecl,
+ PREDEF_DECL_BUILTIN_MS_GUID_ID);
RegisterPredefDecl(Context.ExternCContext, PREDEF_DECL_EXTERN_C_CONTEXT_ID);
RegisterPredefDecl(Context.MakeIntegerSeqDecl,
PREDEF_DECL_MAKE_INTEGER_SEQ_ID);
@@ -5660,7 +5659,7 @@ void ASTWriter::PrepareWritingSpecialDecls(Sema &SemaRef) {
// Make sure all decls associated with an identifier are registered for
// serialization, if we're storing decls with identifiers.
if (!WritingModule || !getLangOpts().CPlusPlus) {
- llvm::SmallVector<const IdentifierInfo *, 256> IIs;
+ llvm::SmallVector<const IdentifierInfo*, 256> IIs;
for (const auto &ID : SemaRef.PP.getIdentifierTable()) {
const IdentifierInfo *II = ID.second;
if (!Chain || !II->isFromAST() || II->hasChangedSinceDeserialization())
@@ -5777,7 +5776,7 @@ void ASTWriter::WriteSpecialDeclRecords(Sema &SemaRef) {
AddDeclRef(D, DeclsToCheckForDeferredDiags);
if (!DeclsToCheckForDeferredDiags.empty())
Stream.EmitRecord(DECLS_TO_CHECK_FOR_DEFERRED_DIAGS,
- DeclsToCheckForDeferredDiags);
+ DeclsToCheckForDeferredDiags);
// Write the record containing CUDA-specific declaration references.
RecordData CUDASpecialDeclRefs;
@@ -6003,8 +6002,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema *SemaPtr, StringRef isysroot,
uint32_t None = std::numeric_limits<uint32_t>::max();
auto writeBaseIDOrNone = [&](auto BaseID, bool ShouldWrite) {
- assert(BaseID < std::numeric_limits<uint32_t>::max() &&
- "base id too high");
+ assert(BaseID < std::numeric_limits<uint32_t>::max() && "base id too high");
if (ShouldWrite)
LE.write<uint32_t>(BaseID);
else
@@ -6021,8 +6019,8 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema *SemaPtr, StringRef isysroot,
}
}
RecordData::value_type Record[] = {MODULE_OFFSET_MAP};
- Stream.EmitRecordWithBlob(ModuleOffsetMapAbbrev, Record, Buffer.data(),
- Buffer.size());
+ Stream.EmitRecordWithBlob(ModuleOffsetMapAbbrev, Record,
+ Buffer.data(), Buffer.size());
}
if (SemaPtr)
@@ -6057,7 +6055,8 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema *SemaPtr, StringRef isysroot,
// Write the record containing weak undeclared identifiers.
if (!WeakUndeclaredIdentifiers.empty())
- Stream.EmitRecord(WEAK_UNDECLARED_IDENTIFIERS, WeakUndeclaredIdentifiers);
+ Stream.EmitRecord(WEAK_UNDECLARED_IDENTIFIERS,
+ WeakUndeclaredIdentifiers);
if (!WritingModule) {
// Write the submodules that were imported, if any.
@@ -6425,7 +6424,7 @@ void ASTWriter::WriteDeclUpdatesBlocks(ASTContext &Context,
// specialization. If so, record which one.
auto From = Spec->getInstantiatedFrom();
if (auto PartialSpec =
- From.dyn_cast<ClassTemplatePartialSpecializationDecl *>()) {
+ From.dyn_cast<ClassTemplatePartialSpecializationDecl*>()) {
Record.push_back(true);
Record.AddDeclRef(PartialSpec);
Record.AddTemplateArgumentList(
@@ -6455,7 +6454,7 @@ void ASTWriter::WriteDeclUpdatesBlocks(ASTContext &Context,
case UPD_CXX_RESOLVED_EXCEPTION_SPEC: {
auto prototype =
- cast<FunctionDecl>(D)->getType()->castAs<FunctionProtoType>();
+ cast<FunctionDecl>(D)->getType()->castAs<FunctionProtoType>();
Record.writeExceptionSpecInfo(prototype->getExceptionSpecInfo());
break;
}
@@ -6542,8 +6541,10 @@ FileID ASTWriter::getAdjustedFileID(FileID FID) const {
}
unsigned ASTWriter::getAdjustedNumCreatedFIDs(FileID FID) const {
- unsigned NumCreatedFIDs =
- PP->getSourceManager().getLocalSLocEntry(FID.ID).getFile().NumCreatedFIDs;
+ unsigned NumCreatedFIDs = PP->getSourceManager()
+ .getLocalSLocEntry(FID.ID)
+ .getFile()
+ .NumCreatedFIDs;
unsigned AdjustedNumCreatedFIDs = 0;
for (unsigned I = FID.ID, N = I + NumCreatedFIDs; I != N; ++I)
@@ -6634,8 +6635,7 @@ void ASTRecordWriter::AddAPFloat(const llvm::APFloat &Value) {
AddAPInt(Value.bitcastToAPInt());
}
-void ASTWriter::AddIdentifierRef(const IdentifierInfo *II,
- RecordDataImpl &Record) {
+void ASTWriter::AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record) {
Record.push_back(getIdentifierRef(II));
}
@@ -6659,7 +6659,7 @@ MacroID ASTWriter::getMacroRef(MacroInfo *MI, const IdentifierInfo *Name) {
MacroID &ID = MacroIDs[MI];
if (ID == 0) {
ID = NextMacroID++;
- MacroInfoToEmitData Info = {Name, MI, ID};
+ MacroInfoToEmitData Info = { Name, MI, ID };
MacroInfosToEmit.push_back(Info);
}
return ID;
@@ -6729,8 +6729,8 @@ void ASTRecordWriter::AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg) {
AddTemplateArgument(Arg.getArgument());
if (Arg.getArgument().getKind() == TemplateArgument::Expression) {
- bool InfoHasSameExpr =
- Arg.getArgument().getAsExpr() == Arg.getLocInfo().getAsExpr();
+ bool InfoHasSameExpr
+ = Arg.getArgument().getAsExpr() == Arg.getLocInfo().getAsExpr();
Record->push_back(InfoHasSameExpr);
if (InfoHasSameExpr)
return; // Avoid storing the same expr twice.
@@ -6991,7 +6991,7 @@ void ASTRecordWriter::AddQualifierInfo(const QualifierInfo &Info) {
void ASTRecordWriter::AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS) {
// Nested name specifiers usually aren't too long. I think that 8 would
// typically accommodate the vast majority.
- SmallVector<NestedNameSpecifierLoc, 8> NestedNames;
+ SmallVector<NestedNameSpecifierLoc , 8> NestedNames;
// Push each of the nested-name-specifiers's onto a stack for
// serialization in reverse order.
@@ -7001,10 +7001,10 @@ void ASTRecordWriter::AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS) {
}
Record->push_back(NestedNames.size());
- while (!NestedNames.empty()) {
+ while(!NestedNames.empty()) {
NNS = NestedNames.pop_back_val();
- NestedNameSpecifier::SpecifierKind Kind =
- NNS.getNestedNameSpecifier()->getKind();
+ NestedNameSpecifier::SpecifierKind Kind
+ = NNS.getNestedNameSpecifier()->getKind();
Record->push_back(Kind);
switch (Kind) {
case NestedNameSpecifier::Identifier:
@@ -7082,8 +7082,8 @@ void ASTRecordWriter::AddASTTemplateArgumentListInfo(
void ASTRecordWriter::AddUnresolvedSet(const ASTUnresolvedSet &Set) {
Record->push_back(Set.size());
- for (ASTUnresolvedSet::const_iterator I = Set.begin(), E = Set.end(); I != E;
- ++I) {
+ for (ASTUnresolvedSet::const_iterator
+ I = Set.begin(), E = Set.end(); I != E; ++I) {
AddDeclRef(I.getDecl());
Record->push_back(I.getAccess());
}
@@ -7097,8 +7097,8 @@ void ASTRecordWriter::AddCXXBaseSpecifier(const CXXBaseSpecifier &Base) {
Record->push_back(Base.getInheritConstructors());
AddTypeSourceInfo(Base.getTypeSourceInfo());
AddSourceRange(Base.getSourceRange());
- AddSourceLocation(Base.isPackExpansion() ? Base.getEllipsisLoc()
- : SourceLocation());
+ AddSourceLocation(Base.isPackExpansion()? Base.getEllipsisLoc()
+ : SourceLocation());
}
static uint64_t EmitCXXBaseSpecifiers(ASTContext &Context, ASTWriter &W,
@@ -7133,7 +7133,7 @@ EmitCXXCtorInitializers(ASTContext &Context, ASTWriter &W,
} else if (Init->isDelegatingInitializer()) {
Writer.push_back(CTOR_INITIALIZER_DELEGATING);
Writer.AddTypeSourceInfo(Init->getTypeSourceInfo());
- } else if (Init->isMemberInitializer()) {
+ } else if (Init->isMemberInitializer()){
Writer.push_back(CTOR_INITIALIZER_MEMBER);
Writer.AddDeclRef(Init->getMember());
} else {
@@ -7281,8 +7281,10 @@ void ASTRecordWriter::AddVarDeclInit(const VarDecl *VD) {
void ASTWriter::ReaderInitialized(ASTReader *Reader) {
assert(Reader && "Cannot remove chain");
assert((!Chain || Chain == Reader) && "Cannot replace chain");
- assert(FirstDeclID == NextDeclID && FirstTypeID == NextTypeID &&
- FirstIdentID == NextIdentID && FirstMacroID == NextMacroID &&
+ assert(FirstDeclID == NextDeclID &&
+ FirstTypeID == NextTypeID &&
+ FirstIdentID == NextIdentID &&
+ FirstMacroID == NextMacroID &&
FirstSubmoduleID == NextSubmoduleID &&
FirstSelectorID == NextSelectorID &&
"Setting chain after writing has started.");
@@ -7378,8 +7380,7 @@ void ASTWriter::ModuleRead(serialization::SubmoduleID ID, Module *Mod) {
}
void ASTWriter::CompletedTagDefinition(const TagDecl *D) {
- if (Chain && Chain->isProcessingUpdateRecords())
- return;
+ if (Chain && Chain->isProcessingUpdateRecords()) return;
assert(D->isCompleteDefinition());
assert(!WritingAST && "Already writing the AST!");
if (auto *RD = dyn_cast<CXXRecordDecl>(D)) {
@@ -7406,10 +7407,9 @@ static bool isImportedDeclContext(ASTReader *Chain, const Decl *D) {
}
void ASTWriter::AddedVisibleDecl(const DeclContext *DC, const Decl *D) {
- if (Chain && Chain->isProcessingUpdateRecords())
- return;
+ if (Chain && Chain->isProcessingUpdateRecords()) return;
assert(DC->isLookupContext() &&
- "Should not add lookup results to non-lookup contexts!");
+ "Should not add lookup results to non-lookup contexts!");
// TU is handled elsewhere.
if (isa<TranslationUnitDecl>(DC))
@@ -7441,8 +7441,7 @@ void ASTWriter::AddedVisibleDecl(const DeclContext *DC, const Decl *D) {
}
void ASTWriter::AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) {
- if (Chain && Chain->isProcessingUpdateRecords())
- return;
+ if (Chain && Chain->isProcessingUpdateRecords()) return;
assert(D->isImplicit());
// We're only interested in cases where a local declaration is added to an
@@ -7460,11 +7459,9 @@ void ASTWriter::AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) {
}
void ASTWriter::ResolvedExceptionSpec(const FunctionDecl *FD) {
- if (Chain && Chain->isProcessingUpdateRecords())
- return;
+ if (Chain && Chain->isProcessingUpdateRecords()) return;
assert(!DoneWritingDeclsAndTypes && "Already done writing updates!");
- if (!Chain)
- return;
+ if (!Chain) return;
Chain->forEachImportedKeyDecl(FD, [&](const Decl *D) {
// If we don't already know the exception specification for this redecl
// chain, add an update record for it.
@@ -7477,11 +7474,9 @@ void ASTWriter::ResolvedExceptionSpec(const FunctionDecl *FD) {
}
void ASTWriter::DeducedReturnType(const FunctionDecl *FD, QualType ReturnType) {
- if (Chain && Chain->isProcessingUpdateRecords())
- return;
+ if (Chain && Chain->isProcessingUpdateRecords()) return;
assert(!WritingAST && "Already writing the AST!");
- if (!Chain)
- return;
+ if (!Chain) return;
Chain->forEachImportedKeyDecl(FD, [&](const Decl *D) {
DeclUpdates[D].push_back(
DeclUpdate(UPD_CXX_DEDUCED_RETURN_TYPE, ReturnType));
@@ -7491,20 +7486,17 @@ void ASTWriter::DeducedReturnType(const FunctionDecl *FD, QualType ReturnType) {
void ASTWriter::ResolvedOperatorDelete(const CXXDestructorDecl *DD,
const FunctionDecl *Delete,
Expr *ThisArg) {
- if (Chain && Chain->isProcessingUpdateRecords())
- return;
+ if (Chain && Chain->isProcessingUpdateRecords()) return;
assert(!WritingAST && "Already writing the AST!");
assert(Delete && "Not given an operator delete");
- if (!Chain)
- return;
+ if (!Chain) return;
Chain->forEachImportedKeyDecl(DD, [&](const Decl *D) {
DeclUpdates[D].push_back(DeclUpdate(UPD_CXX_RESOLVED_DTOR_DELETE, Delete));
});
}
void ASTWriter::CompletedImplicitDefinition(const FunctionDecl *D) {
- if (Chain && Chain->isProcessingUpdateRecords())
- return;
+ if (Chain && Chain->isProcessingUpdateRecords()) return;
assert(!WritingAST && "Already writing the AST!");
if (!D->isFromASTFile())
return; // Declaration not imported from PCH.
@@ -7518,8 +7510,7 @@ void ASTWriter::CompletedImplicitDefinition(const FunctionDecl *D) {
}
void ASTWriter::VariableDefinitionInstantiated(const VarDecl *D) {
- if (Chain && Chain->isProcessingUpdateRecords())
- return;
+ if (Chain && Chain->isProcessingUpdateRecords()) return;
assert(!WritingAST && "Already writing the AST!");
if (!D->isFromASTFile())
return;
@@ -7528,8 +7519,7 @@ void ASTWriter::VariableDefinitionInstantiated(const VarDecl *D) {
}
void ASTWriter::FunctionDefinitionInstantiated(const FunctionDecl *D) {
- if (Chain && Chain->isProcessingUpdateRecords())
- return;
+ if (Chain && Chain->isProcessingUpdateRecords()) return;
assert(!WritingAST && "Already writing the AST!");
if (!D->isFromASTFile())
return;
@@ -7542,8 +7532,7 @@ void ASTWriter::FunctionDefinitionInstantiated(const FunctionDecl *D) {
}
void ASTWriter::InstantiationRequested(const ValueDecl *D) {
- if (Chain && Chain->isProcessingUpdateRecords())
- return;
+ if (Chain && Chain->isProcessingUpdateRecords()) return;
assert(!WritingAST && "Already writing the AST!");
if (!D->isFromASTFile())
return;
@@ -7559,8 +7548,7 @@ void ASTWriter::InstantiationRequested(const ValueDecl *D) {
}
void ASTWriter::DefaultArgumentInstantiated(const ParmVarDecl *D) {
- if (Chain && Chain->isProcessingUpdateRecords())
- return;
+ if (Chain && Chain->isProcessingUpdateRecords()) return;
assert(!WritingAST && "Already writing the AST!");
if (!D->isFromASTFile())
return;
@@ -7580,20 +7568,18 @@ void ASTWriter::DefaultMemberInitializerInstantiated(const FieldDecl *D) {
void ASTWriter::AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD,
const ObjCInterfaceDecl *IFD) {
- if (Chain && Chain->isProcessingUpdateRecords())
- return;
+ if (Chain && Chain->isProcessingUpdateRecords()) return;
assert(!WritingAST && "Already writing the AST!");
if (!IFD->isFromASTFile())
return; // Declaration not imported from PCH.
assert(IFD->getDefinition() && "Category on a class without a definition?");
ObjCClassesWithCategories.insert(
- const_cast<ObjCInterfaceDecl *>(IFD->getDefinition()));
+ const_cast<ObjCInterfaceDecl *>(IFD->getDefinition()));
}
void ASTWriter::DeclarationMarkedUsed(const Decl *D) {
- if (Chain && Chain->isProcessingUpdateRecords())
- return;
+ if (Chain && Chain->isProcessingUpdateRecords()) return;
assert(!WritingAST && "Already writing the AST!");
// If there is *any* declaration of the entity that's not from an AST file,
@@ -7607,8 +7593,7 @@ void ASTWriter::DeclarationMarkedUsed(const Decl *D) {
}
void ASTWriter::DeclarationMarkedOpenMPThreadPrivate(const Decl *D) {
- if (Chain && Chain->isProcessingUpdateRecords())
- return;
+ if (Chain && Chain->isProcessingUpdateRecords()) return;
assert(!WritingAST && "Already writing the AST!");
if (!D->isFromASTFile())
return;
@@ -7617,8 +7602,7 @@ void ASTWriter::DeclarationMarkedOpenMPThreadPrivate(const Decl *D) {
}
void ASTWriter::DeclarationMarkedOpenMPAllocate(const Decl *D, const Attr *A) {
- if (Chain && Chain->isProcessingUpdateRecords())
- return;
+ if (Chain && Chain->isProcessingUpdateRecords()) return;
assert(!WritingAST && "Already writing the AST!");
if (!D->isFromASTFile())
return;
@@ -7628,8 +7612,7 @@ void ASTWriter::DeclarationMarkedOpenMPAllocate(const Decl *D, const Attr *A) {
void ASTWriter::DeclarationMarkedOpenMPDeclareTarget(const Decl *D,
const Attr *Attr) {
- if (Chain && Chain->isProcessingUpdateRecords())
- return;
+ if (Chain && Chain->isProcessingUpdateRecords()) return;
assert(!WritingAST && "Already writing the AST!");
if (!D->isFromASTFile())
return;
@@ -7639,8 +7622,7 @@ void ASTWriter::DeclarationMarkedOpenMPDeclareTarget(const Decl *D,
}
void ASTWriter::RedefinedHiddenDefinition(const NamedDecl *D, Module *M) {
- if (Chain && Chain->isProcessingUpdateRecords())
- return;
+ if (Chain && Chain->isProcessingUpdateRecords()) return;
assert(!WritingAST && "Already writing the AST!");
assert(!D->isUnconditionallyVisible() && "expected a hidden declaration");
DeclUpdates[D].push_back(DeclUpdate(UPD_DECL_EXPORTED, M));
@@ -7648,8 +7630,7 @@ void ASTWriter::RedefinedHiddenDefinition(const NamedDecl *D, Module *M) {
void ASTWriter::AddedAttributeToRecord(const Attr *Attr,
const RecordDecl *Record) {
- if (Chain && Chain->isProcessingUpdateRecords())
- return;
+ if (Chain && Chain->isProcessingUpdateRecords()) return;
assert(!WritingAST && "Already writing the AST!");
if (!Record->isFromASTFile())
return;
@@ -7711,7 +7692,7 @@ class OMPClauseWriter : public OMPClauseVisitor<OMPClauseWriter> {
void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C);
};
-} // namespace
+}
void ASTRecordWriter::writeOMPClause(OMPClause *C) {
OMPClauseWriter(*this).writeClause(C);
@@ -7831,7 +7812,7 @@ void OMPClauseWriter::VisitOMPOrderedClause(OMPOrderedClause *C) {
Record.AddStmt(C->getNumForLoops());
for (Expr *NumIter : C->getLoopNumIterations())
Record.AddStmt(NumIter);
- for (unsigned I = 0, E = C->getLoopNumIterations().size(); I < E; ++I)
+ for (unsigned I = 0, E = C->getLoopNumIterations().size(); I <E; ++I)
Record.AddStmt(C->getLoopCounter(I));
Record.AddSourceLocation(C->getLParenLoc());
}
@@ -8043,7 +8024,7 @@ void OMPClauseWriter::VisitOMPReductionClause(OMPReductionClause *C) {
Record.push_back(PrivateFlags.size());
for (bool Flag : PrivateFlags)
Record.push_back(Flag);
- }
+}
void OMPClauseWriter::VisitOMPTaskReductionClause(OMPTaskReductionClause *C) {
Record.push_back(C->varlist_size());
@@ -8442,8 +8423,9 @@ void OMPClauseWriter::VisitOMPUnifiedSharedMemoryClause(
void OMPClauseWriter::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {}
-void OMPClauseWriter::VisitOMPDynamicAllocatorsClause(
- OMPDynamicAllocatorsClause *) {}
+void
+OMPClauseWriter::VisitOMPDynamicAllocatorsClause(OMPDynamicAllocatorsClause *) {
+}
void OMPClauseWriter::VisitOMPAtomicDefaultMemOrderClause(
OMPAtomicDefaultMemOrderClause *C) {
@@ -8613,7 +8595,7 @@ void ASTRecordWriter::writeOpenACCClause(const OpenACCClause *C) {
case OpenACCClauseKind::If: {
const auto *IC = cast<OpenACCIfClause>(C);
writeSourceLocation(IC->getLParenLoc());
- AddStmt(const_cast<Expr *>(IC->getConditionExpr()));
+ AddStmt(const_cast<Expr*>(IC->getConditionExpr()));
return;
}
case OpenACCClauseKind::Self: {
@@ -8642,7 +8624,7 @@ void ASTRecordWriter::writeOpenACCClause(const OpenACCClause *C) {
case OpenACCClauseKind::DeviceNum: {
const auto *DNC = cast<OpenACCDeviceNumClause>(C);
writeSourceLocation(DNC->getLParenLoc());
- AddStmt(const_cast<Expr *>(DNC->getIntExpr()));
+ AddStmt(const_cast<Expr*>(DNC->getIntExpr()));
return;
}
case OpenACCClauseKind::DefaultAsync: {
@@ -8654,13 +8636,13 @@ void ASTRecordWriter::writeOpenACCClause(const OpenACCClause *C) {
case OpenACCClauseKind::NumWorkers: {
const auto *NWC = cast<OpenACCNumWorkersClause>(C);
writeSourceLocation(NWC->getLParenLoc());
- AddStmt(const_cast<Expr *>(NWC->getIntExpr()));
+ AddStmt(const_cast<Expr*>(NWC->getIntExpr()));
return;
}
case OpenACCClauseKind::VectorLength: {
const auto *NWC = cast<OpenACCVectorLengthClause>(C);
writeSourceLocation(NWC->getLParenLoc());
- AddStmt(const_cast<Expr *>(NWC->getIntExpr()));
+ AddStmt(const_cast<Expr*>(NWC->getIntExpr()));
return;
}
case OpenACCClauseKind::Private: {
@@ -8769,7 +8751,7 @@ void ASTRecordWriter::writeOpenACCClause(const OpenACCClause *C) {
writeSourceLocation(AC->getLParenLoc());
writeBool(AC->hasIntExpr());
if (AC->hasIntExpr())
- AddStmt(const_cast<Expr *>(AC->getIntExpr()));
+ AddStmt(const_cast<Expr*>(AC->getIntExpr()));
return;
}
case OpenACCClauseKind::Wait: {
More information about the cfe-commits
mailing list