[clang] e8cd046 - [AST] Initialize local counter

Vitaly Buka via cfe-commits cfe-commits at lists.llvm.org
Thu May 18 01:19:17 PDT 2023


Author: Vitaly Buka
Date: 2023-05-18T01:19:11-07:00
New Revision: e8cd04624e503ae063e925eb5609281a88716d83

URL: https://github.com/llvm/llvm-project/commit/e8cd04624e503ae063e925eb5609281a88716d83
DIFF: https://github.com/llvm/llvm-project/commit/e8cd04624e503ae063e925eb5609281a88716d83.diff

LOG: [AST] Initialize local counter

I assume it's optional and ReadAST does not have to set the
counter on success.

Without the patch msan complains that we pass
uninitialized value into noundef parameters of setCounterValue.

Reviewed By: bnbarham, barannikov88

Differential Revision: https://reviews.llvm.org/D150492

Added: 
    

Modified: 
    clang/lib/Frontend/ASTUnit.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index b1e7db1f6b39..14971da4da0b 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -822,7 +822,6 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
   // Gather Info for preprocessor construction later on.
 
   HeaderSearch &HeaderInfo = *AST->HeaderInfo;
-  unsigned Counter;
 
   AST->PP = std::make_shared<Preprocessor>(
       AST->PPOpts, AST->getDiagnostics(), *AST->LangOpts,
@@ -846,6 +845,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
       /*isysroot=*/"",
       /*DisableValidationKind=*/disableValid, AllowASTWithCompilerErrors);
 
+  unsigned Counter = 0;
   AST->Reader->setListener(std::make_unique<ASTInfoCollector>(
       *AST->PP, AST->Ctx.get(), *AST->HSOpts, *AST->PPOpts, *AST->LangOpts,
       AST->TargetOpts, AST->Target, Counter));


        


More information about the cfe-commits mailing list