Eugene.Zelenko created this revision.
Eugene.Zelenko added a reviewer: hans.
Eugene.Zelenko added a subscriber: cfe-commits.
Eugene.Zelenko set the repository for this revision to rL LLVM.
Herald added a subscriber: klimek.

I checked this patch on my own build on RHEL 6. Regressions were OK.

Please check it in if it's OK, because I don't have SVN write access.

Repository:
  rL LLVM

http://reviews.llvm.org/D13759

Files:
  include/clang/AST/ASTVector.h
  include/clang/AST/DeclContextInternals.h
  include/clang/AST/DeclTemplate.h
  include/clang/ASTMatchers/ASTMatchersInternal.h
  include/clang/Analysis/Analyses/Consumed.h
  include/clang/Rewrite/Core/Rewriter.h
  include/clang/Sema/Template.h
  include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
  include/clang/StaticAnalyzer/Core/CheckerManager.h
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===================================================================
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -952,7 +952,7 @@
     }
 
     void writeTemplateInstantiation(raw_ostream &OS) const override {
-      OS << "      " << getType() << " *tempInst" << getUpperName()
+      OS << "      auto *tempInst" << getUpperName()
          << " = new (C, 16) " << getType()
          << "[A->" << getLowerName() << "_size()];\n";
       OS << "      {\n";
@@ -1506,7 +1506,7 @@
     }
     OS << ", SourceRange Loc = SourceRange()";
     OS << ") {\n";
-    OS << "    " << R.getName() << "Attr *A = new (Ctx) " << R.getName();
+    OS << "    auto *A = new (Ctx) " << R.getName();
     OS << "Attr(Loc, Ctx, ";
     for (auto const &ai : Args) {
       ai->writeImplicitCtorArgs(OS);
@@ -1848,7 +1848,7 @@
     OS << "  case attr::" << R.getName() << ": {\n";
     Args = R.getValueAsListOfDefs("Args");
     if (R.isSubClassOf(InhClass) || !Args.empty())
-      OS << "    const " << R.getName() << "Attr *SA = cast<" << R.getName()
+      OS << "    const auto *SA = cast<" << R.getName()
          << "Attr>(A);\n";
     if (R.isSubClassOf(InhClass))
       OS << "    Record.push_back(SA->isInherited());\n";
@@ -2164,7 +2164,7 @@
       continue;
     }
 
-    OS << "      const " << R.getName() << "Attr *A = cast<"
+    OS << "      const auto *A = cast<"
        << R.getName() << "Attr>(At);\n";
     bool TDependent = R.getValueAsBit("TemplateDependent");
 
@@ -2767,7 +2767,7 @@
 
     Args = R.getValueAsListOfDefs("Args");
     if (!Args.empty()) {
-      OS << "    const " << R.getName() << "Attr *SA = cast<" << R.getName()
+      OS << "    const auto *SA = cast<" << R.getName()
          << "Attr>(A);\n";
       for (const auto *Arg : Args)
         createArgument(*Arg, R.getName())->writeDump(OS);
Index: include/clang/ASTMatchers/ASTMatchersInternal.h
===================================================================
--- include/clang/ASTMatchers/ASTMatchersInternal.h
+++ include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -76,7 +76,7 @@
   /// it cannot be converted to the specified type.
   template <typename T>
   const T *getNodeAs(StringRef ID) const {
-    IDToNodeMap::const_iterator It = NodeMap.find(ID);
+    const auto It = NodeMap.find(ID);
     if (It == NodeMap.end()) {
       return nullptr;
     }
@@ -84,7 +84,7 @@
   }
 
   ast_type_traits::DynTypedNode getNode(StringRef ID) const {
-    IDToNodeMap::const_iterator It = NodeMap.find(ID);
+    const auto It = NodeMap.find(ID);
     if (It == NodeMap.end()) {
       return ast_type_traits::DynTypedNode();
     }
@@ -131,7 +131,7 @@
   /// BoundNodesTree.
   class Visitor {
   public:
-    virtual ~Visitor() {}
+    virtual ~Visitor() = default;
 
     /// \brief Called multiple times during a single call to VisitMatches(...).
     ///
@@ -209,7 +209,7 @@
 template <typename T>
 class MatcherInterface : public DynMatcherInterface {
 public:
-  ~MatcherInterface() override {}
+  ~MatcherInterface() override = default;
 
   /// \brief Returns true if 'Node' can be matched.
   ///
@@ -798,7 +798,7 @@
     AMM_ParentOnly
   };
 
-  virtual ~ASTMatchFinder() {}
+  virtual ~ASTMatchFinder() = default;
 
   /// \brief Returns true if the given class is directly or indirectly derived
   /// from a base type matching \c base.
@@ -1575,4 +1575,4 @@
 } // end namespace ast_matchers
 } // end namespace clang
 
-#endif
+#endif // LLVM_CLANG_ASTMATCHERS_ASTMATCHERSINTERNAL_H
Index: include/clang/StaticAnalyzer/Core/CheckerManager.h
===================================================================
--- include/clang/StaticAnalyzer/Core/CheckerManager.h
+++ include/clang/StaticAnalyzer/Core/CheckerManager.h
@@ -140,7 +140,7 @@
     if (ref)
       return static_cast<CHECKER *>(ref); // already registered.
 
-    CHECKER *checker = new CHECKER();
+    auto *checker = new CHECKER();
     checker->Name = CurrentCheckName;
     CheckerDtors.push_back(CheckerDtor(checker, destruct<CHECKER>));
     CHECKER::_register(checker, *this);
@@ -155,7 +155,7 @@
     if (ref)
       return static_cast<CHECKER *>(ref); // already registered.
 
-    CHECKER *checker = new CHECKER(AOpts);
+    auto *checker = new CHECKER(AOpts);
     checker->Name = CurrentCheckName;
     CheckerDtors.push_back(CheckerDtor(checker, destruct<CHECKER>));
     CHECKER::_register(checker, *this);
@@ -239,7 +239,6 @@
                               Eng);
   }
 
