Skip to content

Commit

Permalink
[NFC] Fix the warning for dangling pointer for c0d6f85
Browse files Browse the repository at this point in the history
The bot notes a warning-converted-error for the dangling pointer. And
the patch fixes that.
  • Loading branch information
ChuanqiXu9 committed May 24, 2023
1 parent 72ab89e commit 597dd1f
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions clang/unittests/Serialization/VarDeclConstantInitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,10 @@ export namespace Fibonacci
CreateInvocationOptions CIOpts;
CIOpts.Diags = Diags;

llvm::Twine CacheBMIPath = TestDir + "/Cached.pcm";
const char *Args[] = {"clang++",
"-std=c++20",
"--precompile",
"-working-directory",
TestDir.c_str(),
"Cached.cppm",
"-o",
CacheBMIPath.str().c_str()};
std::string CacheBMIPath = llvm::Twine(TestDir + "/Cached.pcm").str();
const char *Args[] = {
"clang++", "-std=c++20", "--precompile", "-working-directory",
TestDir.c_str(), "Cached.cppm", "-o", CacheBMIPath.c_str()};
std::shared_ptr<CompilerInvocation> Invocation =
createInvocation(Args, CIOpts);
ASSERT_TRUE(Invocation);
Expand All @@ -115,12 +110,13 @@ export namespace Fibonacci
ASSERT_TRUE(Instance.ExecuteAction(Action));
ASSERT_FALSE(Diags->hasErrorOccurred());

llvm::Twine DepArg = "-fmodule-file=Fibonacci.Cache=" + CacheBMIPath;
std::string DepArg =
llvm::Twine("-fmodule-file=Fibonacci.Cache=" + CacheBMIPath).str();
std::unique_ptr<ASTUnit> AST = tooling::buildASTFromCodeWithArgs(
R"cpp(
import Fibonacci.Cache;
)cpp",
/*Args=*/{"-std=c++20", DepArg.str().c_str()});
/*Args=*/{"-std=c++20", DepArg.c_str()});

using namespace clang::ast_matchers;
ASTContext &Ctx = AST->getASTContext();
Expand Down

0 comments on commit 597dd1f

Please sign in to comment.