[clang] [clang][ExtractAPI] Fix quirks in interaction with submodules (PR #105868)

via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 23 11:18:28 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 d5e9691509aa774d1acedc4d3fa2d497757a2d6d a2ec6f0f79348cdb211dfa10d0412ecfd8c0e4d5 --extensions c,cpp,h -- clang/include/clang/ExtractAPI/DeclarationFragments.h clang/include/clang/ExtractAPI/ExtractAPIVisitor.h clang/lib/ExtractAPI/DeclarationFragments.cpp clang/lib/ExtractAPI/ExtractAPIConsumer.cpp clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp clang/test/ExtractAPI/bool.c clang/test/ExtractAPI/emit-symbol-graph/multi_file.c clang/test/ExtractAPI/emit-symbol-graph/single_file.c clang/test/ExtractAPI/macros.c
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
index b23a622676..0adc23280f 100644
--- a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
+++ b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
@@ -305,13 +305,16 @@ public:
 
       auto DefLoc = MI->getDefinitionLoc();
 
-      if (SM.isWrittenInBuiltinFile(DefLoc) || SM.isWrittenInCommandLineFile(DefLoc))
+      if (SM.isWrittenInBuiltinFile(DefLoc) ||
+          SM.isWrittenInCommandLineFile(DefLoc))
         continue;
 
       auto AssociatedModuleMacros = MD.getModuleMacros();
       StringRef OwningModuleName;
       if (!AssociatedModuleMacros.empty())
-        OwningModuleName = AssociatedModuleMacros.back()->getOwningModule()->getTopLevelModuleName();
+        OwningModuleName = AssociatedModuleMacros.back()
+                               ->getOwningModule()
+                               ->getTopLevelModuleName();
 
       if (!shouldMacroBeIncluded(DefLoc, OwningModuleName))
         continue;
@@ -325,11 +328,13 @@ public:
           DeclarationFragmentsBuilder::getFragmentsForMacro(Name, MI),
           DeclarationFragmentsBuilder::getSubHeadingForMacro(Name),
           SM.isInSystemHeader(DefLoc));
-
     }
   }
 
-  virtual bool shouldMacroBeIncluded(const SourceLocation &MacroLoc, StringRef ModuleName) { return true; }
+  virtual bool shouldMacroBeIncluded(const SourceLocation &MacroLoc,
+                                     StringRef ModuleName) {
+    return true;
+  }
 
   const SourceManager &SM;
   APISet &API;
@@ -342,7 +347,8 @@ public:
                    LocationFileChecker &LCF)
       : MacroCallback(SM, API, PP), LCF(LCF) {}
 
-  bool shouldMacroBeIncluded(const SourceLocation &MacroLoc, StringRef ModuleName) override {
+  bool shouldMacroBeIncluded(const SourceLocation &MacroLoc,
+                             StringRef ModuleName) override {
     // Do not include macros from external files
     return LCF(MacroLoc) || API.ProductName == ModuleName;
   }
diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index 54124ddbb2..030509d378 100644
--- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -928,7 +928,7 @@ bool SymbolGraphSerializer::traverseObjCCategoryRecord(
     return true;
 
   auto *CurrentModule = ModuleForCurrentSymbol;
-  if (auto ModuleExtendedByRecord= Record->getExtendedExternalModule())
+  if (auto ModuleExtendedByRecord = Record->getExtendedExternalModule())
     ModuleForCurrentSymbol = &ExtendedModules[*ModuleExtendedByRecord];
 
   if (!walkUpFromObjCCategoryRecord(Record))

``````````

</details>


https://github.com/llvm/llvm-project/pull/105868


More information about the cfe-commits mailing list