UNDER THE HOOD
weavec::Frontend — Clang integration
lib/Frontend adapts the analysis to Clang’s frontend machinery:
WeaveCActionis anASTFrontendActionwhose consumer hands the whole translation unit toTranslationUnitAnalyzer; every definition contributes a summary, but by default only those in the main file are reported. The same consumer (createWeaveCConsumer) is whatweavec-ccmultiplexes beside Clang’s code generator.FrontendOptionscarries the analysis options, the program database to consult, the diagnostics already reported for the unit, and a receiver for the unit’s exports.ClangDiagnosticSinkforwardscore::Diagnostics (including fix-its) to Clang’sDiagnosticsEngine, so WeaveC’s output is rendered exactly like Clang’s own (carets, colours,-fdiagnostics-format=,-fdiagnostics-parseable-fixits,-Werror, …).DiagnosticControlapplies-Wno-weavec-<id>,-Wno-error=weavec-<id>,-Werror=weavecand friends before the sink sees a diagnostic;FilteringSinkdrops diagnostics already reported by an earlier step and repeats of a boundary warning within a program.ProgramAnalysisis the whole-program algorithm over an abstractProgramUnit(something that can parse a unit and run an action over it): discover every unit’s exports, build the unit graph (who imports whose definitions, who calls through a type someone else has a candidate for), analyse acyclic units once and cyclic groups to a fixpoint, each against the database of what has been analysed so far, then one more reporting pass over the units that looked up a sized field the program confirmed after they were analysed (RFC 0012; a fact about a type, which the call graph’s order does not carry).CompilationDatabaseUnitparses from a compilation database.Sidecar.hreads and writesfoo.o.weavec: the unit’s exports, the cc1 command that produced it and the diagnostics already reported, in a line-oriented text format versioned by itsweavec-summaries 23header.Driver.hisweavec-cc: Clang’sdriver::Driverplans the jobs, each-cc1job runs in-process with WeaveC’s consumer multiplexed beside Clang’s, the compile step writes the sidecar, and the link step runsProgramAnalysisover the sidecars of the objects being linked before the linker.ResourceDir.hlocatesweavec.h, Clang’s resource directory and theclangbinary in installed and build-tree layouts.