Skip to content

[clang] Fix use of dangling ptr in CommandLineTest #119798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions clang/unittests/Frontend/CompilerInvocationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@ class CommandLineTest : public ::testing::Test {
public:
IntrusiveRefCntPtr<DiagnosticsEngine> Diags;
SmallVector<const char *, 32> GeneratedArgs;
SmallVector<std::string, 32> GeneratedArgsStorage;
BumpPtrAllocator Alloc;
StringSaver StringPool;
CompilerInvocation Invocation;

const char *operator()(const Twine &Arg) {
return GeneratedArgsStorage.emplace_back(Arg.str()).c_str();
return StringPool.save(Arg).data();
}

CommandLineTest()
: Diags(CompilerInstance::createDiagnostics(
*llvm::vfs::getRealFileSystem(), new DiagnosticOptions(),
new TextDiagnosticBuffer())) {}
new TextDiagnosticBuffer())),
StringPool(Alloc) {}
};

template <typename M>
Expand Down
Loading