pub struct CompileCommands {
pub commands: Vec<CompileCommand>,
pub malformed: usize,
}Expand description
A parsed compile database, and what was skipped.
Fields§
§commands: Vec<CompileCommand>§malformed: usizeHow many entries were present but not understood.
Reported rather than ignored: a database where most entries failed to parse is one whose include paths are mostly missing, and an analysis built on it would be quietly wrong rather than loudly incomplete.
Implementations§
Source§impl CompileCommands
impl CompileCommands
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
Sourcepub fn a_unanimous_standard(&self) -> Option<&str>
pub fn a_unanimous_standard(&self) -> Option<&str>
The one standard every command that states one agrees on, or None.
A header has no translation unit of its own, and the standard is what decides which half of every guarded
header exists. Measured on a <ranges> fixture whose only database entry is
... /std:c++latest …\ for \main.cpp: <ranges>'s own config had no command, so it had no standard,
so _HAS_CXX20\ was false and the cooked rendering of the header was the 12-byte #pragma once\ stub —
the pipeline’s type could never be inferred. A project where the entries disagree is one where the header
really is built two ways, and then this answers \None\ rather than picking one.
Sourcepub fn command_for(&self, file: &Path) -> Option<&CompileCommand>
pub fn command_for(&self, file: &Path) -> Option<&CompileCommand>
The command for a file, if the database has one.
Compared by the tail of the path, and falling back to the tail is the point: a database writes
absolute paths from the machine that produced it, and a project opened somewhere else has the same
files with a different prefix — a different checkout directory, a container path, a drive letter.
Requiring an exact match would make a checked-in compile_commands.json useless, which is the case
it is most often generated for.
The two are matched by their longest common tail: the request’s tails are collected into a set and the stored path’s tails are looked up in it. Comparing only one side’s tails would match in one direction — a request with a prefix the database lacks, but not a database entry with a prefix the request lacks — and the two directions are the same question asked twice.
Sourcepub fn a_command_for_a_header(&self, file: &Path) -> Option<&CompileCommand>
pub fn a_command_for_a_header(&self, file: &Path) -> Option<&CompileCommand>
A command for a file the database has no entry for — a header, in practice.
A build lists its sources; a header is compiled as part of one of them and appears nowhere. So
CompileCommands::command_for answers None for it, and the project-wide configuration that answers
instead knows nothing about the -I/-isystem flags the build passed — measured on neovim: src/nvim/os/fs.h
includes <uv.h>, the header has no entry, and the -isystem .deps/usr/include that resolves it is in the
response file of src/nvim/os/fs.c. Eleven headers of one closure reported uv.h unresolved, and one
unresolved include is what takes the macro environment’s completeness claim back (Marked::mark_incomplete)
for every file whose closure reaches it.
The entry borrowed is a source in the same directory, the smallest path so the answer is deterministic.
Same directory and not “any entry”: a database may describe several targets with different include roots, and
a header is the file the source beside it is most likely to compile. None when the directory has no
source — a header-only tree keeps the project-wide answer.
Trait Implementations§
Source§impl Clone for CompileCommands
impl Clone for CompileCommands
Source§fn clone(&self) -> CompileCommands
fn clone(&self) -> CompileCommands
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CompileCommands
impl Debug for CompileCommands
Source§impl Default for CompileCommands
impl Default for CompileCommands
Source§fn default() -> CompileCommands
fn default() -> CompileCommands
impl Eq for CompileCommands
Source§impl PartialEq for CompileCommands
impl PartialEq for CompileCommands
impl StructuralPartialEq for CompileCommands
Auto Trait Implementations§
impl Forget for CompileCommands
impl Freeze for CompileCommands
impl Move for CompileCommands
impl RefUnwindSafe for CompileCommands
impl Send for CompileCommands
impl Sync for CompileCommands
impl Unpin for CompileCommands
impl UnsafeUnpin for CompileCommands
impl UnwindSafe for CompileCommands
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more