Index: clang-tidy/ClangTidy.h
===================================================================
--- clang-tidy/ClangTidy.h
+++ clang-tidy/ClangTidy.h
@@ -16,6 +16,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Tooling/Refactoring.h"
+#include <vector>
 
 namespace clang {
 
@@ -124,14 +125,14 @@
 ClangTidyStats runClangTidy(const ClangTidyOptions &Options,
                             const tooling::CompilationDatabase &Compilations,
                             ArrayRef<std::string> Ranges,
-                            SmallVectorImpl<ClangTidyError> *Errors);
+                            std::vector<ClangTidyError> *Errors);
 
 // FIXME: This interface will need to be significantly extended to be useful.
 // FIXME: Implement confidence levels for displaying/fixing errors.
 //
 /// \brief Displays the found \p Errors to the users. If \p Fix is true, \p
 /// Errors containing fixes are automatically applied.
-void handleErrors(SmallVectorImpl<ClangTidyError> &Errors, bool Fix);
+void handleErrors(const std::vector<ClangTidyError> &Errors, bool Fix);
 
 } // end namespace tidy
 } // end namespace clang
Index: clang-tidy/ClangTidy.cpp
===================================================================
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -40,7 +40,6 @@
 #include "llvm/Support/Signals.h"
 #include <algorithm>
 #include <utility>
-#include <vector>
 
 using namespace clang::ast_matchers;
 using namespace clang::driver;
@@ -292,8 +291,7 @@
 }
 
 std::vector<std::string> getCheckNames(const ClangTidyOptions &Options) {
-  SmallVector<ClangTidyError, 8> Errors;
-  clang::tidy::ClangTidyContext Context(&Errors, Options);
+  clang::tidy::ClangTidyContext Context(Options);
   ClangTidyASTConsumerFactory Factory(Context, Options);
   return Factory.getCheckNames();
 }
@@ -301,11 +299,11 @@
 ClangTidyStats runClangTidy(const ClangTidyOptions &Options,
                             const tooling::CompilationDatabase &Compilations,
                             ArrayRef<std::string> Ranges,
-                            SmallVectorImpl<ClangTidyError> *Errors) {
+                            std::vector<ClangTidyError> *Errors) {
   // FIXME: Ranges are currently full files. Support selecting specific
   // (line-)ranges.
   ClangTool Tool(Compilations, Ranges);
-  clang::tidy::ClangTidyContext Context(Errors, Options);
+  clang::tidy::ClangTidyContext Context(Options);
   ClangTidyDiagnosticConsumer DiagConsumer(Context);
 
   Tool.setDiagnosticConsumer(&DiagConsumer);
@@ -333,10 +331,11 @@
   };
 
   Tool.run(new ActionFactory(new ClangTidyASTConsumerFactory(Context, Options)));
+  *Errors = Context.getErrors();
   return Context.getStats();
 }
 