-
   /// \brief Run checkers for visiting obj-c messages.
   void runCheckersForObjCMessage(ObjCMessageVisitKind visitKind,
                                  ExplodedNodeSet &Dst,
@@ -629,4 +628,4 @@
 
 } // end clang namespace
 
-#endif
+#endif // LLVM_CLANG_STATICANALYZER_CORE_CHECKERMANAGER_H
Index: include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
===================================================================
--- include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
+++ include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
@@ -27,6 +27,7 @@
 #include <vector>
 
 namespace clang {
+
 class ConditionalOperator;
 class AnalysisDeclContext;
 class BinaryOperator;
@@ -86,9 +87,6 @@
     PDFileEntry::ConsumerFiles *getFiles(const PathDiagnostic &PD);
   };
 
-private:
-  virtual void anchor();
-public:
   PathDiagnosticConsumer() : flushed(false) {}
   virtual ~PathDiagnosticConsumer();
 
@@ -112,6 +110,9 @@
 protected:
   bool flushed;
   llvm::FoldingSet<PathDiagnostic> Diags;
+
+private:
+  virtual void anchor();
 };
 
 //===----------------------------------------------------------------------===//
@@ -308,6 +309,7 @@
 class PathDiagnosticLocationPair {
 private:
   PathDiagnosticLocation Start, End;
+
 public:
   PathDiagnosticLocationPair(const PathDiagnosticLocation &start,
                              const PathDiagnosticLocation &end)
@@ -417,7 +419,6 @@
   virtual void dump() const = 0;
 };
   
