aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Basic
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2025-04-04 10:11:14 -0700
committerGitHub <noreply@github.com>2025-04-04 10:11:14 -0700
commit1688c3062a56b4fca1f8ad28f2865df0ed8ca940 (patch)
tree54a166397652bb5c96fdd30caabf46765eb06f6e /clang/unittests/Basic
parent90cf2e31abdee050b5811155c86605935046b07e (diff)
downloadllvm-1688c3062a56b4fca1f8ad28f2865df0ed8ca940.zip
llvm-1688c3062a56b4fca1f8ad28f2865df0ed8ca940.tar.gz
llvm-1688c3062a56b4fca1f8ad28f2865df0ed8ca940.tar.bz2
[clang] Do not share ownership of `PreprocessorOptions` (#133467)
This PR makes it so that `CompilerInvocation` is the sole owner of the `PreprocessorOptions` instance.
Diffstat (limited to 'clang/unittests/Basic')
-rw-r--r--clang/unittests/Basic/SourceManagerTest.cpp35
1 files changed, 15 insertions, 20 deletions
diff --git a/clang/unittests/Basic/SourceManagerTest.cpp b/clang/unittests/Basic/SourceManagerTest.cpp
index 1f2dba6..201c3f9 100644
--- a/clang/unittests/Basic/SourceManagerTest.cpp
+++ b/clang/unittests/Basic/SourceManagerTest.cpp
@@ -136,12 +136,11 @@ TEST_F(SourceManagerTest, isBeforeInTranslationUnit) {
SourceMgr.setMainFileID(mainFileID);
HeaderSearchOptions HSOpts;
+ PreprocessorOptions PPOpts;
TrivialModuleLoader ModLoader;
HeaderSearch HeaderInfo(HSOpts, SourceMgr, Diags, LangOpts, &*Target);
- Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts,
- SourceMgr, HeaderInfo, ModLoader,
- /*IILookup =*/nullptr,
- /*OwnsHeaderSearch =*/false);
+ Preprocessor PP(PPOpts, Diags, LangOpts, SourceMgr, HeaderInfo, ModLoader,
+ /*IILookup =*/nullptr, /*OwnsHeaderSearch =*/false);
PP.Initialize(*Target);
PP.EnterMainSourceFile();
@@ -186,12 +185,11 @@ TEST_F(SourceManagerTest, isBeforeInTranslationUnitWithTokenSplit) {
SourceMgr.createFileID(llvm::MemoryBuffer::getMemBuffer(main)));
HeaderSearchOptions HSOpts;
+ PreprocessorOptions PPOpts;
TrivialModuleLoader ModLoader;
HeaderSearch HeaderInfo(HSOpts, SourceMgr, Diags, LangOpts, &*Target);
- Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts,
- SourceMgr, HeaderInfo, ModLoader,
- /*IILookup =*/nullptr,
- /*OwnsHeaderSearch =*/false);
+ Preprocessor PP(PPOpts, Diags, LangOpts, SourceMgr, HeaderInfo, ModLoader,
+ /*IILookup=*/nullptr, /*OwnsHeaderSearch=*/false);
PP.Initialize(*Target);
PP.EnterMainSourceFile();
llvm::SmallString<8> Scratch;
@@ -462,11 +460,10 @@ TEST_F(SourceManagerTest, ResetsIncludeLocMap) {
auto ParseFile = [&] {
TrivialModuleLoader ModLoader;
HeaderSearchOptions HSOpts;
+ PreprocessorOptions PPOpts;
HeaderSearch HeaderInfo(HSOpts, SourceMgr, Diags, LangOpts, &*Target);
- Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts,
- SourceMgr, HeaderInfo, ModLoader,
- /*IILookup =*/nullptr,
- /*OwnsHeaderSearch =*/false);
+ Preprocessor PP(PPOpts, Diags, LangOpts, SourceMgr, HeaderInfo, ModLoader,
+ /*IILookup=*/nullptr, /*OwnsHeaderSearch=*/false);
PP.Initialize(*Target);
PP.EnterMainSourceFile();
PP.LexTokensUntilEOF();
@@ -538,13 +535,12 @@ TEST_F(SourceManagerTest, getMacroArgExpandedLocation) {
SourceMgr.overrideFileContents(headerFile, std::move(HeaderBuf));
HeaderSearchOptions HSOpts;
+ PreprocessorOptions PPOpts;
TrivialModuleLoader ModLoader;
HeaderSearch HeaderInfo(HSOpts, SourceMgr, Diags, LangOpts, &*Target);
- Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts,
- SourceMgr, HeaderInfo, ModLoader,
- /*IILookup =*/nullptr,
- /*OwnsHeaderSearch =*/false);
+ Preprocessor PP(PPOpts, Diags, LangOpts, SourceMgr, HeaderInfo, ModLoader,
+ /*IILookup=*/nullptr, /*OwnsHeaderSearch=*/false);
// Ensure we can get expanded locations in presence of implicit includes.
// These are different than normal includes since predefines buffer doesn't
// have a valid insertion location.
@@ -657,12 +653,11 @@ TEST_F(SourceManagerTest, isBeforeInTranslationUnitWithMacroInInclude) {
SourceMgr.overrideFileContents(headerFile, std::move(HeaderBuf));
HeaderSearchOptions HSOpts;
+ PreprocessorOptions PPOpts;
TrivialModuleLoader ModLoader;
HeaderSearch HeaderInfo(HSOpts, SourceMgr, Diags, LangOpts, &*Target);
- Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts,
- SourceMgr, HeaderInfo, ModLoader,
- /*IILookup =*/nullptr,
- /*OwnsHeaderSearch =*/false);
+ Preprocessor PP(PPOpts, Diags, LangOpts, SourceMgr, HeaderInfo, ModLoader,
+ /*IILookup=*/nullptr, /*OwnsHeaderSearch=*/false);
PP.Initialize(*Target);
std::vector<MacroAction> Macros;