clang
20.0.0git
include
clang
Tooling
Inclusions
HeaderAnalysis.h
Go to the documentation of this file.
1
//===--- HeaderAnalysis.h -----------------------------------------*-C++-*-===//
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
//===----------------------------------------------------------------------===//
8
9
#ifndef LLVM_CLANG_TOOLING_INCLUSIONS_HEADER_ANALYSIS_H
10
#define LLVM_CLANG_TOOLING_INCLUSIONS_HEADER_ANALYSIS_H
11
12
#include "
clang/Basic/FileEntry.h
"
13
#include "llvm/ADT/StringRef.h"
14
#include <optional>
15
16
namespace
clang
{
17
class
SourceManager;
18
class
HeaderSearch
;
19
20
namespace
tooling {
21
22
/// Returns true if the given physical file is a self-contained header.
23
///
24
/// A header is considered self-contained if
25
// - it has a proper header guard or has been #imported or contains #import(s)
26
// - *and* it doesn't have a dont-include-me pattern.
27
///
28
/// This function can be expensive as it may scan the source code to find out
29
/// dont-include-me pattern heuristically.
30
bool
isSelfContainedHeader
(FileEntryRef FE,
const
SourceManager &
SM
,
31
const
HeaderSearch &HeaderInfo);
32
33
/// This scans the given source code to see if it contains #import(s).
34
bool
codeContainsImports
(llvm::StringRef Code);
35
36
/// If Text begins an Include-What-You-Use directive, returns it.
37
/// Given "// IWYU pragma: keep", returns "keep".
38
/// Input is a null-terminated char* as provided by SM.getCharacterData().
39
/// (This should not be StringRef as we do *not* want to scan for its length).
40
/// For multi-line comments, we return only the first line.
41
std::optional<llvm::StringRef>
parseIWYUPragma
(
const
char
*
Text
);
42
43
}
// namespace tooling
44
}
// namespace clang
45
46
#endif
// LLVM_CLANG_TOOLING_INCLUSIONS_HEADER_ANALYSIS_H
SM
#define SM(sm)
Definition:
Cuda.cpp:83
FileEntry.h
Defines interfaces for clang::FileEntry and clang::FileEntryRef.
Text
StringRef Text
Definition:
Format.cpp:3002
clang::tooling::dependencies::ScanningOptimizations::HeaderSearch
@ HeaderSearch
Remove unused header search paths including header maps.
clang::tooling::codeContainsImports
bool codeContainsImports(llvm::StringRef Code)
This scans the given source code to see if it contains #import(s).
Definition:
HeaderAnalysis.cpp:83
clang::tooling::isSelfContainedHeader
bool isSelfContainedHeader(FileEntryRef FE, const SourceManager &SM, const HeaderSearch &HeaderInfo)
Returns true if the given physical file is a self-contained header.
Definition:
HeaderAnalysis.cpp:69
clang::tooling::parseIWYUPragma
std::optional< llvm::StringRef > parseIWYUPragma(const char *Text)
If Text begins an Include-What-You-Use directive, returns it.
Definition:
HeaderAnalysis.cpp:95
clang
The JSON file list parser is used to communicate input to InstallAPI.
Definition:
CalledOnceCheck.h:17
Generated on Fri Nov 22 2024 09:47:24 for clang by
1.9.6