Add CompilerInstance::has* methods for testing if the instance has a particular
subobject. llvm-svn: 87096
This commit is contained in:
parent
df3e30c41c
commit
adf6c242a0
|
@ -84,7 +84,9 @@ public:
|
||||||
/// @name LLVM Context
|
/// @name LLVM Context
|
||||||
/// {
|
/// {
|
||||||
|
|
||||||
llvm::LLVMContext &getLLVMContext() {
|
bool hasLLVMContext() const { return LLVMContext != 0; }
|
||||||
|
|
||||||
|
llvm::LLVMContext &getLLVMContext() const {
|
||||||
assert(LLVMContext && "Compiler instance has no LLVM context!");
|
assert(LLVMContext && "Compiler instance has no LLVM context!");
|
||||||
return *LLVMContext;
|
return *LLVMContext;
|
||||||
}
|
}
|
||||||
|
@ -175,6 +177,8 @@ public:
|
||||||
/// @name Diagnostics Engine
|
/// @name Diagnostics Engine
|
||||||
/// {
|
/// {
|
||||||
|
|
||||||
|
bool hasDiagnostics() const { return Diagnostics != 0; }
|
||||||
|
|
||||||
Diagnostic &getDiagnostics() const {
|
Diagnostic &getDiagnostics() const {
|
||||||
assert(Diagnostics && "Compiler instance has no diagnostics!");
|
assert(Diagnostics && "Compiler instance has no diagnostics!");
|
||||||
return *Diagnostics;
|
return *Diagnostics;
|
||||||
|
@ -204,6 +208,8 @@ public:
|
||||||
/// @name Target Info
|
/// @name Target Info
|
||||||
/// {
|
/// {
|
||||||
|
|
||||||
|
bool hasTarget() const { return Target != 0; }
|
||||||
|
|
||||||
TargetInfo &getTarget() const {
|
TargetInfo &getTarget() const {
|
||||||
assert(Target && "Compiler instance has no target!");
|
assert(Target && "Compiler instance has no target!");
|
||||||
return *Target;
|
return *Target;
|
||||||
|
@ -221,6 +227,8 @@ public:
|
||||||
/// @name File Manager
|
/// @name File Manager
|
||||||
/// {
|
/// {
|
||||||
|
|
||||||
|
bool hasFileManager() const { return FileMgr != 0; }
|
||||||
|
|
||||||
FileManager &getFileManager() const {
|
FileManager &getFileManager() const {
|
||||||
assert(FileMgr && "Compiler instance has no file manager!");
|
assert(FileMgr && "Compiler instance has no file manager!");
|
||||||
return *FileMgr;
|
return *FileMgr;
|
||||||
|
@ -238,6 +246,8 @@ public:
|
||||||
/// @name Source Manager
|
/// @name Source Manager
|
||||||
/// {
|
/// {
|
||||||
|
|
||||||
|
bool hasSourceManager() const { return SourceMgr != 0; }
|
||||||
|
|
||||||
SourceManager &getSourceManager() const {
|
SourceManager &getSourceManager() const {
|
||||||
assert(SourceMgr && "Compiler instance has no source manager!");
|
assert(SourceMgr && "Compiler instance has no source manager!");
|
||||||
return *SourceMgr;
|
return *SourceMgr;
|
||||||
|
@ -255,6 +265,8 @@ public:
|
||||||
/// @name Preprocessor
|
/// @name Preprocessor
|
||||||
/// {
|
/// {
|
||||||
|
|
||||||
|
bool hasPreprocessor() const { return PP != 0; }
|
||||||
|
|
||||||
Preprocessor &getPreprocessor() const {
|
Preprocessor &getPreprocessor() const {
|
||||||
assert(PP && "Compiler instance has no preprocessor!");
|
assert(PP && "Compiler instance has no preprocessor!");
|
||||||
return *PP;
|
return *PP;
|
||||||
|
@ -272,6 +284,8 @@ public:
|
||||||
/// @name ASTContext
|
/// @name ASTContext
|
||||||
/// {
|
/// {
|
||||||
|
|
||||||
|
bool hasASTContext() const { return Context != 0; }
|
||||||
|
|
||||||
ASTContext &getASTContext() const {
|
ASTContext &getASTContext() const {
|
||||||
assert(Context && "Compiler instance has no AST context!");
|
assert(Context && "Compiler instance has no AST context!");
|
||||||
return *Context;
|
return *Context;
|
||||||
|
|
|
@ -839,7 +839,7 @@ int main(int argc, char **argv) {
|
||||||
// client to use for any errors during option handling.
|
// client to use for any errors during option handling.
|
||||||
InitializeDiagnosticOptions(Clang.getDiagnosticOpts());
|
InitializeDiagnosticOptions(Clang.getDiagnosticOpts());
|
||||||
Clang.createDiagnostics(argc, argv);
|
Clang.createDiagnostics(argc, argv);
|
||||||
if (!&Clang.getDiagnostics())
|
if (!Clang.hasDiagnostics())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
// Set an error handler, so that any LLVM backend diagnostics go through our
|
// Set an error handler, so that any LLVM backend diagnostics go through our
|
||||||
|
@ -856,7 +856,7 @@ int main(int argc, char **argv) {
|
||||||
Clang.setTarget(
|
Clang.setTarget(
|
||||||
ConstructCompilerInvocation(Clang.getInvocation(), Clang.getDiagnostics(),
|
ConstructCompilerInvocation(Clang.getInvocation(), Clang.getDiagnostics(),
|
||||||
argv[0], IsAST));
|
argv[0], IsAST));
|
||||||
if (!&Clang.getTarget())
|
if (!Clang.hasTarget())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
// Validate/process some options
|
// Validate/process some options
|
||||||
|
|
Loading…
Reference in New Issue