Hades: A Mobile Static Analysis Framework for Large-Scale iOS Projects
Hades is a self‑developed static‑analysis framework for Meituan‑Dianping’s large‑scale iOS codebases that leverages Clang/LLVM to build a high‑level semantic model, enabling global, incremental checks, custom lint tools, CI integration, and efficient code‑quality maintenance across massive projects.
In response to the rapid growth of Meituan‑Dianping’s mobile services, the iOS development team needed a more efficient way to maintain code quality and accelerate product iteration for large‑scale projects.
The team therefore created Hades , a self‑developed static analysis framework that goes beyond traditional lint tools by providing semantic analysis of the source code.
Existing open‑source static analysis solutions such as Static Analyzer, Infer and OCLint suffer from high integration cost, limited cross‑compilation‑unit analysis, difficult incremental analysis, and a focus on style checking rather than deeper semantic issues.
Hades adopts a four‑layer architecture:
Compiler layer : based on Clang/LLVM, which offers fast compilation, low memory usage and a modular design.
Core layer : transforms the Clang AST into a higher‑level semantic model called HadesModel.
Interface layer : exposes rich APIs for accessing the semantic model.
Static‑analysis applications : Lint tools, CI checks, and other analysis utilities built on top of the model.
The framework uses Clang’s LibTooling (chosen for its ability to run independently and fully control the AST). Key Clang concepts such as ASTContext, node types (Decl, Stmt, Type) and traversal mechanisms ( RecursiveASTVisitor and ASTMatcher) are leveraged to extract information. HadesModel captures interface declarations, class hierarchies, macro definitions, method calls and other semantic details for an entire compilation unit, and can be serialized to JSON for storage or further processing.
Example: a simple Objective‑C file HadesViewController.m is parsed into a model that records the class name, its superclass, defined macros, and method implementations. The following TypeScript snippet shows how a rule can list all class names from the generated models:
this.hadesModels.each((hadesModel: HadesModel.HModel) => {
hadesModel.class_list.forEach((occlass: HadesNode.Class) => {
console.log(occlass.name);
})
});HadesLint, a lint tool built on top of Hades, is written in TypeScript, benefits from VSCode’s type system and debugging support, and uses lazy loading (via Lazy.js) to handle large model data efficiently.
For persistent storage, HadesModel can be saved in a document‑oriented database such as CouchDB. The following map‑reduce function extracts macro definitions from stored models:
function (doc) {
if (doc.extracontext.macro_list !== null) {
emit(doc._id, doc.extracontext.macro_list);
}
}By providing a structured, language‑agnostic representation of code semantics, Hades enables global analysis, incremental checks, and easy integration into CI pipelines, significantly reducing manual review effort for large iOS codebases. The framework is slated to be open‑sourced soon.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Meituan Technology Team
Over 10,000 engineers powering China’s leading lifestyle services e‑commerce platform. Supporting hundreds of millions of consumers, millions of merchants across 2,000+ industries. This is the public channel for the tech teams behind Meituan, Dianping, Meituan Waimai, Meituan Select, and related services.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
