This change introduces a thread-safe version of the 'SerializedDiagnosticConsumer' and refactors scanning compilation instance creation code to ensure this consumer gets added when the scanner query configuration command-line includes '-serialized-diagnostics-path' option.
We've been converging the implementations of educational notes and
diagnostic groups, where both provide category information in
diagnostics (e.g., `[#StrictMemorySafety]`) and corresponding
short-form documentation files. The diagnostic group model is more
useful in a few ways:
* It provides warnings-as-errors control for warnings in the group
* It is easier to associate a diagnostic with a group with
GROUPED_ERROR/GROUPED_WARNING than it is to have a separate diagnostic
ID -> mapping.
* It is easier to see our progress on diagnostic-group coverage
* It provides an easy name to use for diagnostic purposes.
Collapse the educational-notes infrastructure into diagnostic groups,
migrating all of the existing educational notes into new groups.
Simplify the code paths that dealt with multiple educational notes to
have a single, possibly-missing "category documentation URL", which is
how we're treating this.
Emit the category documentation URL into serialized diagnostics as part of
the existing RECORD_CATEGORY, using the form
<category name>@<category URL>
and keeping the existing "category name length" field referring to the
length of the category name itself (up to the @). There is a corresponding
update to libclang to process such category names correctly and add
API, but it isn't strictly necessary: readers that use the category
name length field correctly will see no behavior change, whereas
readers that ignore it will merely see the extra `@<category URL>`.
This is a step toward staging out our (mis)use of the "flags" field as
the place to stash educational note and diagnostic group documentation
URLs.
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
Use flag record (currently unused) to emit semi-colon separated
list of paths to educational notes associated with a diagnostic.
Resolves: rdar://118993780
The serialized diagnostics reader has one very specific limitation it
places on filenames: they must not end in `/`, because that makes them
look like a directory. This is not documented, and the diagnostics
reader will unceremoniously crash when trying to read such a file.
While the reader should be fixed to at least fail gracefully in such
cases, Swift also shouldn't generate such filenames. Right now, they
can be generated when referencing an entity named `/` that is
synthesized or comes from a module. When we encounter such file names,
append `_operator` to avoid the problem.
Fixes rdar://118217560.
Introduce a new key `generated_buffers`, which
stores an array of generated buffers. These
include the buffer text, as well as its original
location and any parent buffers.
While here, also fix rdar://107281079 such that
only apply the filename fallback logic to the
pretty-printed Decl case. We ought to remove this
fallback once the editor can handle it though.
rdar://107281079
rdar://107952288
Macro expansion buffers, along with other generated source buffers,
need more precise "original source ranges" that can be had with the
token-based `SourceRange`. Switch over to `CharSourceRange` and provide
more thoughtfully-determined original source ranges.
Add frontend flag `-emit-macro-expansion-files diagnostics` to emit any
macro expansion buffers referenced by diagnostics into files in a
temporary directory. This makes debugging type-checking failures in
macro expansions far easier, because you can see them after the
compiler process has exited.
File IDs have been expressed using a 10-bit fixed field. This limits us
to 1023 different files in which we can emit diagnostics, where
overflowing would simply crash. With the introduction of macros and
their generated source buffers, we're much more likely to overflow.
Switch to a 5-bit VBR field, which is slightly smaller for the common
case where there are few files involving diagnositcs, and which also
allows us to have up to 2^32-1 file IDs.
When emitting generated source file buffers, we could end up
reallocating the DenseMap that tracks file IDs while still holding a
reference to it. Hilarity ensues. Stop that hilarity by taking a copy.
Additionally, make sure we don't emit an invalid source range, and
instead put in empty source locations.
Extend the serialized diagnostics file format to also support providing
the contents of source files, which can include a reference to the
"original source range" whose text is conceptually replaced with the
contents of the serialized diagnostics file, e.g., due to macro
expansion.
Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances in the swift repo.
The Bitstream part of Bitcode moved to llvm/Bitstream in LLVM. This
updates the uses in swift.
See r365091 [Bitcode] Move Bitstream to a separate library.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
This allows reporting successful and unsuccessful optimizations similar to
clang/llvm.
This first patch adds support for the
options -Rpass=<pass-name-regex> -Rpass-missed=<pass-name-regex>. These allow
reporting successful/unsuccessful optimization on the compiler output for passes
specified by the regex. I've also added one missed and one passed remark type
to the inliner to test the infrastructure.
Clang also has the option of collecting these records in an external YAML data
file. This will be added in a later patch.
A few notes:
* The goal is to use this facility for both user-lever "performance" warnings
and expert-level performance analysis. There will probably be a flag in the
future differentiating the verbosity.
* The intent is match clang/llvm as much as it makes sense. On the other hand I
did make some changes. Unlike in llvm, the emitter is not a pass which
simplifies things. Also the remark class hierarchy is greatly simplified since
we don't derive from DiagnosticInfo. We also don't derive from Diagnostic to
support the streaming API for arbitrary named-value pairs.
* Currently function names are printed mangled which should be fixed.
Some of the tools rely on the presence of buffer offset to correctly
navigate to the diagnostic area from the serialized diagnostics output,
let's get it based on the source location provided.
Resolves: rdar://problem/22935476
Changes:
* Terminate all namespaces with the correct closing comment.
* Make sure argument names in comments match the corresponding parameter name.
* Remove redundant get() calls on smart pointers.
* Prefer using "override" or "final" instead of "virtual". Remove "virtual" where appropriate.