[PATCH] D35068: [analyzer] Detect usages of unsafe I/O functions

Daniel Kolozsvari via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 5 05:25:05 PST 2018

koldaniel added inline comments.

Comment at: lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp:618
+  StringRef Name = FD->getIdentifier()->getName();
+  int ArgIndex = llvm::StringSwitch<int>(Name)
+                     .Case("sprintf", 1)
george.karpenkov wrote:
> That's a lot of duplication of 1/0/-1.
> And also 1/0/-1 are cryptic symbols, why not use an enum with a descriptive name?
> Maybe use
> `.Cases("sprintf", "vsprintf", "vfscanf", WARN_UNSAFE)` ?
The duplications will be solved by using .Cases, but is using enum necessary? 1 and 0 refers to the index of the argument which could be a format string. -1 means there is no need to look for a string like this.


More information about the cfe-commits mailing list