<div dir="ltr">Kirill, FYI.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 25, 2016 at 3:21 AM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Wed, Feb 24, 2016 at 5:36 AM, Alexander Kornienko via cfe-commits<br>
<<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br>
> Author: alexfh<br>
> Date: Wed Feb 24 07:36:34 2016<br>
> New Revision: 261738<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=261738&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=261738&view=rev</a><br>
> Log:<br>
> [clang-tidy] introduce modernize-deprecated-headers check<br>
><br>
> Summary:<br>
> This patch introduces the modernize-deprecated-headers check, which is supposed to replace deprecated C library headers with the C++ STL-ones.<br>
><br>
> For information see documentation; for exmaples see the test cases.<br>
><br>
> Reviewers: Eugene.Zelenko, LegalizeAdulthood, alexfh<br>
><br>
> Subscribers: cfe-commits<br>
><br>
> Patch by Kirill Bobyrev!<br>
><br>
> Differential Revision: <a href="http://reviews.llvm.org/D17484" rel="noreferrer" target="_blank">http://reviews.llvm.org/D17484</a><br>
><br>
> Added:<br>
>     clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp<br>
>     clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h<br>
>     clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-deprecated-headers.rst<br>
>     clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp<br>
>     clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp<br>
> Modified:<br>
>     clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt<br>
>     clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp<br>
>     clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst<br>
><br>
> Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=261738&r1=261737&r2=261738&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=261738&r1=261737&r2=261738&view=diff</a><br>
> ==============================================================================<br>
> --- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)<br>
> +++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Wed Feb 24 07:36:34 2016<br>
> @@ -1,6 +1,7 @@<br>
>  set(LLVM_LINK_COMPONENTS support)<br>
><br>
>  add_clang_library(clangTidyModernizeModule<br>
> +  DeprecatedHeadersCheck.cpp<br>
>    LoopConvertCheck.cpp<br>
>    LoopConvertUtils.cpp<br>
>    MakeUniqueCheck.cpp<br>
><br>
> Added: clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp?rev=261738&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp?rev=261738&view=auto</a><br>
> ==============================================================================<br>
> --- clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp (added)<br>
> +++ clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp Wed Feb 24 07:36:34 2016<br>
> @@ -0,0 +1,110 @@<br>
> +//===--- DeprecatedHeadersCheck.cpp - clang-tidy---------------------------===//<br>
> +//<br>
> +//                     The LLVM Compiler Infrastructure<br>
> +//<br>
> +// This file is distributed under the University of Illinois Open Source<br>
> +// License. See LICENSE.TXT for details.<br>
> +//<br>
> +//===----------------------------------------------------------------------===//<br>
> +<br>
> +#include "DeprecatedHeadersCheck.h"<br>
> +#include "clang/Frontend/CompilerInstance.h"<br>
> +#include "clang/Lex/PPCallbacks.h"<br>
> +#include "clang/Lex/Preprocessor.h"<br>
> +#include "llvm/ADT/StringMap.h"<br>
> +<br>
> +#include <vector><br>
> +<br>
> +namespace clang {<br>
> +namespace tidy {<br>
> +namespace modernize {<br>
> +<br>
> +namespace {<br>
> +class IncludeModernizePPCallbacks : public PPCallbacks {<br>
> +public:<br>
> +  explicit IncludeModernizePPCallbacks(ClangTidyCheck &Check,<br>
> +                                       LangOptions LangOpts);<br>
> +<br>
> +  void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,<br>
> +                          StringRef FileName, bool IsAngled,<br>
> +                          CharSourceRange FilenameRange, const FileEntry *File,<br>
> +                          StringRef SearchPath, StringRef RelativePath,<br>
> +                          const Module *Imported) override;<br>
> +<br>
> +private:<br>
> +  ClangTidyCheck &Check;<br>
> +  LangOptions LangOpts;<br>
> +  llvm::StringMap<std::string> CStyledHeaderToCxx;<br>
> +};<br>
> +} // namespace<br>
> +<br>
> +void DeprecatedHeadersCheck::registerPPCallbacks(CompilerInstance &Compiler) {<br>
> +  if (this->getLangOpts().CPlusPlus) {<br>
> +    Compiler.getPreprocessor().addPPCallbacks(<br>
> +        ::llvm::make_unique<IncludeModernizePPCallbacks>(*this,<br>
> +                                                         this->getLangOpts()));<br>
> +  }<br>
> +}<br>
> +<br>
> +IncludeModernizePPCallbacks::IncludeModernizePPCallbacks(ClangTidyCheck &Check,<br>
> +                                                         LangOptions LangOpts)<br>
> +    : Check(Check), LangOpts(LangOpts),<br>
> +      CStyledHeaderToCxx({{"assert.h", "cassert"},<br>
> +                          {"complex.h", "ccomplex"},<br>
<br>
</div></div>It'd be better to convert this one to <complex>, or leave it alone.<br>
<ccomplex> is an unnecessary wart.<br>
<br>
(The contents of C++11's <complex.h> / <ccomplex> / <complex> (all of<br>
which are identical) aren't comparable to C99's <complex.h>, so if<br>
this was C++98 code using the C99 header, the code will be broken with<br>
or without this transformation.)<br>
<span class=""><br>
> +                          {"ctype.h", "cctype"},<br>
> +                          {"errno.h", "cerrno"},<br>
> +                          {"float.h", "cfloat"},<br>
> +                          {"inttypes.h", "cinttypes"},<br>
<br>
> +                          {"iso646.h", "ciso646"},<br>
<br>
</span>Just delete #includes of this one. <ciso646> does nothing.<br>
<span class=""><br>
> +                          {"limits.h", "climits"},<br>
> +                          {"locale.h", "clocale"},<br>
> +                          {"math.h", "cmath"},<br>
> +                          {"setjmp.h", "csetjmp"},<br>
> +                          {"signal.h", "csignal"},<br>
> +                          {"stdarg.h", "cstdarg"},<br>
> +                          {"stddef.h", "cstddef"},<br>
> +                          {"stdint.h", "cstdint"},<br>
> +                          {"stdio.h", "cstdio"},<br>
> +                          {"stdlib.h", "cstdlib"},<br>
> +                          {"string.h", "cstring"},<br>
> +                          {"time.h", "ctime"},<br>
> +                          {"wchar.h", "cwchar"},<br>
> +                          {"wctype.h", "cwctype"}}) {<br>
> +  // Add C++ 11 headers.<br>
> +  if (LangOpts.CPlusPlus11) {<br>
> +    for (const auto &it : std::vector<std::pair<std::string, std::string>>(<br>
> +             {{"fenv.h", "cfenv"},<br>
<br>
> +              {"stdalign.h", "cstdalign"},<br>
> +              {"stdbool.h", "cstdbool"},<br>
<br>
</span>We should just delete these two includes. These headers do nothing in C++.<br>
<span class=""><br>
> +              {"tgmath.h", "ctgmath"},<br>
<br>
</span>This one is pretty broken, but transitioning to <ctgmath> is better<br>
than nothing.<br>
<div class="HOEnZb"><div class="h5"><br>
> +              {"uchar.h", "cuchar"}})) {<br>
> +      CStyledHeaderToCxx.insert(it);<br>
> +    }<br>
> +  }<br>
> +}<br>
> +<br>
> +void IncludeModernizePPCallbacks::InclusionDirective(<br>
> +    SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,<br>
> +    bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File,<br>
> +    StringRef SearchPath, StringRef RelativePath, const Module *Imported) {<br>
> +  // FIXME: Take care of library symbols from the global namespace.<br>
> +  //<br>
> +  // Reasonable options for the check:<br>
> +  //<br>
> +  // 1. Insert std prefix for every such symbol occurance.<br>
> +  // 2. Insert `using namespace std;` to the beginning of TU.<br>
> +  // 3. Do nothing and let the user deal with the migration himself.<br>
> +  if (CStyledHeaderToCxx.count(FileName) != 0) {<br>
> +    std::string Replacement =<br>
> +        (llvm::Twine("<") + CStyledHeaderToCxx[FileName] + ">").str();<br>
> +    Check.diag(FilenameRange.getBegin(),<br>
> +               "inclusion of deprecated C++ header '%0'; consider using '%1' instead")<br>
> +        << FileName << CStyledHeaderToCxx[FileName]<br>
> +        << FixItHint::CreateReplacement(FilenameRange.getAsRange(),<br>
> +                                        Replacement);<br>
> +  }<br>
> +}<br>
> +<br>
> +} // namespace modernize<br>
> +} // namespace tidy<br>
> +} // namespace clang<br>
><br>
> Added: clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h?rev=261738&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h?rev=261738&view=auto</a><br>
> ==============================================================================<br>
> --- clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h (added)<br>
> +++ clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h Wed Feb 24 07:36:34 2016<br>
> @@ -0,0 +1,42 @@<br>
> +//===--- DeprecatedHeadersCheck.h - clang-tidy-------------------*- C++ -*-===//<br>
> +//<br>
> +//                     The LLVM Compiler Infrastructure<br>
> +//<br>
> +// This file is distributed under the University of Illinois Open Source<br>
> +// License. See LICENSE.TXT for details.<br>
> +//<br>
> +//===----------------------------------------------------------------------===//<br>
> +<br>
> +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_C_HEADERS_TO_CXX_H<br>
> +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_C_HEADERS_TO_CXX_H<br>
> +<br>
> +#include "../ClangTidy.h"<br>
> +<br>
> +namespace clang {<br>
> +namespace tidy {<br>
> +namespace modernize {<br>
> +<br>
> +/// This check replaces deprecated C library headers with their C++ STL<br>
> +/// alternatives.<br>
> +///<br>
> +/// Before:<br>
> +///   #include <header.h><br>
> +/// After:<br>
> +///   #include <cheader><br>
> +///<br>
> +/// Example: <stdio.h> => <cstdio><br>
> +///<br>
> +/// For the user-facing documentation see:<br>
> +/// <a href="http://clang.llvm.org/extra/clang-tidy/checks/modernize-deprecated-headers.html" rel="noreferrer" target="_blank">http://clang.llvm.org/extra/clang-tidy/checks/modernize-deprecated-headers.html</a><br>
> +class DeprecatedHeadersCheck : public ClangTidyCheck {<br>
> +public:<br>
> +  DeprecatedHeadersCheck(StringRef Name, ClangTidyContext *Context)<br>
> +      : ClangTidyCheck(Name, Context) {}<br>
> +  void registerPPCallbacks(CompilerInstance &Compiler) override;<br>
> +};<br>
> +<br>
> +} // namespace modernize<br>
> +} // namespace tidy<br>
> +} // namespace clang<br>
> +<br>
> +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_C_HEADERS_TO_CXX_H<br>
><br>
> Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=261738&r1=261737&r2=261738&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=261738&r1=261737&r2=261738&view=diff</a><br>
> ==============================================================================<br>
> --- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp (original)<br>
> +++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Wed Feb 24 07:36:34 2016<br>
> @@ -10,6 +10,7 @@<br>
>  #include "../ClangTidy.h"<br>
>  #include "../ClangTidyModule.h"<br>
>  #include "../ClangTidyModuleRegistry.h"<br>
> +#include "DeprecatedHeadersCheck.h"<br>
>  #include "LoopConvertCheck.h"<br>
>  #include "MakeUniqueCheck.h"<br>
>  #include "PassByValueCheck.h"<br>
> @@ -30,6 +31,8 @@ namespace modernize {<br>
>  class ModernizeModule : public ClangTidyModule {<br>
>  public:<br>
>    void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {<br>
> +    CheckFactories.registerCheck<DeprecatedHeadersCheck>(<br>
> +        "modernize-deprecated-headers");<br>
>      CheckFactories.registerCheck<LoopConvertCheck>("modernize-loop-convert");<br>
>      CheckFactories.registerCheck<MakeUniqueCheck>("modernize-make-unique");<br>
>      CheckFactories.registerCheck<PassByValueCheck>("modernize-pass-by-value");<br>
><br>
> Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst?rev=261738&r1=261737&r2=261738&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst?rev=261738&r1=261737&r2=261738&view=diff</a><br>
> ==============================================================================<br>
> --- clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst (original)<br>
> +++ clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Wed Feb 24 07:36:34 2016<br>
> @@ -74,6 +74,7 @@ Clang-Tidy Checks<br>
>     misc-unused-parameters<br>
>     misc-unused-raii<br>
>     misc-virtual-near-miss<br>
> +   modernize-deprecated-headers<br>
>     modernize-loop-convert<br>
>     modernize-make-unique<br>
>     modernize-pass-by-value<br>
><br>
> Added: clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-deprecated-headers.rst<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-deprecated-headers.rst?rev=261738&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-deprecated-headers.rst?rev=261738&view=auto</a><br>
> ==============================================================================<br>
> --- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-deprecated-headers.rst (added)<br>
> +++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-deprecated-headers.rst Wed Feb 24 07:36:34 2016<br>
> @@ -0,0 +1,45 @@<br>
> +.. title:: clang-tidy - modernize-deprecated-headers<br>
> +<br>
> +modernize-deprecated-headers<br>
> +==========================<br>
> +<br>
> +Some headers from C library were deprecated in C++ and are no longer welcome in<br>
> +C++ codebases. For more details refer to the C++ 14 Standard [depr.c.headers]<br>
> +section.<br>
> +<br>
> +This check replaces C standard library headers with their C++ alternatives.<br>
> +<br>
> +Improtant note: the Standard doesn't guarantee that the C++ headers declare all<br>
> +the same functions in the global namespace. The check in its current form can<br>
> +break the code that uses library symbols from the global namespace.<br>
> +<br>
> +* `<assert.h>`<br>
> +* `<complex.h>`<br>
> +* `<ctype.h>`<br>
> +* `<errno.h>`<br>
> +* `<fenv.h>`     // deprecated since C++11<br>
> +* `<float.h>`<br>
> +* `<inttypes.h>`<br>
> +* `<iso646.h>`<br>
> +* `<limits.h>`<br>
> +* `<locale.h>`<br>
> +* `<math.h>`<br>
> +* `<setjmp.h>`<br>
> +* `<signal.h>`<br>
> +* `<stdalign.h>` // deprecated since C++11<br>
> +* `<stdarg.h>`<br>
> +* `<stdbool.h>`  // deprecated since C++11<br>
> +* `<stddef.h>`<br>
> +* `<stdint.h>`<br>
> +* `<stdio.h>`<br>
> +* `<stdlib.h>`<br>
> +* `<string.h>`<br>
> +* `<tgmath.h>`   // deprecated since C++11<br>
> +* `<time.h>`<br>
> +* `<uchar.h>`    // deprecated since C++11<br>
> +* `<wchar.h>`<br>
> +* `<wctype.h>`<br>
> +<br>
> +If the specified standard is older than C++11 the check will only replace<br>
> +headers deprecated before C++11, otherwise -- every header that appeared in<br>
> +the list.<br>
><br>
> Added: clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp?rev=261738&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp?rev=261738&view=auto</a><br>
> ==============================================================================<br>
> --- clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp (added)<br>
> +++ clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp Wed Feb 24 07:36:34 2016<br>
> @@ -0,0 +1,147 @@<br>
> +// RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- -- -std=c++03 -isystem %S/Inputs/Headers<br>
> +<br>
> +#include <assert.h><br>
> +#include <complex.h><br>
> +#include <ctype.h><br>
> +#include <errno.h><br>
> +#include <float.h><br>
> +#include <inttypes.h><br>
> +#include <iso646.h><br>
> +#include <limits.h><br>
> +#include <locale.h><br>
> +#include <math.h><br>
> +#include <setjmp.h><br>
> +#include <signal.h><br>
> +#include <stdarg.h><br>
> +#include <stddef.h><br>
> +#include <stdint.h><br>
> +#include <stdio.h><br>
> +#include <stdlib.h><br>
> +#include <string.h><br>
> +#include <time.h><br>
> +#include <wchar.h><br>
> +#include <wctype.h><br>
> +<br>
> +// Headers deprecated since C++11: expect no diagnostics.<br>
> +#include <fenv.h><br>
> +#include <stdalign.h><br>
> +#include <stdbool.h><br>
> +#include <tgmath.h><br>
> +#include <uchar.h><br>
> +<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'complex.h'; consider using 'ccomplex' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'ctype.h'; consider using 'cctype' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'errno.h'; consider using 'cerrno' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'float.h'; consider using 'cfloat' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'inttypes.h'; consider using 'cinttypes' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'iso646.h'; consider using 'ciso646' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'limits.h'; consider using 'climits' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'locale.h'; consider using 'clocale' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'setjmp.h'; consider using 'csetjmp' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'signal.h'; consider using 'csignal' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'stdarg.h'; consider using 'cstdarg' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'stddef.h'; consider using 'cstddef' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'stdint.h'; consider using 'cstdint' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'stdio.h'; consider using 'cstdio' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'stdlib.h'; consider using 'cstdlib' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'string.h'; consider using 'cstring' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'time.h'; consider using 'ctime' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'wchar.h'; consider using 'cwchar' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'wctype.h'; consider using 'cwctype' instead<br>
> +<br>
> +// CHECK-FIXES: #include <cassert><br>
> +// CHECK-FIXES: #include <ccomplex><br>
> +// CHECK-FIXES: #include <cctype><br>
> +// CHECK-FIXES: #include <cerrno><br>
> +// CHECK-FIXES: #include <cfloat><br>
> +// CHECK-FIXES: #include <cinttypes><br>
> +// CHECK-FIXES: #include <ciso646><br>
> +// CHECK-FIXES: #include <climits><br>
> +// CHECK-FIXES: #include <clocale><br>
> +// CHECK-FIXES: #include <cmath><br>
> +// CHECK-FIXES: #include <csetjmp><br>
> +// CHECK-FIXES: #include <csignal><br>
> +// CHECK-FIXES: #include <cstdarg><br>
> +// CHECK-FIXES: #include <cstddef><br>
> +// CHECK-FIXES: #include <cstdint><br>
> +// CHECK-FIXES: #include <cstdio><br>
> +// CHECK-FIXES: #include <cstdlib><br>
> +// CHECK-FIXES: #include <cstring><br>
> +// CHECK-FIXES: #include <ctime><br>
> +// CHECK-FIXES: #include <cwchar><br>
> +// CHECK-FIXES: #include <cwctype><br>
> +<br>
> +#include "assert.h"<br>
> +#include "complex.h"<br>
> +#include "ctype.h"<br>
> +#include "errno.h"<br>
> +#include "float.h"<br>
> +#include "inttypes.h"<br>
> +#include "iso646.h"<br>
> +#include "limits.h"<br>
> +#include "locale.h"<br>
> +#include "math.h"<br>
> +#include "setjmp.h"<br>
> +#include "signal.h"<br>
> +#include "stdarg.h"<br>
> +#include "stddef.h"<br>
> +#include "stdint.h"<br>
> +#include "stdio.h"<br>
> +#include "stdlib.h"<br>
> +#include "string.h"<br>
> +#include "time.h"<br>
> +#include "wchar.h"<br>
> +#include "wctype.h"<br>
> +<br>
> +// Headers deprecated since C++11; expect no diagnostics<br>
> +#include "fenv.h"<br>
> +#include "stdalign.h"<br>
> +#include "stdbool.h"<br>
> +#include "tgmath.h"<br>
> +#include "uchar.h"<br>
> +<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'complex.h'; consider using 'ccomplex' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'ctype.h'; consider using 'cctype' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'errno.h'; consider using 'cerrno' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'float.h'; consider using 'cfloat' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'inttypes.h'; consider using 'cinttypes' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'iso646.h'; consider using 'ciso646' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'limits.h'; consider using 'climits' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'locale.h'; consider using 'clocale' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'setjmp.h'; consider using 'csetjmp' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'signal.h'; consider using 'csignal' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'stdarg.h'; consider using 'cstdarg' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'stddef.h'; consider using 'cstddef' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'stdint.h'; consider using 'cstdint' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'stdio.h'; consider using 'cstdio' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'stdlib.h'; consider using 'cstdlib' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'string.h'; consider using 'cstring' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'time.h'; consider using 'ctime' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'wchar.h'; consider using 'cwchar' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++ header 'wctype.h'; consider using 'cwctype' instead<br>
> +<br>
> +// CHECK-FIXES: #include <cassert><br>
> +// CHECK-FIXES: #include <ccomplex><br>
> +// CHECK-FIXES: #include <cctype><br>
> +// CHECK-FIXES: #include <cerrno><br>
> +// CHECK-FIXES: #include <cfloat><br>
> +// CHECK-FIXES: #include <cinttypes><br>
> +// CHECK-FIXES: #include <ciso646><br>
> +// CHECK-FIXES: #include <climits><br>
> +// CHECK-FIXES: #include <clocale><br>
> +// CHECK-FIXES: #include <cmath><br>
> +// CHECK-FIXES: #include <csetjmp><br>
> +// CHECK-FIXES: #include <csignal><br>
> +// CHECK-FIXES: #include <cstdarg><br>
> +// CHECK-FIXES: #include <cstddef><br>
> +// CHECK-FIXES: #include <cstdint><br>
> +// CHECK-FIXES: #include <cstdio><br>
> +// CHECK-FIXES: #include <cstdlib><br>
> +// CHECK-FIXES: #include <cstring><br>
> +// CHECK-FIXES: #include <ctime><br>
> +// CHECK-FIXES: #include <cwchar><br>
> +// CHECK-FIXES: #include <cwctype><br>
><br>
> Added: clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp?rev=261738&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp?rev=261738&view=auto</a><br>
> ==============================================================================<br>
> --- clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp (added)<br>
> +++ clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp Wed Feb 24 07:36:34 2016<br>
> @@ -0,0 +1,163 @@<br>
> +// RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- -- -std=c++11 -isystem %S/Inputs/Headers<br>
> +<br>
> +#include <assert.h><br>
> +#include <complex.h><br>
> +#include <ctype.h><br>
> +#include <errno.h><br>
> +#include <fenv.h><br>
> +#include <float.h><br>
> +#include <inttypes.h><br>
> +#include <iso646.h><br>
> +#include <limits.h><br>
> +#include <locale.h><br>
> +#include <math.h><br>
> +#include <setjmp.h><br>
> +#include <signal.h><br>
> +#include <stdalign.h><br>
> +#include <stdarg.h><br>
> +#include <stdbool.h><br>
> +#include <stddef.h><br>
> +#include <stdint.h><br>
> +#include <stdio.h><br>
> +#include <stdlib.h><br>
> +#include <string.h><br>
> +#include <tgmath.h><br>
> +#include <time.h><br>
> +#include <uchar.h><br>
> +#include <wchar.h><br>
> +#include <wctype.h><br>
> +<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'complex.h'; consider using 'ccomplex' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'ctype.h'; consider using 'cctype' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'errno.h'; consider using 'cerrno' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'fenv.h'; consider using 'cfenv' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'float.h'; consider using 'cfloat' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'inttypes.h'; consider using 'cinttypes' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'iso646.h'; consider using 'ciso646' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'limits.h'; consider using 'climits' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'locale.h'; consider using 'clocale' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'setjmp.h'; consider using 'csetjmp' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'signal.h'; consider using 'csignal' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdalign.h'; consider using 'cstdalign' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdarg.h'; consider using 'cstdarg' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdbool.h'; consider using 'cstdbool' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stddef.h'; consider using 'cstddef' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdint.h'; consider using 'cstdint' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdio.h'; consider using 'cstdio' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdlib.h'; consider using 'cstdlib' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'string.h'; consider using 'cstring' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'tgmath.h'; consider using 'ctgmath' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'time.h'; consider using 'ctime' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'uchar.h'; consider using 'cuchar' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'wchar.h'; consider using 'cwchar' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'wctype.h'; consider using 'cwctype' instead<br>
> +<br>
> +// CHECK-FIXES: #include <cassert><br>
> +// CHECK-FIXES: #include <ccomplex><br>
> +// CHECK-FIXES: #include <cctype><br>
> +// CHECK-FIXES: #include <cerrno><br>
> +// CHECK-FIXES: #include <cfenv><br>
> +// CHECK-FIXES: #include <cfloat><br>
> +// CHECK-FIXES: #include <cinttypes><br>
> +// CHECK-FIXES: #include <ciso646><br>
> +// CHECK-FIXES: #include <climits><br>
> +// CHECK-FIXES: #include <clocale><br>
> +// CHECK-FIXES: #include <cmath><br>
> +// CHECK-FIXES: #include <csetjmp><br>
> +// CHECK-FIXES: #include <csignal><br>
> +// CHECK-FIXES: #include <cstdalign><br>
> +// CHECK-FIXES: #include <cstdarg><br>
> +// CHECK-FIXES: #include <cstdbool><br>
> +// CHECK-FIXES: #include <cstddef><br>
> +// CHECK-FIXES: #include <cstdint><br>
> +// CHECK-FIXES: #include <cstdio><br>
> +// CHECK-FIXES: #include <cstdlib><br>
> +// CHECK-FIXES: #include <cstring><br>
> +// CHECK-FIXES: #include <ctgmath><br>
> +// CHECK-FIXES: #include <ctime><br>
> +// CHECK-FIXES: #include <cuchar><br>
> +// CHECK-FIXES: #include <cwchar><br>
> +// CHECK-FIXES: #include <cwctype><br>
> +<br>
> +#include "assert.h"<br>
> +#include "complex.h"<br>
> +#include "ctype.h"<br>
> +#include "errno.h"<br>
> +#include "fenv.h"<br>
> +#include "float.h"<br>
> +#include "inttypes.h"<br>
> +#include "iso646.h"<br>
> +#include "limits.h"<br>
> +#include "locale.h"<br>
> +#include "math.h"<br>
> +#include "setjmp.h"<br>
> +#include "signal.h"<br>
> +#include "stdalign.h"<br>
> +#include "stdarg.h"<br>
> +#include "stdbool.h"<br>
> +#include "stddef.h"<br>
> +#include "stdint.h"<br>
> +#include "stdio.h"<br>
> +#include "stdlib.h"<br>
> +#include "string.h"<br>
> +#include "tgmath.h"<br>
> +#include "time.h"<br>
> +#include "uchar.h"<br>
> +#include "wchar.h"<br>
> +#include "wctype.h"<br>
> +<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'complex.h'; consider using 'ccomplex' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'ctype.h'; consider using 'cctype' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'errno.h'; consider using 'cerrno' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'fenv.h'; consider using 'cfenv' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'float.h'; consider using 'cfloat' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'inttypes.h'; consider using 'cinttypes' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'iso646.h'; consider using 'ciso646' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'limits.h'; consider using 'climits' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'locale.h'; consider using 'clocale' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'setjmp.h'; consider using 'csetjmp' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'signal.h'; consider using 'csignal' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdalign.h'; consider using 'cstdalign' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdarg.h'; consider using 'cstdarg' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdbool.h'; consider using 'cstdbool' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stddef.h'; consider using 'cstddef' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdint.h'; consider using 'cstdint' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdio.h'; consider using 'cstdio' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdlib.h'; consider using 'cstdlib' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'string.h'; consider using 'cstring' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'tgmath.h'; consider using 'ctgmath' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'time.h'; consider using 'ctime' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'uchar.h'; consider using 'cuchar' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'wchar.h'; consider using 'cwchar' instead<br>
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'wctype.h'; consider using 'cwctype' instead<br>
> +<br>
> +// CHECK-FIXES: #include <cassert><br>
> +// CHECK-FIXES: #include <ccomplex><br>
> +// CHECK-FIXES: #include <cctype><br>
> +// CHECK-FIXES: #include <cerrno><br>
> +// CHECK-FIXES: #include <cfenv><br>
> +// CHECK-FIXES: #include <cfloat><br>
> +// CHECK-FIXES: #include <cinttypes><br>
> +// CHECK-FIXES: #include <ciso646><br>
> +// CHECK-FIXES: #include <climits><br>
> +// CHECK-FIXES: #include <clocale><br>
> +// CHECK-FIXES: #include <cmath><br>
> +// CHECK-FIXES: #include <csetjmp><br>
> +// CHECK-FIXES: #include <csignal><br>
> +// CHECK-FIXES: #include <cstdalign><br>
> +// CHECK-FIXES: #include <cstdarg><br>
> +// CHECK-FIXES: #include <cstdbool><br>
> +// CHECK-FIXES: #include <cstddef><br>
> +// CHECK-FIXES: #include <cstdint><br>
> +// CHECK-FIXES: #include <cstdio><br>
> +// CHECK-FIXES: #include <cstdlib><br>
> +// CHECK-FIXES: #include <cstring><br>
> +// CHECK-FIXES: #include <ctgmath><br>
> +// CHECK-FIXES: #include <ctime><br>
> +// CHECK-FIXES: #include <cuchar><br>
> +// CHECK-FIXES: #include <cwchar><br>
> +// CHECK-FIXES: #include <cwctype><br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div>