Untangle static analyzer and SSAF tests

The clang static analyzer and SSAF (scalable static analysis framework) are independent projects, they should have separate test directories and separate “run the tests” targets.

To ensure this, I propose the following changes:

  • Move the SSAF tests from clang/test/Analysis/Scalable to e.g. clang/test/SSAF or any other name preferred by the SSAF developers.
  • Rename clang/test/Analysis to clang/test/StaticAnalyzer to reflect the fact that apart from the recently added SSAF tests it only contains tests for the static analyzer (see this older discourse thread where I verified this and removed a handful of misplaced tests).
  • Restore that check-clang-analysis only runs the static analyzer tests.
    • Alternatively, if you think that this traditional name is too general, introduce a target e.g. check-clang-static-analyzer that only runs the static analyzer tests.
  • Introduce a target that only runs the SSAF tests (if there isn’t one already existing).

See also [SSAF] Mark two failing tests as unsupported by NagyDonat · Pull Request #223976 · llvm/llvm-project · GitHub where the testing of these two projects interfere with each other.

@steakhal @Xazax-hun @NoQ @necto @ziqingluo-90 What do you think about this?

(Please also forward this topic to anybody on the SSAF team who may be interested but doesn’t follow the static analyzer discourse.)

I do support the separation. Purely practical benefit: if SSAF is not part of CSA, when I want to run all CSA tests (using llvm-lit.py clang/test/Analysis) I don’t want the other tests to mix in.
I also agree that “test/Analysis” is too vague and invites other static analysis tests. Additionally, it seems that CSA files are spread over “lib/Analysis”, “lib/StaticAnalyzer”, “include/clang/Analysis”, and “include/clang/StaticAnalyzer”, which is confusing.

As an alternative which I am also open to, we could keep Analysis, but group CSA tests in “test/Analysis/StaticAnalyzer” and SSAF in “test/Analysis/SSAF”. This way if you want to run the same set, you can still run lit test/Analysis.

1 Like

As an alternative which I am also open to, we could keep Analysis, but group CSA tests in “test/Analysis/StaticAnalyzer” and SSAF in “test/Analysis/SSAF”. This way if you want to run the same set, you can still run lit test/Analysis.

+1 With this we would hit two birds with one stone. It would reduce the complexity IMHO.

My personal opinion would be that yes, we should untangle these directories. For SSAF, we should stick to the Scalable name. For the static analyzer, we should also go with the name of the directory: StaticAnalyzer

I have a couple of questions though:
What else lives in the Analysis test folder? I’m fairly certain we could sort them case by cases basis when proposing the migration.

Next question is the cost. How is it going to distrupt downstream users. I suppose we should ignore blame the migration commit and handle the outlier cases before hand.
Second, in git, having downstream additional tests, would re-create this Analysis directory for them, so how are we going to make sure that they dont accidentally end up eith both Analysis and StaticAnalyzer test dirs?


So far I’ve seen consensus about:

  • we should change something because what we have today causes friction
  • we ahould have dedicated test dirs for CSA and SSAF

My next question would be, should we entirely eliminate the Analysis dir, and move the tests to more appropriate places?

CFG tests come to mind, such as cfg.cpp. They’re invoked via -analyzer-checker=debug.DumpCFG, and they test the CFG under the analyzer-specific CFG build options, but in theory they have nothing to do with the static analyzer, so it should be possible to untangle them.

As an alternative which I am also open to, we could keep Analysis, but group CSA tests in “test/Analysis/StaticAnalyzer” and SSAF in “test/Analysis/SSAF”.

