16 changes: 8 additions & 8 deletions clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ CompilerInvocationRefBase::CompilerInvocationRefBase()

CompilerInvocationRefBase::CompilerInvocationRefBase(
const CompilerInvocationRefBase &X)
: LangOpts(new LangOptions(*X.getLangOpts())),
: LangOpts(new LangOptions(X.getLangOpts())),
TargetOpts(new TargetOptions(X.getTargetOpts())),
DiagnosticOpts(new DiagnosticOptions(X.getDiagnosticOpts())),
HeaderSearchOpts(new HeaderSearchOptions(X.getHeaderSearchOpts())),
PreprocessorOpts(new PreprocessorOptions(X.getPreprocessorOpts())),
AnalyzerOpts(new AnalyzerOptions(*X.getAnalyzerOpts())) {}
AnalyzerOpts(new AnalyzerOptions(X.getAnalyzerOpts())) {}

CompilerInvocationRefBase::CompilerInvocationRefBase(
CompilerInvocationRefBase &&X) = default;
Expand Down Expand Up @@ -461,7 +461,7 @@ static bool FixupInvocation(CompilerInvocation &Invocation,
InputKind IK) {
unsigned NumErrorsBefore = Diags.getNumErrors();

LangOptions &LangOpts = *Invocation.getLangOpts();
LangOptions &LangOpts = Invocation.getLangOpts();
CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts();
TargetOptions &TargetOpts = Invocation.getTargetOpts();
FrontendOptions &FrontendOpts = Invocation.getFrontendOpts();
Expand Down Expand Up @@ -4365,7 +4365,7 @@ bool CompilerInvocation::CreateFromArgsImpl(
unsigned MissingArgIndex, MissingArgCount;
InputArgList Args = Opts.ParseArgs(CommandLineArgs, MissingArgIndex,
MissingArgCount, VisibilityMask);
LangOptions &LangOpts = *Res.getLangOpts();
LangOptions &LangOpts = Res.getLangOpts();

// Check for missing argument error.
if (MissingArgCount)
Expand All @@ -4385,7 +4385,7 @@ bool CompilerInvocation::CreateFromArgsImpl(

ParseFileSystemArgs(Res.getFileSystemOpts(), Args, Diags);
ParseMigratorArgs(Res.getMigratorOpts(), Args, Diags);
ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags);
ParseAnalyzerArgs(Res.getAnalyzerOpts(), Args, Diags);
ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags,
/*DefaultDiagColor=*/false);
ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags, LangOpts.IsHeaderFile);
Expand Down Expand Up @@ -4446,7 +4446,7 @@ bool CompilerInvocation::CreateFromArgsImpl(

// If sanitizer is enabled, disable OPT_ffine_grained_bitfield_accesses.
if (Res.getCodeGenOpts().FineGrainedBitfieldAccesses &&
!Res.getLangOpts()->Sanitize.empty()) {
!Res.getLangOpts().Sanitize.empty()) {
Res.getCodeGenOpts().FineGrainedBitfieldAccesses = false;
Diags.Report(diag::warn_drv_fine_grained_bitfield_accesses_ignored);
}
Expand Down Expand Up @@ -4617,12 +4617,12 @@ std::vector<std::string> CompilerInvocation::getCC1CommandLine() const {
}

void CompilerInvocation::resetNonModularOptions() {
getLangOpts()->resetNonModularOptions();
getLangOpts().resetNonModularOptions();
getPreprocessorOpts().resetNonModularOptions();
}

void CompilerInvocation::clearImplicitModuleBuildOptions() {
getLangOpts()->ImplicitModules = false;
getLangOpts().ImplicitModules = false;
getHeaderSearchOpts().ImplicitModuleMaps = false;
getHeaderSearchOpts().ModuleCachePath.clear();
getHeaderSearchOpts().ModulesValidateOncePerBuildSession = false;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Frontend/PrecompiledPreamble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ void PrecompiledPreamble::AddImplicitPreamble(
void PrecompiledPreamble::OverridePreamble(
CompilerInvocation &CI, IntrusiveRefCntPtr<llvm::vfs::FileSystem> &VFS,
llvm::MemoryBuffer *MainFileBuffer) const {
auto Bounds = ComputePreambleBounds(*CI.getLangOpts(), *MainFileBuffer, 0);
auto Bounds = ComputePreambleBounds(CI.getLangOpts(), *MainFileBuffer, 0);
configurePreamble(Bounds, CI, VFS, MainFileBuffer);
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ bool ExecuteCompilerInvocation(CompilerInstance *Clang) {
#if CLANG_ENABLE_STATIC_ANALYZER
// These should happen AFTER plugins have been loaded!

AnalyzerOptions &AnOpts = *Clang->getAnalyzerOpts();
AnalyzerOptions &AnOpts = Clang->getAnalyzerOpts();

// Honor -analyzer-checker-help and -analyzer-checker-help-hidden.
if (AnOpts.ShowCheckerHelp || AnOpts.ShowCheckerHelpAlpha ||
Expand Down
60 changes: 30 additions & 30 deletions clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class AnalysisConsumer : public AnalysisASTConsumer,
ASTContext *Ctx;
Preprocessor &PP;
const std::string OutDir;
AnalyzerOptionsRef Opts;
AnalyzerOptions &Opts;
ArrayRef<std::string> Plugins;
CodeInjector *Injector;
cross_tu::CrossTranslationUnitContext CTU;
Expand Down Expand Up @@ -121,15 +121,15 @@ class AnalysisConsumer : public AnalysisASTConsumer,
FunctionSummariesTy FunctionSummaries;

AnalysisConsumer(CompilerInstance &CI, const std::string &outdir,
AnalyzerOptionsRef opts, ArrayRef<std::string> plugins,
AnalyzerOptions &opts, ArrayRef<std::string> plugins,
CodeInjector *injector)
: RecVisitorMode(0), RecVisitorBR(nullptr), Ctx(nullptr),
PP(CI.getPreprocessor()), OutDir(outdir), Opts(std::move(opts)),
PP(CI.getPreprocessor()), OutDir(outdir), Opts(opts),
Plugins(plugins), Injector(injector), CTU(CI),
MacroExpansions(CI.getLangOpts()) {
DigestAnalyzerOptions();
if (Opts->AnalyzerDisplayProgress || Opts->PrintStats ||
Opts->ShouldSerializeStats) {
if (Opts.AnalyzerDisplayProgress || Opts.PrintStats ||
Opts.ShouldSerializeStats) {
AnalyzerTimers = std::make_unique<llvm::TimerGroup>(
"analyzer", "Analyzer timers");
SyntaxCheckTimer = std::make_unique<llvm::Timer>(
Expand All @@ -141,27 +141,27 @@ class AnalysisConsumer : public AnalysisASTConsumer,
*AnalyzerTimers);
}

if (Opts->PrintStats || Opts->ShouldSerializeStats) {
if (Opts.PrintStats || Opts.ShouldSerializeStats) {
llvm::EnableStatistics(/* DoPrintOnExit= */ false);
}

if (Opts->ShouldDisplayMacroExpansions)
if (Opts.ShouldDisplayMacroExpansions)
MacroExpansions.registerForPreprocessor(PP);
}

~AnalysisConsumer() override {
if (Opts->PrintStats) {
if (Opts.PrintStats) {
llvm::PrintStatistics();
}
}

void DigestAnalyzerOptions() {
switch (Opts->AnalysisDiagOpt) {
switch (Opts.AnalysisDiagOpt) {
case PD_NONE:
break;
#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN) \
case PD_##NAME: \
CREATEFN(Opts->getDiagOpts(), PathConsumers, OutDir, PP, CTU, \
CREATEFN(Opts.getDiagOpts(), PathConsumers, OutDir, PP, CTU, \
MacroExpansions); \
break;
#include "clang/StaticAnalyzer/Core/Analyses.def"
Expand All @@ -172,7 +172,7 @@ class AnalysisConsumer : public AnalysisASTConsumer,
// Create the analyzer component creators.
CreateStoreMgr = &CreateRegionStoreManager;

switch (Opts->AnalysisConstraintsOpt) {
switch (Opts.AnalysisConstraintsOpt) {
default:
llvm_unreachable("Unknown constraint manager.");
#define ANALYSIS_CONSTRAINTS(NAME, CMDFLAG, DESC, CREATEFN) \
Expand All @@ -182,7 +182,7 @@ class AnalysisConsumer : public AnalysisASTConsumer,
}

void DisplayTime(llvm::TimeRecord &Time) {
if (!Opts->AnalyzerDisplayProgress) {
if (!Opts.AnalyzerDisplayProgress) {
return;
}
llvm::errs() << " : " << llvm::format("%1.1f", Time.getWallTime() * 1000)
Expand All @@ -191,7 +191,7 @@ class AnalysisConsumer : public AnalysisASTConsumer,

void DisplayFunction(const Decl *D, AnalysisMode Mode,
ExprEngine::InliningModes IMode) {
if (!Opts->AnalyzerDisplayProgress)
if (!Opts.AnalyzerDisplayProgress)
return;

SourceManager &SM = Mgr->getASTContext().getSourceManager();
Expand Down Expand Up @@ -222,12 +222,12 @@ class AnalysisConsumer : public AnalysisASTConsumer,

void Initialize(ASTContext &Context) override {
Ctx = &Context;
checkerMgr = std::make_unique<CheckerManager>(*Ctx, *Opts, PP, Plugins,
checkerMgr = std::make_unique<CheckerManager>(*Ctx, Opts, PP, Plugins,
CheckerRegistrationFns);

Mgr = std::make_unique<AnalysisManager>(*Ctx, PP, PathConsumers,
CreateStoreMgr, CreateConstraintMgr,
checkerMgr.get(), *Opts, Injector);
checkerMgr.get(), Opts, Injector);
}

/// Store the top level decls in the set to be processed later on.
Expand Down Expand Up @@ -278,7 +278,7 @@ class AnalysisConsumer : public AnalysisASTConsumer,
}

bool VisitVarDecl(VarDecl *VD) {
if (!Opts->IsNaiveCTUEnabled)
if (!Opts.IsNaiveCTUEnabled)
return true;

if (VD->hasExternalStorage() || VD->isStaticDataMember()) {
Expand All @@ -293,8 +293,8 @@ class AnalysisConsumer : public AnalysisASTConsumer,
return true;

llvm::Expected<const VarDecl *> CTUDeclOrError =
CTU.getCrossTUDefinition(VD, Opts->CTUDir, Opts->CTUIndexName,
Opts->DisplayCTUProgress);
CTU.getCrossTUDefinition(VD, Opts.CTUDir, Opts.CTUIndexName,
Opts.DisplayCTUProgress);

if (!CTUDeclOrError) {
handleAllErrors(CTUDeclOrError.takeError(),
Expand Down Expand Up @@ -356,7 +356,7 @@ class AnalysisConsumer : public AnalysisASTConsumer,
AnalysisMode getModeForDecl(Decl *D, AnalysisMode Mode);
void runAnalysisOnTranslationUnit(ASTContext &C);

/// Print \p S to stderr if \c Opts->AnalyzerDisplayProgress is set.
/// Print \p S to stderr if \c Opts.AnalyzerDisplayProgress is set.
void reportAnalyzerProgress(StringRef S);
}; // namespace
} // end anonymous namespace
Expand Down Expand Up @@ -567,12 +567,12 @@ void AnalysisConsumer::runAnalysisOnTranslationUnit(ASTContext &C) {
// name correctly.
// FIXME: The user might have analyzed the requested function in Syntax mode,
// but we are unaware of that.
if (!Opts->AnalyzeSpecificFunction.empty() && NumFunctionsAnalyzed == 0)
reportAnalyzerFunctionMisuse(*Opts, *Ctx);
if (!Opts.AnalyzeSpecificFunction.empty() && NumFunctionsAnalyzed == 0)
reportAnalyzerFunctionMisuse(Opts, *Ctx);
}

void AnalysisConsumer::reportAnalyzerProgress(StringRef S) {
if (Opts->AnalyzerDisplayProgress)
if (Opts.AnalyzerDisplayProgress)
llvm::errs() << S;
}

Expand All @@ -589,21 +589,21 @@ void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
const auto DiagFlusherScopeExit =
llvm::make_scope_exit([this] { Mgr.reset(); });

if (Opts->ShouldIgnoreBisonGeneratedFiles &&
if (Opts.ShouldIgnoreBisonGeneratedFiles &&
fileContainsString("/* A Bison parser, made by", C)) {
reportAnalyzerProgress("Skipping bison-generated file\n");
return;
}

if (Opts->ShouldIgnoreFlexGeneratedFiles &&
if (Opts.ShouldIgnoreFlexGeneratedFiles &&
fileContainsString("/* A lexical scanner generated by flex", C)) {
reportAnalyzerProgress("Skipping flex-generated file\n");
return;
}

// Don't analyze if the user explicitly asked for no checks to be performed
// on this file.
if (Opts->DisableAllCheckers) {
if (Opts.DisableAllCheckers) {
reportAnalyzerProgress("All checks are disabled using a supplied option\n");
return;
}
Expand All @@ -623,16 +623,16 @@ void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {

AnalysisConsumer::AnalysisMode
AnalysisConsumer::getModeForDecl(Decl *D, AnalysisMode Mode) {
if (!Opts->AnalyzeSpecificFunction.empty() &&
AnalysisDeclContext::getFunctionName(D) != Opts->AnalyzeSpecificFunction)
if (!Opts.AnalyzeSpecificFunction.empty() &&
AnalysisDeclContext::getFunctionName(D) != Opts.AnalyzeSpecificFunction)
return AM_None;

// Unless -analyze-all is specified, treat decls differently depending on
// where they came from:
// - Main source file: run both path-sensitive and non-path-sensitive checks.
// - Header files: run non-path-sensitive checks only.
// - System headers: don't run any checks.
if (Opts->AnalyzeAll)
if (Opts.AnalyzeAll)
return Mode;

const SourceManager &SM = Ctx->getSourceManager();
Expand Down Expand Up @@ -757,8 +757,8 @@ ento::CreateAnalysisConsumer(CompilerInstance &CI) {
// Disable the effects of '-Werror' when using the AnalysisConsumer.
CI.getPreprocessor().getDiagnostics().setWarningsAsErrors(false);

AnalyzerOptionsRef analyzerOpts = CI.getAnalyzerOpts();
bool hasModelPath = analyzerOpts->Config.count("model-path") > 0;
AnalyzerOptions &analyzerOpts = CI.getAnalyzerOpts();
bool hasModelPath = analyzerOpts.Config.count("model-path") > 0;

return std::make_unique<AnalysisConsumer>(
CI, CI.getFrontendOpts().OutputFile, analyzerOpts,
Expand Down
10 changes: 5 additions & 5 deletions clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ void ento::printCheckerHelp(raw_ostream &out, CompilerInstance &CI) {
out << "USAGE: -analyzer-checker <CHECKER or PACKAGE,...>\n\n";

auto CheckerMgr = std::make_unique<CheckerManager>(
*CI.getAnalyzerOpts(), CI.getLangOpts(), CI.getDiagnostics(),
CI.getAnalyzerOpts(), CI.getLangOpts(), CI.getDiagnostics(),
CI.getFrontendOpts().Plugins);

CheckerMgr->getCheckerRegistryData().printCheckerWithDescList(
*CI.getAnalyzerOpts(), out);
CI.getAnalyzerOpts(), out);
}

void ento::printEnabledCheckerList(raw_ostream &out, CompilerInstance &CI) {
out << "OVERVIEW: Clang Static Analyzer Enabled Checkers List\n\n";

auto CheckerMgr = std::make_unique<CheckerManager>(
*CI.getAnalyzerOpts(), CI.getLangOpts(), CI.getDiagnostics(),
CI.getAnalyzerOpts(), CI.getLangOpts(), CI.getDiagnostics(),
CI.getFrontendOpts().Plugins);

CheckerMgr->getCheckerRegistryData().printEnabledCheckerList(out);
Expand All @@ -50,11 +50,11 @@ void ento::printEnabledCheckerList(raw_ostream &out, CompilerInstance &CI) {
void ento::printCheckerConfigList(raw_ostream &out, CompilerInstance &CI) {

auto CheckerMgr = std::make_unique<CheckerManager>(
*CI.getAnalyzerOpts(), CI.getLangOpts(), CI.getDiagnostics(),
CI.getAnalyzerOpts(), CI.getLangOpts(), CI.getDiagnostics(),
CI.getFrontendOpts().Plugins);

CheckerMgr->getCheckerRegistryData().printCheckerOptionList(
*CI.getAnalyzerOpts(), out);
CI.getAnalyzerOpts(), out);
}

void ento::printAnalyzerConfigList(raw_ostream &out) {
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ void ModelInjector::onBodySynthesis(const NamedDecl *D) {
SourceManager &SM = CI.getSourceManager();
FileID mainFileID = SM.getMainFileID();

AnalyzerOptionsRef analyzerOpts = CI.getAnalyzerOpts();
llvm::StringRef modelPath = analyzerOpts->ModelPath;
llvm::StringRef modelPath = CI.getAnalyzerOpts().ModelPath;

llvm::SmallString<128> fileName;

Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ ModuleDepCollector::makeInvocationForModuleBuildWithoutOutputs(
// TODO: Figure out better way to set options to their default value.
CI.getCodeGenOpts().MainFileName.clear();
CI.getCodeGenOpts().DwarfDebugFlags.clear();
if (!CI.getLangOpts()->ModulesCodegen) {
if (!CI.getLangOpts().ModulesCodegen) {
CI.getCodeGenOpts().DebugCompilationDir.clear();
CI.getCodeGenOpts().CoverageCompilationDir.clear();
CI.getCodeGenOpts().CoverageDataFile.clear();
Expand All @@ -117,7 +117,7 @@ ModuleDepCollector::makeInvocationForModuleBuildWithoutOutputs(
CI.getFrontendOpts().ARCMTAction = FrontendOptions::ARCMT_None;
CI.getFrontendOpts().ObjCMTAction = FrontendOptions::ObjCMT_None;
CI.getFrontendOpts().MTMigrateDir.clear();
CI.getLangOpts()->ModuleName = Deps.ID.ModuleName;
CI.getLangOpts().ModuleName = Deps.ID.ModuleName;
CI.getFrontendOpts().IsSystemModule = Deps.IsSystem;

// Inputs
Expand Down
6 changes: 3 additions & 3 deletions clang/tools/arcmt-test/arcmt-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static bool checkForMigration(StringRef resourcesPath,
return true;
}

if (!CI.getLangOpts()->ObjC)
if (!CI.getLangOpts().ObjC)
return false;

arcmt::checkForManualIssues(CI, CI.getFrontendOpts().Inputs[0],
Expand Down Expand Up @@ -167,14 +167,14 @@ static bool performTransformations(StringRef resourcesPath,
return true;
}

if (!origCI.getLangOpts()->ObjC)
if (!origCI.getLangOpts().ObjC)
return false;

MigrationProcess migration(origCI, std::make_shared<PCHContainerOperations>(),
DiagClient);

std::vector<TransformFn>
transforms = arcmt::getAllTransformations(origCI.getLangOpts()->getGC(),
transforms = arcmt::getAllTransformations(origCI.getLangOpts().getGC(),
origCI.getMigratorOpts().NoFinalizeRemoval);
assert(!transforms.empty());

Expand Down
32 changes: 16 additions & 16 deletions clang/tools/clang-import-test/clang-import-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,28 +178,28 @@ std::unique_ptr<CompilerInstance> BuildCompilerInstance() {
ID Id = lookupTypeForTypeSpecifier(Input.c_str());
assert(Id != TY_INVALID);
if (isCXX(Id)) {
Inv->getLangOpts()->CPlusPlus = true;
Inv->getLangOpts()->CPlusPlus11 = true;
Inv->getLangOpts().CPlusPlus = true;
Inv->getLangOpts().CPlusPlus11 = true;
Inv->getHeaderSearchOpts().UseLibcxx = true;
}
if (isObjC(Id)) {
Inv->getLangOpts()->ObjC = 1;
Inv->getLangOpts().ObjC = 1;
}
}
Inv->getLangOpts()->ObjCAutoRefCount = ObjCARC;

Inv->getLangOpts()->Bool = true;
Inv->getLangOpts()->WChar = true;
Inv->getLangOpts()->Blocks = true;
Inv->getLangOpts()->DebuggerSupport = true;
Inv->getLangOpts()->SpellChecking = false;
Inv->getLangOpts()->ThreadsafeStatics = false;
Inv->getLangOpts()->AccessControl = false;
Inv->getLangOpts()->DollarIdents = true;
Inv->getLangOpts()->Exceptions = true;
Inv->getLangOpts()->CXXExceptions = true;
Inv->getLangOpts().ObjCAutoRefCount = ObjCARC;

Inv->getLangOpts().Bool = true;
Inv->getLangOpts().WChar = true;
Inv->getLangOpts().Blocks = true;
Inv->getLangOpts().DebuggerSupport = true;
Inv->getLangOpts().SpellChecking = false;
Inv->getLangOpts().ThreadsafeStatics = false;
Inv->getLangOpts().AccessControl = false;
Inv->getLangOpts().DollarIdents = true;
Inv->getLangOpts().Exceptions = true;
Inv->getLangOpts().CXXExceptions = true;
// Needed for testing dynamic_cast.
Inv->getLangOpts()->RTTI = true;
Inv->getLangOpts().RTTI = true;
Inv->getCodeGenOpts().setDebugInfo(llvm::codegenoptions::FullDebugInfo);
Inv->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple();

Expand Down
6 changes: 3 additions & 3 deletions clang/tools/libclang/Indexing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ static CXErrorCode clang_indexSourceFile_Impl(
// (often very broken) source code, where spell-checking can have a
// significant negative impact on performance (particularly when
// precompiled headers are involved), we disable it.
CInvok->getLangOpts()->SpellChecking = false;
CInvok->getLangOpts().SpellChecking = false;

if (index_options & CXIndexOpt_SuppressWarnings)
CInvok->getDiagnosticOpts().IgnoreWarnings = true;
Expand All @@ -571,7 +571,7 @@ static CXErrorCode clang_indexSourceFile_Impl(
// Enable the skip-parsed-bodies optimization only for C++; this may be
// revisited.
bool SkipBodies = (index_options & CXIndexOpt_SkipParsedBodiesInSession) &&
CInvok->getLangOpts()->CPlusPlus;
CInvok->getLangOpts().CPlusPlus;
if (SkipBodies)
CInvok->getFrontendOpts().SkipFunctionBodies = true;

Expand Down Expand Up @@ -608,7 +608,7 @@ static CXErrorCode clang_indexSourceFile_Impl(
PPOpts.DetailedRecord = true;
}

if (!requestedToGetTU && !CInvok->getLangOpts()->Modules)
if (!requestedToGetTU && !CInvok->getLangOpts().Modules)
PPOpts.DetailedRecord = false;

// Unless the user specified that they want the preamble on the first parse
Expand Down
4 changes: 2 additions & 2 deletions clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ class CTUAction : public clang::ASTFrontendAction {
protected:
std::unique_ptr<clang::ASTConsumer>
CreateASTConsumer(clang::CompilerInstance &CI, StringRef) override {
CI.getAnalyzerOpts()->CTUImportThreshold = OverrideLimit;
CI.getAnalyzerOpts()->CTUImportCppThreshold = OverrideLimit;
CI.getAnalyzerOpts().CTUImportThreshold = OverrideLimit;
CI.getAnalyzerOpts().CTUImportCppThreshold = OverrideLimit;
return std::make_unique<CTUASTConsumer>(CI, Success);
}

Expand Down
100 changes: 50 additions & 50 deletions clang/unittests/Frontend/CompilerInvocationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,23 @@ TEST(ContainsN, Two) {

TEST(CompilerInvocationTest, DeepCopyConstructor) {
CompilerInvocation A;
A.getAnalyzerOpts()->Config["Key"] = "Old";
A.getAnalyzerOpts().Config["Key"] = "Old";

CompilerInvocation B(A);
B.getAnalyzerOpts()->Config["Key"] = "New";
B.getAnalyzerOpts().Config["Key"] = "New";

ASSERT_EQ(A.getAnalyzerOpts()->Config["Key"], "Old");
ASSERT_EQ(A.getAnalyzerOpts().Config["Key"], "Old");
}

TEST(CompilerInvocationTest, DeepCopyAssignment) {
CompilerInvocation A;
A.getAnalyzerOpts()->Config["Key"] = "Old";
A.getAnalyzerOpts().Config["Key"] = "Old";

CompilerInvocation B;
B = A;
B.getAnalyzerOpts()->Config["Key"] = "New";
B.getAnalyzerOpts().Config["Key"] = "New";

ASSERT_EQ(A.getAnalyzerOpts()->Config["Key"], "Old");
ASSERT_EQ(A.getAnalyzerOpts().Config["Key"], "Old");
}

// Boolean option with a keypath that defaults to true.
Expand Down Expand Up @@ -506,7 +506,7 @@ TEST_F(CommandLineTest, StringVectorCommaJoinedNone) {
const char *Args[] = {""};

ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_TRUE(Invocation.getLangOpts()->CommentOpts.BlockCommandNames.empty());
ASSERT_TRUE(Invocation.getLangOpts().CommentOpts.BlockCommandNames.empty());

Invocation.generateCC1CommandLine(GeneratedArgs, *this);

Expand All @@ -518,7 +518,7 @@ TEST_F(CommandLineTest, StringVectorCommaJoinedSingle) {
const char *Args[] = {"-fcomment-block-commands=x,y"};

ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_EQ(Invocation.getLangOpts()->CommentOpts.BlockCommandNames,
ASSERT_EQ(Invocation.getLangOpts().CommentOpts.BlockCommandNames,
std::vector<std::string>({"x", "y"}));

Invocation.generateCC1CommandLine(GeneratedArgs, *this);
Expand All @@ -532,7 +532,7 @@ TEST_F(CommandLineTest, StringVectorCommaJoinedMultiple) {
"-fcomment-block-commands=a,b"};

ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_EQ(Invocation.getLangOpts()->CommentOpts.BlockCommandNames,
ASSERT_EQ(Invocation.getLangOpts().CommentOpts.BlockCommandNames,
std::vector<std::string>({"x", "y", "a", "b"}));

Invocation.generateCC1CommandLine(GeneratedArgs, *this);
Expand All @@ -549,9 +549,9 @@ TEST_F(CommandLineTest, ConditionalParsingIfFalseFlagNotPresent) {
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);

ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsDevice);
ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsHost);
ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_None);
ASSERT_FALSE(Invocation.getLangOpts().SYCLIsDevice);
ASSERT_FALSE(Invocation.getLangOpts().SYCLIsHost);
ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(), LangOptions::SYCL_None);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);

Expand All @@ -565,9 +565,9 @@ TEST_F(CommandLineTest, ConditionalParsingIfFalseFlagPresent) {
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);

ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsDevice);
ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsHost);
ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_None);
ASSERT_FALSE(Invocation.getLangOpts().SYCLIsDevice);
ASSERT_FALSE(Invocation.getLangOpts().SYCLIsHost);
ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(), LangOptions::SYCL_None);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);

Expand All @@ -582,9 +582,9 @@ TEST_F(CommandLineTest, ConditionalParsingIfNonsenseSyclStdArg) {
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);

ASSERT_TRUE(Diags->hasErrorOccurred());
ASSERT_TRUE(Invocation.getLangOpts()->SYCLIsDevice);
ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsHost);
ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_None);
ASSERT_TRUE(Invocation.getLangOpts().SYCLIsDevice);
ASSERT_FALSE(Invocation.getLangOpts().SYCLIsHost);
ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(), LangOptions::SYCL_None);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);

Expand All @@ -599,9 +599,9 @@ TEST_F(CommandLineTest, ConditionalParsingIfOddSyclStdArg1) {
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);

ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_TRUE(Invocation.getLangOpts()->SYCLIsDevice);
ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsHost);
ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_2017);
ASSERT_TRUE(Invocation.getLangOpts().SYCLIsDevice);
ASSERT_FALSE(Invocation.getLangOpts().SYCLIsHost);
ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(), LangOptions::SYCL_2017);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);

Expand All @@ -616,9 +616,9 @@ TEST_F(CommandLineTest, ConditionalParsingIfOddSyclStdArg2) {
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);

ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_TRUE(Invocation.getLangOpts()->SYCLIsDevice);
ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsHost);
ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_2017);
ASSERT_TRUE(Invocation.getLangOpts().SYCLIsDevice);
ASSERT_FALSE(Invocation.getLangOpts().SYCLIsHost);
ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(), LangOptions::SYCL_2017);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);

Expand All @@ -633,9 +633,9 @@ TEST_F(CommandLineTest, ConditionalParsingIfOddSyclStdArg3) {
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);

ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_TRUE(Invocation.getLangOpts()->SYCLIsDevice);
ASSERT_FALSE(Invocation.getLangOpts()->SYCLIsHost);
ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_2017);
ASSERT_TRUE(Invocation.getLangOpts().SYCLIsDevice);
ASSERT_FALSE(Invocation.getLangOpts().SYCLIsHost);
ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(), LangOptions::SYCL_2017);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);

Expand All @@ -650,7 +650,7 @@ TEST_F(CommandLineTest, ConditionalParsingIfTrueFlagNotPresentHost) {
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);

ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(),
ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(),
LangOptions::SYCL_Default);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);
Expand All @@ -665,7 +665,7 @@ TEST_F(CommandLineTest, ConditionalParsingIfTrueFlagNotPresentDevice) {
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);

ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(),
ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(),
LangOptions::SYCL_Default);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);
Expand All @@ -680,7 +680,7 @@ TEST_F(CommandLineTest, ConditionalParsingIfTrueFlagPresent) {
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);

ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_EQ(Invocation.getLangOpts()->getSYCLVersion(), LangOptions::SYCL_2017);
ASSERT_EQ(Invocation.getLangOpts().getSYCLVersion(), LangOptions::SYCL_2017);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);

Expand Down Expand Up @@ -712,10 +712,10 @@ TEST_F(CommandLineTest, ImpliedBoolOptionsNoFlagPresent) {
const char *Args[] = {""};

ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_FALSE(Invocation.getLangOpts()->CLUnsafeMath);
ASSERT_FALSE(Invocation.getLangOpts().CLUnsafeMath);
ASSERT_FALSE(Invocation.getCodeGenOpts().LessPreciseFPMAD);
ASSERT_FALSE(Invocation.getLangOpts()->UnsafeFPMath);
ASSERT_FALSE(Invocation.getLangOpts()->AllowRecip);
ASSERT_FALSE(Invocation.getLangOpts().UnsafeFPMath);
ASSERT_FALSE(Invocation.getLangOpts().AllowRecip);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);

Expand All @@ -733,12 +733,12 @@ TEST_F(CommandLineTest, ImpliedBoolOptionsRootFlagPresent) {

ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
// Explicitly provided root flag.
ASSERT_TRUE(Invocation.getLangOpts()->CLUnsafeMath);
ASSERT_TRUE(Invocation.getLangOpts().CLUnsafeMath);
// Directly implied by explicitly provided root flag.
ASSERT_TRUE(Invocation.getCodeGenOpts().LessPreciseFPMAD);
ASSERT_TRUE(Invocation.getLangOpts()->UnsafeFPMath);
ASSERT_TRUE(Invocation.getLangOpts().UnsafeFPMath);
// Transitively implied by explicitly provided root flag.
ASSERT_TRUE(Invocation.getLangOpts()->AllowRecip);
ASSERT_TRUE(Invocation.getLangOpts().AllowRecip);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);

Expand All @@ -756,10 +756,10 @@ TEST_F(CommandLineTest, ImpliedBoolOptionsAllFlagsPresent) {
"-funsafe-math-optimizations", "-freciprocal-math"};

ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_TRUE(Invocation.getLangOpts()->CLUnsafeMath);
ASSERT_TRUE(Invocation.getLangOpts().CLUnsafeMath);
ASSERT_TRUE(Invocation.getCodeGenOpts().LessPreciseFPMAD);
ASSERT_TRUE(Invocation.getLangOpts()->UnsafeFPMath);
ASSERT_TRUE(Invocation.getLangOpts()->AllowRecip);
ASSERT_TRUE(Invocation.getLangOpts().UnsafeFPMath);
ASSERT_TRUE(Invocation.getLangOpts().AllowRecip);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);

Expand All @@ -777,10 +777,10 @@ TEST_F(CommandLineTest, ImpliedBoolOptionsImpliedFlagsPresent) {
"-freciprocal-math"};

ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_FALSE(Invocation.getLangOpts()->CLUnsafeMath);
ASSERT_FALSE(Invocation.getLangOpts().CLUnsafeMath);
ASSERT_TRUE(Invocation.getCodeGenOpts().LessPreciseFPMAD);
ASSERT_TRUE(Invocation.getLangOpts()->UnsafeFPMath);
ASSERT_TRUE(Invocation.getLangOpts()->AllowRecip);
ASSERT_TRUE(Invocation.getLangOpts().UnsafeFPMath);
ASSERT_TRUE(Invocation.getLangOpts().AllowRecip);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);
// Not generated - missing.
Expand Down Expand Up @@ -826,7 +826,7 @@ TEST_F(CommandLineTest, DigraphsImplied) {
const char *Args[] = {""};

ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_TRUE(Invocation.getLangOpts()->Digraphs);
ASSERT_TRUE(Invocation.getLangOpts().Digraphs);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);
ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-digraphs"))));
Expand All @@ -837,7 +837,7 @@ TEST_F(CommandLineTest, DigraphsDisabled) {
const char *Args[] = {"-fno-digraphs"};

ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_FALSE(Invocation.getLangOpts()->Digraphs);
ASSERT_FALSE(Invocation.getLangOpts().Digraphs);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);
ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fno-digraphs")));
Expand All @@ -848,7 +848,7 @@ TEST_F(CommandLineTest, DigraphsNotImplied) {
const char *Args[] = {"-std=c89"};

ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_FALSE(Invocation.getLangOpts()->Digraphs);
ASSERT_FALSE(Invocation.getLangOpts().Digraphs);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);
ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-digraphs"))));
Expand All @@ -859,7 +859,7 @@ TEST_F(CommandLineTest, DigraphsEnabled) {
const char *Args[] = {"-std=c89", "-fdigraphs"};

ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
ASSERT_TRUE(Invocation.getLangOpts()->Digraphs);
ASSERT_TRUE(Invocation.getLangOpts().Digraphs);

Invocation.generateCC1CommandLine(GeneratedArgs, *this);
ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fdigraphs")));
Expand Down Expand Up @@ -964,8 +964,8 @@ TEST_F(CommandLineTest, RoundTrip) {

ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));

ASSERT_TRUE(Invocation.getLangOpts()->C17);
ASSERT_EQ(Invocation.getLangOpts()->MaxTokens, 10u);
ASSERT_TRUE(Invocation.getLangOpts().C17);
ASSERT_EQ(Invocation.getLangOpts().MaxTokens, 10u);

ASSERT_EQ(Invocation.getTargetOpts().SDKVersion, llvm::VersionTuple(1, 2, 3));
ASSERT_EQ(Invocation.getTargetOpts().EABIVersion, EABI::EABI4);
Expand All @@ -982,8 +982,8 @@ TEST_F(CommandLineTest, RoundTrip) {
Contains(std::make_pair(std::string("XY=AB"), false)));
ASSERT_EQ(Invocation.getPreprocessorOpts().ImplicitPCHInclude, "a.pch");

ASSERT_EQ(Invocation.getAnalyzerOpts()->Config["ctu-import-threshold"], "42");
ASSERT_TRUE(Invocation.getAnalyzerOpts()->UnoptimizedCFG);
ASSERT_EQ(Invocation.getAnalyzerOpts().Config["ctu-import-threshold"], "42");
ASSERT_TRUE(Invocation.getAnalyzerOpts().UnoptimizedCFG);

ASSERT_TRUE(Invocation.getMigratorOpts().NoNSAllocReallocError);

Expand Down
8 changes: 4 additions & 4 deletions clang/unittests/Frontend/FrontendActionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ TEST(ASTFrontendAction, IncrementalParsing) {

TEST(ASTFrontendAction, LateTemplateIncrementalParsing) {
auto invocation = std::make_shared<CompilerInvocation>();
invocation->getLangOpts()->CPlusPlus = true;
invocation->getLangOpts()->DelayedTemplateParsing = true;
invocation->getLangOpts().CPlusPlus = true;
invocation->getLangOpts().DelayedTemplateParsing = true;
invocation->getPreprocessorOpts().addRemappedFile(
"test.cc", MemoryBuffer::getMemBuffer(
"template<typename T> struct A { A(T); T data; };\n"
Expand Down Expand Up @@ -233,7 +233,7 @@ struct TypoDiagnosticConsumer : public DiagnosticConsumer {

TEST(ASTFrontendAction, ExternalSemaSource) {
auto Invocation = std::make_shared<CompilerInvocation>();
Invocation->getLangOpts()->CPlusPlus = true;
Invocation->getLangOpts().CPlusPlus = true;
Invocation->getPreprocessorOpts().addRemappedFile(
"test.cc", MemoryBuffer::getMemBuffer("void fooo();\n"
"int main() { foo(); }")
Expand Down Expand Up @@ -266,7 +266,7 @@ TEST(GeneratePCHFrontendAction, CacheGeneratedPCH) {

for (bool ShouldCache : {false, true}) {
auto Invocation = std::make_shared<CompilerInvocation>();
Invocation->getLangOpts()->CacheGeneratedPCH = ShouldCache;
Invocation->getLangOpts().CacheGeneratedPCH = ShouldCache;
Invocation->getPreprocessorOpts().addRemappedFile(
"test.h",
MemoryBuffer::getMemBuffer("int foo(void) { return 1; }\n").release());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class TestAction : public ASTFrontendAction {
Registry.addChecker<InterestingnessTestChecker>("test.Interestingness",
"Description", "");
});
Compiler.getAnalyzerOpts()->CheckersAndPackages = {
Compiler.getAnalyzerOpts().CheckersAndPackages = {
{"test.Interestingness", true}};
return std::move(AnalysisConsumer);
}
Expand Down
2 changes: 1 addition & 1 deletion clang/unittests/StaticAnalyzer/CheckerRegistration.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ template <AddCheckerFn... Fns> class TestAction : public ASTFrontendAction {
else
AnalysisConsumer->AddDiagnosticConsumer(
new PathDiagConsumer(DiagsOutput));
addChecker<Fns...>(*AnalysisConsumer, *Compiler.getAnalyzerOpts());
addChecker<Fns...>(*AnalysisConsumer, Compiler.getAnalyzerOpts());
return std::move(AnalysisConsumer);
}
};
Expand Down
4 changes: 2 additions & 2 deletions clang/unittests/StaticAnalyzer/Reusables.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ class ExprEngineConsumer : public ASTConsumer {
public:
ExprEngineConsumer(CompilerInstance &C)
: C(C),
ChkMgr(C.getASTContext(), *C.getAnalyzerOpts(), C.getPreprocessor()),
ChkMgr(C.getASTContext(), C.getAnalyzerOpts(), C.getPreprocessor()),
CTU(C), Consumers(),
AMgr(C.getASTContext(), C.getPreprocessor(), Consumers,
CreateRegionStoreManager, CreateRangeConstraintManager, &ChkMgr,
*C.getAnalyzerOpts()),
C.getAnalyzerOpts()),
VisitedCallees(), FS(),
Eng(CTU, AMgr, &VisitedCallees, &FS, ExprEngine::Inline_Regular) {}
};
Expand Down