[PATCH] Detect mismatching 'new' and 'delete' uses
Ismail Pazarbasi
ismail.pazarbasi at gmail.com
Tue Sep 30 15:35:13 PDT 2014
================
Comment at: include/clang/Sema/Sema.h:8539-8541
@@ +8538,5 @@
+ ///
+ /// If pointee is initialized with array form of 'new', it should be deleted
+ /// with array form delete. If at least one \a matching new-expression is
+ /// found, the function will return false.
+ /// \param DE delete-expression to analyze
----------------
rsmith wrote:
> This should probably say "with the array form of 'delete'."
>
> Also, the function's return type is `void`; it won't return `false`.
Yes, the reason is.. it was the function that used to detect the mismatch. I should have written documentation for the latest revision. I have written them for myself, primarily, because I've got interrupted frequently while making this patch.
================
Comment at: lib/Sema/SemaExprCXX.cpp:2246-2247
@@ +2245,4 @@
+
+ /// \brief Checks whether pointee of \p DE is initialized with mismatching
+ /// \brief form of \a new.
+ /// \param DE delete-expression to check.
----------------
rsmith wrote:
> `\brief` only goes on the first line.
I vaguely recall that is how multi-line brief was supposed to be, but I can't seem to find that on doxygen documentation.
================
Comment at: lib/Sema/SemaExprCXX.cpp:2451
@@ +2450,3 @@
+ // FIXME: This seems... inefficient.
+ SourceLocation RSquare = Lexer::findLocationAfterToken(
+ DeleteLoc, tok::l_square, SourceMgr, getLangOpts(), true);
----------------
Do you have concerns about this function call?
http://reviews.llvm.org/D4661
More information about the cfe-commits
mailing list