Skip to main content

CompileCommands

Struct CompileCommands 

Source
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: usize

How 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

Source

pub fn is_empty(&self) -> bool

Source

pub fn len(&self) -> usize

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> CompileCommands

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CompileCommands

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for CompileCommands

Source§

fn default() -> CompileCommands

Returns the “default value” for a type. Read more
Source§

impl Eq for CompileCommands

Source§

impl PartialEq for CompileCommands

Source§

fn eq(&self, other: &CompileCommands) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CompileCommands

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.