r350934 - Implementation Feature Test Macros for P0722R3

2019-01-11 Thread Chris Kennelly via cfe-commits
Author: ckennelly
Date: Fri Jan 11 09:09:22 2019
New Revision: 350934

URL: http://llvm.org/viewvc/llvm-project?rev=350934&view=rev
Log:
Implementation Feature Test Macros for P0722R3

Summary:
P1353R0, adopted in San Diego, specified an implementation feature test macro 
for destroying delete (P0722R3).

The implementation of the feature (https://reviews.llvm.org/rL315662) is not 
guarded behind a flag, so the macro is not conditional on language version.

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D55741

Modified:
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Lexer/cxx-features.cpp
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=350934&r1=350933&r2=350934&view=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Fri Jan 11 09:09:22 2019
@@ -543,6 +543,7 @@ static void InitializeCPlusPlusFeatureTe
   // C++20 features.
   if (LangOpts.Char8)
 Builder.defineMacro("__cpp_char8_t", "201811L");
+  Builder.defineMacro("__cpp_impl_destroying_delete", "201806L");
 
   // TS features.
   if (LangOpts.ConceptsTS)

Modified: cfe/trunk/test/Lexer/cxx-features.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/cxx-features.cpp?rev=350934&r1=350933&r2=350934&view=diff
==
--- cfe/trunk/test/Lexer/cxx-features.cpp (original)
+++ cfe/trunk/test/Lexer/cxx-features.cpp Fri Jan 11 09:09:22 2019
@@ -34,6 +34,10 @@
 #error "wrong value for __cpp_char8_t"
 #endif
 
+#if check(impl_destroying_delete, 201806, 201806, 201806, 201806, 201806)
+#error "wrong value for __cpp_impl_destroying_delete"
+#endif
+
 // --- C++17 features ---
 
 #if check(hex_float, 0, 0, 0, 201603, 201603)

Modified: cfe/trunk/www/cxx_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=350934&r1=350933&r2=350934&view=diff
==
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Fri Jan 11 09:09:22 2019
@@ -1054,9 +1054,9 @@ and library features that are not part o
 Available in Clang?
  
 
-  SD-6: SG10 feature test recommendations
-  http://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations";>SD-6
-  N/A
+  SD-6: SG10 feature test recommendations
+  http://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations";>SD-6
+  N/A
   
 Clang 3.4 (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3745";>N3745)
   
@@ -1081,6 +1081,11 @@ and library features that are not part o
 Clang 7 (http://wg21.link/p0096r5";>P0096R5)
   
 
+
+  
+WIP (http://wg21.link/p1353r0";>P1353R0)
+  
+
 

[clang-tools-extra] 16622d5 - [clang-tidy] Recognize single character needles for absl::StrContains.

2020-12-08 Thread Chris Kennelly via cfe-commits

Author: Chris Kennelly
Date: 2020-12-08T10:01:30-05:00
New Revision: 16622d535c021b566c1304b6388a6399e606

URL: 
https://github.com/llvm/llvm-project/commit/16622d535c021b566c1304b6388a6399e606
DIFF: 
https://github.com/llvm/llvm-project/commit/16622d535c021b566c1304b6388a6399e606.diff

LOG: [clang-tidy] Recognize single character needles for absl::StrContains.

Commit fbdff6f3ae0b in the Abseil tree adds an overload for
absl::StrContains to accept a single character needle for optimized
lookups.

Reviewed By: hokein

Differential Revision: https://reviews.llvm.org/D92810

Added: 


Modified: 
clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp 
b/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp
index cd890e4837e0..977c1919cee3 100644
--- a/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp
@@ -31,6 +31,8 @@ using ::clang::transformer::makeRule;
 using ::clang::transformer::node;
 using ::clang::transformer::RewriteRule;
 
+AST_MATCHER(Type, isCharType) { return Node.isCharType(); }
+
 static const char DefaultStringLikeClasses[] = "::std::basic_string;"
"::std::basic_string_view;"
"::absl::string_view";
@@ -58,13 +60,15 @@ MakeRule(const LangOptions &LangOpts,
   hasUnqualifiedDesugaredType(recordType(hasDeclaration(StringLikeClass)));
   auto CharStarType =
   hasUnqualifiedDesugaredType(pointerType(pointee(isAnyCharacter(;
+  auto CharType = hasUnqualifiedDesugaredType(isCharType());
   auto StringNpos = declRefExpr(
   to(varDecl(hasName("npos"), hasDeclContext(StringLikeClass;
   auto StringFind = cxxMemberCallExpr(
   callee(cxxMethodDecl(
   hasName("find"),
-  hasParameter(0, parmVarDecl(anyOf(hasType(StringType),
-hasType(CharStarType)),
+  hasParameter(
+  0, parmVarDecl(anyOf(hasType(StringType), hasType(CharStarType),
+   hasType(CharType)),
   on(hasType(StringType)), hasArgument(0, 
expr().bind("parameter_to_find")),
   anyOf(hasArgument(1, integerLiteral(equals(0))),
 hasArgument(1, cxxDefaultArgExpr())),

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
index 9d4b03aa22f2..81a3fc4d3b97 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp
@@ -226,17 +226,21 @@ void string_literal_and_char_ptr_tests() {
   // CHECK-FIXES: {{^[[:space:]]*}}!absl::StrContains(asv, cc);{{$}}
 }
 
-// Confirms that it does *not* match when the parameter to find() is a char,
-// because absl::StrContains is not implemented for char.
-void no_char_param_tests() {
+void char_param_tests() {
   std::string ss;
   ss.find('c') == std::string::npos;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use !absl::StrContains instead of
+  // CHECK-FIXES: {{^[[:space:]]*}}!absl::StrContains(ss, 'c');{{$}}
 
   std::string_view ssv;
   ssv.find('c') == std::string_view::npos;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use !absl::StrContains instead of
+  // CHECK-FIXES: {{^[[:space:]]*}}!absl::StrContains(ssv, 'c');{{$}}
 
   absl::string_view asv;
   asv.find('c') == absl::string_view::npos;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use !absl::StrContains instead of
+  // CHECK-FIXES: {{^[[:space:]]*}}!absl::StrContains(asv, 'c');{{$}}
 }
 
 #define FOO(a, b, c, d) ((a).find(b) == std::string::npos ? (c) : (d))



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 8d2c095 - [clang-tidy] Omit std::make_unique/make_shared for default initialization.

2020-12-08 Thread Chris Kennelly via cfe-commits

Author: Chris Kennelly
Date: 2020-12-08T10:34:17-05:00
New Revision: 8d2c095e5a6bd34f8bb5cffd5c57c8deea5b8647

URL: 
https://github.com/llvm/llvm-project/commit/8d2c095e5a6bd34f8bb5cffd5c57c8deea5b8647
DIFF: 
https://github.com/llvm/llvm-project/commit/8d2c095e5a6bd34f8bb5cffd5c57c8deea5b8647.diff

LOG: [clang-tidy] Omit std::make_unique/make_shared for default initialization.

This extends the check for default initialization in arrays added in
547f89d6070 to include scalar types and exclude them from the suggested fix for
make_unique/make_shared.

Rewriting std::unique_ptr(new int) as std::make_unique() (or for
other, similar trivial T) switches from default initialization to value
initialization, a performance regression for trivial T.  For these use cases,
std::make_unique_for_overwrite is more suitable alternative.

Reviewed By: hokein

Differential Revision: https://reviews.llvm.org/D90392

Added: 

clang-tools-extra/test/clang-tidy/checkers/modernize-make-unique-default-init.cpp

Modified: 
clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.h
clang-tools-extra/docs/clang-tidy/checks/modernize-make-shared.rst
clang-tools-extra/docs/clang-tidy/checks/modernize-make-unique.rst
clang-tools-extra/test/clang-tidy/checkers/modernize-make-shared.cpp
clang-tools-extra/test/clang-tidy/checkers/modernize-make-unique.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
index c00067fa8257..a7aaca1de5bd 100644
--- a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -6,6 +6,7 @@
 //
 
//===--===//
 
+#include "../utils/TypeTraits.h"
 #include "MakeSharedCheck.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/Lexer.h"
@@ -49,13 +50,17 @@ MakeSmartPtrCheck::MakeSmartPtrCheck(StringRef Name, 
ClangTidyContext *Context,
   Options.get("MakeSmartPtrFunctionHeader", "")),
   MakeSmartPtrFunctionName(
   Options.get("MakeSmartPtrFunction", MakeSmartPtrFunctionName)),
-  IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {}
+  IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)),
+  IgnoreDefaultInitialization(
+  Options.get("IgnoreDefaultInitialization", true)) {}
 
 void MakeSmartPtrCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "IncludeStyle", Inserter.getStyle());
   Options.store(Opts, "MakeSmartPtrFunctionHeader", 
MakeSmartPtrFunctionHeader);
   Options.store(Opts, "MakeSmartPtrFunction", MakeSmartPtrFunctionName);
   Options.store(Opts, "IgnoreMacros", IgnoreMacros);
+  Options.store(Opts, "IgnoreDefaultInitialization",
+IgnoreDefaultInitialization);
 }
 
 bool MakeSmartPtrCheck::isLanguageVersionSupported(
@@ -120,14 +125,18 @@ void MakeSmartPtrCheck::check(const 
MatchFinder::MatchResult &Result) {
   if (New->getType()->getPointeeType()->getContainedAutoType())
 return;
 
-  // Be conservative for cases where we construct an array without any
-  // initialization.
+  // Be conservative for cases where we construct and default initialize.
+  //
   // For example,
+  //P.reset(new int)// check fix: P = std::make_unique()
   //P.reset(new int[5]) // check fix: P = std::make_unique(5)
   //
-  // The fix of the check has side effect, it introduces default initialization
+  // The fix of the check has side effect, it introduces value initialization
   // which maybe unexpected and cause performance regression.
-  if (New->isArray() && !New->hasInitializer())
+  bool Initializes = New->hasInitializer() ||
+ !utils::type_traits::isTriviallyDefaultConstructible(
+ New->getAllocatedType(), *Result.Context);
+  if (!Initializes && IgnoreDefaultInitialization)
 return;
   if (Construct)
 checkConstruct(SM, Result.Context, Construct, Type, New);

diff  --git a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.h 
b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.h
index 7a1bba624c53..ca12d7734162 100644
--- a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.h
+++ b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.h
@@ -50,6 +50,7 @@ class MakeSmartPtrCheck : public ClangTidyCheck {
   const std::string MakeSmartPtrFunctionHeader;
   const std::string MakeSmartPtrFunctionName;
   const bool IgnoreMacros;
+  const bool IgnoreDefaultInitialization;
 
   void checkConstruct(SourceManager &SM, ASTContext *Ctx,
   const CXXConstructExpr *Construct, const QualType *Type,

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/modernize-make-shared.rst 
b/clang-

[clang-tools-extra] 25f5406 - [clang-tidy] Extend bugprone-string-constructor-check to std::string_view.

2020-11-18 Thread Chris Kennelly via cfe-commits

Author: Chris Kennelly
Date: 2020-11-18T21:16:03-05:00
New Revision: 25f5406f087579d43ca9a82dee7f3e76f0691bad

URL: 
https://github.com/llvm/llvm-project/commit/25f5406f087579d43ca9a82dee7f3e76f0691bad
DIFF: 
https://github.com/llvm/llvm-project/commit/25f5406f087579d43ca9a82dee7f3e76f0691bad.diff

LOG: [clang-tidy] Extend bugprone-string-constructor-check to std::string_view.

This allows for matching the constructors std::string has in common with
std::string_view.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D91015

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp
clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.h
clang-tools-extra/docs/clang-tidy/checks/bugprone-string-constructor.rst
clang-tools-extra/test/clang-tidy/checkers/bugprone-string-constructor.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp
index 96d93a1d0413..6b23f7cd4a9c 100644
--- a/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "StringConstructorCheck.h"
+#include "../utils/OptionsUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Tooling/FixIt.h"
@@ -21,17 +22,36 @@ namespace {
 AST_MATCHER_P(IntegerLiteral, isBiggerThan, unsigned, N) {
   return Node.getValue().getZExtValue() > N;
 }
+
+const char DefaultStringNames[] =
+"::std::basic_string;::std::basic_string_view";
+
+static std::vector
+removeNamespaces(const std::vector &Names) {
+  std::vector Result;
+  Result.reserve(Names.size());
+  for (StringRef Name : Names) {
+std::string::size_type ColonPos = Name.rfind(':');
+Result.push_back(
+Name.substr(ColonPos == std::string::npos ? 0 : ColonPos + 1));
+  }
+  return Result;
+}
+
 } // namespace
 
 StringConstructorCheck::StringConstructorCheck(StringRef Name,
ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   WarnOnLargeLength(Options.get("WarnOnLargeLength", true)),
-  LargeLengthThreshold(Options.get("LargeLengthThreshold", 0x80)) {}
+  LargeLengthThreshold(Options.get("LargeLengthThreshold", 0x80)),
+  StringNames(utils::options::parseStringList(
+  Options.get("StringNames", DefaultStringNames))) {}
 
 void StringConstructorCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "WarnOnLargeLength", WarnOnLargeLength);
   Options.store(Opts, "LargeLengthThreshold", LargeLengthThreshold);
+  Options.store(Opts, "StringNames", DefaultStringNames);
 }
 
 void StringConstructorCheck::registerMatchers(MatchFinder *Finder) {
@@ -80,7 +100,8 @@ void StringConstructorCheck::registerMatchers(MatchFinder 
*Finder) {
   // parameters. [i.e. string (const char* s, size_t n);]
   Finder->addMatcher(
   cxxConstructExpr(
-  hasDeclaration(cxxMethodDecl(hasName("basic_string"))),
+  hasDeclaration(cxxConstructorDecl(ofClass(
+  cxxRecordDecl(hasAnyName(removeNamespaces(StringNames)),
   hasArgument(0, hasType(CharPtrType)),
   hasArgument(1, hasType(isInteger())),
   anyOf(
@@ -100,11 +121,17 @@ void StringConstructorCheck::registerMatchers(MatchFinder 
*Finder) {
   // Check the literal string constructor with char pointer.
   // [i.e. string (const char* s);]
   Finder->addMatcher(
-traverse(TK_AsIs,
-  cxxConstructExpr(hasDeclaration(cxxMethodDecl(hasName("basic_string"))),
-   hasArgument(0, expr().bind("from-ptr")),
-   hasArgument(1, unless(hasType(isInteger()
-  .bind("constructor")),
+  traverse(TK_AsIs,
+   cxxConstructExpr(
+   hasDeclaration(cxxConstructorDecl(ofClass(cxxRecordDecl(
+   hasAnyName(removeNamespaces(StringNames)),
+   hasArgument(0, expr().bind("from-ptr")),
+   // do not match std::string(ptr, int)
+   // match std::string(ptr, alloc)
+   // match std::string(ptr)
+   anyOf(hasArgument(1, unless(hasType(isInteger(,
+ argumentCountIs(1)))
+   .bind("constructor")),
   this);
 }
 

diff  --git a/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.h 
b/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.h
index 687f3b106fb4..50338f8abead 100644
--- a/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.h
@@ -32,6 +32,7 @@ class StringCons

[clang-tools-extra] e4f9b5d - [clang-tidy] Include std::basic_string_view in readability-redundant-string-init.

2020-11-20 Thread Chris Kennelly via cfe-commits

Author: Chris Kennelly
Date: 2020-11-20T10:06:57-05:00
New Revision: e4f9b5d442a260dd78b3de581cec1e90567a2aac

URL: 
https://github.com/llvm/llvm-project/commit/e4f9b5d442a260dd78b3de581cec1e90567a2aac
DIFF: 
https://github.com/llvm/llvm-project/commit/e4f9b5d442a260dd78b3de581cec1e90567a2aac.diff

LOG: [clang-tidy] Include std::basic_string_view in 
readability-redundant-string-init.

std::string_view("") produces a string_view instance that compares
equal to std::string_view(), but requires more complex initialization
(storing the address of the string literal, rather than zeroing).

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D91009

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst

clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst

clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
index e5825bc4f0e3..24defc80f161 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
@@ -18,7 +18,8 @@ namespace clang {
 namespace tidy {
 namespace readability {
 
-const char DefaultStringNames[] = "::std::basic_string";
+const char DefaultStringNames[] =
+"::std::basic_string_view;::std::basic_string";
 
 static ast_matchers::internal::Matcher
 hasAnyNameStdString(std::vector Names) {

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index cc9de109900b..5e78de2b0edc 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -152,6 +152,11 @@ Changes in existing checks
 - Removed `google-runtime-references` check because the rule it checks does
   not exist in the Google Style Guide anymore.
 
+- Improved :doc:`readability-redundant-string-init
+  ` check.
+
+  Added `std::basic_string_view` to default list of ``string``-like types.
+
 Improvements to include-fixer
 -
 

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst
index c4556887f89a..dc3dfacb15d5 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst
@@ -19,12 +19,21 @@ Examples
   std::string a;
   std::string b;
 
+  // Initializing a string_view with an empty string literal produces an
+  // instance that compares equal to string_view().
+  std::string_view a = "";
+  std::string_view b("");
+
+  // becomes
+  std::string_view a;
+  std::string_view b;
+
 Options
 ---
 
 .. option:: StringNames
 
-Default is `::std::basic_string`.
+Default is `::std::basic_string;::std::basic_string_view`.
 
 Semicolon-delimited list of class names to apply this check to.
 By default `::std::basic_string` applies to ``std::string`` and

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
index c33d1a7d5f2a..ed3d90ca307e 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
@@ -1,7 +1,7 @@
 // RUN: %check_clang_tidy -std=c++11,c++14 %s 
readability-redundant-string-init %t \
 // RUN:   -config="{CheckOptions: \
 // RUN: [{key: readability-redundant-string-init.StringNames, \
-// RUN:   value: '::std::basic_string;our::TestString'}] \
+// RUN:   value: 
'::std::basic_string;::std::basic_string_view;our::TestString'}] \
 // RUN: }"
 // FIXME: Fix the checker to work in C++17 mode.
 
@@ -19,6 +19,20 @@ struct basic_string {
 };
 typedef basic_string string;
 typedef basic_string wstring;
+
+template , typename A = 
std::allocator>
+struct basic_string_view {
+  using size_type = decltype(sizeof(0));
+
+  basic_string_view();
+  basic_string_view(const basic_string_view &);
+  basic_string_view(const C *, size_type);
+  basic_string_view(const C *);
+  template 
+  basic_string_view(It, End);
+};
+typedef basic_string_view string_view;
+typedef basic_string_view wstring_view;
 }
 
 void f() {
@@ -48,6 +62,33 @@ void f() {
   std::string z;
 }
 
+void fview() {
+  std::string_view a = "";
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: redundant string initialization 
[readability-redundant-string-init]
+  // CHECK-FIXES: std::string_view a;
+  std::str