llvm-project/clang/lib
Nico Weber 0e6daefe8f Warn on mismatched parentheses in memcmp and friends.
Thisadds a new warning that warns on code like this:

  if (memcmp(a, b, sizeof(a) != 0))

The warning looks like:

test4.cc:5:30: warning: size argument in 'memcmp' call is a comparison [-Wmemsize-comparison]
  if (memcmp(a, b, sizeof(a) != 0))
                   ~~~~~~~~~~^~~~
test4.cc:5:7: note: did you mean to compare the result of 'memcmp' instead?
  if (memcmp(a, b, sizeof(a) != 0))
      ^                          ~
                            )
test4.cc:5:20: note: explicitly cast the argument to size_t to silence this warning
  if (memcmp(a, b, sizeof(a) != 0))
                   ^
                   (size_t)(     )
1 warning generated.

This found 2 bugs in chromium and has 0 false positives on both chromium and
llvm.

The idea of triggering this warning on a binop in the size argument is due to
rnk.

llvm-svn: 198063
2013-12-26 23:38:39 +00:00
..
ARCMigrate Replacing calls to getAttr with calls to hasAttr for clarity. No functional change intended -- this only replaces Boolean uses of getAttr. 2013-12-19 02:39:40 +00:00
AST [ms-abi] Fixes improperly sized vfptrs with pragma pack 2013-12-26 22:09:12 +00:00
ASTMatchers [CMake] clang/lib: Prune redundant dependencies. 2013-12-10 02:36:22 +00:00
Analysis Switching getAttrs calls over to using a specific_attr_iterator. No functional changes intended. 2013-12-19 15:35:31 +00:00
Basic Teach the diagnostics engine about the Attr type to make reporting on semantic attributes easier (and not require hard-coded strings). This requires a getSpelling() function on the Attr class, which is table-driven. Updates a handful of cases where a hard-coded string was being used to test the functionality out. Updating associated test cases for the improved quoting. 2013-12-26 18:30:57 +00:00
CodeGen remove dead code. 2013-12-23 19:10:57 +00:00
Driver clang-cl: Support /P and /E (preprocess to file or stdout) 2013-12-20 18:40:46 +00:00
Edit Add front-end infrastructure now address space casts are in LLVM IR. 2013-12-11 13:39:46 +00:00
Format clang-format: (WebKit) Disallow 1-line constructors with initializers. 2013-12-24 13:31:25 +00:00
Frontend TextDiagnosticBuffer: Fix copy-paste mistake in r197856 2013-12-23 07:47:48 +00:00
FrontendTool [CMake] clang/lib: Prune redundant dependencies. 2013-12-10 02:36:22 +00:00
Headers [CMake] clang/lib/Headers: Install just-generated ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h, instead of copied arm_neon.h. 2013-12-21 01:56:00 +00:00
Index [CMake] clang/lib: Satisfy dependencies to add *actually used* libraries on target_link_libraries() and LLVM_LINK_COMPONENTS. 2013-12-09 19:04:43 +00:00
Lex Support and use token kinds as diagnostic arguments 2013-12-24 09:48:30 +00:00
Parse Support and use token kinds as diagnostic arguments 2013-12-24 09:48:30 +00:00
Rewrite Fix raw lex crash and -frewrite-includes noeol-at-eof failure 2013-12-13 17:04:55 +00:00
Sema Warn on mismatched parentheses in memcmp and friends. 2013-12-26 23:38:39 +00:00
Serialization Serialize source range info for TypeTraitExpr. 2013-12-20 01:26:47 +00:00
StaticAnalyzer Fix another misuse of getCustomDiagID() 2013-12-23 17:59:59 +00:00
Tooling CompilationDatabase.cpp:stripPositionalArgs(): Match not "no-integrated-as" but "-no-integrated-as", it really fixes r197229. 2013-12-14 06:03:28 +00:00
CMakeLists.txt Fix dependencies now that the ARC migrator depends on the static analyzer. 2013-08-22 15:50:02 +00:00
Makefile Fix dependencies now that the ARC migrator depends on the static analyzer. 2013-08-22 15:50:02 +00:00