Skip to content

About

My merged contributions to LLVM/Clang: new diagnostics, the -Wunused-template campaign, and bounds-safety API Notes

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

LLVM Contributions

Aditya Medhane · @flash1729 · all PRs on GitHub

Merged PRs Subprojects Focus

I work on Clang's frontend, mostly diagnostics: making the compiler catch more real bugs at compile time, and doing the tree-wide cleanup it takes to turn a warning on by default. Along the way that work has touched almost every corner of the monorepo.

Where the work landed

llvm-project/
├── clang/              ███████████ 11 PRs   new diagnostics, Sema, API Notes
├── llvm/                ███████     7 PRs   -Wunused-template cleanups (IR, MC, ADT, Mips, ORC, ...)
├── compiler-rt/         █████       5 PRs   sanitizer runtime cleanups (hwasan, scudo, nsan)
├── clang-tools-extra/   ██          2 PRs   clangd, clang-doc
├── mlir/                ██          2 PRs   core header cleanups
├── openmp/              ██          2 PRs   libomp, OpenMP frontend
├── flang-rt/            █           1 PR    Fortran runtime
└── libc/                █           1 PR    test infrastructure

Highlights

Diagnosing dual-linkage UB in C · #192116 + reland #193567 An identifier declared with both internal and external linkage is undefined behavior in C, and Clang used to accept it silently. This adds a proper diagnostic. The first landing got reverted on downstream fallout; the reland grew from +88 to +190 lines while working through the edge cases, which taught me more about linkage than the original patch did.

Turning on -Wunused-template under -Wall · #206123 + reland #208001 A one-line flag flip that required a 17-PR campaign: sweep every subproject that builds with -Wall clean of unused-template warnings first, land the flip, fix the runtime configurations the first landing exposed (flang-rt, OpenMP), then reland. Details in the campaign section below.

Upstreaming API Notes for -fbounds-safety · #186960 Upstreamed the API notes format that lets bounds-safety annotations be attached to function parameters externally, so existing C headers can get bounds checking without being edited.

Function references compared to null · #204944 A C++ reference to a function can never be null, so comparing or converting one to a null pointer is always a bug. Clang now says so.

New diagnostics and Sema fixes

PR What it does
#217465 Pointer subtraction on a VLA is no longer misreported as a zero-size subtraction; the size is only known at run time (fixes a Bugzilla-era bug, #28328)
#217342 -Wc++98-compat now flags explicit conversion functions when compiling in C++20 mode
#204944 Warn when a function reference is compared with or converted to a null pointer
#193567 Reland: error on identifiers with both internal and external linkage (UB in C)
#192116 Original landing of the dual-linkage diagnostic

The -Wunused-template campaign

-Wunused-template catches templates that are declared but never instantiated, which usually means dead code or a linkage mistake. It existed but was not part of -Wall, so nobody saw it. Enabling it meant making the entire LLVM monorepo build clean under the warning first. Each cleanup made a real decision: an unused single-definition header template loses its static (internal linkage on a header template is almost always a bug), genuinely dead code gets deleted, and debug-only helpers get [[maybe_unused]].

The flip: #206123 enabled it under -Wall, got reverted on runtime-build fallout, and #208001 relanded it after the fixes below.

PR Area What it cleaned
#202969 llvm/Object ELF header function templates had wrong internal linkage
#202971 llvm/Mips 70 lines of never-instantiated function templates deleted
#202973 llvm/ORC Unused and assert-only JITLink helpers
#202974 llvm/VPlan findUserOf templates in the vectorizer
#202975 llvm/IR Unused and debug-only verifier templates
#202980 clang Frontend helper templates
#202977 clang AST, dataflow, and analysis helpers
#202983 llvm/Transforms Leftover legacy-pass-manager runImpl template
#202987 OpenMP frontend Unused isStrictSubset template
#202988 llvm (MC, Support, ADT, PGO) Assorted library helper templates
#206308 compiler-rt RegisterFlag in sanitizer_common
#206309 clang-doc Unused simple_ilist comparison operators
#206312 clangd Unused onlyValue<bool> overload
#207430 compiler-rt/hwasan Check templates (post-flip runtime fix)
#207441 compiler-rt/nsan Dead checkValueConsistency template
#207706 compiler-rt sanitizer_common test helpers
#207707 libc ErrnoSetterMatcher test helpers
#207708 compiler-rt/scudo LargeBlock header helpers
#207983 openmp/libomp __kmp_wait template linkage
#207979 flang-rt Time intrinsics and test helpers (unblocked the reland)

Phase 2, MLIR (the warning surfaced ~60 more sites once MLIR built with it):

PR What it cleaned
#214756 Core header function templates (OpDefinition, AffineMap, PDL, Pass options)
#214759 Reshape op helper templates in dialect utils

API Notes and bounds safety

PR What it does
#186960 Upstream the API notes format for -fbounds-safety function parameter annotations
#183811 Fix typos and header comment errors in APINotes

In flight

PR Status What it does
#222047 open Silence -Wnon-virtual-dtor for classes with a C++20 destroying operator delete, where a non-virtual destructor is fine
#220573 open Look through the comma operator so conversion checks reach conditional-operator branches
#214218 open New -Wsuspicious-memcmp for memcmp on types without unique object representations
#212768 open Handle _Atomic types in __has_unique_object_representations

31 merged PRs · +859 / −399 lines · last updated 2026-09-09. Regenerate the PR list with tools/fetch-prs.sh.

About

My merged contributions to LLVM/Clang: new diagnostics, the -Wunused-template campaign, and bounds-safety API Notes

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages