Skip to content

Commit 66ad0c1

Browse files
committed
[Gardening] Document InputFile
1 parent 75116e9 commit 66ad0c1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

include/swift/Frontend/InputFile.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,25 @@ enum class InputFileKind {
3333
// Inputs may include buffers that override contents, and eventually should
3434
// always include a buffer.
3535
class InputFile {
36+
/// An \c InputFile encapsulates information about an input passed to the
37+
/// frontend.
38+
///
39+
/// Compiler inputs are usually passed on the command line without a leading
40+
/// flag. However, there are clients that use the \c CompilerInvocation as
41+
/// a library like LLDB and SourceKit that generate their own \c InputFile
42+
/// instances programmatically. Note that an \c InputFile need not actually be
43+
/// backed by a physical file, nor does its file name actually reflect its
44+
/// contents. \c InputFile has a constructor that will try to figure out the file
45+
/// type from the file name if none is provided, but many clients that
46+
/// construct \c InputFile instances themselves may provide bogus file names
47+
/// with pre-computed kinds. It is imperative that \c InputFile::getType be used
48+
/// as a source of truth for this information.
49+
///
50+
/// \warning \c InputFile takes an unfortunately lax view of the ownership of
51+
/// its primary data. It currently only owns the file name and a copy of any
52+
/// assigned \c PrimarySpecificPaths outright. It is the responsibility of the
53+
/// caller to ensure that an associated memory buffer outlives the \c InputFile.
54+
class InputFile final {
3655
std::string Filename;
3756
bool IsPrimary;
3857
/// Points to a buffer overriding the file's contents, or nullptr if there is

0 commit comments

Comments
 (0)