← Latest papers
💻 computer science

Do Code LLMs Do Static Analysis?

This paper investigates whether code LLMs perform static analysis during tasks like code generation and summarization, finding that these models exhibit poor performance on static analysis tasks and that pretraining on such tasks does not generalize to improved code intelligence capabilities.

Original authors: Chia-Yi Su, Collin McMillan

Published 2026-03-27
📖 6 min read🧠 Deep dive

Original authors: Chia-Yi Su, Collin McMillan

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

The Big Question: Are AI Programmers Actually "Thinking"?

Imagine you hire a brilliant new apprentice to help you build a house. This apprentice, let's call him "AI," can write beautiful blueprints, translate instructions from French to English, and even describe what a room looks like just by looking at the walls. Everyone is impressed.

But here is the big question the authors asked: Does this apprentice actually understand how the house works?

In the world of programming, "understanding how a house works" is called Static Analysis. It's the mental process a human programmer uses to figure out:

  • The Call Graph: If I push this button, which other buttons does it trigger? (Like tracing a path through a maze).
  • The Data Flow: If I pour water into this pipe, where does it end up? (Tracking how information moves).
  • The AST (Abstract Syntax Tree): How are all the bricks, beams, and windows organized structurally? (Understanding the skeleton of the code).

Humans do this automatically. We build a mental map of the code before we write it. The authors wanted to know: Do AI models do this too, or are they just guessing?


The Experiment: The "Test Kitchen"

To find out, the researchers set up a "test kitchen" with four different chefs (AI models):

  1. Two famous closed-source chefs: GPT-4o and Gemini (the big, expensive ones you can't see inside).
  2. Two open-source chefs: CodeLlama and Jam (smaller, transparent ones the researchers could tweak).

They gave these chefs three types of tasks:

  1. The "Cooking" Tasks (Code Intelligence): Write a recipe (Code Generation), summarize a recipe (Code Summarization), or translate a recipe from Italian to English (Code Translation).
  2. The "Blueprint" Tasks (Static Analysis): Draw the wiring diagram (Call Graph), trace the water pipes (Data Flow), or build the structural skeleton (AST).

They tested the chefs in three ways:

  • The Raw Test: Can they do the blueprint tasks right out of the box?
  • The Training Test: If we teach them only how to draw blueprints, does that make them better cooks?
  • The Byproduct Test: If we teach them only how to cook, do they accidentally learn how to draw blueprints?

The Results: The "Alien" Mind

The findings were surprising and a bit unsettling for the "AI is thinking like a human" crowd.

1. The Raw Test: "I don't know the plumbing."

When asked to draw the wiring diagrams or trace the pipes (Static Analysis) without any special training, the AI chefs were terrible at it.

  • Analogy: It's like asking a chef to draw the electrical wiring of a kitchen. They might know what a stove looks like, but they have no idea how the wires connect to the breaker box.
  • Result: The AI models got the "Call Graph" and "Data Flow" wrong almost all the time. Even adding "Let's think step by step" (a common trick to make AI smarter) didn't help much. They were just guessing the shape of the wires, not the actual connections.

2. The Training Test: "I can draw, but I still can't cook."

The researchers took the open-source chefs and trained them hard on drawing blueprints (Static Analysis). Then, they asked them to cook (Write Code).

  • Analogy: We taught the apprentice to be a master architect. We expected that knowing the blueprints would make them a better builder.
  • Result: Nope. Being good at drawing the blueprint didn't make them better at cooking. In fact, they made the same logical mistakes in their cooking as they did before. They learned the shape of the blueprint (the syntax) but didn't learn the logic of how the house functions.

3. The Byproduct Test: "I can cook, but I can't draw."

The researchers took the chefs and trained them to be master cooks. Then, they asked them to draw blueprints.

  • Analogy: We taught the apprentice to be a world-class chef. We expected that understanding the food so well would help them understand the kitchen's structure.
  • Result: Nope. They were still terrible at drawing the blueprints. They could write a great recipe, but if you asked them to explain how the ingredients flow through the steps, they got lost.

The "Form vs. Meaning" Metaphor

The paper concludes that AI models are like parrots who have memorized a dictionary but don't speak the language.

  • Humans learn the Semantics (Meaning). When we see a function call openDoor(), we understand that this action physically opens a door, which might trigger a light, which might turn on a fan. We understand the cause and effect.
  • LLMs learn the Form (Pattern). They see that openDoor() is usually followed by turnOnLight(). They memorize that these two things often appear together. They don't know why the light turns on; they just know the pattern.

The "Static Analysis" tasks require understanding the why and the how. Since the AI is just matching patterns (Form) and not understanding the logic (Semantics), it fails at static analysis.

Why Does This Matter?

If you ask an AI to write a complex, safety-critical program (like software for a self-driving car or a medical device), and you assume it "understands" the code like a human engineer does, you might be in trouble.

The AI might write code that looks perfect (good syntax) but has a hidden logical flaw because it never actually "traced the wires" to see if the system would crash. It's like an apprentice who builds a wall that looks straight but has no foundation.

The Takeaway

The paper argues that Code LLMs do not "think" like human programmers. They are incredibly good at mimicking the look of code, but they lack the internal "mental map" (static analysis) that humans use to truly understand how software works.

To make AI truly reliable for complex engineering, we can't just feed them more data. We might need to build a new kind of AI that actually learns to "trace the wires" and understand the logic, not just the pattern.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →