[clang] [clang][analyzer] Add taintedness to argv (PR #178054)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 11 04:42:37 PST 2026


================
@@ -0,0 +1,14 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=optin.taint,core,security.ArrayBound -analyzer-config assume-controlled-environment=false -analyzer-output=text -verify %s
+
+// This file is for testing enhanced diagnostics produced by the GenericTaintChecker
+
+// In an untrusted environment the cmd line arguments
+// are assumed to be tainted.
+int main( int argc, char *argv[], char *envp[] ) {// expected-note {{Taint originated in 'argc'}}
+   if (argc < 1)// expected-note {{'argc' is >= 1}}
+                // expected-note at -1 {{Taking false branch}}
+     return 1;         
----------------
steakhal wrote:

Unless there are compelling reasons for not following the llvm coding style, I'd advocate for honouring it even in tests. Especially for new tests.
https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements

```suggestion
   if (argc < 1) {
     // expected-note at -1  {{'argc' is >= 1}} expected-note at -1 {{Taking false branch}}
     return 1;
   }
```

As a side note, for some reasons your files contain trailing whitespaces. Please get rid of those.

https://github.com/llvm/llvm-project/pull/178054


More information about the cfe-commits mailing list