[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2019-05-06 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan marked 2 inline comments as done. leonardchan added inline comments. Comment at: lib/Sema/SemaType.cpp:4913-4916 +ExpectNoDerefChunk = false; + } + + ExpectNoDerefChunk = state.didParseNoDeref(); dblaikie wrote: > Pointed out in PR41

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2019-05-06 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments. Comment at: lib/Sema/SemaType.cpp:4913-4916 +ExpectNoDerefChunk = false; + } + + ExpectNoDerefChunk = state.didParseNoDeref(); Pointed out in PR41774 there's a dead store to ExpectNoDerefChunk here. Should line 4

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-12-05 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rC348442: [Sema/Attribute] Check for noderef attribute (authored by leonardchan, committed by ). Changed prior to commit: https://reviews.llvm.org/D49511?vs=176907&id=176908#toc Repository: rC Clang C

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-12-05 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 176907. leonardchan marked an inline comment as done. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D49511/new/ https://reviews.llvm.org/D49511 Files: clang/include/clang/Basic/Attr.td clang/include/clang/Basic/AttrDocs

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-12-05 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision. rsmith added a comment. Thanks for your patience. Comment at: clang/lib/Sema/SemaInit.cpp:7838-7854 + if (const auto *FromPtrType = SourceType->getAs()) { +if (const auto *ToPtrType = Step->Type->getAs()) { + if (FromPtrType-

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-12-04 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment. *ping* @rsmith Any more comments on this patch or the one before it (https://reviews.llvm.org/D54014)? That one has the fix for pushing and popping another ExprEvalContext before acting on a function body in this patch. Repository: rC Clang CHANGES SINCE LAST AC

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-11-05 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 172695. leonardchan marked 5 inline comments as done. Repository: rC Clang https://reviews.llvm.org/D49511 Files: clang/include/clang/Basic/Attr.td clang/include/clang/Basic/AttrDocs.td clang/include/clang/Basic/DiagnosticGroups.td clang/includ

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-11-05 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments. Comment at: lib/Parse/ParseStmt.cpp:102-104 + Actions.PushExpressionEvaluationContext( + Actions.ExprEvalContexts.back().Context); ParenBraceBracketBalancer BalancerRAIIObj(*this); leonardchan wrote: > rsmith wrote: > >

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-10-31 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan marked 2 inline comments as done. leonardchan added inline comments. Comment at: lib/Parse/ParseStmt.cpp:102-104 + Actions.PushExpressionEvaluationContext( + Actions.ExprEvalContexts.back().Context); ParenBraceBracketBalancer BalancerRAIIObj(*this); -

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-10-03 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr added a comment. The motivating use case always pairs `noderef` with an `address_space` attribute, and it's already invalid to convert between pointer types in different address spaces without a cast. So I don't think we have a strong opinion one way or the other. In the abstract, I'd

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-10-03 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments. Comment at: include/clang/Basic/AttrDocs.td:3513 + int x = 2; + int &y = x; // warning: 'noderef' can only be used on an array or pointer type + Should `noderef` appear somewhere in this example? :) Comment at:

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-09-10 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 164706. leonardchan added a comment. - Push and pop contexts for every parsed statement inside `ParseStatementOrDeclaration` instead of at the start and end of compound statements Repository: rC Clang https://reviews.llvm.org/D49511 Files: includ

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-09-05 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 164136. leonardchan added a comment. - Push and pop a new ExpressionEvaluationContext when we enter and exit a compound statement. - Remove Start/StopCheckingNoderef functions since we can now warn whenever we pop Repository: rC Clang https://review

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-24 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment. @rsmith ping Repository: rC Clang https://reviews.llvm.org/D49511 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-22 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments. Comment at: lib/Parse/ParseExpr.cpp:1126 + +Actions.StartCheckingNoDeref(); + rsmith wrote: > leonardchan wrote: > > rsmith wrote: > > > This parser-driven start/stop mechanism will not work in C++ templates. > > > Instead,

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-22 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 162126. leonardchan marked 13 inline comments as done. Repository: rC Clang https://reviews.llvm.org/D49511 Files: include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td include/clang/Basic/DiagnosticGroups.td include/clang/Basic/Diagnosti

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-21 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments. Comment at: lib/Parse/ParseExpr.cpp:1126 + +Actions.StartCheckingNoDeref(); + leonardchan wrote: > rsmith wrote: > > This parser-driven start/stop mechanism will not work in C++ templates. > > Instead, can you remove the "start"

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-21 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment. In https://reviews.llvm.org/D49511#1206267, @rsmith wrote: > In https://reviews.llvm.org/D49511#1206265, @rsmith wrote: > > > In https://reviews.llvm.org/D49511#1194716, @leonardchan wrote: > > > > > @rsmith any more feedback on this current version? If it still looks

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-21 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments. Comment at: lib/Parse/ParseExpr.cpp:1126 + +Actions.StartCheckingNoDeref(); + rsmith wrote: > This parser-driven start/stop mechanism will not work in C++ templates. > Instead, can you remove the "start" part and check the

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-21 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 161785. leonardchan marked 6 inline comments as done and an inline comment as not done. Repository: rC Clang https://reviews.llvm.org/D49511 Files: include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td include/clang/Basic/DiagnosticGroups.t

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment. In https://reviews.llvm.org/D49511#1206265, @rsmith wrote: > In https://reviews.llvm.org/D49511#1194716, @leonardchan wrote: > > > @rsmith any more feedback on this current version? If it still looks > > incorrect to use the record this way, I don't mind simplifying it to

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment. In https://reviews.llvm.org/D49511#1194716, @leonardchan wrote: > @rsmith any more feedback on this current version? If it still looks > incorrect to use the record this way, I don't mind simplifying it to work on > lvalue to rvalue conversions without checking for a lea

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments. Comment at: lib/Parse/ParseExpr.cpp:1126 + +Actions.StartCheckingNoDeref(); + This parser-driven start/stop mechanism will not work in C++ templates. Instead, can you remove the "start" part and check the noderef exprs as part o

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-15 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 160892. leonardchan marked 6 inline comments as done. Repository: rC Clang https://reviews.llvm.org/D49511 Files: include/clang/AST/Type.h include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td include/clang/Basic/DiagnosticGroups.td inc

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. A few more minor nits to be cleared up, but otherwise LGTM. You should wait for @rsmith to sign off before committing in case he has further comments, however.

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-13 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments. Comment at: lib/Sema/SemaExpr.cpp:14249 + +if (Sema::TypeHasNoDeref(Inner)) + DeclRef = E; aaron.ballman wrote: > leonardchan wrote: > > aaron.ballman wrote: > > > The sugar was stripped off at the pointer level, but no

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-13 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 160451. leonardchan marked 3 inline comments as done. leonardchan added a comment. - Remove sugar from pointee types Repository: rC Clang https://reviews.llvm.org/D49511 Files: include/clang/AST/Type.h include/clang/Basic/Attr.td include/clang/

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: lib/Sema/SemaExpr.cpp:14249 + +if (Sema::TypeHasNoDeref(Inner)) + DeclRef = E; leonardchan wrote: > aaron.ballman wrote: > > The sugar was stripped off at the pointer level, but not at the pointee > > lev

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-13 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment. @rsmith Comment at: lib/Sema/SemaExpr.cpp:14249 + +if (Sema::TypeHasNoDeref(Inner)) + DeclRef = E; aaron.ballman wrote: > The sugar was stripped off at the pointer level, but not at the pointee > level. e.g., > ``` > typed

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: lib/Sema/SemaExpr.cpp:14249 + +if (Sema::TypeHasNoDeref(Inner)) + DeclRef = E; The sugar was stripped off at the pointer level, but not at the pointee level. e.g., ``` typedef int (bobble); typedef bobble

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-13 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 160403. leonardchan marked an inline comment as done. leonardchan added a comment. - Checks for sugared types and expressions wrapped in parenthesis Repository: rC Clang https://reviews.llvm.org/D49511 Files: include/clang/AST/Type.h include/clan

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: lib/Sema/SemaExpr.cpp:14251-14253 +if (const auto *Ptr = dyn_cast(Ty)) + Inner = Ptr->getPointeeType(); +else if (const auto *Arr = dyn_cast(Ty)) I don't think this strips off sugar from the type, so I

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. Oops, I hit "Send" too soon. I was going to say that you should also keep an eye on https://reviews.llvm.org/D50526 because that may impact this patch (or vice versa if this one lands first). Repository: rC Clang https://reviews.llvm.org/D49511

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-09 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment. @rsmith any more feedback on this current version? If it still looks incorrect to use the record this way, I don't mind simplifying it to work on lvalue to rvalue conversions without checking for a leading address space operation. Repository: rC Clang https://re

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-06 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 159409. leonardchan marked 3 inline comments as done. leonardchan added a comment. - Changed tick to single quote in diagnostic Repository: rC Clang https://reviews.llvm.org/D49511 Files: include/clang/AST/Type.h include/clang/Basic/Attr.td inc

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: include/clang/Basic/AttrDocs.td:3489 + +``noderef`` is currently only supported for C style pointers and arrays and not usable for +references or Objective-C pointers. I would drop the "C style" and just say it's

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-07-31 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 158423. leonardchan added a comment. - Moved the counter and set into `ExpressionEvaluationContextRecord` Repository: rC Clang https://reviews.llvm.org/D49511 Files: include/clang/AST/Type.h include/clang/Basic/Attr.td include/clang/Basic/AttrD

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-07-31 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment. > Your current counter-based approach doesn't work very well in the case where > we switch to another context while processing an expression (for example, > during template instantiation): you'll defer all the diagnostics for the > inner construct until the outer co

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-07-31 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment. > You shouldn't be adding your own `ExpressionEvaluationContextRecord`s. What I > was suggesting is that you store a list of pending `noderef` expressions on > the record, and diagnose them when the record is popped (if they've not been > removed since). This is

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-07-31 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 158407. leonardchan marked 6 inline comments as done. leonardchan added a comment. - Added tests for checking that `noderef` can only be used for C style pointers and arrays (not usable for references or ObjC pointers) - Added warnings for dereferencing a

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-07-27 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr added a comment. I think this wants to be a hard error rather than a warning. Though since we use -Werror anyway if others feel strongly contrary I won't object. Repository: rC Clang https://reviews.llvm.org/D49511 ___ cfe-commits mail

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-07-27 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment. In https://reviews.llvm.org/D49511#1170693, @leonardchan wrote: > Done. I opted for not using `ExpressionEvaluationContextRecord` because I > don't think I was using it correctly. A few other tests in sema failed when I > tried pushing and popping from the stack holding

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-07-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: include/clang/Basic/AttrDocs.td:3426 + let Content = [{ +The ``noderef`` attribute causes clang to throw a warning whenever a pointer marked with +this attribute is dereferenced. This is ideally used with pointers that point to

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-07-25 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment. @aaron.ballman @rsmith Any more feedback on this patch? Repository: rC Clang https://reviews.llvm.org/D49511 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-c

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-07-23 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments. Comment at: include/clang/Basic/AttrDocs.td:3426 + let Content = [{ +The ``noderef`` attribute causes clang to throw a warning whenever a pointer marked with +this attribute is dereferenced. This is ideally used with pointers that point to sp

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-07-23 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 156826. leonardchan marked 21 inline comments as done. Repository: rC Clang https://reviews.llvm.org/D49511 Files: include/clang/AST/Type.h include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td include/clang/Basic/DiagnosticSemaKinds.td

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-07-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: include/clang/Basic/AttrDocs.td:3426 + let Content = [{ +The ``noderef`` attribute causes clang to throw a warning whenever a pointer marked with +this attribute is dereferenced. This is ideally used with pointers that point to

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-07-20 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment. In https://reviews.llvm.org/D49511#1168692, @rsmith wrote: > The way in which you're checking for the problematic cases is unnecessarily > expensive. Instead of performing a separate AST traversal, please detect > whether you should be producing the warning directly

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-07-20 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 156634. leonardchan marked 2 inline comments as done. Repository: rC Clang https://reviews.llvm.org/D49511 Files: include/clang/AST/Type.h include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td include/clang/Basic/DiagnosticGroups.td inc

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-07-19 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a reviewer: aaron.ballman. erik.pilkington added a comment. Thanks for working on this! CCing Aaron, who is code owner for attributes. Comment at: include/clang/Basic/AttrDocs.td:3355 + let Content = [{ +The ``noderef`` attribute allows for showing a warn

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-07-19 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment. The way in which you're checking for the problematic cases is unnecessarily expensive. Instead of performing a separate AST traversal, please detect whether you should be producing the warning directly when forming the problematic expressions. (For example, you could sto

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-07-18 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 156167. leonardchan added a comment. - Added checks for expressions in statements other than declarations or expression statements Repository: rC Clang https://reviews.llvm.org/D49511 Files: include/clang/AST/Type.h include/clang/Basic/Attr.td

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-07-18 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision. leonardchan added reviewers: phosek, mcgrathr. leonardchan added a project: clang. This patch adds the `noderef` attribute in clang and checks for dereferences of types that have this attribute. This attribute is currently used by sparse and would like to be po