aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-11-13 08:20:57 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-11-13 08:20:57 +0000
commit704e48ae75111072eecaa20a365dff46fb49d2be (patch)
tree21d540ce49c18860c9cdad4c4d89f628c2349e2c
parent5eb810024dc8a1d12d5f066c02c978f07c4fcb00 (diff)
Add CompilerInstance::has* methods for testing if the instance has a particular
subobject. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@87096 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Frontend/CompilerInstance.h16
-rw-r--r--tools/clang-cc/clang-cc.cpp4
2 files changed, 17 insertions, 3 deletions
diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h
index 0cc1911c0c..8c638206b6 100644
--- a/include/clang/Frontend/CompilerInstance.h
+++ b/include/clang/Frontend/CompilerInstance.h
@@ -84,7 +84,9 @@ public:
/// @name LLVM Context
/// {
- llvm::LLVMContext &getLLVMContext() {
+ bool hasLLVMContext() const { return LLVMContext != 0; }
+
+ llvm::LLVMContext &getLLVMContext() const {
assert(LLVMContext && "Compiler instance has no LLVM context!");
return *LLVMContext;
}
@@ -175,6 +177,8 @@ public:
/// @name Diagnostics Engine
/// {
+ bool hasDiagnostics() const { return Diagnostics != 0; }
+
Diagnostic &getDiagnostics() const {
assert(Diagnostics && "Compiler instance has no diagnostics!");
return *Diagnostics;
@@ -204,6 +208,8 @@ public:
/// @name Target Info
/// {
+ bool hasTarget() const { return Target != 0; }
+
TargetInfo &getTarget() const {
assert(Target && "Compiler instance has no target!");
return *Target;
@@ -221,6 +227,8 @@ public:
/// @name File Manager
/// {
+ bool hasFileManager() const { return FileMgr != 0; }
+
FileManager &getFileManager() const {
assert(FileMgr && "Compiler instance has no file manager!");
return *FileMgr;
@@ -238,6 +246,8 @@ public:
/// @name Source Manager
/// {
+ bool hasSourceManager() const { return SourceMgr != 0; }
+
SourceManager &getSourceManager() const {
assert(SourceMgr && "Compiler instance has no source manager!");
return *SourceMgr;
@@ -255,6 +265,8 @@ public:
/// @name Preprocessor
/// {
+ bool hasPreprocessor() const { return PP != 0; }
+
Preprocessor &getPreprocessor() const {
assert(PP && "Compiler instance has no preprocessor!");
return *PP;
@@ -272,6 +284,8 @@ public:
/// @name ASTContext
/// {
+ bool hasASTContext() const { return Context != 0; }
+
ASTContext &getASTContext() const {
assert(Context && "Compiler instance has no AST context!");
return *Context;
diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp
index 0393c7301d..764db6f503 100644
--- a/tools/clang-cc/clang-cc.cpp
+++ b/tools/clang-cc/clang-cc.cpp
@@ -839,7 +839,7 @@ int main(int argc, char **argv) {
// client to use for any errors during option handling.
InitializeDiagnosticOptions(Clang.getDiagnosticOpts());
Clang.createDiagnostics(argc, argv);
- if (!&Clang.getDiagnostics())
+ if (!Clang.hasDiagnostics())
return 1;
// 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(
ConstructCompilerInvocation(Clang.getInvocation(), Clang.getDiagnostics(),
argv[0], IsAST));
- if (!&Clang.getTarget())
+ if (!Clang.hasTarget())
return 1;
// Validate/process some options