aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Serialization/ForceCheckFileInputTest.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2025-05-01 07:31:30 -0700
committerGitHub <noreply@github.com>2025-05-01 07:31:30 -0700
commitb69dcb873476cd8e7d3f6f9ffd5b6d0bbe1a3a17 (patch)
tree91fa427a131edc9cd16c9bef896a64083442218e /clang/unittests/Serialization/ForceCheckFileInputTest.cpp
parent0009a1783490a8ff69251a0ec7df1891a427cfb0 (diff)
downloadllvm-b69dcb873476cd8e7d3f6f9ffd5b6d0bbe1a3a17.zip
llvm-b69dcb873476cd8e7d3f6f9ffd5b6d0bbe1a3a17.tar.gz
llvm-b69dcb873476cd8e7d3f6f9ffd5b6d0bbe1a3a17.tar.bz2
[clang][frontend] Require invocation to construct `CompilerInstance` (#137668)
This PR makes it so that `CompilerInvocation` needs to be provided to `CompilerInstance` on construction. There are a couple of benefits in my view: * Making it impossible to mis-use some `CompilerInstance` APIs. For example there are cases, where `createDiagnostics()` was called before `setInvocation()`, causing the `DiagnosticEngine` to use the default-constructed `DiagnosticOptions` instead of the intended ones. * This shrinks `CompilerInstance`'s state space. * This makes it possible to access **the** invocation in `CompilerInstance`'s constructor (to be used in a follow-up).
Diffstat (limited to 'clang/unittests/Serialization/ForceCheckFileInputTest.cpp')
-rw-r--r--clang/unittests/Serialization/ForceCheckFileInputTest.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/clang/unittests/Serialization/ForceCheckFileInputTest.cpp b/clang/unittests/Serialization/ForceCheckFileInputTest.cpp
index 6a839d1..16742a6 100644
--- a/clang/unittests/Serialization/ForceCheckFileInputTest.cpp
+++ b/clang/unittests/Serialization/ForceCheckFileInputTest.cpp
@@ -86,9 +86,8 @@ export int aa = 43;
Buf->release();
- CompilerInstance Instance;
+ CompilerInstance Instance(std::move(Invocation));
Instance.setDiagnostics(Diags.get());
- Instance.setInvocation(Invocation);
Instance.getFrontendOpts().OutputFile = BMIPath;
@@ -121,9 +120,8 @@ export int aa = 43;
EXPECT_TRUE(Invocation);
Invocation->getFrontendOpts().DisableFree = false;
- CompilerInstance Clang;
+ CompilerInstance Clang(std::move(Invocation));
- Clang.setInvocation(Invocation);
Clang.setDiagnostics(Diags.get());
FileManager *FM = Clang.createFileManager(CIOpts.VFS);
Clang.createSourceManager(*FM);