[clang-tools-extra] r261738 - [clang-tidy] introduce modernize-deprecated-headers check
Nico Weber via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 24 13:21:55 PST 2016
This broke the Windows bot:
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/10093/steps/build%20stage%201/logs/stdio
FAILED: C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe /nologo /TP /DWIN32
/D_WINDOWS /W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291
-wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624
-wd4722 -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702
-wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204
-wd4577 -wd4091 -wd4592 -wd4319 -wd4324 -w14062 -we4238 /Zc:inline /Oi
/Zc:rvalueCast /MD /O2 /Ob2 -Itools\clang\tools\extra\clang-tidy\modernize
-ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize
-ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\include
-Itools\clang\include -Iinclude
-ID:\buildslave\clang-x64-ninja-win7\llvm\include -UNDEBUG /EHs-c- /GR-
/showIncludes -DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_OBJC_REWRITER
-DCLANG_ENABLE_STATIC_ANALYZER -DGTEST_HAS_RTTI=0
-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
-D_DEBUG_POINTER_IMPL="" -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0
-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
/Fotools\clang\tools\extra\clang-tidy\modernize\CMakeFiles\clangTidyModernizeModule.dir\DeprecatedHeadersCheck.cpp.obj
/Fdtools\clang\tools\extra\clang-tidy\modernize\CMakeFiles\clangTidyModernizeModule.dir\
/FS -c
D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize\DeprecatedHeadersCheck.cpp
D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize\DeprecatedHeadersCheck.cpp(72)
: error C2668:
'llvm::StringMap<std::string,llvm::MallocAllocator>::StringMap' : ambiguous
call to overloaded function
D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(399):
could be
'llvm::StringMap<std::string,llvm::MallocAllocator>::StringMap(const
llvm::StringMap<std::string,llvm::MallocAllocator> &)'
D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(242):
or
'llvm::StringMap<std::string,llvm::MallocAllocator>::StringMap(llvm::StringMap<std::string,llvm::MallocAllocator>
&&)'
D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(235):
or
'llvm::StringMap<std::string,llvm::MallocAllocator>::StringMap(std::initializer_list<std::pair<llvm::StringRef,ValueTy>>)'
with
[
ValueTy=std::string
]
D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(228):
or
'llvm::StringMap<std::string,llvm::MallocAllocator>::StringMap(AllocatorTy)'
with
[
AllocatorTy=llvm::MallocAllocator
]
D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(225):
or
'llvm::StringMap<std::string,llvm::MallocAllocator>::StringMap(unsigned
int)'
while trying to match the argument list '(initializer-list)'
Creating library lib\libclang.lib and object lib\libclang.exp
On Wed, Feb 24, 2016 at 8:36 AM, Alexander Kornienko via cfe-commits <
cfe-commits at lists.llvm.org> wrote:
> Author: alexfh
> Date: Wed Feb 24 07:36:34 2016
> New Revision: 261738
>
> URL: http://llvm.org/viewvc/llvm-project?rev=261738&view=rev
> Log:
> [clang-tidy] introduce modernize-deprecated-headers check
>
> Summary:
> This patch introduces the modernize-deprecated-headers check, which is
> supposed to replace deprecated C library headers with the C++ STL-ones.
>
> For information see documentation; for exmaples see the test cases.
>
> Reviewers: Eugene.Zelenko, LegalizeAdulthood, alexfh
>
> Subscribers: cfe-commits
>
> Patch by Kirill Bobyrev!
>
> Differential Revision: http://reviews.llvm.org/D17484
>
> Added:
> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h
>
> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-deprecated-headers.rst
>
> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
>
> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
> Modified:
> clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
> clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>
> Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=261738&r1=261737&r2=261738&view=diff
>
> ==============================================================================
> --- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
> +++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Wed Feb 24
> 07:36:34 2016
> @@ -1,6 +1,7 @@
> set(LLVM_LINK_COMPONENTS support)
>
> add_clang_library(clangTidyModernizeModule
> + DeprecatedHeadersCheck.cpp
> LoopConvertCheck.cpp
> LoopConvertUtils.cpp
> MakeUniqueCheck.cpp
>
> Added:
> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp?rev=261738&view=auto
>
> ==============================================================================
> ---
> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
> (added)
> +++
> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp Wed
> Feb 24 07:36:34 2016
> @@ -0,0 +1,110 @@
> +//===--- DeprecatedHeadersCheck.cpp -
> clang-tidy---------------------------===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open Source
> +// License. See LICENSE.TXT for details.
> +//
>
> +//===----------------------------------------------------------------------===//
> +
> +#include "DeprecatedHeadersCheck.h"
> +#include "clang/Frontend/CompilerInstance.h"
> +#include "clang/Lex/PPCallbacks.h"
> +#include "clang/Lex/Preprocessor.h"
> +#include "llvm/ADT/StringMap.h"
> +
> +#include <vector>
> +
> +namespace clang {
> +namespace tidy {
> +namespace modernize {
> +
> +namespace {
> +class IncludeModernizePPCallbacks : public PPCallbacks {
> +public:
> + explicit IncludeModernizePPCallbacks(ClangTidyCheck &Check,
> + LangOptions LangOpts);
> +
> + void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
> + StringRef FileName, bool IsAngled,
> + CharSourceRange FilenameRange, const FileEntry
> *File,
> + StringRef SearchPath, StringRef RelativePath,
> + const Module *Imported) override;
> +
> +private:
> + ClangTidyCheck &Check;
> + LangOptions LangOpts;
> + llvm::StringMap<std::string> CStyledHeaderToCxx;
> +};
> +} // namespace
> +
> +void DeprecatedHeadersCheck::registerPPCallbacks(CompilerInstance
> &Compiler) {
> + if (this->getLangOpts().CPlusPlus) {
> + Compiler.getPreprocessor().addPPCallbacks(
> + ::llvm::make_unique<IncludeModernizePPCallbacks>(*this,
> +
> this->getLangOpts()));
> + }
> +}
> +
> +IncludeModernizePPCallbacks::IncludeModernizePPCallbacks(ClangTidyCheck
> &Check,
> + LangOptions
> LangOpts)
> + : Check(Check), LangOpts(LangOpts),
> + CStyledHeaderToCxx({{"assert.h", "cassert"},
> + {"complex.h", "ccomplex"},
> + {"ctype.h", "cctype"},
> + {"errno.h", "cerrno"},
> + {"float.h", "cfloat"},
> + {"inttypes.h", "cinttypes"},
> + {"iso646.h", "ciso646"},
> + {"limits.h", "climits"},
> + {"locale.h", "clocale"},
> + {"math.h", "cmath"},
> + {"setjmp.h", "csetjmp"},
> + {"signal.h", "csignal"},
> + {"stdarg.h", "cstdarg"},
> + {"stddef.h", "cstddef"},
> + {"stdint.h", "cstdint"},
> + {"stdio.h", "cstdio"},
> + {"stdlib.h", "cstdlib"},
> + {"string.h", "cstring"},
> + {"time.h", "ctime"},
> + {"wchar.h", "cwchar"},
> + {"wctype.h", "cwctype"}}) {
> + // Add C++ 11 headers.
> + if (LangOpts.CPlusPlus11) {
> + for (const auto &it : std::vector<std::pair<std::string,
> std::string>>(
> + {{"fenv.h", "cfenv"},
> + {"stdalign.h", "cstdalign"},
> + {"stdbool.h", "cstdbool"},
> + {"tgmath.h", "ctgmath"},
> + {"uchar.h", "cuchar"}})) {
> + CStyledHeaderToCxx.insert(it);
> + }
> + }
> +}
> +
> +void IncludeModernizePPCallbacks::InclusionDirective(
> + SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
> + bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File,
> + StringRef SearchPath, StringRef RelativePath, const Module *Imported)
> {
> + // FIXME: Take care of library symbols from the global namespace.
> + //
> + // Reasonable options for the check:
> + //
> + // 1. Insert std prefix for every such symbol occurance.
> + // 2. Insert `using namespace std;` to the beginning of TU.
> + // 3. Do nothing and let the user deal with the migration himself.
> + if (CStyledHeaderToCxx.count(FileName) != 0) {
> + std::string Replacement =
> + (llvm::Twine("<") + CStyledHeaderToCxx[FileName] + ">").str();
> + Check.diag(FilenameRange.getBegin(),
> + "inclusion of deprecated C++ header '%0'; consider using
> '%1' instead")
> + << FileName << CStyledHeaderToCxx[FileName]
> + << FixItHint::CreateReplacement(FilenameRange.getAsRange(),
> + Replacement);
> + }
> +}
> +
> +} // namespace modernize
> +} // namespace tidy
> +} // namespace clang
>
> Added:
> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h?rev=261738&view=auto
>
> ==============================================================================
> --- clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h
> (added)
> +++ clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h
> Wed Feb 24 07:36:34 2016
> @@ -0,0 +1,42 @@
> +//===--- DeprecatedHeadersCheck.h - clang-tidy-------------------*- C++
> -*-===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open Source
> +// License. See LICENSE.TXT for details.
> +//
>
> +//===----------------------------------------------------------------------===//
> +
> +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_C_HEADERS_TO_CXX_H
> +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_C_HEADERS_TO_CXX_H
> +
> +#include "../ClangTidy.h"
> +
> +namespace clang {
> +namespace tidy {
> +namespace modernize {
> +
> +/// This check replaces deprecated C library headers with their C++ STL
> +/// alternatives.
> +///
> +/// Before:
> +/// #include <header.h>
> +/// After:
> +/// #include <cheader>
> +///
> +/// Example: <stdio.h> => <cstdio>
> +///
> +/// For the user-facing documentation see:
> +///
> http://clang.llvm.org/extra/clang-tidy/checks/modernize-deprecated-headers.html
> +class DeprecatedHeadersCheck : public ClangTidyCheck {
> +public:
> + DeprecatedHeadersCheck(StringRef Name, ClangTidyContext *Context)
> + : ClangTidyCheck(Name, Context) {}
> + void registerPPCallbacks(CompilerInstance &Compiler) override;
> +};
> +
> +} // namespace modernize
> +} // namespace tidy
> +} // namespace clang
> +
> +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_C_HEADERS_TO_CXX_H
>
> Modified:
> clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=261738&r1=261737&r2=261738&view=diff
>
> ==============================================================================
> --- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
> Wed Feb 24 07:36:34 2016
> @@ -10,6 +10,7 @@
> #include "../ClangTidy.h"
> #include "../ClangTidyModule.h"
> #include "../ClangTidyModuleRegistry.h"
> +#include "DeprecatedHeadersCheck.h"
> #include "LoopConvertCheck.h"
> #include "MakeUniqueCheck.h"
> #include "PassByValueCheck.h"
> @@ -30,6 +31,8 @@ namespace modernize {
> class ModernizeModule : public ClangTidyModule {
> public:
> void addCheckFactories(ClangTidyCheckFactories &CheckFactories)
> override {
> + CheckFactories.registerCheck<DeprecatedHeadersCheck>(
> + "modernize-deprecated-headers");
>
> CheckFactories.registerCheck<LoopConvertCheck>("modernize-loop-convert");
>
> CheckFactories.registerCheck<MakeUniqueCheck>("modernize-make-unique");
>
> CheckFactories.registerCheck<PassByValueCheck>("modernize-pass-by-value");
>
> Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst?rev=261738&r1=261737&r2=261738&view=diff
>
> ==============================================================================
> --- clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst (original)
> +++ clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Wed Feb 24
> 07:36:34 2016
> @@ -74,6 +74,7 @@ Clang-Tidy Checks
> misc-unused-parameters
> misc-unused-raii
> misc-virtual-near-miss
> + modernize-deprecated-headers
> modernize-loop-convert
> modernize-make-unique
> modernize-pass-by-value
>
> Added:
> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-deprecated-headers.rst
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-deprecated-headers.rst?rev=261738&view=auto
>
> ==============================================================================
> ---
> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-deprecated-headers.rst
> (added)
> +++
> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-deprecated-headers.rst
> Wed Feb 24 07:36:34 2016
> @@ -0,0 +1,45 @@
> +.. title:: clang-tidy - modernize-deprecated-headers
> +
> +modernize-deprecated-headers
> +==========================
> +
> +Some headers from C library were deprecated in C++ and are no longer
> welcome in
> +C++ codebases. For more details refer to the C++ 14 Standard
> [depr.c.headers]
> +section.
> +
> +This check replaces C standard library headers with their C++
> alternatives.
> +
> +Improtant note: the Standard doesn't guarantee that the C++ headers
> declare all
> +the same functions in the global namespace. The check in its current form
> can
> +break the code that uses library symbols from the global namespace.
> +
> +* `<assert.h>`
> +* `<complex.h>`
> +* `<ctype.h>`
> +* `<errno.h>`
> +* `<fenv.h>` // deprecated since C++11
> +* `<float.h>`
> +* `<inttypes.h>`
> +* `<iso646.h>`
> +* `<limits.h>`
> +* `<locale.h>`
> +* `<math.h>`
> +* `<setjmp.h>`
> +* `<signal.h>`
> +* `<stdalign.h>` // deprecated since C++11
> +* `<stdarg.h>`
> +* `<stdbool.h>` // deprecated since C++11
> +* `<stddef.h>`
> +* `<stdint.h>`
> +* `<stdio.h>`
> +* `<stdlib.h>`
> +* `<string.h>`
> +* `<tgmath.h>` // deprecated since C++11
> +* `<time.h>`
> +* `<uchar.h>` // deprecated since C++11
> +* `<wchar.h>`
> +* `<wctype.h>`
> +
> +If the specified standard is older than C++11 the check will only replace
> +headers deprecated before C++11, otherwise -- every header that appeared
> in
> +the list.
>
> Added:
> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp?rev=261738&view=auto
>
> ==============================================================================
> ---
> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
> (added)
> +++
> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
> Wed Feb 24 07:36:34 2016
> @@ -0,0 +1,147 @@
> +// RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- --
> -std=c++03 -isystem %S/Inputs/Headers
> +
> +#include <assert.h>
> +#include <complex.h>
> +#include <ctype.h>
> +#include <errno.h>
> +#include <float.h>
> +#include <inttypes.h>
> +#include <iso646.h>
> +#include <limits.h>
> +#include <locale.h>
> +#include <math.h>
> +#include <setjmp.h>
> +#include <signal.h>
> +#include <stdarg.h>
> +#include <stddef.h>
> +#include <stdint.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <time.h>
> +#include <wchar.h>
> +#include <wctype.h>
> +
> +// Headers deprecated since C++11: expect no diagnostics.
> +#include <fenv.h>
> +#include <stdalign.h>
> +#include <stdbool.h>
> +#include <tgmath.h>
> +#include <uchar.h>
> +
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'assert.h'; consider using 'cassert' instead
> [modernize-deprecated-headers]
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'complex.h'; consider using 'ccomplex' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'ctype.h'; consider using 'cctype' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'errno.h'; consider using 'cerrno' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'float.h'; consider using 'cfloat' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'inttypes.h'; consider using 'cinttypes' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'iso646.h'; consider using 'ciso646' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'limits.h'; consider using 'climits' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'locale.h'; consider using 'clocale' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'math.h'; consider using 'cmath' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'setjmp.h'; consider using 'csetjmp' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'signal.h'; consider using 'csignal' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'stdarg.h'; consider using 'cstdarg' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'stddef.h'; consider using 'cstddef' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'stdint.h'; consider using 'cstdint' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'stdio.h'; consider using 'cstdio' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'stdlib.h'; consider using 'cstdlib' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'string.h'; consider using 'cstring' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'time.h'; consider using 'ctime' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'wchar.h'; consider using 'cwchar' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'wctype.h'; consider using 'cwctype' instead
> +
> +// CHECK-FIXES: #include <cassert>
> +// CHECK-FIXES: #include <ccomplex>
> +// CHECK-FIXES: #include <cctype>
> +// CHECK-FIXES: #include <cerrno>
> +// CHECK-FIXES: #include <cfloat>
> +// CHECK-FIXES: #include <cinttypes>
> +// CHECK-FIXES: #include <ciso646>
> +// CHECK-FIXES: #include <climits>
> +// CHECK-FIXES: #include <clocale>
> +// CHECK-FIXES: #include <cmath>
> +// CHECK-FIXES: #include <csetjmp>
> +// CHECK-FIXES: #include <csignal>
> +// CHECK-FIXES: #include <cstdarg>
> +// CHECK-FIXES: #include <cstddef>
> +// CHECK-FIXES: #include <cstdint>
> +// CHECK-FIXES: #include <cstdio>
> +// CHECK-FIXES: #include <cstdlib>
> +// CHECK-FIXES: #include <cstring>
> +// CHECK-FIXES: #include <ctime>
> +// CHECK-FIXES: #include <cwchar>
> +// CHECK-FIXES: #include <cwctype>
> +
> +#include "assert.h"
> +#include "complex.h"
> +#include "ctype.h"
> +#include "errno.h"
> +#include "float.h"
> +#include "inttypes.h"
> +#include "iso646.h"
> +#include "limits.h"
> +#include "locale.h"
> +#include "math.h"
> +#include "setjmp.h"
> +#include "signal.h"
> +#include "stdarg.h"
> +#include "stddef.h"
> +#include "stdint.h"
> +#include "stdio.h"
> +#include "stdlib.h"
> +#include "string.h"
> +#include "time.h"
> +#include "wchar.h"
> +#include "wctype.h"
> +
> +// Headers deprecated since C++11; expect no diagnostics
> +#include "fenv.h"
> +#include "stdalign.h"
> +#include "stdbool.h"
> +#include "tgmath.h"
> +#include "uchar.h"
> +
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'assert.h'; consider using 'cassert' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'complex.h'; consider using 'ccomplex' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'ctype.h'; consider using 'cctype' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'errno.h'; consider using 'cerrno' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'float.h'; consider using 'cfloat' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'inttypes.h'; consider using 'cinttypes' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'iso646.h'; consider using 'ciso646' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'limits.h'; consider using 'climits' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'locale.h'; consider using 'clocale' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'math.h'; consider using 'cmath' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'setjmp.h'; consider using 'csetjmp' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'signal.h'; consider using 'csignal' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'stdarg.h'; consider using 'cstdarg' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'stddef.h'; consider using 'cstddef' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'stdint.h'; consider using 'cstdint' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'stdio.h'; consider using 'cstdio' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'stdlib.h'; consider using 'cstdlib' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'string.h'; consider using 'cstring' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'time.h'; consider using 'ctime' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'wchar.h'; consider using 'cwchar' instead
> +// CHECK-MESSAGES: :[[@LINE-29]]:10: warning: inclusion of deprecated C++
> header 'wctype.h'; consider using 'cwctype' instead
> +
> +// CHECK-FIXES: #include <cassert>
> +// CHECK-FIXES: #include <ccomplex>
> +// CHECK-FIXES: #include <cctype>
> +// CHECK-FIXES: #include <cerrno>
> +// CHECK-FIXES: #include <cfloat>
> +// CHECK-FIXES: #include <cinttypes>
> +// CHECK-FIXES: #include <ciso646>
> +// CHECK-FIXES: #include <climits>
> +// CHECK-FIXES: #include <clocale>
> +// CHECK-FIXES: #include <cmath>
> +// CHECK-FIXES: #include <csetjmp>
> +// CHECK-FIXES: #include <csignal>
> +// CHECK-FIXES: #include <cstdarg>
> +// CHECK-FIXES: #include <cstddef>
> +// CHECK-FIXES: #include <cstdint>
> +// CHECK-FIXES: #include <cstdio>
> +// CHECK-FIXES: #include <cstdlib>
> +// CHECK-FIXES: #include <cstring>
> +// CHECK-FIXES: #include <ctime>
> +// CHECK-FIXES: #include <cwchar>
> +// CHECK-FIXES: #include <cwctype>
>
> Added:
> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp?rev=261738&view=auto
>
> ==============================================================================
> ---
> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
> (added)
> +++
> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
> Wed Feb 24 07:36:34 2016
> @@ -0,0 +1,163 @@
> +// RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- --
> -std=c++11 -isystem %S/Inputs/Headers
> +
> +#include <assert.h>
> +#include <complex.h>
> +#include <ctype.h>
> +#include <errno.h>
> +#include <fenv.h>
> +#include <float.h>
> +#include <inttypes.h>
> +#include <iso646.h>
> +#include <limits.h>
> +#include <locale.h>
> +#include <math.h>
> +#include <setjmp.h>
> +#include <signal.h>
> +#include <stdalign.h>
> +#include <stdarg.h>
> +#include <stdbool.h>
> +#include <stddef.h>
> +#include <stdint.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <tgmath.h>
> +#include <time.h>
> +#include <uchar.h>
> +#include <wchar.h>
> +#include <wctype.h>
> +
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'assert.h'; consider using 'cassert' instead
> [modernize-deprecated-headers]
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'complex.h'; consider using 'ccomplex' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'ctype.h'; consider using 'cctype' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'errno.h'; consider using 'cerrno' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'fenv.h'; consider using 'cfenv' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'float.h'; consider using 'cfloat' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'inttypes.h'; consider using 'cinttypes' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'iso646.h'; consider using 'ciso646' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'limits.h'; consider using 'climits' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'locale.h'; consider using 'clocale' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'math.h'; consider using 'cmath' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'setjmp.h'; consider using 'csetjmp' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'signal.h'; consider using 'csignal' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'stdalign.h'; consider using 'cstdalign' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'stdarg.h'; consider using 'cstdarg' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'stdbool.h'; consider using 'cstdbool' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'stddef.h'; consider using 'cstddef' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'stdint.h'; consider using 'cstdint' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'stdio.h'; consider using 'cstdio' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'stdlib.h'; consider using 'cstdlib' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'string.h'; consider using 'cstring' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'tgmath.h'; consider using 'ctgmath' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'time.h'; consider using 'ctime' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'uchar.h'; consider using 'cuchar' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'wchar.h'; consider using 'cwchar' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'wctype.h'; consider using 'cwctype' instead
> +
> +// CHECK-FIXES: #include <cassert>
> +// CHECK-FIXES: #include <ccomplex>
> +// CHECK-FIXES: #include <cctype>
> +// CHECK-FIXES: #include <cerrno>
> +// CHECK-FIXES: #include <cfenv>
> +// CHECK-FIXES: #include <cfloat>
> +// CHECK-FIXES: #include <cinttypes>
> +// CHECK-FIXES: #include <ciso646>
> +// CHECK-FIXES: #include <climits>
> +// CHECK-FIXES: #include <clocale>
> +// CHECK-FIXES: #include <cmath>
> +// CHECK-FIXES: #include <csetjmp>
> +// CHECK-FIXES: #include <csignal>
> +// CHECK-FIXES: #include <cstdalign>
> +// CHECK-FIXES: #include <cstdarg>
> +// CHECK-FIXES: #include <cstdbool>
> +// CHECK-FIXES: #include <cstddef>
> +// CHECK-FIXES: #include <cstdint>
> +// CHECK-FIXES: #include <cstdio>
> +// CHECK-FIXES: #include <cstdlib>
> +// CHECK-FIXES: #include <cstring>
> +// CHECK-FIXES: #include <ctgmath>
> +// CHECK-FIXES: #include <ctime>
> +// CHECK-FIXES: #include <cuchar>
> +// CHECK-FIXES: #include <cwchar>
> +// CHECK-FIXES: #include <cwctype>
> +
> +#include "assert.h"
> +#include "complex.h"
> +#include "ctype.h"
> +#include "errno.h"
> +#include "fenv.h"
> +#include "float.h"
> +#include "inttypes.h"
> +#include "iso646.h"
> +#include "limits.h"
> +#include "locale.h"
> +#include "math.h"
> +#include "setjmp.h"
> +#include "signal.h"
> +#include "stdalign.h"
> +#include "stdarg.h"
> +#include "stdbool.h"
> +#include "stddef.h"
> +#include "stdint.h"
> +#include "stdio.h"
> +#include "stdlib.h"
> +#include "string.h"
> +#include "tgmath.h"
> +#include "time.h"
> +#include "uchar.h"
> +#include "wchar.h"
> +#include "wctype.h"
> +
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'assert.h'; consider using 'cassert' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'complex.h'; consider using 'ccomplex' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'ctype.h'; consider using 'cctype' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'errno.h'; consider using 'cerrno' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'fenv.h'; consider using 'cfenv' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'float.h'; consider using 'cfloat' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'inttypes.h'; consider using 'cinttypes' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'iso646.h'; consider using 'ciso646' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'limits.h'; consider using 'climits' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'locale.h'; consider using 'clocale' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'math.h'; consider using 'cmath' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'setjmp.h'; consider using 'csetjmp' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'signal.h'; consider using 'csignal' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'stdalign.h'; consider using 'cstdalign' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'stdarg.h'; consider using 'cstdarg' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'stdbool.h'; consider using 'cstdbool' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'stddef.h'; consider using 'cstddef' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'stdint.h'; consider using 'cstdint' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'stdio.h'; consider using 'cstdio' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'stdlib.h'; consider using 'cstdlib' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'string.h'; consider using 'cstring' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'tgmath.h'; consider using 'ctgmath' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'time.h'; consider using 'ctime' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'uchar.h'; consider using 'cuchar' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'wchar.h'; consider using 'cwchar' instead
> +// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++
> header 'wctype.h'; consider using 'cwctype' instead
> +
> +// CHECK-FIXES: #include <cassert>
> +// CHECK-FIXES: #include <ccomplex>
> +// CHECK-FIXES: #include <cctype>
> +// CHECK-FIXES: #include <cerrno>
> +// CHECK-FIXES: #include <cfenv>
> +// CHECK-FIXES: #include <cfloat>
> +// CHECK-FIXES: #include <cinttypes>
> +// CHECK-FIXES: #include <ciso646>
> +// CHECK-FIXES: #include <climits>
> +// CHECK-FIXES: #include <clocale>
> +// CHECK-FIXES: #include <cmath>
> +// CHECK-FIXES: #include <csetjmp>
> +// CHECK-FIXES: #include <csignal>
> +// CHECK-FIXES: #include <cstdalign>
> +// CHECK-FIXES: #include <cstdarg>
> +// CHECK-FIXES: #include <cstdbool>
> +// CHECK-FIXES: #include <cstddef>
> +// CHECK-FIXES: #include <cstdint>
> +// CHECK-FIXES: #include <cstdio>
> +// CHECK-FIXES: #include <cstdlib>
> +// CHECK-FIXES: #include <cstring>
> +// CHECK-FIXES: #include <ctgmath>
> +// CHECK-FIXES: #include <ctime>
> +// CHECK-FIXES: #include <cuchar>
> +// CHECK-FIXES: #include <cwchar>
> +// CHECK-FIXES: #include <cwctype>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160224/8d1a2c53/attachment-0001.html>
More information about the cfe-commits
mailing list