-  
 class PathPieces : public std::list<IntrusiveRefCntPtr<PathDiagnosticPiece> > {
   void flattenTo(PathPieces &Primary, PathPieces &Current,
                  bool ShouldFlattenMacros) const;
@@ -435,6 +436,7 @@
 class PathDiagnosticSpotPiece : public PathDiagnosticPiece {
 private:
   PathDiagnosticLocation Pos;
+
 public:
   PathDiagnosticSpotPiece(const PathDiagnosticLocation &pos,
                           StringRef s,
@@ -481,7 +483,7 @@
 
 public:
   StackHintGeneratorForSymbol(SymbolRef S, StringRef M) : Sym(S), Msg(M) {}
-  ~StackHintGeneratorForSymbol() override {}
+  ~StackHintGeneratorForSymbol() override = default;
 
   /// \brief Search the call expression for the symbol Sym and dispatch the
   /// 'getMessageForX()' methods to construct a specific message.
@@ -598,8 +600,8 @@
   void flattenLocations() override {
     callEnter.flatten();
     callReturn.flatten();
-    for (PathPieces::iterator I = path.begin(), 
-         E = path.end(); I != E; ++I) (*I)->flattenLocations();
+    for (auto &I : path)
+      I->flattenLocations();
   }
   
   static PathDiagnosticCallPiece *construct(const ExplodedNode *N,
@@ -667,7 +669,7 @@
   iterator end()   { return LPairs.end(); }
 
   void flattenLocations() override {
-    for (iterator I=begin(), E=end(); I!=E; ++I) I->flatten();
+    for (auto I=begin(), E=end(); I!=E; ++I) I->flatten();
   }
 
   typedef std::vector<PathDiagnosticLocationPair>::const_iterator
@@ -697,8 +699,8 @@
 
   void flattenLocations() override {
     PathDiagnosticSpotPiece::flattenLocations();
-    for (PathPieces::iterator I = subPieces.begin(), 
-         E = subPieces.end(); I != E; ++I) (*I)->flattenLocations();
+    for (auto &I : subPieces)
+      I->flattenLocations();
   }
 
   static inline bool classof(const PathDiagnosticPiece *P) {
@@ -734,6 +736,7 @@
   const Decl *UniqueingDecl;
 
   PathDiagnostic() = delete;
+
 public:
   PathDiagnostic(StringRef CheckName, const Decl *DeclWithIssue,
                  StringRef bugtype, StringRef verboseDesc, StringRef shortDesc,
@@ -824,8 +827,8 @@
 
   void flattenLocations() {
     Loc.flatten();
-    for (PathPieces::iterator I = pathImpl.begin(), E = pathImpl.end(); 
-         I != E; ++I) (*I)->flattenLocations();
+    for (auto &I : pathImpl)
+      I->flattenLocations();
   }
 
   /// Profiles the diagnostic, independent of the path it references.
@@ -841,8 +844,7 @@
   void FullProfile(llvm::FoldingSetNodeID &ID) const;
 };  
 
-} // end GR namespace
+} // end namespace ento
+} // end namespace clang
 
-} //end clang namespace
-
-#endif
+#endif // LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_PATHDIAGNOSTIC_H
Index: include/clang/AST/ASTVector.h
===================================================================
--- include/clang/AST/ASTVector.h
+++ include/clang/AST/ASTVector.h
@@ -27,8 +27,9 @@
 #include <memory>
 
 namespace clang {
-  class ASTContext;
 
+class ASTContext;
+
 template<typename T>
 class ASTVector {
 private:
@@ -381,7 +382,7 @@
     NewCapacity = MinSize;
 
   // Allocate the memory from the ASTContext.
-  T *NewElts = new (C, llvm::alignOf<T>()) T[NewCapacity];
+  auto *NewElts = new (C, llvm::alignOf<T>()) T[NewCapacity];
 
   // Copy the elements over.
   if (Begin != End) {
@@ -401,5 +402,6 @@
   Capacity.setPointer(Begin+NewCapacity);
 }
 
-} // end: clang namespace
-#endif
+} // end namespace clang
+
+#endif // LLVM_CLANG_AST_ASTVECTOR_H
Index: include/clang/AST/DeclTemplate.h
===================================================================
--- include/clang/AST/DeclTemplate.h
+++ include/clang/AST/DeclTemplate.h
@@ -1693,8 +1693,7 @@
                           const TemplateArgumentList *TemplateArgs) {
     assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
            "Already set to a class template partial specialization!");
-    SpecializedPartialSpecialization *PS
-      = new (getASTContext()) SpecializedPartialSpecialization();
+    auto *PS = new (getASTContext()) SpecializedPartialSpecialization();
     PS->PartialSpecialization = PartialSpec;
     PS->TemplateArgs = TemplateArgs;
     SpecializedTemplate = PS;
@@ -2239,7 +2238,6 @@
     return static_cast<TypeAliasDecl*>(TemplatedDecl);
   }
 
-
   TypeAliasTemplateDecl *getCanonicalDecl() override {
     return cast<TypeAliasTemplateDecl>(
              RedeclarableTemplateDecl::getCanonicalDecl());
@@ -2269,7 +2267,6 @@
              RedeclarableTemplateDecl::getInstantiatedFromMemberTemplate());
   }
 
-
   /// \brief Create a function template node.
   static TypeAliasTemplateDecl *Create(ASTContext &C, DeclContext *DC,
                                        SourceLocation L,
@@ -2552,8 +2549,7 @@
                           const TemplateArgumentList *TemplateArgs) {
     assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
            "Already set to a variable template partial specialization!");
-    SpecializedPartialSpecialization *PS =
-        new (getASTContext()) SpecializedPartialSpecialization();
+    auto *PS = new (getASTContext()) SpecializedPartialSpecialization();
     PS->PartialSpecialization = PartialSpec;
     PS->TemplateArgs = TemplateArgs;
     SpecializedTemplate = PS;
@@ -2922,6 +2918,6 @@
   friend class ASTDeclWriter;
 };
 
-} /* end of namespace clang */
+} // end namespace clang
 
-#endif
+#endif // LLVM_CLANG_AST_DECLTEMPLATE_H
Index: include/clang/AST/DeclContextInternals.h
===================================================================
--- include/clang/AST/DeclContextInternals.h
+++ include/clang/AST/DeclContextInternals.h
@@ -11,6 +11,7 @@
 //  of DeclContext.
 //
 //===----------------------------------------------------------------------===//
+
 #ifndef LLVM_CLANG_AST_DECLCONTEXTINTERNALS_H
 #define LLVM_CLANG_AST_DECLCONTEXTINTERNALS_H
 