-void handleErrors(SmallVectorImpl<ClangTidyError> &Errors, bool Fix) {
+void handleErrors(const std::vector<ClangTidyError> &Errors, bool Fix) {
   ErrorReporter Reporter(Fix);
   for (const ClangTidyError &Error : Errors) {
     Reporter.reportDiagnostic(Error.Message, DiagnosticsEngine::Warning,
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===================================================================
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -90,8 +90,7 @@
 /// \endcode
 class ClangTidyContext {
 public:
-  ClangTidyContext(SmallVectorImpl<ClangTidyError> *Errors,
-                   const ClangTidyOptions &Options);
+  ClangTidyContext(const ClangTidyOptions &Options);
 
   /// \brief Report any errors detected using this method.
   ///
@@ -120,6 +119,7 @@
   ChecksFilter &getChecksFilter() { return Filter; }
   const ClangTidyOptions &getOptions() const { return Options; }
   const ClangTidyStats &getStats() const { return Stats; }
+  const std::vector<ClangTidyError> &getErrors() const { return Errors; }
 
 private:
   friend class ClangTidyDiagnosticConsumer; // Calls storeError().
@@ -127,7 +127,7 @@
   /// \brief Store a \c ClangTidyError.
   void storeError(const ClangTidyError &Error);
 
-  SmallVectorImpl<ClangTidyError> *Errors;
+  std::vector<ClangTidyError> Errors;
   DiagnosticsEngine *DiagEngine;
   ClangTidyOptions Options;
   ChecksFilter Filter;
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===================================================================
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -119,9 +119,8 @@
   return EnableChecks.match(Name) && !DisableChecks.match(Name);
 }
 
-ClangTidyContext::ClangTidyContext(SmallVectorImpl<ClangTidyError> *Errors,
-                                   const ClangTidyOptions &Options)
-    : Errors(Errors), DiagEngine(nullptr), Options(Options), Filter(Options) {}
+ClangTidyContext::ClangTidyContext(const ClangTidyOptions &Options)
+    : DiagEngine(nullptr), Options(Options), Filter(Options) {}
 
 DiagnosticBuilder ClangTidyContext::diag(
     StringRef CheckName, SourceLocation Loc, StringRef Description,
@@ -158,7 +157,7 @@
 
 /// \brief Store a \c ClangTidyError.
 void ClangTidyContext::storeError(const ClangTidyError &Error) {
-  Errors->push_back(Error);
+  Errors.push_back(Error);
 }
 
 StringRef ClangTidyContext::getCheckName(unsigned DiagnosticID) const {
@@ -201,6 +200,7 @@
     assert(!Errors.empty() &&
            "A diagnostic note can only be appended to a message.");
   } else {
+    // FIXME: Pass all errors here regardless of filters and non-user code.
     finalizeLastError();
     StringRef WarningOption =
         Context.DiagEngine->getDiagnosticIDs()->getWarningOptionForDiag(
Index: clang-tidy/tool/ClangTidyMain.cpp
===================================================================
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -102,7 +102,7 @@
     return 0;
   }
 
-  SmallVector<clang::tidy::ClangTidyError, 16> Errors;
+  std::vector<clang::tidy::ClangTidyError> Errors;
   clang::tidy::ClangTidyStats Stats =
       clang::tidy::runClangTidy(Options, OptionsParser.getCompilations(),
                                 OptionsParser.getSourcePathList(), &Errors);
Index: unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
===================================================================
--- unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
+++ unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
@@ -20,8 +20,8 @@
 };
 
 TEST(ClangTidyDiagnosticConsumer, SortsErrors) {
-  SmallVector<ClangTidyError, 8> Errors;
-  runCheckOnCode<TestCheck>("int a;", Errors);
+  std::vector<ClangTidyError> Errors;
+  runCheckOnCode<TestCheck>("int a;", &Errors);
   EXPECT_EQ(2ul, Errors.size());
   // FIXME: Remove " []" once the check name is removed from the message text.
   EXPECT_EQ("type specifier []", Errors[0].Message.Message);
Index: unittests/clang-tidy/ClangTidyTest.h
===================================================================
--- unittests/clang-tidy/ClangTidyTest.h
+++ unittests/clang-tidy/ClangTidyTest.h
@@ -41,9 +41,10 @@
 
 template <typename T>
 std::string runCheckOnCode(StringRef Code,
-                           SmallVectorImpl<ClangTidyError> &Errors) {
+                           std::vector<ClangTidyError> *Errors = nullptr) {
   T Check;
-  ClangTidyContext Context(&Errors, ClangTidyOptions());
+  ClangTidyOptions Options;
+  ClangTidyContext Context(Options);
   ClangTidyDiagnosticConsumer DiagConsumer(Context);
   Check.setContext(&Context);
   std::vector<std::string> ArgCXX11(1, "-std=c++11");
@@ -59,16 +60,13 @@
     return "";
   DiagConsumer.finish();
   tooling::Replacements Fixes;
-  for (const ClangTidyError &Error : Errors)
+  for (const ClangTidyError &Error : Context.getErrors())
     Fixes.insert(Error.Fix.begin(), Error.Fix.end());
+  if (Errors)
+    *Errors = Context.getErrors();
   return tooling::applyAllReplacements(Code, Fixes);
 }
 
-template <typename T> std::string runCheckOnCode(StringRef Code) {
-  SmallVector<ClangTidyError, 16> Errors;
-  return runCheckOnCode<T>(Code, Errors);
-}
-
 } // namespace test
 } // namespace tidy
 } // namespace clang