Skip to content

Commit

Permalink
[AST] Initialize local counter
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vitalybuka committed May 18, 2023
1 parent fc89e90 commit e8cd046
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/Frontend/ASTUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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));
Expand Down

0 comments on commit e8cd046

Please sign in to comment.