[flang][runtime] Make defined formatted I/O process format elementally (#74150)
[llvm-project.git] / libcxx / test / tools / clang_tidy_checks / qualify_declval.cpp
blobf1c84ee16e92e2d991b9cd3fe83797ec0dca3771
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "qualify_declval.hpp"
11 namespace {
12 AST_MATCHER(clang::UnresolvedLookupExpr, requiresADL) { return Node.requiresADL(); }
13 AST_MATCHER(clang::UnresolvedLookupExpr, isDeclval) { return Node.getName().getAsString() == "declval"; }
14 } // namespace
16 namespace libcpp {
17 qualify_declval::qualify_declval(llvm::StringRef name, clang::tidy::ClangTidyContext* context)
18 : clang::tidy::ClangTidyCheck(name, context) {}
20 void qualify_declval::registerMatchers(clang::ast_matchers::MatchFinder* finder) {
21 using namespace clang::ast_matchers;
22 finder->addMatcher(callExpr(has(unresolvedLookupExpr(requiresADL(), isDeclval()))).bind("ADLcall"), this);
25 void qualify_declval::check(const clang::ast_matchers::MatchFinder::MatchResult& result) {
26 if (const auto* call = result.Nodes.getNodeAs<clang::CallExpr>("ADLcall"); call != nullptr) {
27 diag(call->getBeginLoc(), "declval should be qualified to get better error messages")
28 << clang::FixItHint::CreateInsertion(call->getBeginLoc(), "std::");
31 } // namespace libcpp