1. May 17, 2024
  2. May 16, 2024
    • Florian Hahn's avatar
      [VPlan] Address remaining comments for #85689. · 309a881d
      Florian Hahn authored
      Address comments missed when landing
      https://github.com/llvm/llvm-project/pull/85689.
      309a881d
    • Matt Arsenault's avatar
    • Renaud Kauffmann's avatar
      [flang] AliasAnalysis: More formally define and distinguish between data and non-data (#91020) · ee407e17
      Renaud Kauffmann authored
      This PR is an implementation for changes proposed in
      https://discourse.llvm.org/t/rfc-distinguish-between-data-and-non-data-in-fir-alias-analysis/78759
      
      Test updates were made when the query was on the wrong reference. So, it
      is my hope that this will clear ambiguity on the nature of the queries
      from here on.
      There are also some TODOs that were addressed. 
      
      It also partly implements what
      https://github.com/llvm/llvm-project/pull/87723 is attempting to
      accomplish. At least, on a point-to-point query between references, the
      distinction is made. To apply it to TBAA, would be another PR.
      
      Note that, the changes were minimal in the TBAA code to retain the
      current results.
      ee407e17
    • Dana Jansens's avatar
      Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (#91777) · 5ac34358
      Dana Jansens authored
      The -Wunsafe-buffer-usage warning should fire on any call to a function
      annotated with [[clang::unsafe_buffer_usage]], however it omitted calls
      to constructors, since the expression is a CXXConstructExpr which does
      not subclass CallExpr. Thus the matcher on callExpr() does not find
      these expressions.
      
      Add a new WarningGadget that matches cxxConstructExpr that are calling a
      CXXConstructDecl annotated by [[clang::unsafe_buffer_usage]] and fires
      the warning. The new UnsafeBufferUsageCtorAttrGadget gadget explicitly
      avoids matching against the std::span(ptr, size) constructor because
      that is handled by SpanTwoParamConstructorGadget and we never want two
      gadgets to match the same thing (and this is guarded by asserts).
      
      The gadgets themselves do not report the warnings, instead each gadget's
      Stmt is passed to the UnsafeBufferUsageHandler (implemented by
      UnsafeBufferUsageReporter). The Reporter is previously hardcoded that a
      CXXConstructExpr statement must be a match for std::span(ptr, size), but
      that is no longer the case. We want the Reporter to generate different
      warnings (in the -Wunsafe-buffer-usage-in-container subgroup) for the
      span contructor. And we will want it to report more warnings for other
      std-container-specific gadgets in the future. To handle this we allow
      the gadget to control if the warning is general (it calls
      handleUnsafeBufferUsage()) or is a std-container-specific warning (it
      calls handleUnsafeOperationInContainer()).
      
      Then the WarningGadget grows a virtual method to dispatch to the
      appropriate path in the UnsafeBufferUsageHandler. By doing so, we no
      longer need getBaseStmt in the Gadget interface. The only use of it for
      FixableGadgets was to get the SourceLocation, so we make an explicit
      virtual method for that on Gadget. Then the handleUnsafeOperation()
      dispatcher can be a virtual method that is only in WarningGadget.
      
      The SpanTwoParamConstructorGadget gadget dispatches to
      handleUnsafeOperationInContainer() while the other WarningGadgets all
      dispatch to the original handleUnsafeBufferUsage().
      
      Tests are added for annotated constructors, conversion operattors, call
      operators, fold expressions, and regular methods.
      
      Issue #80482
      5ac34358
    • Vlad Serebrennikov's avatar
      d1f96d4c