[PATCH] D15606: Remove clang-modernize.

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 22 14:21:33 PST 2015


Will add this and other clang-tidy-related news to the release notes. Any
ideas why there's no separate release notes file for clang-tools-extra?
On Dec 17, 2015 9:47 PM, "Justin Bogner" <mail at justinbogner.com> wrote:

> Alexander Kornienko via cfe-commits <cfe-commits at lists.llvm.org> writes:
> > alexfh created this revision.
> > alexfh added a reviewer: klimek.
> > alexfh added a subscriber: cfe-commits.
> >
> > clang-modernize transforms have moved to clang-tidy. Removing
> > the old tool now.
>
> Please add a note to the release notes mentioning this.
>
> > http://reviews.llvm.org/D15606
> >
> > Files:
> >   CMakeLists.txt
> >   Makefile
> >   clang-modernize/
> >   clang-modernize/AddOverride/
> >   clang-modernize/AddOverride/AddOverride.cpp
> >   clang-modernize/AddOverride/AddOverride.h
> >   clang-modernize/AddOverride/AddOverrideActions.cpp
> >   clang-modernize/AddOverride/AddOverrideActions.h
> >   clang-modernize/AddOverride/AddOverrideMatchers.cpp
> >   clang-modernize/AddOverride/AddOverrideMatchers.h
> >   clang-modernize/CMakeLists.txt
> >   clang-modernize/Core/
> >   clang-modernize/Core/CMakeLists.txt
> >   clang-modernize/Core/CustomMatchers.h
> >   clang-modernize/Core/IncludeDirectives.cpp
> >   clang-modernize/Core/IncludeDirectives.h
> >   clang-modernize/Core/IncludeExcludeInfo.cpp
> >   clang-modernize/Core/IncludeExcludeInfo.h
> >   clang-modernize/Core/Makefile
> >   clang-modernize/Core/PerfSupport.cpp
> >   clang-modernize/Core/PerfSupport.h
> >   clang-modernize/Core/Refactoring.h
> >   clang-modernize/Core/ReplacementHandling.cpp
> >   clang-modernize/Core/ReplacementHandling.h
> >   clang-modernize/Core/Transform.cpp
> >   clang-modernize/Core/Transform.h
> >   clang-modernize/Core/Transforms.cpp
> >   clang-modernize/Core/Transforms.h
> >   clang-modernize/LoopConvert/
> >   clang-modernize/LoopConvert/LoopActions.cpp
> >   clang-modernize/LoopConvert/LoopActions.h
> >   clang-modernize/LoopConvert/LoopConvert.cpp
> >   clang-modernize/LoopConvert/LoopConvert.h
> >   clang-modernize/LoopConvert/LoopMatchers.cpp
> >   clang-modernize/LoopConvert/LoopMatchers.h
> >   clang-modernize/LoopConvert/StmtAncestor.cpp
> >   clang-modernize/LoopConvert/StmtAncestor.h
> >   clang-modernize/LoopConvert/VariableNaming.cpp
> >   clang-modernize/LoopConvert/VariableNaming.h
> >   clang-modernize/Makefile
> >   clang-modernize/PassByValue/
> >   clang-modernize/PassByValue/PassByValue.cpp
> >   clang-modernize/PassByValue/PassByValue.h
> >   clang-modernize/PassByValue/PassByValueActions.cpp
> >   clang-modernize/PassByValue/PassByValueActions.h
> >   clang-modernize/PassByValue/PassByValueMatchers.cpp
> >   clang-modernize/PassByValue/PassByValueMatchers.h
> >   clang-modernize/ReplaceAutoPtr/
> >   clang-modernize/ReplaceAutoPtr/ReplaceAutoPtr.cpp
> >   clang-modernize/ReplaceAutoPtr/ReplaceAutoPtr.h
> >   clang-modernize/ReplaceAutoPtr/ReplaceAutoPtrActions.cpp
> >   clang-modernize/ReplaceAutoPtr/ReplaceAutoPtrActions.h
> >   clang-modernize/ReplaceAutoPtr/ReplaceAutoPtrMatchers.cpp
> >   clang-modernize/ReplaceAutoPtr/ReplaceAutoPtrMatchers.h
> >   clang-modernize/UseAuto/
> >   clang-modernize/UseAuto/UseAuto.cpp
> >   clang-modernize/UseAuto/UseAuto.h
> >   clang-modernize/UseAuto/UseAutoActions.cpp
> >   clang-modernize/UseAuto/UseAutoActions.h
> >   clang-modernize/UseAuto/UseAutoMatchers.cpp
> >   clang-modernize/UseAuto/UseAutoMatchers.h
> >   clang-modernize/UseNullptr/
> >   clang-modernize/UseNullptr/NullptrActions.cpp
> >   clang-modernize/UseNullptr/NullptrActions.h
> >   clang-modernize/UseNullptr/NullptrMatchers.cpp
> >   clang-modernize/UseNullptr/NullptrMatchers.h
> >   clang-modernize/UseNullptr/UseNullptr.cpp
> >   clang-modernize/UseNullptr/UseNullptr.h
> >   clang-modernize/tool/
> >   clang-modernize/tool/CMakeLists.txt
> >   clang-modernize/tool/ClangModernize.cpp
> >   clang-modernize/tool/Makefile
> >   docs/AddOverrideTransform.rst
> >   docs/LoopConvertTransform.rst
> >   docs/MigratorUsage.rst
> >   docs/ModernizerUsage.rst
> >   docs/PassByValueTransform.rst
> >   docs/ReplaceAutoPtrTransform.rst
> >   docs/UseAutoTransform.rst
> >   docs/UseNullptrTransform.rst
> >   docs/clang-modernize.rst
> >   docs/cpp11-migrate.rst
> >   docs/index.rst
> >   test/CMakeLists.txt
> >   test/clang-modernize/
> >   test/clang-modernize/AddOverride/
> >   test/clang-modernize/AddOverride/basic.cpp
> >   test/clang-modernize/AddOverride/pure_specifier_fail.cpp
> >   test/clang-modernize/Combined/
> >   test/clang-modernize/Combined/combined.cpp
> >   test/clang-modernize/Combined/compilers.cpp
> >   test/clang-modernize/Compilations/
> >   test/clang-modernize/Compilations/Inputs/
> >   test/clang-modernize/Compilations/Inputs/compilations.cpp
> >   test/clang-modernize/Compilations/Inputs/compilations_expected.cpp
> >   test/clang-modernize/Compilations/Inputs/compile_commands.json
> >   test/clang-modernize/Compilations/Inputs/cpp11.cpp
> >   test/clang-modernize/Compilations/Inputs/cpp11_expected.cpp
> >   test/clang-modernize/Compilations/compilation_inc.cpp
> >   test/clang-modernize/Compilations/compilation_inc_sources.cpp
> >   test/clang-modernize/Compilations/compilation_not_inc.cpp
> >   test/clang-modernize/Compilations/detect_from_path.cpp
> >   test/clang-modernize/Compilations/detect_from_source.cpp
> >   test/clang-modernize/Compilations/fixed_comp.cpp
> >   test/clang-modernize/Compilations/fixed_comp_inc.cpp
> >   test/clang-modernize/Compilations/no_compilation.cpp
> >   test/clang-modernize/Core/
> >   test/clang-modernize/Core/Inputs/
> >   test/clang-modernize/Core/Inputs/.clang-format
> >   test/clang-modernize/Core/Reformatting.cpp
> >   test/clang-modernize/HeaderReplacements/
> >   test/clang-modernize/HeaderReplacements/Inputs/
> >   test/clang-modernize/HeaderReplacements/Inputs/no_yaml.h
> >   test/clang-modernize/HeaderReplacements/common.cpp
> >   test/clang-modernize/HeaderReplacements/common.h
> >   test/clang-modernize/HeaderReplacements/common_expected.yaml
> >   test/clang-modernize/HeaderReplacements/main.cpp
> >   test/clang-modernize/HeaderReplacements/main_expected.yaml
> >   test/clang-modernize/HeaderReplacements/no_yaml.cpp
> >   test/clang-modernize/LoopConvert/
> >   test/clang-modernize/LoopConvert/Inputs/
> >   test/clang-modernize/LoopConvert/Inputs/macro_problem.h
> >   test/clang-modernize/LoopConvert/Inputs/negative-header.h
> >   test/clang-modernize/LoopConvert/Inputs/structures.h
> >   test/clang-modernize/LoopConvert/array.cpp
> >   test/clang-modernize/LoopConvert/confidence.cpp
> >   test/clang-modernize/LoopConvert/dependency.cpp
> >   test/clang-modernize/LoopConvert/free_begin_end_fail.cpp
> >   test/clang-modernize/LoopConvert/iterator.cpp
> >   test/clang-modernize/LoopConvert/macro_problem.cpp
> >   test/clang-modernize/LoopConvert/naming-alias.cpp
> >   test/clang-modernize/LoopConvert/naming-conflict.cpp
> >   test/clang-modernize/LoopConvert/negative-iterator.cpp
> >   test/clang-modernize/LoopConvert/negative-multi-end-call.cpp
> >   test/clang-modernize/LoopConvert/negative-pseudoarray-extra.cpp
> >   test/clang-modernize/LoopConvert/negative-pseudoarray.cpp
> >   test/clang-modernize/LoopConvert/negative.cpp
> >   test/clang-modernize/LoopConvert/nesting.cpp
> >   test/clang-modernize/LoopConvert/nocompile.cpp
> >   test/clang-modernize/LoopConvert/pseudoarray.cpp
> >   test/clang-modernize/LoopConvert/single-iterator.cpp
> >   test/clang-modernize/PassByValue/
> >   test/clang-modernize/PassByValue/basic.cpp
> >   test/clang-modernize/PassByValue/basic.h
> >   test/clang-modernize/ReplaceAutoPtr/
> >   test/clang-modernize/ReplaceAutoPtr/Inputs/
> >   test/clang-modernize/ReplaceAutoPtr/Inputs/basic.h
> >   test/clang-modernize/ReplaceAutoPtr/Inputs/memory_stub.h
> >   test/clang-modernize/ReplaceAutoPtr/basic.cpp
> >   test/clang-modernize/ReplaceAutoPtr/move.cpp
> >   test/clang-modernize/ReplaceAutoPtr/template_fail.cpp
> >   test/clang-modernize/UseAuto/
> >   test/clang-modernize/UseAuto/Inputs/
> >   test/clang-modernize/UseAuto/Inputs/test_std_container.h
> >   test/clang-modernize/UseAuto/basic_iterator_tests.cpp
> >   test/clang-modernize/UseAuto/iterator.cpp
> >   test/clang-modernize/UseAuto/new.cpp
> >   test/clang-modernize/UseAuto/new_cv_failing.cpp
> >   test/clang-modernize/UseNullptr/
> >   test/clang-modernize/UseNullptr/Inputs/
> >   test/clang-modernize/UseNullptr/Inputs/basic.h
> >   test/clang-modernize/UseNullptr/basic.cpp
> >   test/clang-modernize/UseNullptr/basic_failing.cpp
> >   test/clang-modernize/UseNullptr/macros.cpp
> >   test/clang-modernize/UseNullptr/nullptr_t.cpp
> >   unittests/CMakeLists.txt
> >   unittests/Makefile
> >   unittests/clang-modernize/
> >   unittests/clang-modernize/CMakeLists.txt
> >   unittests/clang-modernize/IncludeDirectivesTest.cpp
> >   unittests/clang-modernize/IncludeExcludeTest.cpp
> >   unittests/clang-modernize/Makefile
> >   unittests/clang-modernize/PerfSupportTest.cpp
> >   unittests/clang-modernize/TransformTest.cpp
> >   unittests/clang-modernize/UniqueHeaderNameTest.cpp
> >   unittests/include/common/Utility.h
> >
> > Index: unittests/include/common/Utility.h
> > ===================================================================
> > --- unittests/include/common/Utility.h
> > +++ /dev/null
> > @@ -1,25 +0,0 @@
> > -//=-- clang-modernize/Utility.h - Utility functions and macros---*- C++
> -*-===//
> > -//
> > -//                     The LLVM Compiler Infrastructure
> > -//
> > -// This file is distributed under the University of Illinois Open Source
> > -// License. See LICENSE.TXT for details.
> > -//
> >
> -//===----------------------------------------------------------------------===//
> > -
> > -#ifndef CLANG_MODERNIZE_UNITTESTS_UTILITY_H
> > -#define CLANG_MODERNIZE_UNITTESTS_UTILITY_H
> > -
> > -// FIXME: copied from unittests/Support/Path.cpp
> > -#define ASSERT_NO_ERROR(x)
>        \
> > -  if (std::error_code ASSERT_NO_ERROR_ec = x) {
>         \
> > -    llvm::SmallString<128> MessageStorage;
>        \
> > -    llvm::raw_svector_ostream Message(MessageStorage);
>        \
> > -    Message << #x ": did not return errc::success.\n"
>         \
> > -            << "error number: " << ASSERT_NO_ERROR_ec.value() << "\n"
>         \
> > -            << "error message: " << ASSERT_NO_ERROR_ec.message() <<
> "\n";      \
> > -    GTEST_FATAL_FAILURE_(MessageStorage.c_str());
>         \
> > -  } else {
>        \
> > -  }
> > -
> > -#endif // CLANG_MODERNIZE_UNITTESTS_UTILITY_H
> > Index: unittests/clang-modernize/UniqueHeaderNameTest.cpp
> > ===================================================================
> > --- unittests/clang-modernize/UniqueHeaderNameTest.cpp
> > +++ /dev/null
> > @@ -1,61 +0,0 @@
> > -//===- unittests/clang-modernize/UniqueHeaderNameTest.cpp
> -----------------===//
> > -//
> > -//                     The LLVM Compiler Infrastructure
> > -//
> > -// This file is distributed under the University of Illinois Open Source
> > -// License. See LICENSE.TXT for details.
> > -//
> >
> -//===----------------------------------------------------------------------===//
> > -//
> > -// Test for the generateReplacementsFileName() in FileOverrides.h
> > -//
> >
> -//===----------------------------------------------------------------------===//
> > -
> > -#include "gtest/gtest.h"
> > -#include "Core/ReplacementHandling.h"
> > -#include "llvm/Support/FileSystem.h"
> > -#include "llvm/Support/Path.h"
> > -#include "llvm/Support/Regex.h"
> > -#include <system_error>
> > -
> > -TEST(UniqueHeaderName, testUniqueHeaderName) {
> > -  using namespace llvm::sys::path;
> > -
> > -  llvm::SmallString<32> TmpDir;
> > -  system_temp_directory(true, TmpDir);
> > -
> > -  llvm::SmallString<128> SourceFile(TmpDir);
> > -  append(SourceFile, "project/lib/feature.cpp");
> > -  native(SourceFile.str().str(), SourceFile);
> > -
> > -  llvm::SmallString<128> DestDir(TmpDir);
> > -  append(DestDir, "replacements");
> > -
> > -  llvm::SmallString<128> FullActualPath;
> > -  llvm::SmallString<128> Error;
> > -  bool Result = ReplacementHandling::generateReplacementsFileName(
> > -      DestDir, SourceFile, FullActualPath, Error);
> > -
> > -  ASSERT_TRUE(Result);
> > -  EXPECT_TRUE(Error.empty());
> > -
> > -  // We need to check the directory name and filename separately since
> on
> > -  // Windows, the path separator is '\' which is a regex escape
> character.
> > -  llvm::SmallString<128> ExpectedPath =
> > -      llvm::sys::path::parent_path(SourceFile);
> > -  llvm::SmallString<128> ActualPath =
> > -      llvm::sys::path::parent_path(FullActualPath);
> > -  llvm::SmallString<128> ActualName =
> > -      llvm::sys::path::filename(FullActualPath);
> > -
> > -  EXPECT_STREQ(DestDir.c_str(), ActualPath.c_str());
> > -
> > -  llvm::StringRef ExpectedName =
> > -      "^feature.cpp_[0-9a-f]{2}_[0-9a-f]{2}_[0-9a-f]{2}_[0-9a-f]{2}_["
> > -      "0-9a-f]{2}_[0-9a-f]{2}.yaml$";
> > -  llvm::Regex R(ExpectedName);
> > -  ASSERT_TRUE(R.match(ActualName))
> > -      << "ExpectedName: " << ExpectedName.data()
> > -      << "\nActualName: " << ActualName.c_str();
> > -  ASSERT_TRUE(Error.empty()) << "Error: " << Error.c_str();
> > -}
> > Index: unittests/clang-modernize/TransformTest.cpp
> > ===================================================================
> > --- unittests/clang-modernize/TransformTest.cpp
> > +++ /dev/null
> > @@ -1,299 +0,0 @@
> > -//===- clang-modernize/TransformTest.cpp - Transform unit tests
> -----------===//
> > -//
> > -//                     The LLVM Compiler Infrastructure
> > -//
> > -// This file is distributed under the University of Illinois Open Source
> > -// License. See LICENSE.TXT for details.
> > -//
> >
> -//===----------------------------------------------------------------------===//
> > -
> > -#include "gtest/gtest.h"
> > -#include "Core/Transform.h"
> > -#include "clang/AST/ASTConsumer.h"
> > -#include "clang/AST/DeclGroup.h"
> > -#include "clang/ASTMatchers/ASTMatchFinder.h"
> > -#include "clang/ASTMatchers/ASTMatchers.h"
> > -#include "llvm/Support/FileSystem.h"
> > -#include "llvm/Support/Path.h"
> > -#include "llvm/Support/Process.h"
> > -
> > -using namespace clang;
> > -using namespace ast_matchers;
> > -
> > -class DummyTransform : public Transform {
> > -public:
> > -  DummyTransform(llvm::StringRef Name, const TransformOptions &Options)
> > -      : Transform(Name, Options) {}
> > -
> > -  int apply(const tooling::CompilationDatabase &,
> > -            const std::vector<std::string> &) override {
> > -    return 0;
> > -  }
> > -
> > -  void setAcceptedChanges(unsigned Changes) {
> > -    Transform::setAcceptedChanges(Changes);
> > -  }
> > -  void setRejectedChanges(unsigned Changes) {
> > -    Transform::setRejectedChanges(Changes);
> > -  }
> > -  void setDeferredChanges(unsigned Changes) {
> > -    Transform::setDeferredChanges(Changes);
> > -  }
> > -
> > -};
> > -
> > -TEST(Transform, Interface) {
> > -  TransformOptions Options;
> > -  DummyTransform T("my_transform", Options);
> > -
> > -  ASSERT_EQ("my_transform", T.getName());
> > -  ASSERT_EQ(0u, T.getAcceptedChanges());
> > -  ASSERT_EQ(0u, T.getRejectedChanges());
> > -  ASSERT_EQ(0u, T.getDeferredChanges());
> > -  ASSERT_FALSE(T.getChangesMade());
> > -  ASSERT_FALSE(T.getChangesNotMade());
> > -
> > -  T.setAcceptedChanges(1);
> > -  ASSERT_TRUE(T.getChangesMade());
> > -
> > -  T.setDeferredChanges(1);
> > -  ASSERT_TRUE(T.getChangesNotMade());
> > -
> > -  T.setRejectedChanges(1);
> > -  ASSERT_TRUE(T.getChangesNotMade());
> > -
> > -  T.Reset();
> > -  ASSERT_EQ(0u, T.getAcceptedChanges());
> > -  ASSERT_EQ(0u, T.getRejectedChanges());
> > -  ASSERT_EQ(0u, T.getDeferredChanges());
> > -
> > -  T.setRejectedChanges(1);
> > -  ASSERT_TRUE(T.getChangesNotMade());
> > -}
> > -
> > -class TimePassingASTConsumer : public ASTConsumer {
> > -public:
> > -  TimePassingASTConsumer(bool *Called) : Called(Called) {}
> > -
> > -  bool HandleTopLevelDecl(DeclGroupRef DeclGroup) override {
> > -    llvm::sys::TimeValue UserStart;
> > -    llvm::sys::TimeValue SystemStart;
> > -    llvm::sys::TimeValue UserNow;
> > -    llvm::sys::TimeValue SystemNow;
> > -    llvm::sys::TimeValue Wall;
> > -
> > -    // Busy-wait until the user/system time combined is more than 1ms
> > -    llvm::sys::TimeValue OneMS(0, 1000000);
> > -    llvm::sys::Process::GetTimeUsage(Wall, UserStart, SystemStart);
> > -    do {
> > -      llvm::sys::Process::GetTimeUsage(Wall, UserNow, SystemNow);
> > -    } while (UserNow - UserStart + SystemNow - SystemStart < OneMS);
> > -    *Called = true;
> > -    return true;
> > -  }
> > -  bool *Called;
> > -};
> > -
> > -struct ConsumerFactory {
> > -  std::unique_ptr<ASTConsumer> newASTConsumer() {
> > -    return llvm::make_unique<TimePassingASTConsumer>(&Called);
> > -  }
> > -  bool Called;
> > -};
> > -
> > -struct CallbackForwarder : public clang::tooling::SourceFileCallbacks {
> > -  CallbackForwarder(Transform &Callee) : Callee(Callee) {}
> > -
> > -  bool handleBeginSource(CompilerInstance &CI, StringRef Filename)
> override {
> > -    return Callee.handleBeginSource(CI, Filename);
> > -  }
> > -
> > -  void handleEndSource() override { Callee.handleEndSource(); }
> > -
> > -  Transform &Callee;
> > -};
> > -
> > -TEST(Transform, Timings) {
> > -  TransformOptions Options;
> > -  Options.EnableTiming = true;
> > -  DummyTransform T("timing_transform", Options);
> > -
> > -  // All the path stuff is to make the test work independently of OS.
> > -
> > -  // The directory used is not important since the path gets mapped to
> a virtual
> > -  // file anyway. What is important is that we have an absolute path
> with which
> > -  // to use with mapVirtualFile().
> > -  SmallString<128> CurrentDir;
> > -  std::error_code EC = llvm::sys::fs::current_path(CurrentDir);
> > -  assert(!EC);
> > -  (void)EC;
> > -
> > -  SmallString<128> FileA = CurrentDir;
> > -  llvm::sys::path::append(FileA, "a.cc");
> > -
> > -  SmallString<128> FileB = CurrentDir;
> > -  llvm::sys::path::append(FileB, "b.cc");
> > -
> > -  tooling::FixedCompilationDatabase Compilations(CurrentDir.str(),
> > -
>  std::vector<std::string>());
> > -  std::vector<std::string> Sources;
> > -  Sources.push_back(FileA.str());
> > -  Sources.push_back(FileB.str());
> > -  tooling::ClangTool Tool(Compilations, Sources);
> > -
> > -  Tool.mapVirtualFile(FileA, "void a() {}");
> > -  Tool.mapVirtualFile(FileB, "void b() {}");
> > -
> > -  // Factory to create TimePassingASTConsumer for each source file the
> tool
> > -  // runs on.
> > -  ConsumerFactory Factory;
> > -
> > -  // We don't care about any of Transform's functionality except to get
> it to
> > -  // record timings. For that, we need to forward handleBeginSource()
> and
> > -  // handleEndSource() calls to it.
> > -  CallbackForwarder Callbacks(T);
> > -
> > -  Tool.run(
> > -      clang::tooling::newFrontendActionFactory(&Factory,
> &Callbacks).get());
> > -
> > -  EXPECT_TRUE(Factory.Called);
> > -  Transform::TimingVec::const_iterator I = T.timing_begin();
> > -  EXPECT_GT(I->second.getProcessTime(), 0.0);
> > -
> > -  // The success of the test shouldn't depend on the order of iteration
> through
> > -  // timers.
> > -  StringRef FirstFile = I->first;
> > -  if (FileA == FirstFile) {
> > -    ++I;
> > -    EXPECT_EQ(FileB, I->first);
> > -    EXPECT_GT(I->second.getProcessTime(), 0.0);
> > -  } else if (FileB == FirstFile) {
> > -    ++I;
> > -    EXPECT_EQ(FileA, I->first);
> > -    EXPECT_GT(I->second.getProcessTime(), 0.0);
> > -  } else {
> > -    FAIL() << "Unexpected file name " << I->first << " in timing data.";
> > -  }
> > -  ++I;
> > -  EXPECT_EQ(T.timing_end(), I);
> > -}
> > -
> > -class ModifiableCallback
> > -    : public clang::ast_matchers::MatchFinder::MatchCallback {
> > -public:
> > -  ModifiableCallback(const Transform &Owner)
> > -      : Owner(Owner) {}
> > -
> > -  void
> > -  run(const clang::ast_matchers::MatchFinder::MatchResult &Result)
> override {
> > -    const VarDecl *Decl = Result.Nodes.getNodeAs<VarDecl>("decl");
> > -    ASSERT_TRUE(Decl != nullptr);
> > -
> > -    const SourceManager &SM = *Result.SourceManager;
> > -
> > -    // Decl 'a' comes from the main source file. This test should
> always pass.
> > -    if (Decl->getName().equals("a"))
> > -      EXPECT_TRUE(Owner.isFileModifiable(SM, Decl->getLocStart()));
> > -
> > -    // Decl 'c' comes from an excluded header. This test should never
> pass.
> > -    else if (Decl->getName().equals("c"))
> > -      EXPECT_FALSE(Owner.isFileModifiable(SM, Decl->getLocStart()));
> > -
> > -    // Decl 'b' comes from an included header.
> > -    else if (Decl->getName().equals("b"))
> > -      EXPECT_TRUE(Owner.isFileModifiable(SM, Decl->getLocStart()));
> > -
> > -    // Make sure edge cases are handled gracefully (they should never be
> > -    // allowed).
> > -    SourceLocation DummyLoc;
> > -    EXPECT_FALSE(Owner.isFileModifiable(SM, DummyLoc));
> > -  }
> > -
> > -private:
> > -  const Transform &Owner;
> > -};
> > -
> > -TEST(Transform, isFileModifiable) {
> > -  TransformOptions Options;
> > -
> > -  ///
> > -  /// SETUP
> > -  ///
> > -  /// To test Transform::isFileModifiable() we need a SourceManager
> primed with
> > -  /// actual files and SourceLocations to test. Easiest way to
> accomplish this
> > -  /// is to use Tooling classes.
> > -  ///
> > -  /// 1) Simulate a source file that includes two headers, one that is
> allowed
> > -  ///    to be modified and the other that is not allowed. Each of the
> three
> > -  ///    files involved will declare a single variable with a different
> name.
> > -  /// 2) A matcher is created to find VarDecls.
> > -  /// 3) A MatchFinder callback calls Transform::isFileModifiable()
> with the
> > -  ///    SourceLocations of found VarDecls and thus tests the function.
> > -  ///
> > -
> > -  // All the path stuff is to make the test work independently of OS.
> > -
> > -  // The directory used is not important since the path gets mapped to
> a virtual
> > -  // file anyway. What is important is that we have an absolute path
> with which
> > -  // to use with mapVirtualFile().
> > -  SmallString<128> CurrentDir;
> > -  std::error_code EC = llvm::sys::fs::current_path(CurrentDir);
> > -  assert(!EC);
> > -  (void)EC;
> > -
> > -  SmallString<128> SourceFile = CurrentDir;
> > -  llvm::sys::path::append(SourceFile, "a.cc");
> > -
> > -  SmallString<128> HeaderFile = CurrentDir;
> > -  llvm::sys::path::append(HeaderFile, "a.h");
> > -
> > -  SmallString<128> HeaderBFile = CurrentDir;
> > -  llvm::sys::path::append(HeaderBFile, "temp");
> > -  llvm::sys::path::append(HeaderBFile, "b.h");
> > -
> > -  StringRef ExcludeDir = llvm::sys::path::parent_path(HeaderBFile);
> > -
> > -  IncludeExcludeInfo IncInfo;
> > -  Options.ModifiableFiles.readListFromString(CurrentDir, ExcludeDir);
> > -
> > -  tooling::FixedCompilationDatabase Compilations(CurrentDir.str(),
> > -
>  std::vector<std::string>());
> > -  std::vector<std::string> Sources;
> > -  Sources.push_back(SourceFile.str());
> > -  tooling::ClangTool Tool(Compilations, Sources);
> > -
> > -  Tool.mapVirtualFile(SourceFile,
> > -                      "#include \"a.h\"\n"
> > -                      "#include \"temp/b.h\"\n"
> > -                      "int a;");
> > -  Tool.mapVirtualFile(HeaderFile, "int b;");
> > -  Tool.mapVirtualFile(HeaderBFile, "int c;");
> > -
> > -  DummyTransform T("dummy", Options);
> > -  MatchFinder Finder;
> > -  ModifiableCallback Callback(T);
> > -  Finder.addMatcher(varDecl().bind("decl"), &Callback);
> > -  Tool.run(tooling::newFrontendActionFactory(&Finder).get());
> > -}
> > -
> > -TEST(VersionTest, Interface) {
> > -  Version V;
> > -
> > -  ASSERT_TRUE(V.isNull());
> > -  ASSERT_TRUE(Version(1) < Version(1, 1));
> > -  ASSERT_TRUE(Version(1) < Version(2));
> > -  ASSERT_TRUE(Version(1, 1) < Version(2));
> > -  ASSERT_TRUE(Version(1, 1) == Version(1, 1));
> > -  ASSERT_EQ(Version(1).getMajor(), unsigned(1));
> > -  ASSERT_EQ(Version(1).getMinor(), unsigned(0));
> > -  ASSERT_EQ(Version(1, 2).getMinor(), unsigned(2));
> > -}
> > -
> > -TEST(VersionTest, getFromString) {
> > -  ASSERT_EQ(Version(1), Version::getFromString("1"));
> > -  ASSERT_EQ(Version(1, 2), Version::getFromString("1.2"));
> > -  ASSERT_TRUE(Version::getFromString("foo").isNull());
> > -  ASSERT_TRUE(Version::getFromString("1bar").isNull());
> > -  // elements after major.minor are ignored
> > -  ASSERT_EQ(Version(1, 2), Version::getFromString("1.2.3"));
> > -}
> > Index: unittests/clang-modernize/PerfSupportTest.cpp
> > ===================================================================
> > --- unittests/clang-modernize/PerfSupportTest.cpp
> > +++ /dev/null
> > @@ -1,97 +0,0 @@
> > -//===- clang-modernize/PerfSupportTest.cpp - PerfSupport unit tests
> -------===//
> > -//
> > -//                     The LLVM Compiler Infrastructure
> > -//
> > -// This file is distributed under the University of Illinois Open Source
> > -// License. See LICENSE.TXT for details.
> > -//
> >
> -//===----------------------------------------------------------------------===//
> > -
> > -#include "gtest/gtest.h"
> > -#include "Core/PerfSupport.h"
> > -
> > -using namespace llvm;
> > -using namespace clang;
> > -
> > -class TransformA : public Transform {
> > -public:
> > -  TransformA(const TransformOptions &Options)
> > -      : Transform("TransformA", Options) {}
> > -
> > -  int apply(const tooling::CompilationDatabase &,
> > -            const std::vector<std::string> &) override {
> > -    return 0;
> > -  }
> > -
> > -  void addTiming(StringRef Label, TimeRecord Duration) {
> > -    Transform::addTiming(Label, Duration);
> > -  }
> > -};
> > -
> > -class TransformB : public Transform {
> > -public:
> > -  TransformB(const TransformOptions &Options)
> > -      : Transform("TransformB", Options) {}
> > -
> > -  int apply(const tooling::CompilationDatabase &,
> > -            const std::vector<std::string> &) override {
> > -    return 0;
> > -  }
> > -
> > -  void addTiming(StringRef Label, TimeRecord Duration) {
> > -    Transform::addTiming(Label, Duration);
> > -  }
> > -};
> > -
> > -struct ExpectedResults {
> > -  const char *SourceName;
> > -  unsigned DataCount;
> > -  struct Datum {
> > -    const char *Label;
> > -    float Duration;
> > -  } Data[2];
> > -};
> > -
> > -TEST(PerfSupport, collectSourcePerfData) {
> > -  TransformOptions Options;
> > -  TransformA A(Options);
> > -  TransformB B(Options);
> > -
> > -  // The actual durations don't matter. Below only their relative
> ordering is
> > -  // tested to ensure times, labels, and sources all stay together
> properly.
> > -  A.addTiming("FileA.cpp", TimeRecord::getCurrentTime(/*Start=*/true));
> > -  A.addTiming("FileC.cpp", TimeRecord::getCurrentTime(/*Start=*/true));
> > -  B.addTiming("FileC.cpp", TimeRecord::getCurrentTime(/*Start=*/true));
> > -  B.addTiming("FileB.cpp", TimeRecord::getCurrentTime(/*Start=*/true));
> > -
> > -  SourcePerfData PerfData;
> > -  collectSourcePerfData(A, PerfData);
> > -
> > -  SourcePerfData::const_iterator FileAI = PerfData.find("FileA.cpp");
> > -  EXPECT_NE(FileAI, PerfData.end());
> > -  SourcePerfData::const_iterator FileCI = PerfData.find("FileC.cpp");
> > -  EXPECT_NE(FileCI, PerfData.end());
> > -  EXPECT_EQ(2u, PerfData.size());
> > -
> > -  EXPECT_EQ(1u, FileAI->second.size());
> > -  EXPECT_EQ("TransformA", FileAI->second[0].Label);
> > -  EXPECT_EQ(1u, FileCI->second.size());
> > -  EXPECT_EQ("TransformA", FileCI->second[0].Label);
> > -  EXPECT_LE(FileAI->second[0].Duration, FileCI->second[0].Duration);
> > -
> > -  collectSourcePerfData(B, PerfData);
> > -
> > -  SourcePerfData::const_iterator FileBI = PerfData.find("FileB.cpp");
> > -  EXPECT_NE(FileBI, PerfData.end());
> > -  EXPECT_EQ(3u, PerfData.size());
> > -
> > -  EXPECT_EQ(1u, FileAI->second.size());
> > -  EXPECT_EQ("TransformA", FileAI->second[0].Label);
> > -  EXPECT_EQ(2u, FileCI->second.size());
> > -  EXPECT_EQ("TransformA", FileCI->second[0].Label);
> > -  EXPECT_EQ("TransformB", FileCI->second[1].Label);
> > -  EXPECT_LE(FileCI->second[0].Duration, FileCI->second[1].Duration);
> > -  EXPECT_EQ(1u, FileBI->second.size());
> > -  EXPECT_EQ("TransformB", FileBI->second[0].Label);
> > -  EXPECT_LE(FileCI->second[1].Duration, FileBI->second[0].Duration);
> > -}
> > Index: unittests/clang-modernize/Makefile
> > ===================================================================
> > --- unittests/clang-modernize/Makefile
> > +++ /dev/null
> > @@ -1,27 +0,0 @@
> > -##===- unittests/clang-modernize/Makefile ------------------*- Makefile
> -*-===##
> > -#
> > -#                     The LLVM Compiler Infrastructure
> > -#
> > -# This file is distributed under the University of Illinois Open Source
> > -# License. See LICENSE.TXT for details.
> > -#
> >
> -##===----------------------------------------------------------------------===##
> > -
> > -CLANG_LEVEL = ../../../..
> > -include $(CLANG_LEVEL)/../../Makefile.config
> > -
> > -TESTNAME = ClangModernizeTests
> > -LINK_COMPONENTS := asmparser bitreader support MC MCParser option \
> > -             TransformUtils
> > -USEDLIBS = modernizeCore.a clangFormat.a clangApplyReplacements.a \
> > -        clangTooling.a clangToolingCore.a clangFrontend.a \
> > -           clangSerialization.a clangDriver.a clangRewriteFrontend.a \
> > -           clangRewrite.a clangParse.a clangSema.a clangAnalysis.a \
> > -           clangAST.a clangASTMatchers.a clangEdit.a clangLex.a \
> > -           clangBasic.a
> > -
> > -include $(CLANG_LEVEL)/Makefile
> > -MAKEFILE_UNITTEST_NO_INCLUDE_COMMON := 1
> > -CPP.Flags += -I$(PROJ_SRC_DIR)/../../clang-modernize
> -I$(PROJ_SRC_DIR)/../../clang-apply-replacements/include \
> > -                -I$(PROJ_SRC_DIR)/../include
> > -include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
> > Index: unittests/clang-modernize/IncludeExcludeTest.cpp
> > ===================================================================
> > --- unittests/clang-modernize/IncludeExcludeTest.cpp
> > +++ /dev/null
> > @@ -1,149 +0,0 @@
> > -//===- clang-modernize/IncludeExcludeTest.cpp - IncludeExclude unit
> tests -===//
> > -//
> > -//                     The LLVM Compiler Infrastructure
> > -//
> > -// This file is distributed under the University of Illinois Open Source
> > -// License. See LICENSE.TXT for details.
> > -//
> >
> -//===----------------------------------------------------------------------===//
> > -
> > -#include "common/Utility.h"
> > -#include "Core/IncludeExcludeInfo.h"
> > -#include "llvm/Support/FileSystem.h"
> > -#include "llvm/Support/Path.h"
> > -#include "gtest/gtest.h"
> > -#include <fstream>
> > -
> > -TEST(IncludeExcludeTest, ParseString) {
> > -  IncludeExcludeInfo IEManager;
> > -  std::error_code Err = IEManager.readListFromString(
> > -      /*include=*/ "a,b/b2,c/c2,d/../d2/../d3",
> > -      /*exclude=*/ "a/af.cpp,a/a2,b/b2/b2f.cpp,c/c2");
> > -
> > -  ASSERT_EQ(Err, std::error_code());
> > -
> > -  // If the file does not appear on the include list then it is not
> safe to
> > -  // transform. Files are not safe to transform by default.
> > -  EXPECT_FALSE(IEManager.isFileIncluded("f.cpp"));
> > -  EXPECT_FALSE(IEManager.isFileIncluded("b/dir/f.cpp"));
> > -  EXPECT_FALSE(IEManager.isFileIncluded("d/f.cpp"));
> > -  EXPECT_FALSE(IEManager.isFileIncluded("d2/f.cpp"));
> > -
> > -  // If the file appears on only the include list then it is safe to
> transform.
> > -  EXPECT_TRUE(IEManager.isFileIncluded("a/f.cpp"));
> > -  EXPECT_TRUE(IEManager.isFileIncluded("a/dir/f.cpp"));
> > -  EXPECT_TRUE(IEManager.isFileIncluded("b/b2/f.cpp"));
> > -  EXPECT_TRUE(IEManager.isFileIncluded("d3/f.cpp"));
> > -
> > -  // If the file appears on both the include or exclude list then it is
> not
> > -  // safe to transform.
> > -  EXPECT_FALSE(IEManager.isFileIncluded("a/af.cpp"));
> > -  EXPECT_FALSE(IEManager.isFileIncluded("a/a2/f.cpp"));
> > -  EXPECT_FALSE(IEManager.isFileIncluded("a/a2/dir/f.cpp"));
> > -  EXPECT_FALSE(IEManager.isFileIncluded("b/b2/b2f.cpp"));
> > -  EXPECT_FALSE(IEManager.isFileIncluded("c/c2/c3/f.cpp"));
> > -
> > -#ifdef LLVM_ON_WIN32
> > -  // Check for cases when the path separators are different between the
> path
> > -  // that was read and the path that we are checking for. This can
> happen on
> > -  // windows where lit provides "\" and the test has "/".
> > -  ASSERT_NO_ERROR(IEManager.readListFromString(
> > -        /*include=*/ "C:\\foo,a\\b/c,a/../b\\c/..\\d",
> > -        /*exclude=*/ "C:\\bar"
> > -        ));
> > -  EXPECT_TRUE(IEManager.isFileIncluded("C:/foo/code.h"));
> > -  EXPECT_FALSE(IEManager.isFileIncluded("C:/bar/code.h"));
> > -  EXPECT_TRUE(IEManager.isFileIncluded("a/b\\c/code.h"));
> > -  EXPECT_FALSE(IEManager.isFileIncluded("b\\c/code.h"));
> > -  EXPECT_TRUE(IEManager.isFileIncluded("b/d\\code.h"));
> > -#endif
> > -}
> > -
> > -TEST(IncludeExcludeTest, ParseStringCases) {
> > -  IncludeExcludeInfo IEManager;
> > -  std::error_code Err = IEManager.readListFromString(
> > -      /*include=*/  "a/.,b/b2/,c/c2/c3/../../c4/,d/d2/./d3/,/e/e2/.",
> > -      /*exclude=*/ "");
> > -
> > -  ASSERT_EQ(Err, std::error_code());
> > -
> > -  EXPECT_TRUE(IEManager.isFileIncluded("a/f.cpp"));
> > -  EXPECT_TRUE(IEManager.isFileIncluded("b/b2/f.cpp"));
> > -  EXPECT_TRUE(IEManager.isFileIncluded("c/c4/f.cpp"));
> > -  EXPECT_TRUE(IEManager.isFileIncluded("d/d2/d3/f.cpp"));
> > -  EXPECT_TRUE(IEManager.isFileIncluded("/e/e2/f.cpp"));
> > -
> > -  EXPECT_FALSE(IEManager.isFileIncluded("c/c2/c3/f.cpp"));
> > -}
> > -
> > -// Utility for creating and filling files with data for
> IncludeExcludeFileTest
> > -// tests.
> > -struct InputFiles {
> > -
> > -  // This function uses fatal assertions. The caller is responsible for
> making
> > -  // sure fatal assertions propagate.
> > -  void CreateFiles(bool UnixMode) {
> > -    llvm::SmallString<128> Path;
> > -    int FD;
> > -
> > -    ASSERT_NO_ERROR(
> > -        llvm::sys::fs::createTemporaryFile("include", "", FD, Path));
> > -    IncludeDataPath = Path.str();
> > -    {
> > -      llvm::raw_fd_ostream IncludeDataFile(FD, true);
> > -      for (unsigned i = 0; i < sizeof(IncludeData) / sizeof(char *);
> ++i) {
> > -        IncludeDataFile << IncludeData[i] << (UnixMode ? "\n" : "\r\n");
> > -      }
> > -    }
> > -
> > -    ASSERT_NO_ERROR(
> > -        llvm::sys::fs::createTemporaryFile("exclude", "", FD, Path));
> > -    ExcludeDataPath = Path.str();
> > -    {
> > -      llvm::raw_fd_ostream ExcludeDataFile(FD, true);
> > -      for (unsigned i = 0; i < sizeof(ExcludeData) / sizeof(char *);
> ++i) {
> > -        ExcludeDataFile << ExcludeData[i] << (UnixMode ? "\n" : "\r\n");
> > -      }
> > -    }
> > -  }
> > -
> > -  static const char *IncludeData[3];
> > -  static const char *ExcludeData[4];
> > -
> > -  std::string IncludeDataPath;
> > -  std::string ExcludeDataPath;
> > -};
> > -
> > -const char *InputFiles::IncludeData[3] = { "a", "b/b2", "c/c2" };
> > -const char *InputFiles::ExcludeData[4] = { "a/af.cpp", "a/a2",
> "b/b2/b2f.cpp",
> > -                                           "c/c2" };
> > -
> > -TEST(IncludeExcludeFileTest, UNIXFile) {
> > -  InputFiles UnixFiles;
> > -  ASSERT_NO_FATAL_FAILURE(UnixFiles.CreateFiles(/* UnixMode= */true));
> > -
> > -  IncludeExcludeInfo IEManager;
> > -  std::error_code Err = IEManager.readListFromFile(
> > -      UnixFiles.IncludeDataPath.c_str(),
> UnixFiles.ExcludeDataPath.c_str());
> > -
> > -  ASSERT_EQ(Err, std::error_code());
> > -
> > -  EXPECT_FALSE(IEManager.isFileIncluded("f.cpp"));
> > -  EXPECT_TRUE(IEManager.isFileIncluded("a/f.cpp"));
> > -  EXPECT_FALSE(IEManager.isFileIncluded("a/af.cpp"));
> > -}
> > -
> > -TEST(IncludeExcludeFileTest, DOSFile) {
> > -  InputFiles DOSFiles;
> > -  ASSERT_NO_FATAL_FAILURE(DOSFiles.CreateFiles(/* UnixMode= */false));
> > -
> > -  IncludeExcludeInfo IEManager;
> > -  std::error_code Err = IEManager.readListFromFile(
> > -      DOSFiles.IncludeDataPath.c_str(),
> DOSFiles.ExcludeDataPath.c_str());
> > -
> > -  ASSERT_EQ(Err, std::error_code());
> > -
> > -  EXPECT_FALSE(IEManager.isFileIncluded("f.cpp"));
> > -  EXPECT_TRUE(IEManager.isFileIncluded("a/f.cpp"));
> > -  EXPECT_FALSE(IEManager.isFileIncluded("a/af.cpp"));
> > -}
> > Index: unittests/clang-modernize/IncludeDirectivesTest.cpp
> > ===================================================================
> > --- unittests/clang-modernize/IncludeDirectivesTest.cpp
> > +++ /dev/null
> > @@ -1,410 +0,0 @@
> > -//===- clang-modernize/IncludeDirectivesTest.cpp
> --------------------------===//
> > -//
> > -//                     The LLVM Compiler Infrastructure
> > -//
> > -// This file is distributed under the University of Illinois Open Source
> > -// License. See LICENSE.TXT for details.
> > -//
> >
> -//===----------------------------------------------------------------------===//
> > -
> > -#include "Core/IncludeDirectives.h"
> > -#include "common/VirtualFileHelper.h"
> > -#include "clang/Frontend/CompilerInstance.h"
> > -#include "clang/Frontend/FrontendActions.h"
> > -#include "llvm/Support/Path.h"
> > -#include "gtest/gtest.h"
> > -
> > -using namespace llvm;
> > -using namespace clang;
> > -
> > -/// \brief A convenience method around \c
> tooling::runToolOnCodeWithArgs() that
> > -/// adds the current directory to the include search paths.
> > -static void applyActionOnCode(FrontendAction *ToolAction, StringRef
> Code) {
> > -  SmallString<128> CurrentDir;
> > -  ASSERT_FALSE(llvm::sys::fs::current_path(CurrentDir));
> > -
> > -  // Add the current directory to the header search paths so angled
> includes can
> > -  // find them.
> > -  std::vector<std::string> Args;
> > -  Args.push_back("-I");
> > -  Args.push_back(CurrentDir.str().str());
> > -
> > -  // mapVirtualFile() needs absolute path for the input file as well.
> > -  SmallString<128> InputFile(CurrentDir);
> > -  sys::path::append(InputFile, "input.cc");
> > -
> > -  ASSERT_TRUE(
> > -      tooling::runToolOnCodeWithArgs(ToolAction, Code, Args,
> InputFile.str()));
> > -}
> > -
> > -namespace {
> > -class TestAddIncludeAction : public PreprocessOnlyAction {
> > -public:
> > -  TestAddIncludeAction(StringRef Include, tooling::Replacements
> &Replaces,
> > -                       const char *HeaderToModify = nullptr)
> > -      : Include(Include), Replaces(Replaces),
> HeaderToModify(HeaderToModify) {
> > -    // some headers that the tests can include
> > -    mapVirtualHeader("foo-inner.h", "#pragma once\n");
> > -    mapVirtualHeader("foo.h", "#pragma once\n"
> > -                              "#include <foo-inner.h>\n");
> > -    mapVirtualHeader("bar-inner.h", "#pragma once\n");
> > -    mapVirtualHeader("bar.h", "#pragma once\n"
> > -                              "#include <bar-inner.h>\n");
> > -    mapVirtualHeader("xmacro.def", "X(Val1)\n"
> > -                                   "X(Val2)\n"
> > -                                   "X(Val3)\n");
> > -  }
> > -
> > -  /// \brief Make \p FileName an absolute path.
> > -  ///
> > -  /// Header files are mapped in the current working directory. The
> current
> > -  /// working directory is used because it's important to map files with
> > -  /// absolute paths.
> > -  ///
> > -  /// When used in conjunction with \c applyActionOnCode() (which adds
> the
> > -  /// current working directory to the header search paths) it is
> possible to
> > -  /// refer to the headers by using '\<FileName\>'.
> > -  std::string makeHeaderFileName(StringRef FileName) const {
> > -    SmallString<128> Path;
> > -    std::error_code EC = llvm::sys::fs::current_path(Path);
> > -    assert(!EC);
> > -    (void)EC;
> > -
> > -    sys::path::append(Path, FileName);
> > -    return Path.str().str();
> > -  }
> > -
> > -  /// \brief Map additional header files.
> > -  ///
> > -  /// \sa makeHeaderFileName()
> > -  void mapVirtualHeader(StringRef FileName, StringRef Content) {
> > -    VFHelper.mapFile(makeHeaderFileName(FileName), Content);
> > -  }
> > -
> > -private:
> > -  bool BeginSourceFileAction(CompilerInstance &CI,
> > -                             StringRef FileName) override {
> > -    if (!PreprocessOnlyAction::BeginSourceFileAction(CI, FileName))
> > -      return false;
> > -    VFHelper.mapVirtualFiles(CI.getSourceManager());
> > -
> > -    FileToModify =
> > -        HeaderToModify ? makeHeaderFileName(HeaderToModify) :
> FileName.str();
> > -
> > -    FileIncludes.reset(new IncludeDirectives(CI));
> > -    return true;
> > -  }
> > -
> > -  void EndSourceFileAction() override {
> > -    const tooling::Replacement &Replace =
> > -        FileIncludes->addAngledInclude(FileToModify, Include);
> > -    if (Replace.isApplicable())
> > -      Replaces.insert(Replace);
> > -  }
> > -
> > -  StringRef Include;
> > -  VirtualFileHelper VFHelper;
> > -  tooling::Replacements &Replaces;
> > -  std::unique_ptr<IncludeDirectives> FileIncludes;
> > -  std::string FileToModify;
> > -  // if non-null, add the include directives in this file instead of
> the main
> > -  // file.
> > -  const char *HeaderToModify;
> > -};
> > -
> > -std::string addIncludeInCode(StringRef Include, StringRef Code) {
> > -  tooling::Replacements Replaces;
> > -
> > -  applyActionOnCode(new TestAddIncludeAction(Include, Replaces), Code);
> > -
> > -  if (::testing::Test::HasFailure())
> > -    return "<<unexpected error from applyActionOnCode()>>";
> > -
> > -  return tooling::applyAllReplacements(Code, Replaces);
> > -}
> > -} // end anonymous namespace
> > -
> > -TEST(IncludeDirectivesTest2, endOfLinesVariants) {
> > -  EXPECT_EQ("#include <foo.h>\n"
> > -            "#include <bar>\n",
> > -            addIncludeInCode("bar", "#include <foo.h>\n"));
> > -  EXPECT_EQ("#include <foo.h>\r\n"
> > -            "#include <bar>\r\n",
> > -            addIncludeInCode("bar", "#include <foo.h>\r\n"));
> > -  EXPECT_EQ("#include <foo.h>\r"
> > -            "#include <bar>\r",
> > -            addIncludeInCode("bar", "#include <foo.h>\r"));
> > -}
> > -
> > -TEST(IncludeDirectivesTest, ppToken) {
> > -  EXPECT_EQ("#define FOO <foo.h>\n"
> > -            "#include FOO\n"
> > -            "#include <bar>\n"
> > -            "int i;\n",
> > -            addIncludeInCode("bar", "#define FOO <foo.h>\n"
> > -                                    "#include FOO\n"
> > -                                    "int i;\n"));
> > -}
> > -
> > -TEST(IncludeDirectivesTest, noFileHeader) {
> > -  EXPECT_EQ("#include <bar>\n"
> > -            "\n"
> > -            "int foo;\n",
> > -            addIncludeInCode("bar", "int foo;\n"));
> > -}
> > -
> > -TEST(IncludeDirectivesTest, commentBeforeTopMostCode) {
> > -  EXPECT_EQ("#include <bar>\n"
> > -            "\n"
> > -            "// Foo\n"
> > -            "int foo;\n",
> > -            addIncludeInCode("bar", "// Foo\n"
> > -                                    "int foo;\n"));
> > -}
> > -
> > -TEST(IncludeDirectivesTest, multiLineComment) {
> > -  EXPECT_EQ("#include <foo.h> /* \n */\n"
> > -            "#include <bar>\n",
> > -            addIncludeInCode("bar", "#include <foo.h> /* \n */\n"));
> > -  EXPECT_EQ("#include <foo.h> /* \n */"
> > -            "\n#include <bar>",
> > -            addIncludeInCode("bar", "#include <foo.h> /* \n */"));
> > -}
> > -
> > -TEST(IncludeDirectivesTest, multilineCommentWithTrailingSpace) {
> > -  EXPECT_EQ("#include <foo.h> /*\n*/ \n"
> > -            "#include <bar>\n",
> > -            addIncludeInCode("bar", "#include <foo.h> /*\n*/ \n"));
> > -  EXPECT_EQ("#include <foo.h> /*\n*/ "
> > -            "\n#include <bar>",
> > -            addIncludeInCode("bar", "#include <foo.h> /*\n*/ "));
> > -}
> > -
> > -TEST(IncludeDirectivesTest, fileHeaders) {
> > -  EXPECT_EQ("// this is a header\n"
> > -            "// some license stuff here\n"
> > -            "\n"
> > -            "#include <bar>\n"
> > -            "\n"
> > -            "/// \\brief Foo\n"
> > -            "int foo;\n",
> > -            addIncludeInCode("bar", "// this is a header\n"
> > -                                    "// some license stuff here\n"
> > -                                    "\n"
> > -                                    "/// \\brief Foo\n"
> > -                                    "int foo;\n"));
> > -}
> > -
> > -TEST(IncludeDirectivesTest, preferablyAngledNextToAngled) {
> > -  EXPECT_EQ("#include <foo.h>\n"
> > -            "#include <bar>\n"
> > -            "#include \"bar.h\"\n",
> > -            addIncludeInCode("bar", "#include <foo.h>\n"
> > -                                    "#include \"bar.h\"\n"));
> > -  EXPECT_EQ("#include \"foo.h\"\n"
> > -            "#include \"bar.h\"\n"
> > -            "#include <bar>\n",
> > -            addIncludeInCode("bar", "#include \"foo.h\"\n"
> > -                                    "#include \"bar.h\"\n"));
> > -}
> > -
> > -TEST(IncludeDirectivesTest, avoidDuplicates) {
> > -  EXPECT_EQ("#include <foo.h>\n",
> > -            addIncludeInCode("foo.h", "#include <foo.h>\n"));
> > -}
> > -
> > -// Tests includes in the middle of the code are ignored.
> > -TEST(IncludeDirectivesTest, ignoreHeadersMeantForMultipleInclusion) {
> > -  std::string Expected = "#include \"foo.h\"\n"
> > -                         "#include <bar>\n"
> > -                         "\n"
> > -                         "enum Kind {\n"
> > -                         "#define X(A) K_##A,\n"
> > -                         "#include \"xmacro.def\"\n"
> > -                         "#undef X\n"
> > -                         "  K_NUM_KINDS\n"
> > -                         "};\n";
> > -  std::string Result = addIncludeInCode("bar", "#include \"foo.h\"\n"
> > -                                               "\n"
> > -                                               "enum Kind {\n"
> > -                                               "#define X(A) K_##A,\n"
> > -                                               "#include
> \"xmacro.def\"\n"
> > -                                               "#undef X\n"
> > -                                               "  K_NUM_KINDS\n"
> > -                                               "};\n");
> > -  EXPECT_EQ(Expected, Result);
> > -}
> > -
> > -namespace {
> > -TestAddIncludeAction *makeIndirectTestsAction(const char
> *HeaderToModify,
> > -                                              tooling::Replacements
> &Replaces) {
> > -  StringRef IncludeToAdd = "c.h";
> > -  TestAddIncludeAction *TestAction =
> > -      new TestAddIncludeAction(IncludeToAdd, Replaces, HeaderToModify);
> > -  TestAction->mapVirtualHeader("c.h", "#pragma once\n");
> > -  TestAction->mapVirtualHeader("a.h", "#pragma once\n"
> > -                                      "#include <c.h>\n");
> > -  TestAction->mapVirtualHeader("b.h", "#pragma once\n");
> > -  return TestAction;
> > -}
> > -} // end anonymous namespace
> > -
> > -TEST(IncludeDirectivesTest, indirectIncludes) {
> > -  // In TestAddIncludeAction 'foo.h' includes 'foo-inner.h'. Check that
> we
> > -  // aren't including foo-inner.h again.
> > -  EXPECT_EQ("#include <foo.h>\n",
> > -            addIncludeInCode("foo-inner.h", "#include <foo.h>\n"));
> > -
> > -  tooling::Replacements Replaces;
> > -  StringRef Code = "#include <a.h>\n"
> > -                   "#include <b.h>\n";
> > -
> > -  // a.h already includes c.h
> > -  {
> > -    FrontendAction *Action = makeIndirectTestsAction("a.h", Replaces);
> > -    ASSERT_NO_FATAL_FAILURE(applyActionOnCode(Action, Code));
> > -    EXPECT_EQ(unsigned(0), Replaces.size());
> > -  }
> > -
> > -  // c.h is included before b.h but b.h doesn't include c.h directly,
> so check
> > -  // that it will be inserted.
> > -  {
> > -    FrontendAction *Action = makeIndirectTestsAction("b.h", Replaces);
> > -    ASSERT_NO_FATAL_FAILURE(applyActionOnCode(Action, Code));
> > -    EXPECT_EQ("#include <c.h>\n\n\n",
> > -              tooling::applyAllReplacements("\n", Replaces));
> > -  }
> > -}
> > -
> > -/// \brief Convenience method to test header guards detection
> implementation.
> > -static std::string addIncludeInGuardedHeader(StringRef IncludeToAdd,
> > -                                             StringRef
> GuardedHeaderCode) {
> > -  const char *GuardedHeaderName = "guarded.h";
> > -  tooling::Replacements Replaces;
> > -  TestAddIncludeAction *TestAction =
> > -      new TestAddIncludeAction(IncludeToAdd, Replaces,
> GuardedHeaderName);
> > -  TestAction->mapVirtualHeader(GuardedHeaderName, GuardedHeaderCode);
> > -
> > -  applyActionOnCode(TestAction, "#include <guarded.h>\n");
> > -  if (::testing::Test::HasFailure())
> > -    return "<<unexpected error from applyActionOnCode()>>";
> > -
> > -  return tooling::applyAllReplacements(GuardedHeaderCode, Replaces);
> > -}
> > -
> > -TEST(IncludeDirectivesTest, insertInsideIncludeGuard) {
> > -  EXPECT_EQ("#ifndef GUARD_H\n"
> > -            "#define GUARD_H\n"
> > -            "\n"
> > -            "#include <foo>\n"
> > -            "\n"
> > -            "struct foo {};\n"
> > -            "\n"
> > -            "#endif // GUARD_H\n",
> > -            addIncludeInGuardedHeader("foo", "#ifndef GUARD_H\n"
> > -                                             "#define GUARD_H\n"
> > -                                             "\n"
> > -                                             "struct foo {};\n"
> > -                                             "\n"
> > -                                             "#endif // GUARD_H\n"));
> > -}
> > -
> > -TEST(IncludeDirectivesTest, guardAndHeader) {
> > -  EXPECT_EQ("// File header\n"
> > -            "\n"
> > -            "#ifndef GUARD_H\n"
> > -            "#define GUARD_H\n"
> > -            "\n"
> > -            "#include <foo>\n"
> > -            "\n"
> > -            "struct foo {};\n"
> > -            "\n"
> > -            "#endif // GUARD_H\n",
> > -            addIncludeInGuardedHeader("foo", "// File header\n"
> > -                                             "\n"
> > -                                             "#ifndef GUARD_H\n"
> > -                                             "#define GUARD_H\n"
> > -                                             "\n"
> > -                                             "struct foo {};\n"
> > -                                             "\n"
> > -                                             "#endif // GUARD_H\n"));
> > -}
> > -
> > -TEST(IncludeDirectivesTest, fullHeaderFitsAsAPreamble) {
> > -  EXPECT_EQ("#ifndef GUARD_H\n"
> > -            "#define GUARD_H\n"
> > -            "\n"
> > -            "#include <foo>\n"
> > -            "\n"
> > -            "#define FOO 1\n"
> > -            "\n"
> > -            "#endif // GUARD_H\n",
> > -            addIncludeInGuardedHeader("foo", "#ifndef GUARD_H\n"
> > -                                             "#define GUARD_H\n"
> > -                                             "\n"
> > -                                             "#define FOO 1\n"
> > -                                             "\n"
> > -                                             "#endif // GUARD_H\n"));
> > -}
> > -
> > -TEST(IncludeDirectivesTest, codeBeforeIfndef) {
> > -  EXPECT_EQ("#include <foo>\n"
> > -            "\n"
> > -            "int bar;\n"
> > -            "\n"
> > -            "#ifndef GUARD_H\n"
> > -            "#define GUARD_H\n"
> > -            "\n"
> > -            "struct foo;"
> > -            "\n"
> > -            "#endif // GUARD_H\n",
> > -            addIncludeInGuardedHeader("foo", "int bar;\n"
> > -                                             "\n"
> > -                                             "#ifndef GUARD_H\n"
> > -                                             "#define GUARD_H\n"
> > -                                             "\n"
> > -                                             "struct foo;"
> > -                                             "\n"
> > -                                             "#endif // GUARD_H\n"));
> > -}
> > -
> > -TEST(IncludeDirectivesTest, codeAfterEndif) {
> > -  EXPECT_EQ("#include <foo>\n"
> > -            "\n"
> > -            "#ifndef GUARD_H\n"
> > -            "#define GUARD_H\n"
> > -            "\n"
> > -            "struct foo;"
> > -            "\n"
> > -            "#endif // GUARD_H\n"
> > -            "\n"
> > -            "int bar;\n",
> > -            addIncludeInGuardedHeader("foo", "#ifndef GUARD_H\n"
> > -                                             "#define GUARD_H\n"
> > -                                             "\n"
> > -                                             "struct foo;"
> > -                                             "\n"
> > -                                             "#endif // GUARD_H\n"
> > -                                             "\n"
> > -                                             "int bar;\n"));
> > -}
> > -
> > -TEST(IncludeDirectivesTest, headerGuardWithInclude) {
> > -  EXPECT_EQ("#ifndef GUARD_H\n"
> > -            "#define GUARD_H\n"
> > -            "\n"
> > -            "#include <bar.h>\n"
> > -            "#include <foo>\n"
> > -            "\n"
> > -            "struct foo;\n"
> > -            "\n"
> > -            "#endif // GUARD_H\n",
> > -            addIncludeInGuardedHeader("foo", "#ifndef GUARD_H\n"
> > -                                             "#define GUARD_H\n"
> > -                                             "\n"
> > -                                             "#include <bar.h>\n"
> > -                                             "\n"
> > -                                             "struct foo;\n"
> > -                                             "\n"
> > -                                             "#endif // GUARD_H\n"));
> > -}
> > Index: unittests/clang-modernize/CMakeLists.txt
> > ===================================================================
> > --- unittests/clang-modernize/CMakeLists.txt
> > +++ /dev/null
> > @@ -1,33 +0,0 @@
> > -set(LLVM_LINK_COMPONENTS
> > -  support
> > -  )
> > -
> > -get_filename_component(CLANG_MODERNIZE_SOURCE_DIR
> > -  ${CMAKE_CURRENT_SOURCE_DIR}/../../clang-modernize REALPATH)
> > -get_filename_component(ClangReplaceLocation
> > -  "${CMAKE_CURRENT_SOURCE_DIR}/../../clang-apply-replacements/include"
> REALPATH)
> > -get_filename_component(CommonIncLocation
> > -  "${CMAKE_CURRENT_SOURCE_DIR}/../include" REALPATH)
> > -include_directories(
> > -  ${CLANG_MODERNIZE_SOURCE_DIR}
> > -  ${ClangReplaceLocation}
> > -  ${CommonIncLocation}
> > -  )
> > -
> > -add_extra_unittest(ClangModernizeTests
> > -  IncludeExcludeTest.cpp
> > -  PerfSupportTest.cpp
> > -  TransformTest.cpp
> > -  UniqueHeaderNameTest.cpp
> > -  IncludeDirectivesTest.cpp
> > -  )
> > -
> > -target_link_libraries(ClangModernizeTests
> > -  clangAST
> > -  clangASTMatchers
> > -  clangBasic
> > -  clangFrontend
> > -  clangTooling
> > -  clangToolingCore
> > -  modernizeCore
> > -  )
> > Index: unittests/Makefile
> > ===================================================================
> > --- unittests/Makefile
> > +++ unittests/Makefile
> > @@ -10,6 +10,6 @@
> >  CLANG_LEVEL := ../../..
> >  include $(CLANG_LEVEL)/../../Makefile.config
> >
> > -PARALLEL_DIRS := clang-apply-replacements clang-modernize clang-query
> clang-tidy clang-rename
> > +PARALLEL_DIRS := clang-apply-replacements clang-query clang-tidy
> clang-rename
> >
> >  include $(CLANG_LEVEL)/Makefile
> > Index: unittests/CMakeLists.txt
> > ===================================================================
> > --- unittests/CMakeLists.txt
> > +++ unittests/CMakeLists.txt
> > @@ -6,7 +6,6 @@
> >  endfunction()
> >
> >  add_subdirectory(clang-apply-replacements)
> > -add_subdirectory(clang-modernize)
> >  add_subdirectory(clang-rename)
> >  add_subdirectory(clang-query)
> >  add_subdirectory(clang-tidy)
> > Index: test/clang-modernize/UseNullptr/nullptr_t.cpp
> > ===================================================================
> > --- test/clang-modernize/UseNullptr/nullptr_t.cpp
> > +++ /dev/null
> > @@ -1,29 +0,0 @@
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -final-syntax-check -use-nullptr %t.cpp --
> --std=c++11 -I %S
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -
> > -namespace std {
> > -
> > -typedef decltype(nullptr) nullptr_t;
> > -
> > -} // namespace std
> > -
> > -// Just to make sure make_null() could have side effects.
> > -void external();
> > -
> > -std::nullptr_t make_null() {
> > -  external();
> > -  return nullptr;
> > -}
> > -
> > -void func() {
> > -  void *CallTest = make_null();
> > -  // CHECK: void *CallTest = make_null();
> > -
> > -  int var = 1;
> > -  void *CommaTest = (var+=2, make_null());
> > -  // CHECK: void *CommaTest = (var+=2, make_null());
> > -
> > -  int *CastTest = static_cast<int*>(make_null());
> > -  // CHECK: int *CastTest = static_cast<int*>(make_null());
> > -}
> > Index: test/clang-modernize/UseNullptr/macros.cpp
> > ===================================================================
> > --- test/clang-modernize/UseNullptr/macros.cpp
> > +++ /dev/null
> > @@ -1,164 +0,0 @@
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-nullptr %t.cpp -- -I %S
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t2.cpp
> > -// RUN: clang-modernize -use-nullptr -user-null-macros=MY_NULL %t2.cpp
> -- -I %S
> > -// RUN: FileCheck -check-prefix=USER-SUPPLIED-NULL -input-file=%t2.cpp
> %s
> > -
> > -#define NULL 0
> > -// CHECK: #define NULL 0
> > -
> > -void dummy(int*) {}
> > -void side_effect() {}
> > -
> > -#define MACRO_EXPANSION_HAS_NULL \
> > -  void foo() { \
> > -    dummy(0); \
> > -    dummy(NULL); \
> > -    side_effect(); \
> > -  }
> > -  // CHECK: void foo() { \
> > -  // CHECK-NEXT:   dummy(0); \
> > -  // CHECK-NEXT:   dummy(NULL); \
> > -
> > -MACRO_EXPANSION_HAS_NULL;
> > -// CHECK: MACRO_EXPANSION_HAS_NULL;
> > -#undef MACRO_EXPANSION_HAS_NULL
> > -
> > -
> > -void test_macro_expansion1() {
> > -#define MACRO_EXPANSION_HAS_NULL \
> > -  dummy(NULL); \
> > -  side_effect();
> > -  // CHECK: dummy(NULL); \
> > -  // CHECK-NEXT: side_effect();
> > -
> > -  MACRO_EXPANSION_HAS_NULL;
> > -  // CHECK: MACRO_EXPANSION_HAS_NULL;
> > -
> > -#undef MACRO_EXPANSION_HAS_NULL
> > -}
> > -
> > -// Test macro expansion with cast sequence, PR15572
> > -void test_macro_expansion2() {
> > -#define MACRO_EXPANSION_HAS_NULL \
> > -  dummy((int*)0); \
> > -  side_effect();
> > -  // CHECK: dummy((int*)0); \
> > -  // CHECK-NEXT: side_effect();
> > -
> > -  MACRO_EXPANSION_HAS_NULL;
> > -  // CHECK: MACRO_EXPANSION_HAS_NULL;
> > -
> > -#undef MACRO_EXPANSION_HAS_NULL
> > -}
> > -
> > -void test_macro_expansion3() {
> > -#define MACRO_EXPANSION_HAS_NULL \
> > -  dummy(NULL); \
> > -  side_effect();
> > -  // CHECK: dummy(NULL); \
> > -  // CHECK-NEXT: side_effect();
> > -
> > -#define OUTER_MACRO \
> > -  MACRO_EXPANSION_HAS_NULL; \
> > -  side_effect();
> > -
> > -  OUTER_MACRO;
> > -  // CHECK: OUTER_MACRO;
> > -
> > -#undef OUTER_MACRO
> > -#undef MACRO_EXPANSION_HAS_NULL
> > -}
> > -
> > -void test_macro_expansion4() {
> > -#define MY_NULL NULL
> > -  int *p = MY_NULL;
> > -  // CHECK: int *p = MY_NULL;
> > -  // USER-SUPPLIED-NULL: int *p = nullptr;
> > -#undef MY_NULL
> > -}
> > -
> > -#define IS_EQ(x, y) if (x != y) return;
> > -void test_macro_args() {
> > -  int i = 0;
> > -  int *Ptr;
> > -
> > -  IS_EQ(static_cast<int*>(0), Ptr);
> > -  // CHECK: IS_EQ(static_cast<int*>(nullptr), Ptr);
> > -  IS_EQ(0, Ptr);    // literal
> > -  // CHECK: IS_EQ(nullptr, Ptr);
> > -  IS_EQ(NULL, Ptr); // macro
> > -  // CHECK: IS_EQ(nullptr, Ptr);
> > -
> > -  // These are ok since the null literal is not spelled within a macro.
> > -#define myassert(x) if (!(x)) return;
> > -  myassert(0 == Ptr);
> > -  // CHECK: myassert(nullptr == Ptr);
> > -  myassert(NULL == Ptr);
> > -  // CHECK: myassert(nullptr == Ptr);
> > -
> > -  // These are bad as the null literal is buried in a macro.
> > -#define BLAH(X) myassert(0 == (X));
> > -  // CHECK: #define BLAH(X) myassert(0 == (X));
> > -#define BLAH2(X) myassert(NULL == (X));
> > -  // CHECK: #define BLAH2(X) myassert(NULL == (X));
> > -  BLAH(Ptr);
> > -  // CHECK: BLAH(Ptr);
> > -  BLAH2(Ptr);
> > -  // CHECK: BLAH2(Ptr);
> > -
> > -  // Same as above but testing extra macro expansion.
> > -#define EXPECT_NULL(X) IS_EQ(0, X);
> > -  // CHECK: #define EXPECT_NULL(X) IS_EQ(0, X);
> > -#define EXPECT_NULL2(X) IS_EQ(NULL, X);
> > -  // CHECK: #define EXPECT_NULL2(X) IS_EQ(NULL, X);
> > -  EXPECT_NULL(Ptr);
> > -  // CHECK: EXPECT_NULL(Ptr);
> > -  EXPECT_NULL2(Ptr);
> > -  // CHECK: EXPECT_NULL2(Ptr);
> > -
> > -  // Almost the same as above but now null literal is not in a macro so
> ok
> > -  // to transform.
> > -#define EQUALS_PTR(X) IS_EQ(X, Ptr);
> > -  EQUALS_PTR(0);
> > -  EQUALS_PTR(NULL);
> > -
> > -  // Same as above but testing extra macro expansion.
> > -#define EQUALS_PTR_I(X) EQUALS_PTR(X)
> > -  EQUALS_PTR_I(0);
> > -  // CHECK: EQUALS_PTR_I(nullptr);
> > -  EQUALS_PTR_I(NULL);
> > -  // CHECK: EQUALS_PTR_I(nullptr);
> > -
> > -  // Ok since null literal not within macro. However, now testing macro
> > -  // used as arg to another macro.
> > -#define decorate(EXPR) side_effect(); EXPR;
> > -  decorate(IS_EQ(NULL, Ptr));
> > -  // CHECK: decorate(IS_EQ(nullptr, Ptr));
> > -  decorate(IS_EQ(0, Ptr));
> > -  // CHECK: decorate(IS_EQ(nullptr, Ptr));
> > -
> > -  // This macro causes a NullToPointer cast to happen where 0 is
> assigned to z
> > -  // but the 0 literal cannot be replaced because it is also used as an
> > -  // integer in the comparison.
> > -#define INT_AND_PTR_USE(X) do { int *z = X; if (X == 4) break; }
> while(false)
> > -  INT_AND_PTR_USE(0);
> > -  // CHECK: INT_AND_PTR_USE(0);
> > -
> > -  // Both uses of X in this case result in NullToPointer casts so
> replacement
> > -  // is possible.
> > -#define PTR_AND_PTR_USE(X) do { int *z = X; if (X != z) break; }
> while(false)
> > -  PTR_AND_PTR_USE(0);
> > -  // CHECK: PTR_AND_PTR_USE(nullptr);
> > -  PTR_AND_PTR_USE(NULL);
> > -  // CHECK: PTR_AND_PTR_USE(nullptr);
> > -
> > -#define OPTIONAL_CODE(...) __VA_ARGS__
> > -#define NOT_NULL dummy(0)
> > -#define CALL(X) X
> > -  OPTIONAL_CODE(NOT_NULL);
> > -  // CHECK: OPTIONAL_CODE(NOT_NULL);
> > -  CALL(NOT_NULL);
> > -  // CHECK: CALL(NOT_NULL);
> > -}
> > Index: test/clang-modernize/UseNullptr/basic_failing.cpp
> > ===================================================================
> > --- test/clang-modernize/UseNullptr/basic_failing.cpp
> > +++ /dev/null
> > @@ -1,27 +0,0 @@
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-nullptr %t.cpp -- -I %S
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -// XFAIL: *
> > -
> > -#define NULL 0
> > -
> > -template <typename T>
> > -class A {
> > -public:
> > -  A(T *p = NULL) {}
> > -  // CHECK: A(T *p = nullptr) {}
> > -
> > -  void f() {
> > -    Ptr = NULL;
> > -    // CHECK: Ptr = nullptr;
> > -  }
> > -
> > -  T *Ptr;
> > -};
> > -
> > -template <typename T>
> > -T *f2(T *a = NULL) {
> > -  // CHECK: T *f2(T *a = nullptr) {
> > -  return a ? a : NULL;
> > -  // CHECK: return a ? a : nullptr;
> > -}
> > Index: test/clang-modernize/UseNullptr/basic.cpp
> > ===================================================================
> > --- test/clang-modernize/UseNullptr/basic.cpp
> > +++ /dev/null
> > @@ -1,291 +0,0 @@
> > -// RUN: mkdir -p %T/Inputs
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/basic.h > %T/Inputs/basic.h
> > -// RUN: clang-modernize -use-nullptr -include=%T %t.cpp -- -std=c++98
> -I %T -Wno-non-literal-null-conversion
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -// RUN: FileCheck -input-file=%T/Inputs/basic.h %S/Inputs/basic.h
> > -
> > -#include "Inputs/basic.h"
> > -
> > -const unsigned int g_null = 0;
> > -#define NULL 0
> > -// CHECK: #define NULL 0
> > -
> > -void test_assignment() {
> > -  int *p1 = 0;
> > -  // CHECK: int *p1 = nullptr;
> > -  p1 = 0;
> > -  // CHECK: p1 = nullptr;
> > -
> > -  int *p2 = NULL;
> > -  // CHECK: int *p2 = nullptr;
> > -
> > -  p2 = p1;
> > -  // CHECK: p2 = p1;
> > -
> > -  const int null = 0;
> > -  int *p3 = null;
> > -  // CHECK: int *p3 = nullptr;
> > -
> > -  p3 = NULL;
> > -  // CHECK: p3 = nullptr;
> > -
> > -  int *p4 = p3;
> > -  // CHECK: int *p4 = p3;
> > -
> > -  p4 = null;
> > -  // CHECK: p4 = nullptr;
> > -
> > -  int i1 = 0;
> > -  // CHECK: int i1 = 0;
> > -
> > -  int i2 = NULL;
> > -  // CHECK: int i2 = NULL;
> > -
> > -  int i3 = null;
> > -  // CHECK: int i3 = null;
> > -
> > -  int *p5, *p6, *p7;
> > -  p5 = p6 = p7 = NULL;
> > -  // CHECK: p5 = p6 = p7 = nullptr;
> > -}
> > -
> > -struct Foo {
> > -  Foo(int *p = NULL) : m_p1(p) {}
> > -  // CHECK: Foo(int *p = nullptr) : m_p1(p) {}
> > -
> > -  void bar(int *p = 0) {}
> > -  // CHECK: void bar(int *p = nullptr) {}
> > -
> > -  void baz(int i = 0) {}
> > -  // CHECK: void baz(int i = 0) {}
> > -
> > -  int *m_p1;
> > -  static int *m_p2;
> > -};
> > -
> > -int *Foo::m_p2 = NULL;
> > -// CHECK: int *Foo::m_p2 = nullptr;
> > -
> > -template <typename T>
> > -struct Bar {
> > -  Bar(T *p) : m_p(p) {
> > -    m_p = static_cast<T*>(NULL);
> > -    // CHECK: m_p = static_cast<T*>(nullptr);
> > -
> > -    m_p = static_cast<T*>(reinterpret_cast<int*>((void*)NULL));
> > -    // CHECK: m_p = static_cast<T*>(nullptr);
> > -
> > -    m_p = static_cast<T*>(p ? p : static_cast<void*>(g_null));
> > -    // CHECK: m_p = static_cast<T*>(p ? p :
> static_cast<void*>(nullptr));
> > -
> > -    T *p2 = static_cast<T*>(reinterpret_cast<int*>((void*)NULL));
> > -    // CHECK: T *p2 = static_cast<T*>(nullptr);
> > -
> > -    m_p = NULL;
> > -    // CHECK: m_p = nullptr;
> > -
> > -    int i = static_cast<int>(0.f);
> > -    // CHECK: int i = static_cast<int>(0.f);
> > -    T *i2 = static_cast<int>(0.f);
> > -    // CHECK: T *i2 = nullptr;
> > -  }
> > -
> > -  T *m_p;
> > -};
> > -
> > -struct Baz {
> > -  Baz() : i(0) {}
> > -  int i;
> > -};
> > -
> > -void test_cxx_cases() {
> > -  Foo f(g_null);
> > -  // CHECK: Foo f(nullptr);
> > -
> > -  f.bar(NULL);
> > -  // CHECK: f.bar(nullptr);
> > -
> > -  f.baz(g_null);
> > -  // CHECK: f.baz(g_null);
> > -
> > -  f.m_p1 = 0;
> > -  // CHECK: f.m_p1 = nullptr;
> > -
> > -  Bar<int> b(g_null);
> > -  // CHECK: Bar<int> b(nullptr);
> > -
> > -  Baz b2;
> > -  int Baz::*memptr(0);
> > -  // CHECK: int Baz::*memptr(nullptr);
> > -
> > -  memptr = 0;
> > -  // CHECK: memptr = nullptr;
> > -}
> > -
> > -void test_function_default_param1(void *p = 0);
> > -// CHECK: void test_function_default_param1(void *p = nullptr);
> > -
> > -void test_function_default_param2(void *p = NULL);
> > -// CHECK: void test_function_default_param2(void *p = nullptr);
> > -
> > -void test_function_default_param3(void *p = g_null);
> > -// CHECK: void test_function_default_param3(void *p = nullptr);
> > -
> > -void test_function(int *p) {}
> > -// CHECK: void test_function(int *p) {}
> > -
> > -void test_function_no_ptr_param(int i) {}
> > -
> > -void test_function_call() {
> > -  test_function(0);
> > -  // CHECK: test_function(nullptr);
> > -
> > -  test_function(NULL);
> > -  // CHECK: test_function(nullptr);
> > -
> > -  test_function(g_null);
> > -  // CHECK: test_function(nullptr);
> > -
> > -  test_function_no_ptr_param(0);
> > -  // CHECK: test_function_no_ptr_param(0);
> > -}
> > -
> > -char *test_function_return1() {
> > -  return 0;
> > -  // CHECK: return nullptr;
> > -}
> > -
> > -void *test_function_return2() {
> > -  return NULL;
> > -  // CHECK: return nullptr;
> > -}
> > -
> > -long *test_function_return3() {
> > -  return g_null;
> > -  // CHECK: return nullptr;
> > -}
> > -
> > -int test_function_return4() {
> > -  return 0;
> > -  // CHECK: return 0;
> > -}
> > -
> > -int test_function_return5() {
> > -  return NULL;
> > -  // CHECK: return NULL;
> > -}
> > -
> > -int test_function_return6() {
> > -  return g_null;
> > -  // CHECK: return g_null;
> > -}
> > -
> > -int *test_function_return_cast1() {
> > -  return(int)0;
> > -  // CHECK: return nullptr;
> > -}
> > -
> > -int *test_function_return_cast2() {
> > -  #define RET return
> > -  RET(int)0;
> > -  // CHECK: RET nullptr;
> > -  #undef RET
> > -}
> > -
> > -// Test parentheses expressions resulting in a nullptr.
> > -int *test_parentheses_expression1() {
> > -  return(0);
> > -  // CHECK: return(nullptr);
> > -}
> > -
> > -int *test_parentheses_expression2() {
> > -  return(int(0.f));
> > -  // CHECK: return(nullptr);
> > -}
> > -
> > -int *test_nested_parentheses_expression() {
> > -  return((((0))));
> > -  // CHECK: return((((nullptr))));
> > -}
> > -
> > -void *test_parentheses_explicit_cast() {
> > -  return(static_cast<void*>(0));
> > -  // CHECK: return(static_cast<void*>(nullptr));
> > -}
> > -
> > -void *test_parentheses_explicit_cast_sequence1() {
> > -  return(static_cast<void*>(static_cast<int*>((void*)NULL)));
> > -  // CHECK: return(static_cast<void*>(nullptr));
> > -}
> > -
> > -void *test_parentheses_explicit_cast_sequence2() {
> > -  return(static_cast<void*>(reinterpret_cast<int*>((float*)int(0.f))));
> > -  // CHECK: return(static_cast<void*>(nullptr));
> > -}
> > -
> > -// Test explicit cast expressions resulting in nullptr
> > -struct Bam {
> > -  Bam(int *a) {}
> > -  Bam(float *a) {}
> > -  Bam operator=(int *a) { return Bam(a); }
> > -  Bam operator=(float *a) { return Bam(a); }
> > -};
> > -
> > -void ambiguous_function(int *a) {}
> > -void ambiguous_function(float *a) {}
> > -void const_ambiguous_function(const int *p) {}
> > -void const_ambiguous_function(const float *p) {}
> > -
> > -void test_explicit_cast_ambiguous1() {
> > -  ambiguous_function((int*)0);
> > -  // CHECK: ambiguous_function((int*)nullptr);
> > -}
> > -
> > -void test_explicit_cast_ambiguous2() {
> > -  ambiguous_function((int*)(0));
> > -  // CHECK: ambiguous_function((int*)nullptr);
> > -}
> > -
> > -void test_explicit_cast_ambiguous3() {
> > -
> ambiguous_function(static_cast<int*>(reinterpret_cast<int*>((float*)0)));
> > -  // CHECK: ambiguous_function(static_cast<int*>(nullptr));
> > -}
> > -
> > -Bam test_explicit_cast_ambiguous4() {
> > -  return(((int*)(0)));
> > -  // CHECK: return(((int*)nullptr));
> > -}
> > -
> > -void test_explicit_cast_ambiguous5() {
> > -  // Test for ambiguous overloaded constructors
> > -  Bam k((int*)(0));
> > -  // CHECK: Bam k((int*)nullptr);
> > -
> > -  // Test for ambiguous overloaded operators
> > -  k = (int*)0;
> > -  // CHECK: k = (int*)nullptr;
> > -}
> > -
> > -void test_const_pointers_abiguous() {
> > -  const_ambiguous_function((int*)0);
> > -  // CHECK: const_ambiguous_function((int*)nullptr);
> > -}
> > -
> > -// Test where the implicit cast to null is surrounded by another
> implict cast
> > -// with possible explict casts in-between.
> > -void test_const_pointers() {
> > -  const int *const_p1 = 0;
> > -  // CHECK: const int *const_p1 = nullptr;
> > -  const int *const_p2 = NULL;
> > -  // CHECK: const int *const_p2 = nullptr;
> > -  const int *const_p3 = (int)0;
> > -  // CHECK: const int *const_p3 = nullptr;
> > -  const int *const_p4 = (int)0.0f;
> > -  // CHECK: const int *const_p4 = nullptr;
> > -  const int *const_p5 = (int*)0;
> > -  // CHECK: const int *const_p5 = (int*)nullptr;
> > -  int *t;
> > -  const int *const_p6 = static_cast<int*>(t ? t : static_cast<int*>(0));
> > -  // CHECK: const int *const_p6 = static_cast<int*>(t ? t :
> static_cast<int*>(nullptr));
> > -}
> > Index: test/clang-modernize/UseNullptr/Inputs/basic.h
> > ===================================================================
> > --- test/clang-modernize/UseNullptr/Inputs/basic.h
> > +++ /dev/null
> > @@ -1,2 +0,0 @@
> > -int *global_p = 0;
> > -// CHECK: int *global_p = nullptr;
> > Index: test/clang-modernize/UseAuto/new_cv_failing.cpp
> > ===================================================================
> > --- test/clang-modernize/UseAuto/new_cv_failing.cpp
> > +++ /dev/null
> > @@ -1,36 +0,0 @@
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp -- -std=c++11
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -// XFAIL: *
> > -
> > -// None of these tests can pass right now because TypeLoc information
> where CV
> > -// qualifiers are concerned is not reliable/available.
> > -
> > -class MyType {
> > -};
> > -
> > -int main (int argc, char **argv) {
> > -  const MyType *d = new MyType();
> > -  // CHECK: const auto *d = new MyType();
> > -
> > -  volatile MyType *d2 = new MyType();
> > -  // CHECK: volatile auto *d2 = new MyType();
> > -
> > -  const MyType * volatile e = new MyType();
> > -  // CHECK: const auto * volatile d = new MyType();
> > -
> > -  volatile MyType * const f = new MyType();
> > -  // CHECK: volatile auto * const d2 = new MyType();
> > -
> > -  const MyType *d5 = new const MyType();
> > -  // CHECK: auto d5 = new const MyType();
> > -
> > -  volatile MyType *d6 = new volatile MyType();
> > -  // CHECK: auto d6 = new volatile MyType();
> > -
> > -  const MyType * const d7 = new const MyType();
> > -  // CHECK: const auto d7 = new const MyType();
> > -
> > -  volatile MyType * volatile d8 = new volatile MyType();
> > -  // CHECK: volatile auto d8 = new volatile MyType();
> > -}
> > Index: test/clang-modernize/UseAuto/new.cpp
> > ===================================================================
> > --- test/clang-modernize/UseAuto/new.cpp
> > +++ /dev/null
> > @@ -1,97 +0,0 @@
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp -- -std=c++11
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -
> > -class MyType {
> > -};
> > -
> > -class MyDerivedType : public MyType {
> > -};
> > -
> > -int main(int argc, char **argv) {
> > -  MyType *a = new MyType();
> > -  // CHECK: auto a = new MyType();
> > -
> > -  static MyType *a_static = new MyType();
> > -  // CHECK: static auto a_static = new MyType();
> > -
> > -  MyType *b = new MyDerivedType();
> > -  // CHECK: MyType *b = new MyDerivedType();
> > -
> > -  void *c = new MyType();
> > -  // CHECK: void *c = new MyType();
> > -
> > -  // CV-qualifier tests.
> > -  //
> > -  // NOTE : the form "type const" is expected here because of a
> deficiency in
> > -  // TypeLoc where CV qualifiers are not considered part of the type
> location
> > -  // info. That is, all that is being replaced in each case is "MyType
> *" and
> > -  // not "MyType * const".
> > -  {
> > -    static MyType * const d_static = new MyType();
> > -    // CHECK: static auto const d_static = new MyType();
> > -
> > -    MyType * const d3 = new MyType();
> > -    // CHECK: auto const d3 = new MyType();
> > -
> > -    MyType * volatile d4 = new MyType();
> > -    // CHECK: auto volatile d4 = new MyType();
> > -  }
> > -
> > -  int (**func)(int, int) = new (int(*[5])(int,int));
> > -  // CHECK: int (**func)(int, int) = new (int(*[5])(int,int));
> > -
> > -  int *e = new int[5];
> > -  // CHECK: auto e = new int[5];
> > -
> > -  MyType *f(new MyType);
> > -  // CHECK: auto f(new MyType);
> > -
> > -  MyType *g{new MyType};
> > -  // CHECK: MyType *g{new MyType};
> > -
> > -  // Test for declaration lists.
> > -  {
> > -    MyType *a = new MyType(), *b = new MyType(), *c = new MyType();
> > -    // CHECK: auto a = new MyType(), b = new MyType(), c = new MyType();
> > -
> > -    // Non-initialized declaration should not be transformed.
> > -    MyType *d = new MyType(), *e;
> > -    // CHECK: MyType *d = new MyType(), *e;
> > -
> > -    MyType **f = new MyType*(), **g = new MyType*();
> > -    // CHECK: auto f = new MyType*(), g = new MyType*();
> > -
> > -    // Mismatching types in declaration lists should not be transformed.
> > -    MyType *h = new MyType(), **i = new MyType*();
> > -    // CHECK: MyType *h = new MyType(), **i = new MyType*();
> > -
> > -    // '*' shouldn't be removed in case of mismatching types with
> multiple
> > -    // declarations.
> > -    MyType *j = new MyType(), *k = new MyType(), **l = new MyType*();
> > -    // CHECK: MyType *j = new MyType(), *k = new MyType(), **l = new
> MyType*();
> > -  }
> > -
> > -  // Test for typedefs.
> > -  {
> > -    typedef int * int_p;
> > -
> > -    int_p a = new int;
> > -    // CHECK: auto a = new int;
> > -    int_p *b = new int*;
> > -    // CHECK: auto b = new int*;
> > -
> > -    // Test for typedefs in declarations lists.
> > -    int_p c = new int, d = new int;
> > -    // CHECK: auto c = new int, d = new int;
> > -
> > -    // Different types should not be transformed.
> > -    int_p e = new int, *f = new int_p;
> > -    // CHECK: int_p e = new int, *f = new int_p;
> > -
> > -    int_p *g = new int*, *h = new int_p;
> > -    // CHECK: auto g = new int*, h = new int_p;
> > -  }
> > -
> > -  return 0;
> > -}
> > Index: test/clang-modernize/UseAuto/iterator.cpp
> > ===================================================================
> > --- test/clang-modernize/UseAuto/iterator.cpp
> > +++ /dev/null
> > @@ -1,178 +0,0 @@
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp -- --std=c++11 -I %S/Inputs
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp -- --std=c++11 -I %S/Inputs \
> > -// RUN:   -DUSE_INLINE_NAMESPACE=1
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -
> > -
> > -#define CONTAINER array
> > -#include "test_std_container.h"
> > -#undef CONTAINER
> > -
> > -#define CONTAINER vector
> > -#include "test_std_container.h"
> > -#undef CONTAINER
> > -
> > -#define CONTAINER unordered_map
> > -#define USE_BASE_CLASS_ITERATORS 1
> > -#include "test_std_container.h"
> > -#undef USE_BASE_CLASS_ITERATORS
> > -#undef CONTAINER
> > -
> > -typedef std::vector<int>::iterator int_iterator;
> > -
> > -namespace foo {
> > -  template <typename T>
> > -  class vector {
> > -  public:
> > -    class iterator {};
> > -
> > -    iterator begin() { return iterator(); }
> > -  };
> > -} // namespace foo
> > -
> > -int main(int argc, char **argv) {
> > -  std::vector<int> Vec;
> > -  // CHECK: std::vector<int> Vec;
> > -
> > -  std::unordered_map<int> Map;
> > -  // CHECK: std::unordered_map<int> Map;
> > -
> > -  // Types with more sugar should work. Types with less should not.
> > -  {
> > -    int_iterator more_sugar = Vec.begin();
> > -    // CHECK: auto more_sugar = Vec.begin();
> > -
> > -    internal::iterator_wrapper<std::vector<int>, 0> less_sugar =
> Vec.begin();
> > -    // CHECK: internal::iterator_wrapper<std::vector<int>, 0>
> less_sugar = Vec.begin();
> > -  }
> > -
> > -  // Initialization from initializer lists isn't allowed. Using 'auto'
> > -  // would result in std::initializer_list being deduced for the type.
> > -  {
> > -    std::unordered_map<int>::iterator I{Map.begin()};
> > -    // CHECK: std::unordered_map<int>::iterator I{Map.begin()};
> > -
> > -    std::unordered_map<int>::iterator I2 = {Map.begin()};
> > -    // CHECK: std::unordered_map<int>::iterator I2 = {Map.begin()};
> > -  }
> > -
> > -  // Various forms of construction. Default constructors and
> constructors with
> > -  // all-default parameters shouldn't get transformed. Construction
> from other
> > -  // types is also not allowed.
> > -  {
> > -    std::unordered_map<int>::iterator copy(Map.begin());
> > -    // CHECK: auto copy(Map.begin());
> > -
> > -    std::unordered_map<int>::iterator def;
> > -    // CHECK: std::unordered_map<int>::iterator def;
> > -
> > -    // const_iterator has no default constructor, just one that has >0
> params
> > -    // with defaults.
> > -    std::unordered_map<int>::const_iterator constI;
> > -    // CHECK: std::unordered_map<int>::const_iterator constI;
> > -
> > -    // Uses iterator_provider::const_iterator's conversion constructor.
> > -
> > -    std::unordered_map<int>::const_iterator constI2 = def;
> > -    // CHECK: std::unordered_map<int>::const_iterator constI2 = def;
> > -
> > -    std::unordered_map<int>::const_iterator constI3(def);
> > -    // CHECK: std::unordered_map<int>::const_iterator constI3(def);
> > -
> > -    // Explicit use of conversion constructor
> > -
> > -    std::unordered_map<int>::const_iterator constI4 =
> std::unordered_map<int>::const_iterator(def);
> > -    // CHECK: auto constI4 =
> std::unordered_map<int>::const_iterator(def);
> > -
> > -    // Uses iterator_provider::iterator's const_iterator conversion
> operator.
> > -
> > -    std::unordered_map<int>::iterator I = constI;
> > -    // CHECK: std::unordered_map<int>::iterator I = constI;
> > -
> > -    std::unordered_map<int>::iterator I2(constI);
> > -    // CHECK: std::unordered_map<int>::iterator I2(constI);
> > -  }
> > -
> > -  // Weird cases of pointers and references to iterators are not
> transformed.
> > -  {
> > -    int_iterator I = Vec.begin();
> > -
> > -    int_iterator *IPtr = &I;
> > -    // CHECK: int_iterator *IPtr = &I;
> > -
> > -    int_iterator &IRef = I;
> > -    // CHECK: int_iterator &IRef = I;
> > -  }
> > -
> > -  {
> > -    // Variable declarations in iteration statements.
> > -    for (std::vector<int>::iterator I = Vec.begin(); I != Vec.end();
> ++I) {
> > -      // CHECK: for (auto I = Vec.begin(); I != Vec.end(); ++I) {
> > -    }
> > -
> > -    // Range-based for loops.
> > -    std::array<std::vector<int>::iterator> iter_arr;
> > -    for (std::vector<int>::iterator I: iter_arr) {
> > -      // CHECK: for (auto I: iter_arr) {
> > -    }
> > -
> > -    // Test with init-declarator-list.
> > -    for (int_iterator I = Vec.begin(),
> > -         E = Vec.end(); I != E; ++I) {
> > -      // CHECK:      for (auto I = Vec.begin(),
> > -      // CHECK-NEXT:      E = Vec.end(); I != E; ++I) {
> > -    }
> > -  }
> > -
> > -  // Only std containers should be changed.
> > -  {
> > -    using namespace foo;
> > -    vector<int> foo_vec;
> > -    vector<int>::iterator I = foo_vec.begin();
> > -    // CHECK: vector<int>::iterator I = foo_vec.begin();
> > -  }
> > -
> > -  // Ensure using directives don't interfere with replacement.
> > -  {
> > -    using namespace std;
> > -    vector<int> std_vec;
> > -    vector<int>::iterator I = std_vec.begin();
> > -    // CHECK: auto I = std_vec.begin();
> > -  }
> > -
> > -  // Make sure references and cv qualifiers don't get removed (i.e.
> replaced
> > -  // with just 'auto').
> > -  {
> > -    const auto & I = Vec.begin();
> > -    // CHECK: const auto & I = Vec.begin();
> > -
> > -    auto && I2 = Vec.begin();
> > -    // CHECK: auto && I2 = Vec.begin();
> > -  }
> > -
> > -  // Passing a string as an argument to introduce a temporary object
> > -  // that will create an expression with cleanups. Bugzilla: 15550
> > -  {
> > -    std::unordered_map<int> MapFind;
> > -    std::unordered_map<int>::iterator I = MapFind.find("foo");
> > -    // CHECK: auto I = MapFind.find("foo");
> > -  }
> > -
> > -  // Test for declaration lists
> > -  {
> > -    // Ensusre declaration lists that matches the declaration type with
> written
> > -    // no-list initializer are transformed.
> > -    std::vector<int>::iterator I = Vec.begin(), E = Vec.end();
> > -    // CHECK: auto I = Vec.begin(), E = Vec.end();
> > -
> > -    // Declaration lists with non-initialized variables should not be
> > -    // transformed.
> > -    std::vector<int>::iterator J = Vec.begin(), K;
> > -    // CHECK: std::vector<int>::iterator J = Vec.begin(), K;
> > -  }
> > -  return 0;
> > -}
> > Index: test/clang-modernize/UseAuto/basic_iterator_tests.cpp
> > ===================================================================
> > --- test/clang-modernize/UseAuto/basic_iterator_tests.cpp
> > +++ /dev/null
> > @@ -1,123 +0,0 @@
> > -// This file contains basic positive tests for the use-auto transform's
> ability
> > -// to replace standard iterators. Variables considered:
> > -// * All std container names
> > -// * All std iterator names
> > -// * Different patterns of defining iterators and containers
> > -//
> > -// // The most basic test.
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp -- -DCONTAINER=array -I
> %S/Inputs
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -//
> > -//
> > -// Test variations on how the container and its iterators might be
> defined.
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp -- -DCONTAINER=array \
> > -// RUN:   -DUSE_INLINE_NAMESPACE=1 -I %S/Inputs
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp -- -DCONTAINER=array \
> > -// RUN:   -DUSE_BASE_CLASS_ITERATORS=1 -I %S/Inputs
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp -- -DCONTAINER=array \
> > -// RUN:   -DUSE_INNER_CLASS_ITERATORS=1 -I %S/Inputs
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -//
> > -//
> > -// Test all of the other container names in a basic configuration.
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp -- -DCONTAINER=deque -I
> %S/Inputs
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp -- -DCONTAINER=forward_list -I
> %S/Inputs
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp -- -DCONTAINER=list -I
> %S/Inputs
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp -- -DCONTAINER=vector -I
> %S/Inputs
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp -- -DCONTAINER=map -I %S/Inputs
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp -- -DCONTAINER=multimap -I
> %S/Inputs
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp -- -DCONTAINER=set -I %S/Inputs
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp -- -DCONTAINER=multiset -I
> %S/Inputs
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp -- -DCONTAINER=unordered_map
> -I %S/Inputs
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp --
> -DCONTAINER=unordered_multimap -I %S/Inputs
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp -- -DCONTAINER=unordered_set
> -I %S/Inputs
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp --
> -DCONTAINER=unordered_multiset -I %S/Inputs
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp -- -DCONTAINER=queue -I
> %S/Inputs
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp -- -DCONTAINER=priority_queue
> -I %S/Inputs
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -use-auto %t.cpp -- -DCONTAINER=stack -I
> %S/Inputs
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -
> > -#ifndef CONTAINER
> > -#error You must define CONTAINER to the name of the container for
> testing.
> > -#endif
> > -
> > -#include "test_std_container.h"
> > -
> > -int main(int argc, char **argv) {
> > -  {
> > -    std::CONTAINER<int> C;
> > -    std::CONTAINER<int>::iterator I = C.begin();
> > -    // CHECK: auto I = C.begin();
> > -  }
> > -  {
> > -    std::CONTAINER<int> C;
> > -    std::CONTAINER<int>::reverse_iterator I = C.rbegin();
> > -    // CHECK: auto I = C.rbegin();
> > -  }
> > -  {
> > -    const std::CONTAINER<int> C;
> > -    std::CONTAINER<int>::const_iterator I = C.begin();
> > -    // CHECK: auto I = C.begin();
> > -  }
> > -  {
> > -    const std::CONTAINER<int> C;
> > -    std::CONTAINER<int>::const_reverse_iterator I = C.rbegin();
> > -    // CHECK: auto I = C.rbegin();
> > -  }
> > -
> > -  return 0;
> > -}
> > Index: test/clang-modernize/UseAuto/Inputs/test_std_container.h
> > ===================================================================
> > --- test/clang-modernize/UseAuto/Inputs/test_std_container.h
> > +++ /dev/null
> > @@ -1,119 +0,0 @@
> > -//===-----------------------------------------------------------*- C++
> -*--===//
> > -//
> > -// This file contains a shell implementation of a standard container
> with
> > -// iterators. This shell is targeted at supporting the container
> interfaces
> > -// recognized by clang-modernize's use-auto transformation. It requires
> the
> > -// preprocessor to parameterize the name of the container, and allows
> the
> > -// preprocessor to parameterize various mechanisms used in the
> implementation
> > -// of the container / iterator.
> > -//
> > -// Variations for how iterator types are presented:
> > -// * Typedef (array, deque, forward_list, list, vector)
> > -// * Nested class (map, multimap, set, multiset)
> > -// * Using declaration {unordered_} X {map, multimap, set, multiset}
> > -//
> > -// Variations for how container types are presented:
> > -// * Defined directly in namespace std
> > -// * Imported into namespace std with using declarations (a la libc++).
> > -//
> >
> -//===----------------------------------------------------------------------===//
> > -
> > -#ifndef CONTAINER
> > -#error You must define CONTAINER to the name of the desired container.
> > -#endif
> > -
> > -// If the test code needs multiple containers, only define our helpers
> once.
> > -#ifndef TEST_STD_CONTAINER_HELPERS
> > -#define TEST_STD_CONTAINER_HELPERS
> > -
> > -namespace internal {
> > -
> > -template <typename T, int i>
> > -struct iterator_wrapper {
> > -  iterator_wrapper() {}
> > -
> > -  // These are required for tests using iteration statements.
> > -  bool operator!=(const iterator_wrapper<T, i>&) { return false; }
> > -  iterator_wrapper& operator++() { return *this; }
> > -  typename T::value_type operator*() { return typename T::value_type();
> }
> > -};
> > -
> > -template <typename T>
> > -class iterator_provider {
> > -public:
> > -  class iterator {
> > -  public:
> > -    iterator() {}
> > -    iterator(const iterator&) {}
> > -  };
> > -  class const_iterator {
> > -  public:
> > -    const_iterator(int i=0) {}
> > -    const_iterator(const iterator &) {}
> > -    const_iterator(const const_iterator &) {}
> > -    operator iterator() { return iterator(); }
> > -  };
> > -  class reverse_iterator {};
> > -  class const_reverse_iterator {};
> > -};
> > -
> > -} // namespace internal
> > -
> > -#endif // TEST_STD_CONTAINER_HELPERS
> > -
> > -namespace std {
> > -
> > -#if USE_INLINE_NAMESPACE
> > -inline namespace _1 {
> > -#endif
> > -
> > -template <typename T>
> > -class CONTAINER
> > -#if USE_BASE_CLASS_ITERATORS
> > -  : internal::iterator_provider<CONTAINER<T> >
> > -#endif
> > -{
> > -public:
> > -
> > -#if USE_BASE_CLASS_ITERATORS
> > -  using typename internal::iterator_provider<CONTAINER<T> >::iterator;
> > -  using typename internal::iterator_provider<CONTAINER<T>
> >::const_iterator;
> > -  using typename internal::iterator_provider<CONTAINER<T>
> >::reverse_iterator;
> > -  using typename internal::iterator_provider<CONTAINER<T>
> >::const_reverse_iterator;
> > -#elif USE_INNER_CLASS_ITERATORS
> > -  class iterator {};
> > -  class const_iterator {};
> > -  class reverse_iterator {};
> > -  class const_reverse_iterator {};
> > -#else
> > -  typedef T value_type;
> > -  typedef typename internal::iterator_wrapper<CONTAINER<T>, 0> iterator;
> > -  typedef typename internal::iterator_wrapper<CONTAINER<T>, 1>
> const_iterator;
> > -  typedef typename internal::iterator_wrapper<CONTAINER<T>, 3>
> reverse_iterator;
> > -  typedef typename internal::iterator_wrapper<CONTAINER<T>, 2>
> const_reverse_iterator;
> > -#endif
> > -
> > -  // Every class requires these functions.
> > -  CONTAINER() {}
> > -
> > -  iterator begin() { return iterator(); }
> > -  iterator end() { return iterator(); }
> > -
> > -  const_iterator begin() const { return const_iterator(); }
> > -  const_iterator end() const { return const_iterator(); }
> > -
> > -  reverse_iterator rbegin() { return reverse_iterator(); }
> > -  reverse_iterator rend() { return reverse_iterator(); }
> > -
> > -  const_reverse_iterator rbegin() const { return
> const_reverse_iterator(); }
> > -  const_reverse_iterator rend() const { return
> const_reverse_iterator(); }
> > -
> > -  template <typename K>
> > -  iterator find(const K &Key) { return iterator(); }
> > -};
> > -
> > -#if USE_INLINE_NAMESPACE
> > -} // namespace _1
> > -#endif
> > -
> > -} // namespace std
> > Index: test/clang-modernize/ReplaceAutoPtr/template_fail.cpp
> > ===================================================================
> > --- test/clang-modernize/ReplaceAutoPtr/template_fail.cpp
> > +++ /dev/null
> > @@ -1,31 +0,0 @@
> > -// XFAIL: *
> > -//
> > -// Without inline namespace:
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -replace-auto_ptr %t.cpp -- -I %S/Inputs
> std=c++11
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -//
> > -// With inline namespace:
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -replace-auto_ptr %t.cpp -- -I %S/Inputs
> std=c++11 \
> > -// RUN:
>  -DUSE_INLINE_NAMESPACE=1
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -
> > -#include "memory_stub.h"
> > -
> > -// Fail to modify when the template is never instantiated.
> > -//
> > -// This might not be an issue. If it's never used it doesn't really
> matter if
> > -// it's changed or not. If it's a header and one of the source use it,
> then it
> > -// will still be changed.
> > -template <typename X>
> > -void f() {
> > -  std::auto_ptr<X> p;
> > -  // CHECK: std::unique_ptr<X> p;
> > -}
> > -
> > -// Alias template could be replaced if a matcher existed.
> > -template <typename T> using aaaaaaaa = auto_ptr<T>;
> > -// CHECK: template <typename T> using aaaaaaaa = unique_ptr<T>;
> > Index: test/clang-modernize/ReplaceAutoPtr/move.cpp
> > ===================================================================
> > --- test/clang-modernize/ReplaceAutoPtr/move.cpp
> > +++ /dev/null
> > @@ -1,63 +0,0 @@
> > -// Without inline namespace:
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -replace-auto_ptr %t.cpp -- -I %S/Inputs
> std=c++11
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -//
> > -// With inline namespace:
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: clang-modernize -replace-auto_ptr %t.cpp -- -I %S/Inputs
> std=c++11 \
> > -// RUN:
>  -DUSE_INLINE_NAMESPACE=1
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -
> > -#include "memory_stub.h"
> > -
> > -void takes_ownership_fn(std::auto_ptr<int> x);
> > -// CHECK: void takes_ownership_fn(std::unique_ptr<int> x);
> > -
> > -std::auto_ptr<int> get_by_value();
> > -// CHECK: std::unique_ptr<int> get_by_value();
> > -
> > -class Wrapper {
> > -public:
> > -  std::auto_ptr<int> &get_wrapped();
> > -
> > -private:
> > -  std::auto_ptr<int> wrapped;
> > -};
> > -
> > -void f() {
> > -  std::auto_ptr<int> a, b, c;
> > -  // CHECK: std::unique_ptr<int> a, b, c;
> > -  Wrapper wrapper_a, wrapper_b;
> > -
> > -  a = b;
> > -  // CHECK: a = std::move(b);
> > -
> > -  wrapper_a.get_wrapped() = wrapper_b.get_wrapped();
> > -  // CHECK: wrapper_a.get_wrapped() =
> std::move(wrapper_b.get_wrapped());
> > -
> > -  // Test that 'std::move()' is inserted when call to the
> > -  // copy-constructor are made.
> > -  takes_ownership_fn(c);
> > -  // CHECK: takes_ownership_fn(std::move(c));
> > -  takes_ownership_fn(wrapper_a.get_wrapped());
> > -  // CHECK: takes_ownership_fn(std::move(wrapper_a.get_wrapped()));
> > -
> > -  std::auto_ptr<int> d[] = { std::auto_ptr<int>(new int(1)),
> > -                             std::auto_ptr<int>(new int(2)) };
> > -  std::auto_ptr<int> e = d[0];
> > -  // CHECK: std::unique_ptr<int> d[] = { std::unique_ptr<int>(new
> int(1)),
> > -  // CHECK-NEXT:                         std::unique_ptr<int>(new
> int(2)) };
> > -  // CHECK-NEXT: std::unique_ptr<int> e = std::move(d[0]);
> > -
> > -  // Test that std::move() is not used when assigning an rvalue
> > -  std::auto_ptr<int> f;
> > -  f = std::auto_ptr<int>(new int(0));
> > -  // CHECK: std::unique_ptr<int> f;
> > -  // CHECK-NEXT: f = std::unique_ptr<int>(new int(0));
> > -
> > -  std::auto_ptr<int> g = get_by_value();
> > -  // CHECK: std::unique_ptr<int> g = get_by_value();
> > -}
> > Index: test/clang-modernize/ReplaceAutoPtr/basic.cpp
> > ===================================================================
> > --- test/clang-modernize/ReplaceAutoPtr/basic.cpp
> > +++ /dev/null
> > @@ -1,154 +0,0 @@
> > -// RUN: mkdir -p %T/Inputs
> > -//
> > -// Without inline namespace:
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/basic.h > %T/Inputs/basic.h
> > -// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/memory_stub.h >
> %T/Inputs/memory_stub.h
> > -// RUN: clang-modernize -include=%T -replace-auto_ptr %t.cpp -- \
> > -// RUN:               -std=c++11 -I %T
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -// RUN: FileCheck -input-file=%T/Inputs/basic.h %S/Inputs/basic.h
> > -//
> > -// With inline namespace:
> > -//
> > -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
> > -// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/basic.h > %T/Inputs/basic.h
> > -// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/memory_stub.h >
> %T/Inputs/memory_stub.h
> > -// RUN: clang-modernize -include=%T -replace-auto_ptr %t.cpp -- \
> > -// RUN:               -DUSE_INLINE_NAMESPACE=1 -std=c++11 -I %T
> > -// RUN: FileCheck -input-file=%t.cpp %s
> > -// RUN: FileCheck -input-file=%T/Inputs/basic.h %S/Inputs/basic.h
> > -
> > -#include "Inputs/basic.h"
> > -
> > -void f_1() {
> > -  std::auto_ptr<int> a;
> > -  // CHECK: std::unique_ptr<int> a;
> > -
> > -  // check that spaces aren't modified unnecessarily
> > -  std:: auto_ptr <int> b;
> > -  // CHECK: std:: unique_ptr <int> b;
> > -  std :: auto_ptr < char > c(new char());
> > -  // CHECK: std :: unique_ptr < char > c(new char());
> > -
> > -  // Test construction from a temporary
> > -  std::auto_ptr<char> d = std::auto_ptr<char>();
> > -  // CHECK: std::unique_ptr<char> d = std::unique_ptr<char>();
> > -
> > -  typedef std::auto_ptr<int> int_ptr_t;
> > -  // CHECK: typedef std::unique_ptr<int> int_ptr_t;
> > -  int_ptr_t e(new int());
> > -  // CHECK: int_ptr_t e(new int());
> > -
> > -  // Test pointers
> > -  std::auto_ptr<int> *f;
> > -  // CHECK: std::unique_ptr<int> *f;
> > -
> > -  // Test 'static' declarations
> > -  static std::auto_ptr<int> g;
> > -  // CHECK: static std::unique_ptr<int> g;
> > -
> > -  // Test with cv-qualifiers
> > -  const std::auto_ptr<int> h;
> > -  // CHECK: const std::unique_ptr<int> h;
> > -  volatile std::auto_ptr<int> i;
> > -  // CHECK: volatile std::unique_ptr<int> i;
> > -  const volatile std::auto_ptr<int> j;
> > -  // CHECK: const volatile std::unique_ptr<int> j;
> > -
> > -  // Test auto and initializer-list
> > -  auto k = std::auto_ptr<int>{};
> > -  // CHECK: auto k = std::unique_ptr<int>{};
> > -  std::auto_ptr<int> l{std::auto_ptr<int>()};
> > -  // CHECK: std::unique_ptr<int> l{std::unique_ptr<int>()};
> > -
> > -  // Test interlocked auto_ptr
> > -  std::auto_ptr<std::auto_ptr<int> > m;
> > -  // CHECK: std::unique_ptr<std::unique_ptr<int> > m;
> > -
> > -  // Test temporaries
> > -  std::auto_ptr<char>();
> > -  // CHECK: std::unique_ptr<char>();
> > -
> > -  // Test void-specialization
> > -  std::auto_ptr<void> n;
> > -  // CHECK: std::unique_ptr<void> n;
> > -
> > -  // Test template WITH instantiation (instantiation)
> > -  B<double> o;
> > -  std::auto_ptr<double> p(o.create());
> > -  // CHECK: std::unique_ptr<double> p(o.create());
> > -
> > -  // Test 'using' in a namespace ("definition")
> > -  ns_1::auto_ptr<int> q;
> > -  // CHECK: ns_1::unique_ptr<int> q;
> > -
> > -  // Test construction with an 'auto_ptr_ref'
> > -  std::auto_ptr<Base> r(create_derived_ptr());
> > -  // CHECK: std::unique_ptr<Base> r(create_derived_ptr());
> > -}
> > -
> > -// Test without the nested name specifiers
> > -void f_2() {
> > -  using namespace std;
> > -
> > -  auto_ptr<int> a;
> > -  // CHECK: unique_ptr<int> a;
> > -}
> > -
> > -// Test using declaration
> > -void f_3() {
> > -  using std::auto_ptr;
> > -  // CHECK: using std::unique_ptr;
> > -
> > -  auto_ptr<int> a;
> > -  // CHECK: unique_ptr<int> a;
> > -}
> > -
> > -// Test messing-up with macros
> > -void f_4() {
> > -#define MACRO_1 <char>
> > -  std::auto_ptr MACRO_1 p(new char());
> > -// CHECK: std::unique_ptr MACRO_1 p(new char());
> > -#define MACRO_2 auto_ptr
> > -  std::MACRO_2<int> q;
> > -// CHECK: #define MACRO_2 unique_ptr
> > -#define MACRO_3(Type) std::auto_ptr<Type>
> > -  MACRO_3(float)r(new float());
> > -// CHECK: #define MACRO_3(Type) std::unique_ptr<Type>
> > -#define MACRO_4 std::auto_ptr
> > -  using MACRO_4;
> > -// CHECK: #define MACRO_4 std::unique_ptr
> > -#undef MACRO_1
> > -#undef MACRO_2
> > -#undef MACRO_3
> > -#undef MACRO_4
> > -}
> > -
> > -// Test function return values (definition)
> > -std::auto_ptr<char> f_5()
> > -// CHECK: std::unique_ptr<char> f_5()
> > -{
> > -  // Test constructor
> > -  return std::auto_ptr<char>(new char());
> > -  // CHECK: return std::unique_ptr<char>(new char());
> > -}
> > -
> > -// Test that non-std auto_ptr aren't replaced
> > -void f_8() {
> > -  ns_2::auto_ptr<char> a;
> > -  // CHECK: ns_2::auto_ptr<char> a;
> > -  using namespace ns_2;
> > -  auto_ptr<int> b;
> > -  // CHECK: auto_ptr<int> b;
> > -}
> > -
> > -namespace std {
> > -template <typename T> using aaaaaaaa = auto_ptr<T>;
> > -}
> > -// We want to avoid replacing 'aaaaaaaa' by unique_ptr here. It's
> better to
> > -// change the type alias directly.
> > -// XXX: maybe another test will be more relevant to test this potential
> error.
> > -std::aaaaaaaa<int> d;
> > -// CHECK: std::aaaaaaaa<int> d;
> > Index: test/clang-modernize/ReplaceAutoPtr/Inputs/memory_stub.h
> > ===================================================================
> > --- test/clang-modernize/ReplaceAutoPtr/Inputs/memory_stub.h
> > +++ /dev/null
> > @@ -1,61 +0,0 @@
> > -//===-----------------------------------------------------------*- C++
> -*--===//
> > -//
> > -// This file contains a shell implementation of the 'auto_ptr' type
> from the
> > -// standard library. This shell aims to support the variations between
> standard
> > -// library implementations.
> > -//
> > -// Variations for how 'auto_ptr' is presented:
> > -// 1. Defined directly in namespace std
> > -// 2. Use a versioned inline namespace in std (default on libc++).
> > -//
> > -// Use the preprocessor to define USE_INLINE_NAMESPACE=1 and use the
> second
> > -// variation.
> > -//
> >
> -//===----------------------------------------------------------------------===//
> > -
> > -namespace std {
> > -
> > -#if USE_INLINE_NAMESPACE
> > -inline namespace _1 {
> > -#endif
> > -
> > -template <class Y> struct auto_ptr_ref {
> > -  Y *y_;
> > -};
> > -
> > -template <class X> class auto_ptr {
> > -public:
> > -  typedef X element_type;
> > -  // D.10.1.1 construct/copy/destroy:
> > -  explicit auto_ptr(X *p = 0) throw() {}
> > -  auto_ptr(auto_ptr &) throw() {}
> > -  template <class Y> auto_ptr(auto_ptr<Y> &) throw() {}
> > -  auto_ptr &operator=(auto_ptr &) throw() { return *this; }
> > -  template <class Y> auto_ptr &operator=(auto_ptr<Y> &) throw() {
> > -    return *this;
> > -  }
> > -  auto_ptr &operator=(auto_ptr_ref<X> r) throw() { return *this; }
> > -  ~auto_ptr() throw() {}
> > -  // D.10.1.3 conversions:
> > -  auto_ptr(auto_ptr_ref<X> r) throw() : x_(r.y_) {}
> > -  template <class Y> operator auto_ptr_ref<Y>() throw() {
> > -    auto_ptr_ref<Y> r;
> > -    r.y_ = x_;
> > -    return r;
> > -  }
> > -  template <class Y> operator auto_ptr<Y>() throw() { return
> auto_ptr<Y>(x_); }
> > -
> > -private:
> > -  X *x_;
> > -};
> > -
> > -template <> class auto_ptr<void> {
> > -public:
> > -  typedef void element_type;
> > -};
> > -
> > -#if USE_INLINE_NAMESPACE
> > -} // namespace _1
> > -#endif
> > -
> > -} // end namespace std
> > Index: test/clang-modernize/ReplaceAutoPtr/Inputs/basic.h
> > ===================================================================
> > --- test/clang-modernize/ReplaceAutoPtr/Inputs/basi...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151222/cb4f9e15/attachment-0001.html>


More information about the cfe-commits mailing list