Do not warn about format strings that are indexed string literals.
authorStephen Hines <srhines@google.com>
Fri, 16 Sep 2016 01:07:04 +0000 (01:07 +0000)
committerStephen Hines <srhines@google.com>
Fri, 16 Sep 2016 01:07:04 +0000 (01:07 +0000)
commit648c369ef28c7348b707a90f17ef5ba02e5c7832
tree5329982de435cd0bdaf545b0122a9540c82c6ff1
parentb53b62eb69cd5768423786c5ced700bc2d1d2e20
Do not warn about format strings that are indexed string literals.

Summary:
The warning for a format string not being a string literal and therefore
being potentially insecure is overly strict for indices into string
literals. This fix checks if the index into the string literal is
precomputable. If that's the case it will check if the suffix of that
string literal is a valid format string string literal. It will still
issue the aforementioned warning for out of range indices into the
string literal.

Patch by Meike Baumgärtner (meikeb)

Reviewers: rsmith

Subscribers: srhines, cfe-commits

Differential Revision: https://reviews.llvm.org/D24584

llvm-svn: 281686
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/format-strings.c