I think clang/test/StaticAnalyzer is significantly better than clang/test/Analysis/StaticAnalyzer because it is analogous with clang/lib/StaticAnalyzer, clang/unittests/StaticAnalyzer and clang/include/clang/StaticAnalyzer (under include we presumably have an extra clang layer because we want that spelled out in the #include directives).

This way if you want to run the same set, you can still run lit test/Analysis.

Running the static analyzer and the SSAF tests together is not very useful, they are independent tools. Even if somebody wants to do so, they could still easily use lit test/StaticAnalyzer; lit test/Scalable.


In early 2025 (before the addition of Scalable), I confirmed/ensured that practically [1] all tests in the Analysis folder either invoked the analyzer with %clang_analyze_cc1, tested analyzer-related features (e.g. help printouts for analyzer options) or tested closely related tools (scan-build, exploded-graph-rewriter).

Based on this I was confident that all tests in the Analysis folder “belong to” the analyzer, because I didn’t think about the possibility that some tests just use the analyzer as a tool for validating something – like the CFG tests mentioned by @NoQ do.

  1. Does anybody know about any other such “uses the analyzer but tests something else” test group?
  2. Are these CFG tests (31 files) significant enough to have their own separate directory apart from the analyzer tests?

[1] Now that I ran a quick check I noticed that I forgot to remove/relocate PR9741.cpp at that time. We should re-check the directory for such stragglers, but we can be confident that there is at most one or two such exception among the many hundreds of test files.


I will discuss this with my colleagues, in particular with @gamesh411 who usually works on the integration of the upstream and downstream changes.

My first guess is that it would be easier to ensure a clean transition if the Analysis dir does not exist at all in the new directory layout. Then e.g. we could include test under the test-clang-analysis target which fails if clang/test/Analysis exists (and prints a helpful message that describes the transition).

Let’s revive this thread which was apparently forgotten for a month :sweat_smile:

I discussed this with @gamesh411 and my other colleagues, they supported moving the static analyzer tests from clang/test/Analysis to clang/test/StaticAnalyzer and say that it will be easy to follow this with our downstream stuff.

@necto Do I understand it correctly that you would also support this move?

@steakhal @ any other SSAF dev:
Where would you want to put SSAF tests in this framework? (Do I understand correctly that you prefer clang/test/Scalable?)

@NoQ Would it be acceptable if we move CFG tests together with the “real” static analyzer tests? (Or what else should we do with them?)


By the way, as I wrote above, I think we should remove the directory clang/test/Analysis to reduce the chance for confusion – then if it would reappear, we can immediately spot and delete it.

Renaming/splitting the build target check-clang-analysis is out of scope for this discussion, but we should probably think about it afterwards.

@DonatNagyE Can we proceed with this at the soonest this Friday and preferably finish by next week?

I had a chat downstream and for SSAF, we would prefer mirroring the existing/future practice to name the test dir after the library component. This leads us to clang/test/ScalableStaticAnalysis.

There are other Analyses, such as FlowSensitive and FlowSensitive, ThreadSafety. I’m not sure if we can touch any of those TBH. We would need consensus and strong arguments for moving any of those. And the library component argument really pushes for keeping a clang/test/Analysis directory because their libs and headers live under clang/lib/Analysis/{ThreadSafety.cpp,FlowSensitive,LifetimeSafety} so I suppose those should remain untouched inside clang/test/Analysis.

IMO we should also at least add a target for check-clang-static-analyzer to align with the clang/test/StaticAnalyzer directory. But let’s keep that much less intrusive change for the future after this move is done.

Yes, as we discussed.

Ok, that’s a good principle; I support it as an outsider.

Seems fair. [I assume that you intended LifetimeSafety instead of one of the repeated FlowSensitives.]

By the way, the LifetimeSafety tests under test/Analysis/LifetimeSafety have appeared under test/Analysis in July 2025 after my survey for Taking ownership of /clang/test/Analysis in February 2025 – that is why I didn’t know about them.

As far as I see there are no FlowSensitive tests under clang/test/Analysis. I tried find . -iname '*flow*' and it found nothing relevant (assuming that Scalable/PointerFlow is unrelated) and git grep flow.\?sensitve also only finds three ancient static analyzer testcases where “flow-sensitive” is apparently used as an inaccurate synonym of what we currently call “path-sensitive”: no-exit-cfg.c, security-syntax-checks.m and unreachable-code-path.c.

There is only a single test for -Wthread-safety under clang/test/Analysis, which was added in May 2025, again after my cleanup. All the other -Wthread-safety tests (19 files) are scattered in other subdirectories of clang/test according to the other features that appear in them, e.g. in Sema, SemaCXX, SemaObjC, SemaObjCXX, Modules, PCH etc. I’m not sure if we should leave it in place or move it elsewhere.


Based on your feedback, my current proposal is:

  • move test/Analysis/Scalable to test/ScalableStaticAnalysis
  • move test/Analysis/thread-safety-handle-parenthesis.cpp to test/SemaCXX/thread-safety-handle-parenthesis.cpp (because it’s a cpp test and this is the directory where more than half of -Wthread-safety tests appear)
  • leave test/Analysis/LifetimeSafety in place for now, but open discussion for finding a different place for it
  • move the rest of test/Analysis to test/StaticAnalyzer
    • this includes the CFG tests that are not tests of the analyzer, but require the analyzer as a testing tool

@steakhal @ anybody else What do you think about this?

1 Like

This plan looks good to me.
I think we should move the CFG tests out to somewhere else because those are unrelated. The argument that they use CSA as a driver is not a solid argument. That should be changed somehow anyway. It is awkward.

I like the proposal and it makes sense to me. One thing I’d add (so other folks following this RFC will know about it as well) is that I am currently working on adding regression tests to test/Analysis/Regression which based on my understanding of @DonatNagyE’s roadmap would also go under test/StaticAnalyzer/Regression.

Do we need to handle this right now, or is it OK if we move them now together with the StaticAnalyzer tests and relocate them in a separate change later?

There are only 30 or so CFG tests, so I felt that they “don’t deserve” to invoke CSA from a second separate test directory – but they don’t “dilute” the static analyzer tests too much if they appear among them.

Also, while the CFG tests use CSA they might be affected affected by CSA engine changes, so I don’t want to have them in a place that doesn’t get executed together with the “real” analyzer tests.

It would be nice to reimplement them without CSA (because CSA seems to be “too heavy”), but I don’t know how difficult would it be and if there are any concrete benefits. While the status quo of testing them among the analyzer tests is a bit awkward, it works as far as I see.


Yes, test/Analysis has many subdirectories, and unless I explicitly mentioned them, they – including this new one – go under test/StaticAnalyzer.

1 Like

It’s okay to move them in the future.

IMO these are exactly the reasons why they should live separately from CSA tests. Because they impact many other tools and diagnostics, like clang’s sema-based diags, thread-safety, lifetime-safety, clang-tidy and more. Many of these users don’t care about CSA itself.

CFG dumps don’t use CSA beyond just legacy reasons that it builds one and already had some flags to dump it.

I don’t think it worth writing anything specific for dumping the CFG. It’s fine to use the CSA “debug.DumpCFG” outside of the clang/test/StaticAnalyzer and this is what I push for in this discussion. The same situation goes for the debug.DumpCallGraph - that also has nothing to do with CSA.

I wasn’t aware of these plans. A directory called Regressions wouldn’t make sense to me - after all, all of the lit tests are regression tests. If someone wants to add tests, then their job is to find the relevant place to put it. Preferably extending an existing test file.

2 Likes

I created [NFC][clang][Sema] Move two tests to SemaCXX by NagyDonat · Pull Request #240864 · llvm/llvm-project · GitHub to move two “dangling” test files (one for -Wthread-safety and one for -Wuninitialized) out of the way before doing the “bulk” moves.

By the way, I’d welcome if clang/test/Analysis was eventually recreated and repopulated by the folks who maintain the analysis-based compiler warnings (after we remove the oppressive amounts of misplaced static analyzer tests…).

However, I think it is more comfortable to split two independent phases:

  1. Remove CSA, SSAF etc. tests that do not belong to clang/test/Analysis from clang/test/Analysis to other locations. (Coordinated by us, discussed in this thread.)
  2. Bring the tests of the analysis-based compiler warnings from other locations (e.g. clang/test/Sema<Language>) to the now-available clang/test/Analysis. This should be coordinated by the maintainers of those warnings, if and when they want to perform this.

We (CSA and SSAF contributors) do not need to be involved in step 2; but we should leave clang/test/Analysis in a nice clean state where (1) the maintainers of the analyzer-based warnings can easily bring in their own tests and (2) they don’t need to act immediately.

I think “clang/test/Analysis does not exist” is a cleaner state than “clang/test/Analysis contains five or so random test files”, this is why I created https://github.com/llvm/llvm-project/pull/240864.

Perhaps eventually those three tests will be moved back to a renewed clang/test/Analysis (along with at least dozens, but probably hundreds of other tests), but until then it is better to have them in SemaCXX (which is the de facto standard place for similar tests) instead of being hidden away in an almost-empty test directory.

@steakhal So do I understand it correctly that you think the “big” commit that moves the bulk of the tests should preserve the status quo that check-clang-analysis executes both the static analyzer and the SSAF tests?

(And after that we introduce separate test targets in a quick follow-up commit.)

By the way, should the move happen in one PR (that creates bot clang/test/StaticAnalyzer and clang/test/ScalableStaticAnalysis) or two PRs (one moves clang/test/Analysis/Scalable to clang/test/ScalableStaticAnalysis, then the other moves the static analyzer tests)?

(I don’t have a strong preference either way.)

For large patches shouldn’t have semantic changes - including cmake config changes. I don’t know how it translates now because there is two ways to think about it:

  1. We move the tests and the cmake target runs the tests in the related LIT directory. This means that after the move the coverage of the cmake target dramatically changes - which might be surprising.
  2. We move the tests and we make the cmake target to still run the same set of tests. This is also surprising because it used to run the tests of the LIT dir that it related to.

It’s bad either way. The question is, which is worse, and pick the other.

IMO the generic principle that the cmake target refers to the related LIT dir wins over short term goals - like not breaking user expectations. And then break those regardless in a followup patch.
So this suggests to me that with the move, the cmake targets will change their test coverage, and also that the new directory should also have a dedicated cmake target to run it. That should also hook into the check-clang cmake target.

I think if we don’t have a strong argument for doing them together, then we should split patches by default. So please propose them as separate changes.

1 Like

Based on this discussion I’ll create two “big” PRs:

  1. Move clang/test/Analysis/Scalable to clang/test/ScalableStaticAnalysis and introduce a new target check-clang-scalable-static-analysis for it. (@steakhal Do I understand it correctly that this would be the natural name?)
  2. Move almost all contents of clang/test/Analysis to clang/test/StaticAnalyzer and introduce a new target check-clang-static-analyzer for it.
    • The directory clang/test/Analysis/LifetimeSafety (which contains only three files!) would remain in place.
    • Should we also leave the 11 files that match cfg* (the CFG tests) in place?

(Plus the already existing “small” PR that moves three tests – I’ll merge that this afternoon or tomorrow morning.)

1 Like

I started to prepare the first „big” commit (moving the SSAF tests), but it turns out that the CMake config is more complex than what I would’ve guessed (a/k/a I don’t know enough about it) so – due to my other tasks – I won’t have time to do it this week.

@steakhal If you happen to be more familiar with the CMake setup and you can quickly create this commit, I’d be very grateful if you could prepare the move of the SSAF tests. (If you don’t have time for it, then I’ll probably be able to make it next week Monday or Tuesday.)

1 Like

PR for moving SSAF tests: [clang][ssaf] Move lit tests to clang/test/ScalableStaticAnalysis by steakhal · Pull Request #241883 · llvm/llvm-project · GitHub