[cfe-commits] r87096 - in /cfe/trunk: include/clang/Frontend/CompilerInstance.h tools/clang-cc/clang-cc.cpp

Daniel Dunbar daniel at zuster.org
Fri Nov 13 00:20:57 PST 2009


Author: ddunbar
Date: Fri Nov 13 02:20:57 2009
New Revision: 87096

URL: http://llvm.org/viewvc/llvm-project?rev=87096&view=rev
Log:
Add CompilerInstance::has* methods for testing if the instance has a particular
subobject.

Modified:
    cfe/trunk/include/clang/Frontend/CompilerInstance.h
    cfe/trunk/tools/clang-cc/clang-cc.cpp

Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=87096&r1=87095&r2=87096&view=diff

==============================================================================
--- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Fri Nov 13 02:20:57 2009
@@ -84,7 +84,9 @@
   /// @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 @@
   /// @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 @@
   /// @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 @@
   /// @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 @@
   /// @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 @@
   /// @name Preprocessor
   /// {
 
+  bool hasPreprocessor() const { return PP != 0; }
+
   Preprocessor &getPreprocessor() const {
     assert(PP && "Compiler instance has no preprocessor!");
     return *PP;
@@ -272,6 +284,8 @@
   /// @name ASTContext
   /// {
 
+  bool hasASTContext() const { return Context != 0; }
+
   ASTContext &getASTContext() const {
     assert(Context && "Compiler instance has no AST context!");
     return *Context;

Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=87096&r1=87095&r2=87096&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Fri Nov 13 02:20:57 2009
@@ -839,7 +839,7 @@
   // 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 @@
   Clang.setTarget(
     ConstructCompilerInvocation(Clang.getInvocation(), Clang.getDiagnostics(),
                                 argv[0], IsAST));
-  if (!&Clang.getTarget())
+  if (!Clang.hasTarget())
     return 1;
 
   // Validate/process some options





More information about the cfe-commits mailing list