[clang] [clang][ExtractAPI] Stop dropping fields of nested anonymous record types when they aren't attached to variable declaration (PR #104600)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 16 07:59:42 PDT 2024
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 2fc7a72733762d685a07f846b44dc17a0585098e e4a4ff0649bac9710b8e77416b77526f16d4762b --extensions h,c,cpp -- clang/include/clang/ExtractAPI/API.h clang/include/clang/ExtractAPI/ExtractAPIVisitor.h clang/lib/ExtractAPI/API.cpp clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp clang/test/ExtractAPI/anonymous_record_no_typedef.c
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/ExtractAPI/API.h b/clang/include/clang/ExtractAPI/API.h
index 3b36dfe032..188e35b721 100644
--- a/clang/include/clang/ExtractAPI/API.h
+++ b/clang/include/clang/ExtractAPI/API.h
@@ -1421,7 +1421,8 @@ public:
createRecord(StringRef USR, StringRef Name, CtorArgsContTy &&...CtorArgs);
auto getTopLevelRecords() const {
- return llvm::iterator_range<decltype(TopLevelRecords)::iterator>(TopLevelRecords);
+ return llvm::iterator_range<decltype(TopLevelRecords)::iterator>(
+ TopLevelRecords);
}
void removeRecord(StringRef USR);
diff --git a/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h b/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
index a5e4dbbe04..8d9ac06203 100644
--- a/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
+++ b/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
@@ -606,7 +606,8 @@ bool ExtractAPIVisitorBase<Derived>::VisitRecordDecl(const RecordDecl *Decl) {
}
template <typename Derived>
-bool ExtractAPIVisitorBase<Derived>::TraverseCXXRecordDecl(CXXRecordDecl *Decl) {
+bool ExtractAPIVisitorBase<Derived>::TraverseCXXRecordDecl(
+ CXXRecordDecl *Decl) {
bool Ret = Base::TraverseCXXRecordDecl(Decl);
if (!isEmbeddedInVarDeclarator(*Decl) && Decl->isAnonymousStructOrUnion()) {
diff --git a/clang/lib/ExtractAPI/API.cpp b/clang/lib/ExtractAPI/API.cpp
index 48d8bb7f60..9dbc023885 100644
--- a/clang/lib/ExtractAPI/API.cpp
+++ b/clang/lib/ExtractAPI/API.cpp
@@ -70,7 +70,8 @@ void RecordContext::stealRecordChain(RecordContext &Other) {
Last = Other.Last;
- for (auto *StolenRecord = Other.First; StolenRecord != nullptr; StolenRecord = StolenRecord->getNextInContext())
+ for (auto *StolenRecord = Other.First; StolenRecord != nullptr;
+ StolenRecord = StolenRecord->getNextInContext())
StolenRecord->Parent = SymbolReference(cast<APIRecord>(this));
// Delete Other's chain to ensure we don't accidentally traverse it.
@@ -135,25 +136,22 @@ SymbolReference APISet::createSymbolReference(StringRef Name, StringRef USR,
return SymbolReference(copyString(Name), copyString(USR), copyString(Source));
}
-
void APISet::removeRecord(StringRef USR) {
auto Result = USRBasedLookupTable.find(USR);
if (Result != USRBasedLookupTable.end()) {
auto *Record = Result->getSecond().get();
- auto &ParentReference= Record->Parent;
+ auto &ParentReference = Record->Parent;
auto *ParentRecord = const_cast<APIRecord *>(ParentReference.Record);
if (!ParentRecord)
ParentRecord = findRecordForUSR(ParentReference.USR);
if (auto *ParentCtx = llvm::cast_if_present<RecordContext>(ParentRecord)) {
ParentCtx->removeFromRecordChain(Record);
- if (auto *RecordAsCtx=
- llvm::dyn_cast<RecordContext>(Record))
+ if (auto *RecordAsCtx = llvm::dyn_cast<RecordContext>(Record))
ParentCtx->stealRecordChain(*RecordAsCtx);
} else {
TopLevelRecords.erase(Record);
- if (auto *RecordAsCtx=
- llvm::dyn_cast<RecordContext>(Record)) {
+ if (auto *RecordAsCtx = llvm::dyn_cast<RecordContext>(Record)) {
for (const auto *Child = RecordAsCtx->First; Child != nullptr;
Child = Child->getNextInContext())
TopLevelRecords.insert(Child);
@@ -163,9 +161,7 @@ void APISet::removeRecord(StringRef USR) {
}
}
-void APISet::removeRecord(APIRecord *Record) {
- removeRecord(Record->USR);
-}
+void APISet::removeRecord(APIRecord *Record) { removeRecord(Record->USR); }
APIRecord::~APIRecord() {}
TagRecord::~TagRecord() {}
``````````
</details>
https://github.com/llvm/llvm-project/pull/104600
More information about the cfe-commits
mailing list