namespace clang {
+class CompilerInvocation;
class DiagnosticsEngine;
+
+class CompilerInvocationBase : public llvm::RefCountedBase<CompilerInvocation> {
+protected:
+ /// Options controlling the language variant.
+ llvm::IntrusiveRefCntPtr<LangOptions> LangOpts;
+public:
+ CompilerInvocationBase();
+ CompilerInvocationBase(const CompilerInvocationBase &X);
+
+ LangOptions *getLangOpts() { return LangOpts.getPtr(); }
+ const LangOptions *getLangOpts() const { return LangOpts.getPtr(); }
+};
+
/// CompilerInvocation - Helper class for holding the data necessary to invoke
/// the compiler.
///
/// This class is designed to represent an abstract "invocation" of the
/// compiler, including data such as the include paths, the code generation
/// options, the warning flags, and so on.
-class CompilerInvocation : public llvm::RefCountedBase<CompilerInvocation> {
+class CompilerInvocation : public CompilerInvocationBase {
/// Options controlling the static analyzer.
AnalyzerOptions AnalyzerOpts;
/// Options controlling the #include directive.
HeaderSearchOptions HeaderSearchOpts;
- /// Options controlling the language variant.
- llvm::IntrusiveRefCntPtr<LangOptions> LangOpts;
-
/// Options controlling the preprocessor (aside from #include handling).
PreprocessorOptions PreprocessorOpts;
TargetOptions TargetOpts;
public:
- CompilerInvocation();
+ CompilerInvocation() {}
/// @name Utility Methods
/// @{
/// \param LangStd - The input language standard.
void setLangDefaults(InputKind IK,
LangStandard::Kind LangStd = LangStandard::lang_unspecified) {
- setLangDefaults(*LangOpts, IK, LangStd);
+ setLangDefaults(*getLangOpts(), IK, LangStd);
}
/// setLangDefaults - Set language defaults for the given input language and
return FrontendOpts;
}
- LangOptions *getLangOpts() { return LangOpts.getPtr(); }
- const LangOptions *getLangOpts() const { return LangOpts.getPtr(); }
-
- void setLangOpts(LangOptions *LangOpts);
-
PreprocessorOptions &getPreprocessorOpts() { return PreprocessorOpts; }
const PreprocessorOptions &getPreprocessorOpts() const {
return PreprocessorOpts;
// Initialization.
//===----------------------------------------------------------------------===//
-CompilerInvocation::CompilerInvocation()
+CompilerInvocationBase::CompilerInvocationBase()
: LangOpts(new LangOptions()) {}
-void CompilerInvocation::setLangOpts(LangOptions *LOpts) {
- LangOpts = LOpts;
-}
+CompilerInvocationBase::CompilerInvocationBase(const CompilerInvocationBase &X)
+ : LangOpts(new LangOptions(*X.getLangOpts())) {}
//===----------------------------------------------------------------------===//
// Utility functions.