[NFC][analyzer] Use %clang_analyze_cc1 consistently (#145895)

A large majority of the LIT tests of the clang static analyzer use RUN
lines with the placeholder `%clang_analyze_cc1` which expands to
`%clang_cc1 -analyze -setup-static-analyzer` where the only effect of
`-setup-static-analyzer` is that it ensures that the macro
`__clang_analyzer__` is defined. However, there were some tests that
used `%clang_cc1 -analyze` directly; this commit changes those to using
`%clang_analyze_cc1` for the sake of consistency.

Previously `%clang_analyze_cc1` did not work within the directory
`exploded-graph-rewriter` (because that directory has its own custom
`lit.local.cfg`) but this problem was eliminated by the recent commit
40cc4379cd, so it was possible to resolve
and delete the FIXME comments asking for this change.

There are a few tests that use `%clang --analyze` or other command-line
flags (e.g. help flags), those are not affected by this change.

This cleanup was discussed in the discourse thread
https://discourse.llvm.org/t/taking-ownership-of-clang-test-analysis/84689/11
This commit is contained in:
Donát Nagy
2025-06-30 12:59:51 +02:00
committed by GitHub
parent 3a7d60860d
commit c3f8dd1228
39 changed files with 58 additions and 65 deletions

View File

@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -analyze -analyzer-checker=cplusplus.ArrayDelete -std=c++11 -verify -analyzer-output=text %s
// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.ArrayDelete -std=c++11 -verify -analyzer-output=text %s
struct Base {
virtual ~Base() = default;

View File

@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.cplusplus.DeleteWithNonVirtualDtor -std=c++11 -verify -analyzer-output=text %s
// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.cplusplus.DeleteWithNonVirtualDtor -std=c++11 -verify -analyzer-output=text %s
struct Virtual {
virtual ~Virtual() {}

View File

@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -analyze -analyzer-checker=core -w -DNO_CROSSCHECK -verify %s
// RUN: %clang_cc1 -analyze -analyzer-checker=core -w -analyzer-config crosscheck-with-z3=true -verify %s
// RUN: %clang_analyze_cc1 -analyzer-checker=core -w -DNO_CROSSCHECK -verify %s
// RUN: %clang_analyze_cc1 -analyzer-checker=core -w -analyzer-config crosscheck-with-z3=true -verify %s
// REQUIRES: z3
// XFAIL: *

View File

@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-expand-default-aggr-inits=true %s > %t 2>&1
// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -analyzer-config cfg-expand-default-aggr-inits=true %s > %t 2>&1
// RUN: FileCheck --input-file=%t %s
static char a[] = "foobar";

View File

@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple=i386-apple-darwin10 -verify %s -analyze \
// RUN: %clang_analyze_cc1 -triple=i386-apple-darwin10 -verify %s \
// RUN: -analyzer-checker=debug.ExprInspection
#define NULL 0

View File

@@ -3,7 +3,7 @@
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++17 \
// RUN: -emit-pch -o %t/ctudir/ctu-cxxdefaultinitexpr-import.cpp.ast %S/Inputs/ctu-cxxdefaultinitexpr-import.cpp
// RUN: cp %S/Inputs/ctu-cxxdefaultinitexpr-import.cpp.externalDefMap.ast-dump.txt %t/ctudir/externalDefMap.txt
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++17 -analyze \
// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -std=c++17 \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-config experimental-enable-naive-ctu-analysis=true \
// RUN: -analyzer-config ctu-dir=%t/ctudir \

View File

@@ -3,7 +3,7 @@
// RUN: %clang_cc1 \
// RUN: -emit-pch -o %t/ctudir2/ctu-import.c.ast %S/Inputs/ctu-import.c
// RUN: cp %S/Inputs/ctu-import.c.externalDefMap.ast-dump.txt %t/ctudir2/externalDefMap.txt
// RUN: %clang_cc1 -analyze \
// RUN: %clang_analyze_cc1 \
// RUN: -analyzer-checker=core,debug.ExprInspection \
// RUN: -analyzer-config eagerly-assume=false \
// RUN: -analyzer-config experimental-enable-naive-ctu-analysis=true \

View File

@@ -1,6 +1,6 @@
// Ensure analyzer option 'ctu-import-threshold' is a recognized option.
//
// RUN: %clang_cc1 -analyze -analyzer-config ctu-import-threshold=30 -verify %s
// RUN: %clang_cc1 -analyze -analyzer-config ctu-import-cpp-threshold=30 -verify %s
// RUN: %clang_analyze_cc1 -analyzer-config ctu-import-threshold=30 -verify %s
// RUN: %clang_analyze_cc1 -analyzer-config ctu-import-cpp-threshold=30 -verify %s
//
// expected-no-diagnostics

View File

@@ -7,7 +7,7 @@
// RUN: %clang_cc1 -emit-pch %/S/Inputs/ctu-lookup-name-with-space.cpp -o %t/importee.ast
// RUN: cd %t
// RUN: %clang_cc1 -analyze \
// RUN: %clang_analyze_cc1 \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-config experimental-enable-naive-ctu-analysis=true \
// RUN: -analyzer-config ctu-dir=. \

View File

@@ -4,7 +4,7 @@
// RUN: -emit-pch -o %t/ctudir2/ctu-other.c.ast %S/Inputs/ctu-other.c
// RUN: cp %S/Inputs/ctu-other.c.externalDefMap.ast-dump.txt %t/ctudir2/externalDefMap.txt
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c89 -analyze \
// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -std=c89 \
// RUN: -analyzer-checker=core,debug.ExprInspection \
// RUN: -analyzer-config eagerly-assume=false \
// RUN: -analyzer-config experimental-enable-naive-ctu-analysis=true \
@@ -14,7 +14,7 @@
// Simulate the behavior of the previous CTU implementation by inlining all
// functions during the first phase. This way, the second phase is a noop.
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c89 -analyze \
// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -std=c89 \
// RUN: -analyzer-checker=core,debug.ExprInspection \
// RUN: -analyzer-config eagerly-assume=false \
// RUN: -analyzer-config experimental-enable-naive-ctu-analysis=true \

View File

@@ -11,7 +11,7 @@
//
// RUN: cd "%t" && %clang_extdef_map "%t/ctu-other.c" > externalDefMap.txt
//
// RUN: cd "%t" && %clang_cc1 -std=c89 -analyze \
// RUN: cd "%t" && %clang_analyze_cc1 -std=c89 \
// RUN: -analyzer-checker=core,debug.ExprInspection \
// RUN: -analyzer-config experimental-enable-naive-ctu-analysis=true \
// RUN: -analyzer-config ctu-dir=. \

View File

@@ -3,7 +3,7 @@
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++17 \
// RUN: -emit-pch -o %t/ctudir/ctu-test-import-failure-import.cpp.ast %S/Inputs/ctu-test-import-failure-import.cpp
// RUN: cp %S/Inputs/ctu-test-import-failure-import.cpp.externalDefMap.ast-dump.txt %t/ctudir/externalDefMap.txt
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++17 -analyze \
// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -std=c++17 \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-config experimental-enable-naive-ctu-analysis=true \
// RUN: -analyzer-config ctu-dir=%t/ctudir \

View File

@@ -1,7 +1,6 @@
// FIXME: Figure out how to use %clang_analyze_cc1 with our lit.local.cfg.
// RUN: %clang_cc1 -analyze -triple x86_64-unknown-linux-gnu \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-dump-egraph=%t.dot %s
// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux-gnu \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-dump-egraph=%t.dot %s
// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
struct S {};

View File

@@ -1,7 +1,6 @@
// FIXME: Figure out how to use %clang_analyze_cc1 with our lit.local.cfg.
// RUN: %clang_cc1 -analyze -triple x86_64-unknown-linux-gnu \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-dump-egraph=%t.dot %s
// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux-gnu \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-dump-egraph=%t.dot %s
// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
void escapes(void) {

View File

@@ -1,7 +1,6 @@
// FIXME: Figure out how to use %clang_analyze_cc1 with our lit.local.cfg.
// RUN: %clang_cc1 -analyze -triple x86_64-unknown-linux-gnu \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-dump-egraph=%t.dot %s
// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux-gnu \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-dump-egraph=%t.dot %s
// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
struct A {

View File

@@ -1,8 +1,7 @@
// CAUTION: The name of this file should start with `l` for proper tests.
// FIXME: Figure out how to use %clang_analyze_cc1 with our lit.local.cfg.
// RUN: %clang_cc1 -analyze -triple x86_64-unknown-linux-gnu \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-dump-egraph=%t.dot %s
// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux-gnu \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-dump-egraph=%t.dot %s
// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
void test1() {

View File

@@ -6,10 +6,9 @@ void *foo(void) {
// The code above shall go first, because check tags below are sensetive to the line numbers on which the code is placed.
// You can change lines below in the way you need.
// FIXME: Figure out how to use %clang_analyze_cc1 with our lit.local.cfg.
// RUN: %clang_cc1 -analyze -triple x86_64-unknown-linux-gnu \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-dump-egraph=%t.dot %s
// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux-gnu \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-dump-egraph=%t.dot %s
// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
// CHECK: macros.c:<b>3</b>:<b>10</b>

View File

@@ -1,8 +1,7 @@
// FIXME: Figure out how to use %clang_analyze_cc1 with our lit.local.cfg.
// RUN: %clang_cc1 -std=c++14 -analyze -triple x86_64-unknown-linux-gnu \
// RUN: -analyze-function "test()" \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-dump-egraph=%t.dot %s
// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-unknown-linux-gnu \
// RUN: -analyze-function "test()" \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-dump-egraph=%t.dot %s
// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
struct S {

View File

@@ -1,7 +1,6 @@
// FIXME: Figure out how to use %clang_analyze_cc1 with our lit.local.cfg.
// RUN: %clang_cc1 -analyze -triple x86_64-unknown-linux-gnu \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-dump-egraph=%t.dot %s
// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux-gnu \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-dump-egraph=%t.dot %s
// RUN: %exploded_graph_rewriter --verbose %t.dot 2>&1 | FileCheck %s
// REQUIRES: system-windows

View File

@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -verify %s
// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -verify %s
#include "Inputs/system-header-simulator.h"

View File

@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -analyze \
// RUN: %clang_analyze_cc1 \
// RUN: -analyzer-checker=core,debug.ExprInspection %s -verify
// These test cases demonstrate lack of Static Analyzer features.

View File

@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -analyze \
// RUN: %clang_analyze_cc1 \
// RUN: -analyzer-checker=core,debug.ExprInspection %s -verify
// These test cases demonstrate lack of Static Analyzer features.

View File

@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-config eagerly-assume=false -analyzer-checker=core.uninitialized.Assign,debug.ExprInspection -verify %s
// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -analyzer-config eagerly-assume=false -analyzer-checker=core.uninitialized.Assign,debug.ExprInspection -verify %s
void clang_analyzer_eval(int);

View File

@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -std=c++14 -triple i386-apple-darwin10 -analyze -analyzer-config eagerly-assume=false -analyzer-checker=core.uninitialized.Assign,core.builtin,debug.ExprInspection,core.uninitialized.UndefReturn -verify %s
// RUN: %clang_analyze_cc1 -std=c++14 -triple i386-apple-darwin10 -analyzer-config eagerly-assume=false -analyzer-checker=core.uninitialized.Assign,core.builtin,debug.ExprInspection,core.uninitialized.UndefReturn -verify %s
template <typename T>
void clang_analyzer_dump(T x);

View File

@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-lifetime=true %s > %t 2>&1
// RUN: %clang_analyze_cc1 -fcxx-exceptions -fexceptions -analyzer-checker=debug.DumpCFG -analyzer-config cfg-lifetime=true %s > %t 2>&1
// RUN: FileCheck --input-file=%t %s
// FIXME Most of the cases in this file test only with the objects of type `A`,

View File

@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-loopexit=true %s > %t 2>&1
// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -analyzer-config cfg-loopexit=true %s > %t 2>&1
// RUN: FileCheck --input-file=%t %s
// CHECK: [B6 (ENTRY)]

View File

@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -analyzer-checker=core -verify %s -Wno-incomplete-implementation
// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s -Wno-incomplete-implementation
typedef signed char BOOL;
typedef int NSInteger;
typedef unsigned int NSUInteger;

View File

@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -w -fblocks -analyze -analyzer-checker=core,deadcode,alpha.core,debug.ExprInspection -verify %s
// RUN: %clang_analyze_cc1 -w -fblocks -analyzer-checker=core,deadcode,alpha.core,debug.ExprInspection -verify %s
void *malloc(unsigned long);
void clang_analyzer_warnIfReached(void);

View File

@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -analyze -analyzer-checker=debug.ExprInspection -verify %s
// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify %s
// expected-no-diagnostics
void clang_analyzer_eval(int);

View File

@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core.builtin -fopenmp -verify %s
// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -analyzer-checker=core.builtin -fopenmp -verify %s
// expected-no-diagnostics
void openmp_parallel_crash_test(void) {

View File

@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -analyze -analyzer-checker=debug.AnalysisOrder -analyzer-config debug.AnalysisOrder:PointerEscape=true -analyzer-config debug.AnalysisOrder:PostCall=true %s 2>&1 | FileCheck %s
// RUN: %clang_analyze_cc1 -analyzer-checker=debug.AnalysisOrder -analyzer-config debug.AnalysisOrder:PointerEscape=true -analyzer-config debug.AnalysisOrder:PostCall=true %s 2>&1 | FileCheck %s
void f(int *);

View File

@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-scopes=true %s > %t 2>&1
// RUN: %clang_analyze_cc1 -fcxx-exceptions -fexceptions -analyzer-checker=debug.DumpCFG -analyzer-config cfg-scopes=true %s > %t 2>&1
// RUN: FileCheck --input-file=%t %s
class A {

View File

@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -analyze -analyzer-checker=optin.taint,core,security.ArrayBound -analyzer-output=text -verify %s
// RUN: %clang_analyze_cc1 -analyzer-checker=optin.taint,core,security.ArrayBound -analyzer-output=text -verify %s
// This file is for testing enhanced diagnostics produced by the GenericTaintChecker

View File

@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -analyze -analyzer-checker=debug.AnalysisOrder -analyzer-config debug.AnalysisOrder:Bind=true -analyzer-config debug.AnalysisOrder:RegionChanges=true %s 2>&1 | FileCheck %s
// RUN: %clang_analyze_cc1 -analyzer-checker=debug.AnalysisOrder -analyzer-config debug.AnalysisOrder:Bind=true -analyzer-config debug.AnalysisOrder:RegionChanges=true %s 2>&1 | FileCheck %s
struct Super {
virtual void m();

View File

@@ -1,6 +1,6 @@
// RUN: rm -rf %T/ctudir
// RUN: mkdir %T/ctudir
// RUN: %clang_cc1 -analyze -analyzer-checker=debug.ExprInspection -analyzer-config experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir -verify %s
// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -analyzer-config experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir -verify %s
// expected-no-diagnostics
struct S {

View File

@@ -5,7 +5,7 @@
// DEFINE: %{mocked_clang} = \
// DEFINE: LD_PRELOAD="%llvmshlibdir/MockZ3SolverCheck%pluginext" \
// DEFINE: %clang_cc1 %s -analyze -setup-static-analyzer \
// DEFINE: %clang_analyze_cc1 %s \
// DEFINE: -analyzer-config crosscheck-with-z3=true \
// DEFINE: -analyzer-checker=core

View File

@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -DNO_CROSSCHECK -verify %s
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config crosscheck-with-z3=true -verify %s
// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,unix.Malloc,debug.ExprInspection -DNO_CROSSCHECK -verify %s
// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config crosscheck-with-z3=true -verify %s
// REQUIRES: z3
// XFAIL: *

View File

@@ -1,6 +1,6 @@
// RUN: Z3_SOLVER_RESULTS="SAT,SAT,SAT,SAT,UNDEF" \
// RUN: LD_PRELOAD="%llvmshlibdir/MockZ3SolverCheck%pluginext" \
// RUN: %clang_cc1 -analyze -analyzer-constraints=z3 -setup-static-analyzer \
// RUN: %clang_analyze_cc1 -analyzer-constraints=z3 \
// RUN: -analyzer-checker=core %s -verify
//
// REQUIRES: z3, z3-mock, asserts, shell, system-linux

View File

@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -analyze -analyzer-constraints=z3 -setup-static-analyzer \
// RUN: %clang_analyze_cc1 -analyzer-constraints=z3 \
// RUN: -analyzer-checker=core,debug.ExprInspection %s 2>&1 | FileCheck %s
//
// REQUIRES: z3