@@ -86,7 +87,7 @@
     if (DeclsTy *Vec = getAsVector())
       Data = DeclsAndHasExternalTy(Vec, true);
     else {
-      DeclsTy *VT = new DeclsTy();
+      auto *VT = new DeclsTy();
       if (NamedDecl *OldD = getAsDecl())
         VT->push_back(OldD);
       Data = DeclsAndHasExternalTy(VT, true);
@@ -193,7 +194,7 @@
     // If this is the second decl added to the list, convert this to vector
     // form.
     if (NamedDecl *OldD = getAsDecl()) {
-      DeclsTy *VT = new DeclsTy();
+      auto *VT = new DeclsTy();
       VT->push_back(OldD);
       Data = DeclsAndHasExternalTy(VT, false);
     }
@@ -261,4 +262,4 @@
 
 } // end namespace clang
 
-#endif
+#endif // LLVM_CLANG_AST_DECLCONTEXTINTERNALS_H
Index: include/clang/Sema/Template.h
===================================================================
--- include/clang/Sema/Template.h
+++ include/clang/Sema/Template.h
@@ -9,6 +9,7 @@
 //  This file provides types used in the semantic analysis of C++ templates.
 //
 //===----------------------------------------------------------------------===/
+
 #ifndef LLVM_CLANG_SEMA_TEMPLATE_H
 #define LLVM_CLANG_SEMA_TEMPLATE_H
 
@@ -278,7 +279,7 @@
       // will overwrite it on construction
       LocalInstantiationScope *oldScope = SemaRef.CurrentInstantiationScope;
 
-      LocalInstantiationScope *newScope =
+      auto *newScope =
         new LocalInstantiationScope(SemaRef, CombineWithOuterScope);
 
       newScope->Outer = nullptr;
@@ -299,7 +300,7 @@
           Stored = I->second.get<Decl *>();
         } else {
           DeclArgumentPack *OldPack = I->second.get<DeclArgumentPack *>();
-          DeclArgumentPack *NewPack = new DeclArgumentPack(*OldPack);
+          auto *NewPack = new DeclArgumentPack(*OldPack);
           Stored = NewPack;
           newScope->ArgumentPacks.push_back(NewPack);
         }
@@ -514,6 +515,6 @@
         VarTemplatePartialSpecializationDecl *PartialSpec);
     void InstantiateEnumDefinition(EnumDecl *Enum, EnumDecl *Pattern);
   };  
-}
+} // end namespace clang
 
 #endif // LLVM_CLANG_SEMA_TEMPLATE_H
Index: include/clang/Analysis/Analyses/Consumed.h
===================================================================
--- include/clang/Analysis/Analyses/Consumed.h
+++ include/clang/Analysis/Analyses/Consumed.h
@@ -1,4 +1,4 @@
-//===- Consumed.h ----------------------------------------------*- C++ --*-===//
+//===- Consumed.h -----------------------------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -210,9 +210,8 @@
     ConsumedBlockInfo(unsigned int NumBlocks, PostOrderCFGView *SortedGraph)
         : StateMapsArray(NumBlocks), VisitOrder(NumBlocks, 0) {
       unsigned int VisitOrderCounter = 0;
-      for (PostOrderCFGView::iterator BI = SortedGraph->begin(),
-           BE = SortedGraph->end(); BI != BE; ++BI) {
-        VisitOrder[(*BI)->getBlockID()] = VisitOrderCounter++;
+      for (const auto &BI : *SortedGraph ) {
+        VisitOrder[BI->getBlockID()] = VisitOrderCounter++;
       }
     }
     
@@ -264,6 +263,7 @@
     /// exactly once.
     void run(AnalysisDeclContext &AC);
   };
-}} // end namespace clang::consumed
+} // end namespace consumed
+} // end namespace clang
 
-#endif
+#endif // LLVM_CLANG_ANALYSIS_ANALYSES_CONSUMED_H
Index: include/clang/Rewrite/Core/Rewriter.h
===================================================================
--- include/clang/Rewrite/Core/Rewriter.h
+++ include/clang/Rewrite/Core/Rewriter.h
@@ -168,8 +168,7 @@
   /// getRewriteBufferFor - Return the rewrite buffer for the specified FileID.
   /// If no modification has been made to it, return null.
   const RewriteBuffer *getRewriteBufferFor(FileID FID) const {
-    std::map<FileID, RewriteBuffer>::const_iterator I =
-      RewriteBuffers.find(FID);
+    const auto I = RewriteBuffers.find(FID);
     return I == RewriteBuffers.end() ? nullptr : &I->second;
   }
 
@@ -192,4 +191,4 @@
 
 } // end namespace clang
 
-#endif
+#endif // LLVM_CLANG_REWRITE_CORE_REWRITER_H
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to