llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Ayush Pareek (ayushpareek2003)

<details>
<summary>Changes</summary>

This change resets certain CodeGenOptions fields using = {} instead of 
.clear(), to clean up build-specific data when generating modules or PCH files. 
It helps make the output more consistent and easier to maintain

---
Full diff: https://github.com/llvm/llvm-project/pull/138256.diff


1 Files Affected:

- (modified) clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp 
(+11-10) 


``````````diff
diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp 
b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index b3016f90122df..5fbc502b15c3a 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -209,20 +209,21 @@ void 
ModuleDepCollector::addOutputPaths(CowCompilerInvocation &CI,
 void dependencies::resetBenignCodeGenOptions(frontend::ActionKind 
ProgramAction,
                                              const LangOptions &LangOpts,
                                              CodeGenOptions &CGOpts) {
-  // TODO: Figure out better way to set options to their default value.
+  // For actions that produce modules or PCHs, reset options that could leak 
build-specific data.
   if (ProgramAction == frontend::GenerateModule) {
-    CGOpts.MainFileName.clear();
-    CGOpts.DwarfDebugFlags.clear();
+    CGOpts.MainFileName = {};
+    CGOpts.DwarfDebugFlags = {};
   }
+
   if (ProgramAction == frontend::GeneratePCH ||
       (ProgramAction == frontend::GenerateModule && !LangOpts.ModulesCodegen)) 
{
-    CGOpts.DebugCompilationDir.clear();
-    CGOpts.CoverageCompilationDir.clear();
-    CGOpts.CoverageDataFile.clear();
-    CGOpts.CoverageNotesFile.clear();
-    CGOpts.ProfileInstrumentUsePath.clear();
-    CGOpts.SampleProfileFile.clear();
-    CGOpts.ProfileRemappingFile.clear();
+    CGOpts.DebugCompilationDir = {};
+    CGOpts.CoverageCompilationDir = {};
+    CGOpts.CoverageDataFile = {};
+    CGOpts.CoverageNotesFile = {};
+    CGOpts.ProfileInstrumentUsePath = {};
+    CGOpts.SampleProfileFile = {};
+    CGOpts.ProfileRemappingFile = {};
   }
 }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/138256
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to