← Back to Pull requests

Emit a diagnostic warning about parsing ambiguity in a conjunction #55

Closed
unknown closed this pull request without merging on Sep 03, 2024 17:33 UTC
View on GitHub
unknown unknown commented on May 28, 2024 23:50 UTC
Author

Addresses #11

Testing performed

  • Added a basic parser test to catch a warning message, tested locally.

  • > env LIT_FILTER=cxx2x-ambig-reflect-expr.cpp ninja check-clang -C build-llvm/
    
    ninja: Entering directory `build-llvm/'
    [89/90] Running the Clang regression tests
    llvm-lit: /home/balik/Desktop/clang-p2996/llvm/utils/lit/lit/llvm/config.py:509: note: using clang: /home/balik/Desktop/clang-p2996/build-llvm/bin/clang
    
    Testing Time: 0.04s
    
    Total Discovered Tests: 19357
      Excluded: 19356 (99.99%)
      Passed  :     1 (0.01%)
    
    

  • Manually tested by compiling a code with mentioned issue
  • #include <experimental/meta>
    #include <iostream>
    
    enum MyEnum { x, y, e = -1, f, z = 99 };
    
    int main() {
      MyEnum value{};
      constexpr auto reflValue = ^value; 
      
      if (reflValue != ^MyEnum && true) {
        std::cout << "YES" << std::endl;
      } else {
        std::cout << "NO" << std::endl;
      }
    }
    
    

    > build-llvm/bin/clang++ -std=c++26 -freflection -Wl,-rpath,/home/balik/Development/clang-p2996/build-llvm/lib/x86_64-unknown-linux-gnu -L/home/balik/Development/clang-p2996/build-llvm/lib/x86_64-unknown-linux-gnu -stdlib=libc++ -lc++ -lc++abi -o a.out main.cpp
    
    main.cpp:10:28: warning: given expression may be misinterpreted due to 'T &&' type parsing logic. did you mean '... (^T) && ...'?
       10 |   if (reflValue != ^MyEnum && true) {
          |                            ^
    main.cpp:10:31: error: expected ')'
       10 |   if (reflValue != ^MyEnum && true) {
          |                               ^
    main.cpp:10:6: note: to match this '('
       10 |   if (reflValue != ^MyEnum && true) {
          |      ^
    1 warning and 1 error generated.
    
    

    Additional context

    PR is ready for review IMO.

    Last issue left on my side:

  • Didn't manage to capture a type name to display it in a warning message instead of T. Should be possible but need more investigation.
  • Diff: 242 lines (+181 / -61) across 3 files Reviewer: BaLiKfromUA Review duration: 140742m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.39) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 242 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.329
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #55"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 38.8% (MEDIUM) · Higher = larger blast radius
    38.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.8% · Safe to merge
    16.8%