[clang] [WIP] [Modules] Delay reading type source info of the preferred_name attribute. (PR #122250)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 9 09:04:29 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 568ae0afabe07837ecfae8f8fe9dacf0de74a1e5 bffc6127f2779c9720fb4953c88550e6cfefcbc4 --extensions h,cppm,cpp -- clang/include/clang/Serialization/ASTReader.h clang/include/clang/Serialization/ASTRecordReader.h clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTReaderDecl.cpp clang/lib/Serialization/ASTWriter.cpp clang/test/Modules/preferred_name.cppm
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h
index ba91bb9ab6..1b212d1718 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -1160,7 +1160,7 @@ private:
PendingDeducedVarTypes;
struct PendingPreferredNameAttribute {
- Decl* D;
+ Decl *D;
AttributeCommonInfo Info;
serialization::TypeID TypeID;
bool isInherited;
diff --git a/clang/include/clang/Serialization/ASTRecordReader.h b/clang/include/clang/Serialization/ASTRecordReader.h
index f476d72fcf..3d1e25161a 100644
--- a/clang/include/clang/Serialization/ASTRecordReader.h
+++ b/clang/include/clang/Serialization/ASTRecordReader.h
@@ -343,7 +343,6 @@ public:
/// Reads attributes from the current stream position, advancing Idx.
void readAttributes(AttrVec &Attrs, Decl *D);
-
/// Read an BTFTypeTagAttr object.
BTFTypeTagAttr *readBTFTypeTagAttr() {
return cast<BTFTypeTagAttr>(readAttr());
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index e9d6b87b38..de128b3a89 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -9868,17 +9868,21 @@ void ASTReader::finishPendingActions() {
if (!InfoTy.isNull()) {
TInfo = getContext().CreateTypeSourceInfo(InfoTy);
if (auto Loc = TInfo->getTypeLoc().getAs<ElaboratedTypeLoc>()) {
- Loc.setElaboratedKeywordLoc(PendingPreferredNameAttributes[I].ElaboratedTypedefSourceLocation);
+ Loc.setElaboratedKeywordLoc(PendingPreferredNameAttributes[I]
+ .ElaboratedTypedefSourceLocation);
Loc.setQualifierLoc(PendingPreferredNameAttributes[I].NNS);
if (auto TypedefLoc = Loc.getNextTypeLoc().getAs<TypedefTypeLoc>()) {
- TypedefLoc.setNameLoc(PendingPreferredNameAttributes[I].TypedefSourceLocation);
+ TypedefLoc.setNameLoc(
+ PendingPreferredNameAttributes[I].TypedefSourceLocation);
}
}
}
AttrVec &Attrs = getContext().getDeclAttrs(D);
- PreferredNameAttr *New = new (Context) PreferredNameAttr(Context, PendingPreferredNameAttributes[I].Info, TInfo);
- cast<InheritableAttr>(New)->setInherited(PendingPreferredNameAttributes[I].isInherited);
+ PreferredNameAttr *New = new (Context) PreferredNameAttr(
+ Context, PendingPreferredNameAttributes[I].Info, TInfo);
+ cast<InheritableAttr>(New)->setInherited(
+ PendingPreferredNameAttributes[I].isInherited);
New->setImplicit(PendingPreferredNameAttributes[I].isImplicit);
New->setPackExpansion(PendingPreferredNameAttributes[I].isPackExpansion);
Attrs.push_back(New);
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index ebe2f24cc2..524bab7a26 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -3144,9 +3144,10 @@ public:
bool IsRegularKeywordAttribute = readBool();
AttributeCommonInfo Info(AttrName, ScopeName, AttrRange, ScopeLoc,
- AttributeCommonInfo::Kind(ParsedKind),
- {AttributeCommonInfo::Syntax(Syntax), SpellingIndex,
- IsAlignas, IsRegularKeywordAttribute});
+ AttributeCommonInfo::Kind(ParsedKind),
+ {AttributeCommonInfo::Syntax(Syntax),
+ SpellingIndex, IsAlignas,
+ IsRegularKeywordAttribute});
return Info;
}
@@ -3164,7 +3165,7 @@ public:
ASTContext &Context = Reader.getContext();
Attr *New = nullptr;
auto Record = *this;
- #include "clang/Serialization/AttrPCHRead.inc"
+#include "clang/Serialization/AttrPCHRead.inc"
assert(New && "Unable to decode attribute?");
return New;
@@ -3172,13 +3173,12 @@ public:
};
}
-
Attr *ASTRecordReader::readAttr() {
AttrReader Record(*this);
attr::Kind Kind;
if (auto KindOpt = Record.readAttrKind(); !KindOpt)
return nullptr;
- else
+ else
Kind = *KindOpt;
AttributeCommonInfo Info = Record.readAttributeCommonInfo();
@@ -3190,7 +3190,7 @@ Attr *ASTRecordReader::readAttr(Decl *D) {
attr::Kind Kind;
if (auto KindOpt = Record.readAttrKind(); !KindOpt)
return nullptr;
- else
+ else
Kind = *KindOpt;
AttributeCommonInfo Info = Record.readAttributeCommonInfo();
@@ -3202,7 +3202,9 @@ Attr *ASTRecordReader::readAttr(Decl *D) {
SourceLocation SL = Record.readSourceLocation();
NestedNameSpecifierLoc NNL = readNestedNameSpecifierLoc();
SourceLocation TSL = Record.readSourceLocation();
- Reader->PendingPreferredNameAttributes.push_back({D, Info, TypeID, isInherited, isImplicit, isPackExpansion, SL, NNL, TSL});
+ Reader->PendingPreferredNameAttributes.push_back(
+ {D, Info, TypeID, isInherited, isImplicit, isPackExpansion, SL, NNL,
+ TSL});
return nullptr;
}
@@ -3211,12 +3213,12 @@ Attr *ASTRecordReader::readAttr(Decl *D) {
/// Reads attributes from the current stream position.
void ASTRecordReader::readAttributes(AttrVec &Attrs) {
- for (unsigned I = 0, E = readInt(); I != E; ++I)
+ for (unsigned I = 0, E = readInt(); I != E; ++I)
if (auto *A = readAttr())
Attrs.push_back(A);
}
-void ASTRecordReader::readAttributes(AttrVec &Attrs, Decl* D) {
+void ASTRecordReader::readAttributes(AttrVec &Attrs, Decl *D) {
for (unsigned I = 0, E = readInt(); I != E; ++I)
if (auto *A = readAttr(D))
Attrs.push_back(A);
``````````
</details>
https://github.com/llvm/llvm-project/pull/122250
More information about the cfe-commits
mailing list