[PATCH] Replace OwningPtr::isValid() with conversion to bool.

Ahmed Charles acharles at outlook.com
Fri Mar 7 03:48:42 PST 2014


  clang-format

Hi dblaikie, chandlerc,

http://llvm-reviews.chandlerc.com/D3001

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D3001?vs=7632&id=7635#toc

Files:
  include/clang/Frontend/ASTUnit.h
  include/clang/Frontend/CompilerInstance.h
  include/clang/Frontend/FrontendAction.h
  include/clang/Lex/HeaderSearch.h
  include/clang/Serialization/ASTReader.h
  include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
  lib/Rewrite/Core/Rewriter.cpp
  unittests/Tooling/CompilationDatabaseTest.cpp

Index: include/clang/Frontend/ASTUnit.h
===================================================================
--- include/clang/Frontend/ASTUnit.h
+++ include/clang/Frontend/ASTUnit.h
@@ -500,7 +500,7 @@
   void setASTContext(ASTContext *ctx) { Ctx = ctx; }
   void setPreprocessor(Preprocessor *pp);
 
-  bool hasSema() const { return TheSema.isValid(); }
+  bool hasSema() const { return bool(TheSema); }
   Sema &getSema() const { 
     assert(TheSema && "ASTUnit does not have a Sema object!");
     return *TheSema; 
Index: include/clang/Frontend/CompilerInstance.h
===================================================================
--- include/clang/Frontend/CompilerInstance.h
+++ include/clang/Frontend/CompilerInstance.h
@@ -426,7 +426,7 @@
   /// @name ASTConsumer
   /// {
 
-  bool hasASTConsumer() const { return Consumer.isValid(); }
+  bool hasASTConsumer() const { return bool(Consumer); }
 
   ASTConsumer &getASTConsumer() const {
     assert(Consumer && "Compiler instance has no AST consumer!");
@@ -444,8 +444,8 @@
   /// }
   /// @name Semantic analysis
   /// {
-  bool hasSema() const { return TheSema.isValid(); }
-  
+  bool hasSema() const { return bool(TheSema); }
+
   Sema &getSema() const { 
     assert(TheSema && "Compiler instance has no Sema object!");
     return *TheSema;
@@ -464,9 +464,7 @@
   /// @name Code Completion
   /// {
 
-  bool hasCodeCompletionConsumer() const {
-    return CompletionConsumer.isValid();
-  }
+  bool hasCodeCompletionConsumer() const { return bool(CompletionConsumer); }
 
   CodeCompleteConsumer &getCodeCompletionConsumer() const {
     assert(CompletionConsumer &&
@@ -488,7 +486,7 @@
   /// @name Frontend timer
   /// {
 
-  bool hasFrontendTimer() const { return FrontendTimer.isValid(); }
+  bool hasFrontendTimer() const { return bool(FrontendTimer); }
 
   llvm::Timer &getFrontendTimer() const {
     assert(FrontendTimer && "Compiler instance has no frontend timer!");
Index: include/clang/Frontend/FrontendAction.h
===================================================================
--- include/clang/Frontend/FrontendAction.h
+++ include/clang/Frontend/FrontendAction.h
@@ -124,7 +124,7 @@
 
   bool isCurrentFileAST() const {
     assert(!CurrentInput.isEmpty() && "No current file!");
-    return CurrentASTUnit.isValid();
+    return bool(CurrentASTUnit);
   }
 
   const FrontendInputFile &getCurrentInput() const {
Index: include/clang/Lex/HeaderSearch.h
===================================================================
--- include/clang/Lex/HeaderSearch.h
+++ include/clang/Lex/HeaderSearch.h
@@ -281,9 +281,7 @@
   }
 
   /// \brief Checks whether the map exists or not.
-  bool HasIncludeAliasMap() const {
-    return IncludeAliases.isValid();
-  }
+  bool HasIncludeAliasMap() const { return bool(IncludeAliases); }
 
   /// \brief Map the source include name to the dest include name.
   ///
Index: include/clang/Serialization/ASTReader.h
===================================================================
--- include/clang/Serialization/ASTReader.h
+++ include/clang/Serialization/ASTReader.h
@@ -1333,7 +1333,7 @@
   void setDeserializationListener(ASTDeserializationListener *Listener);
 
   /// \brief Determine whether this AST reader has a global index.
-  bool hasGlobalIndex() const { return GlobalIndex.isValid(); }
+  bool hasGlobalIndex() const { return bool(GlobalIndex); }
 
   /// \brief Attempts to load the global index.
   ///
Index: include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
===================================================================
--- include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
+++ include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
@@ -523,10 +523,8 @@
   bool isPrunable() const {
     return IsPrunable.hasValue() ? IsPrunable.getValue() : false;
   }
-  
-  bool hasCallStackHint() {
-    return CallStackHint.isValid();
-  }
+
+  bool hasCallStackHint() { return bool(CallStackHint); }
 
   /// Produce the hint for the given node. The node contains 
   /// information about the call for which the diagnostic can be generated.
Index: lib/Rewrite/Core/Rewriter.cpp
===================================================================
--- lib/Rewrite/Core/Rewriter.cpp
+++ lib/Rewrite/Core/Rewriter.cpp
@@ -464,7 +464,7 @@
     }
   }
 
-  bool ok() { return FileStream.isValid(); }
+  bool ok() { return bool(FileStream); }
   raw_ostream &getStream() { return *FileStream; }
 
 private:
Index: unittests/Tooling/CompilationDatabaseTest.cpp
===================================================================
--- unittests/Tooling/CompilationDatabaseTest.cpp
+++ unittests/Tooling/CompilationDatabaseTest.cpp
@@ -455,7 +455,7 @@
   };
   OwningPtr<FixedCompilationDatabase> Database(
       FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
-  ASSERT_TRUE(Database.isValid());
+  ASSERT_TRUE(bool(Database));
   std::vector<CompileCommand> Result =
     Database->getCompileCommands("source");
   ASSERT_EQ(1ul, Result.size());
@@ -474,7 +474,7 @@
   const char *Argv[] = { "1", "2", "--\0no-constant-folding" };
   OwningPtr<FixedCompilationDatabase> Database(
       FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
-  ASSERT_TRUE(Database.isValid());
+  ASSERT_TRUE(bool(Database));
   std::vector<CompileCommand> Result =
     Database->getCompileCommands("source");
   ASSERT_EQ(1ul, Result.size());
@@ -491,7 +491,7 @@
   int Argc = sizeof(Argv) / sizeof(char*);
   OwningPtr<FixedCompilationDatabase> Database(
       FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
-  ASSERT_TRUE(Database.isValid());
+  ASSERT_TRUE(bool(Database));
   std::vector<CompileCommand> Result =
     Database->getCompileCommands("source");
   ASSERT_EQ(1ul, Result.size());
@@ -510,7 +510,7 @@
   int Argc = sizeof(Argv) / sizeof(char*);
   OwningPtr<FixedCompilationDatabase> Database(
       FixedCompilationDatabase::loadFromCommandLine(Argc, Argv));
-  ASSERT_TRUE(Database.isValid());
+  ASSERT_TRUE(bool(Database));
   std::vector<CompileCommand> Result =
     Database->getCompileCommands("source");
   ASSERT_EQ(1ul, Result.size());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3001.2.patch
Type: text/x-patch
Size: 6143 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140307/775fd359/attachment.bin>


More information about the cfe-commits mailing list