[PATCH] D35068: [analyzer] Detect usages of unsafe I/O functions
George Karpenkov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 5 16:57:05 PST 2018
george.karpenkov 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.
Right, then I guess 1 and 0 are self-descriptive, but I would still add a separate constant for `-1`.
More information about the cfe-commits