[PATCH] Add warnings so that Clang can catch most of the cases that GCC's -Waddress can catch
David Majnemer
david.majnemer at gmail.com
Tue Feb 18 21:33:33 PST 2014
================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2317
@@ -2299,1 +2316,3 @@
+ "pointer is always %select{true|false}1">,
+ InGroup<TautologicalPointerCompare>;
----------------
`warn_null_array_compare`, `warn_null_function_compare`, and `warn_null_pointer_compare` could be combined using `%select`
================
Comment at: lib/Sema/SemaChecking.cpp:5710
@@ +5709,3 @@
+ bool function = false;
+ bool addressOf = false;
+
----------------
Shouldn't these be capitalized? Something like `IsArray`, `IsFunction`, etc.?
================
Comment at: lib/Sema/SemaChecking.cpp:5751
@@ +5750,3 @@
+ // Pretty print the expression for the diagnostic.
+ std::string str;
+ llvm::raw_string_ostream S(str);
----------------
Same goes for this variable.
================
Comment at: lib/Sema/SemaChecking.cpp:5698
@@ +5697,3 @@
+/// \param Range Extra SourceRange to highlight in the diagnostic
+void Sema::DiagnosePointer(Expr *E, Expr::NullPointerConstantKind NullKind,
+ bool IsEqual, SourceRange Range) {
----------------
`DiagnosePointer` is rather vague, perhaps something like `diagnoseTautologicalPointerCompare` ?
http://llvm-reviews.chandlerc.com/D2645
More information about the cfe-commits
mailing list