[clang] [clang-tools-extra] [clang] Do not share ownership of `PreprocessorOptions` (PR #133467)

via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 28 09:54:33 PDT 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 277ab85d1ccf80750f5193495c0665808c2863de 9348867cfb2d243df7e91f20d6e635217d9af4e1 --extensions h,cpp -- clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp clang-tools-extra/clangd/ModulesBuilder.cpp clang/include/clang/Frontend/CompilerInvocation.h clang/include/clang/Lex/Preprocessor.h clang/lib/Frontend/ASTUnit.cpp clang/lib/Frontend/CompilerInstance.cpp clang/lib/Lex/PPDirectives.cpp clang/lib/Lex/PPLexerChange.cpp clang/lib/Lex/Preprocessor.cpp clang/unittests/Analysis/MacroExpansionContextTest.cpp clang/unittests/Basic/SourceManagerTest.cpp clang/unittests/Lex/LexerTest.cpp clang/unittests/Lex/ModuleDeclStateTest.cpp clang/unittests/Lex/PPCallbacksTest.cpp clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp clang/unittests/Lex/PPDependencyDirectivesTest.cpp clang/unittests/Lex/PPMemoryAllocationsTest.cpp
``````````

</details>

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

``````````diff
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 0b53524e23..866488ff83 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -3420,8 +3420,9 @@ void Preprocessor::HandleIfdefDirective(Token &Result,
       Callbacks->Ifdef(DirectiveTok.getLocation(), MacroNameTok, MD);
   }
 
-  bool RetainExcludedCB = PPOpts.RetainExcludedConditionalBlocks &&
-    getSourceManager().isInMainFile(DirectiveTok.getLocation());
+  bool RetainExcludedCB =
+      PPOpts.RetainExcludedConditionalBlocks &&
+      getSourceManager().isInMainFile(DirectiveTok.getLocation());
 
   // Should we include the stuff contained by this directive?
   if (PPOpts.SingleFileParseMode && !MI) {
@@ -3475,8 +3476,9 @@ void Preprocessor::HandleIfDirective(Token &IfToken,
         IfToken.getLocation(), DER.ExprRange,
         (ConditionalTrue ? PPCallbacks::CVK_True : PPCallbacks::CVK_False));
 
-  bool RetainExcludedCB = PPOpts.RetainExcludedConditionalBlocks &&
-    getSourceManager().isInMainFile(IfToken.getLocation());
+  bool RetainExcludedCB =
+      PPOpts.RetainExcludedConditionalBlocks &&
+      getSourceManager().isInMainFile(IfToken.getLocation());
 
   // Should we include the stuff contained by this directive?
   if (PPOpts.SingleFileParseMode && DER.IncludedUndefinedIds) {
@@ -3547,7 +3549,7 @@ void Preprocessor::HandleElseDirective(Token &Result, const Token &HashToken) {
     Callbacks->Else(Result.getLocation(), CI.IfLoc);
 
   bool RetainExcludedCB = PPOpts.RetainExcludedConditionalBlocks &&
-    getSourceManager().isInMainFile(Result.getLocation());
+                          getSourceManager().isInMainFile(Result.getLocation());
 
   if ((PPOpts.SingleFileParseMode && !CI.FoundNonSkip) || RetainExcludedCB) {
     // In 'single-file-parse mode' undefined identifiers trigger parsing of all
@@ -3626,8 +3628,9 @@ void Preprocessor::HandleElifFamilyDirective(Token &ElifToken,
     }
   }
 
-  bool RetainExcludedCB = PPOpts.RetainExcludedConditionalBlocks &&
-    getSourceManager().isInMainFile(ElifToken.getLocation());
+  bool RetainExcludedCB =
+      PPOpts.RetainExcludedConditionalBlocks &&
+      getSourceManager().isInMainFile(ElifToken.getLocation());
 
   if ((PPOpts.SingleFileParseMode && !CI.FoundNonSkip) || RetainExcludedCB) {
     // In 'single-file-parse mode' undefined identifiers trigger parsing of all

``````````

</details>


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


More information about the cfe-commits mailing list