Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions cuda_core/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0

# Layout is clang-format's job (see .clang-format), so clang-tidy does no
# formatting of its own (FormatStyle: none below). Each enabled check is meant
# to be adoptable on its own, so findings can be fixed one check at a time.
#
# Checks are opt-in (-*) by group, minus the ones below. They cannot be
# commented inline because Checks is a single YAML string.
#
# Disabled because they conflict with the C-style CUDA driver API idioms:
# bugprone-easily-swappable-parameters: wrappers of driver calls take many
# adjacent parameters of the same type; the signatures mirror the API.
# bugprone-assignment-in-if-condition: `if (CUDA_SUCCESS != (err = CALL(...)))`
# is the standard error-handling pattern here.
# performance-no-int-to-ptr: opaque handles and file descriptors are
# converted to pointers with reinterpret_cast on purpose.
# modernize-avoid-c-arrays: arrays are passed to and filled by C APIs.
# modernize-return-braced-init-list: `return {};` vs. an explicit type is
# left to the author; it adds noise for the driver-API result structs.
# bugprone-throwing-static-initialization: the handle registries are
# process-lifetime globals whose constructors allocate on some standard
# libraries (MSVC); running out of memory while loading the module is
# fatal either way.
#
# Disabled because they do not match the codebase style:
# performance-enum-size: enum underlying types are left as they are.
# misc-const-correctness: const on every local is not the convention here.
# readability-function-cognitive-complexity: too disruptive.
# readability-identifier-length: short names such as the handle parameter `h`
# are used throughout.
# readability-implicit-bool-conversion: `if (ptr)` and `if (handle)` are the
# idiom for pointers and handles.
# misc-include-cleaner: too noisy with the CUDA and CPython umbrella headers.
# misc-no-recursion: recursion is used deliberately.
# misc-use-anonymous-namespace: file-local functions use `static`.
# modernize-use-trailing-return-type: the code uses `Type\nname()` layout.
Checks: >
-*,
bugprone-*,
-bugprone-easily-swappable-parameters,
-bugprone-assignment-in-if-condition,
-bugprone-throwing-static-initialization,
clang-analyzer-*,
misc-*,
-misc-include-cleaner,
-misc-const-correctness,
-misc-no-recursion,
-misc-use-anonymous-namespace,
modernize-*,
-modernize-use-trailing-return-type,
-modernize-avoid-c-arrays,
-modernize-return-braced-init-list,
performance-*,
-performance-enum-size,
-performance-no-int-to-ptr,
readability-*,
-readability-function-cognitive-complexity,
-readability-identifier-length,
-readability-implicit-bool-conversion
FormatStyle: none
CheckOptions:
# Records whose members are all public (the *Box and guard structs) are plain
# data holders; only a mix of public and private members is flagged.
misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: true
WarningsAsErrors: '*'
# Only report diagnostics for our own headers, not CUDA/CPython/libstdc++.
HeaderFilterRegex: 'cuda/core/_(cpp|include)/'
ExcludeHeaderFilterRegex: 'cuda/core/_include/(dlpack|aoti_shim)\.h'
Comment on lines +63 to +70

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Supported by static analysis

Script executed:

sed -n '55,75p' cuda_core/.clang-tidy
sed -n '700,765p' cuda_core/build_hooks.py

Repository: NVIDIA/cuda-python

Length of output: 3745


Web query:

clang-tidy HeaderFilterRegex Windows backslash path separators matching normalize forward slashes

Result:

<source_evidence>
<source kind="find_in_page">
<title>llvm-project/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp at main · llvm/llvm-project · GitHub</title>
<location>https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp</location>
<excerpt>citeturn3view1 [wordlim: 200] Crawled: today; Content type: text/html; Source: find({&quot;ref_id&quot;:&quot;turn2view0&quot;,&quot;pattern&quot;:&quot;Filter.matches&quot;}); Total lines: 3373
No matching text found for &quot;Filter.matches&quot;</excerpt>
</source>
<source kind="open_page">
<title>llvm-project/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp at main · llvm/llvm-project · GitHub</title>
<location>https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp</location>
<excerpt>citeturn2view0 [wordlim: 200] Crawled: 2 days ago; Content type: text/html; Source: open({&quot;ref_id&quot;:&quot;https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp&quot;,&quot;lineno&quot;:null}); Total lines: 3394
L0: 【0†Skip to content】
L1: ## Navigation Menu
L2: 
L3: 【1†Sign in】
L4: 
L5: Appearance settings
L6: 
L7:   * Platform
L8: 
L9:     * AI CODE CREATION
L10:       * 【2†GitHub CopilotWrite better code with AI】
L11:       * 【3†GitHub Copilot appDirect agents from issue to merge】
L12:       * 【4†MCP RegistryIntegrate external tools】
L13: 
L14:     * DEVELOPER WORKFLOWS
L15:       * 【5†ActionsAutomate any workflow】
L16:       * 【6†CodespacesInstant dev environments】
L17:       * 【7†IssuesPlan and track work】
L18:       * 【8†Code ReviewManage code changes】
L19:       * 【9†Code QualityEnforce quality at merge】
L20:     * APPLICATION SECURITY
L21:       * 【10†GitHub Advanced SecurityFind and fix vulnerabilities】
L22:       * 【11†Code securitySecure your code as you build】
L23:       * 【12†Secret protectionStop leaks before they start】
L24: 
L25:     * EXPLORE
L26:       * 【13†Why GitHub】
L27:       * 【14†Documentation†docs.github.com】
L28:       * 【15†Blog†github.blog】
L29:       * 【16†Changelog†github.blog】
L30:       * 【17†Marketplace】
L31: 
L32: 【18†View all features】
L33: 
L34:   * Solutions
L35:     * BY COMPANY SIZE
L36:       * 【19†Enterprises】
L37:       * 【20†Small and medium teams】
L38:       * 【21†Startups】
L39:       * 【22†Nonprofits】
L40: 
L41:     * BY USE CASE
L42:       * 【23†App Modernization】
L43:       * 【24†DevSecOps】
L44:       * 【25†DevOps】
L45:       * 【26†CI/CD】
L46:       * 【27†View all use cases】
L47: 
L48:     * BY INDUSTRY
L49:       * 【28†Healthcare】
L50:       * 【29†Financial services】
L51:       * 【30†Manufacturing】
L52:       * 【31†Government】
L53:       * 【32†See all industries】
L54: 
L55: 【33†View all solutions】
L56: 
L57:   * Resources
L58:     * EXPLORE BY TOPIC
L59:       * 【34†AI】
L60:       * 【35†Software Development】
L61:       * 【36†DevOps】
L62:       * 【37†Security】
L63:       * 【38†View all topics】
L64: 
L65:     * EXPLORE BY TYPE
L66:       * 【39†Customer stories】
L67:       * 【40†Events &amp; webinars】
L68:       * 【41†Ebooks &amp; reports】
L69:       * 【42†Business insights】
L70:       * 【43†GitHub Skills†skills.github.com】
L71:     * SUPPORT &amp; SERVICES
L72:       * 【14†Documentation†docs.github.com】
L73:       * 【44†Customer support†support.github.com】
L74:       * 【45†Community forum】
L75:       * 【46†Trust center】
L76:       * 【47†Partners】
L77: 
L78: 【48†View all resources】
L79: 
L80:   * Open Source
L81: 
L82:     * COMMUNITY
L83:       * 【49†GitHub SponsorsFund open source developers】
L84:     * PROGRAMS
L85:       * 【50†Security Lab†securitylab.github.com】
L86:       * 【51†Maintainer Community†maintainers.github.com】
L87:       * 【52†GitHub Stars†stars.github.com】
L88:       * 【53†Archive Program†archiveprogram.github.com】
L89: 
L90:     * REPOSITORIES
L91:       * 【54†Topics】
L92:       * 【55†Trending】
L93:       * 【56†Collections】
L94: 
L95:   * Enterprise
L96: 
L97:     * ENTERPRISE SOLUTIONS
L98:       * 【19†Enterprise platformAI-powered developer platform】
L99:     * AVAILABLE ADD-ONS
L100:       * 【10†GitHub Advanced SecurityEnterprise-grade security features】
L101:       * 【57†Copilot for BusinessEnterprise-grade AI features】
L102:       * 【58†Premium SupportEnterprise-grade 24/7 support】
L103: 
L104:   * 【59†Pricing】
L105: 
L106: Search`/`
L107: 
L108: 【1†Sign in】
L109: 
L110: 【60†Sign up】
L111: 
L112: Appearance settings
L113: You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
L114: 
L115:   1. 【61†llvm】
L116:   2. 【62†llvm-project】
L117: ## Repository navigation
L118: 
L119:   *   * 【62†Code】
L120:   * 【63†Issues5k+ (5k+)】
L121:   * 【64†Pull requests5k+ (5k+)】
L122:   * 【65†Actions】
L123:   * 【66†Security and quality】
L124:   * 【67†Insights】
L125: 
L126: More items
L127: 
L128: ## Files Expand file tree
L129: 
L130: main
L131: 
L132: ## Breadcrumbs
L133: 
L134:   1. 【68†llvm-project】
L135:   2. /【69†clang-tools-extra】
L136:   3. /【70†clang-tidy】
L137: 
L138: /
L139: 
L140: # ClangTidyDiagnosticConsumer.cpp
L141: 
L142: Copy path
L143: 
L144: [Input: Go to file]
L145: 
L146: Blame More file actions
L147: 
L148: Blame More file actions
L149: 
L150: ## Latest commit
L151: 
L152: 
L153: 
L154: ## History
L155: 
L156: History
L157: 
L158: main
L159: ## Breadcrumbs
L160: 
L161:   1. 【68†llvm-project】
L162:   2. /【69†clang-tools-extra】
L163:   3. /【70†clang-tidy】
L164: 
L165: /
L166: 
L167: # ClangTidyDiagnosticConsumer.cpp
L168: 
L169: Copy path
L170: 
L171: Top
L172: ## File metadata and controls
L173: 
L174:   * Code
L175: 
L176:   * Blame
L177: 
L178: 862 lines (775 loc) · 32.9 KB
L179: 
L180: 【71†Raw】
L181: 
L182: Copy raw file
L183: 
L184: Download raw file
L185: 
L186: Open symbols panel
L187: 
L188: Edit and raw actions
L189: 
L190: 1
L191: 
L192: 2
L193: 
L194: 3
L195: 
L196: 4
L197: 
L198: 5
L199: 
L200: 6
L201: 
L202: 7
L203: 
L204: 8
L205: 
L206: 9
L207: 
L208: 10
L209: 
L210: 11
L211: 
L212: 12
L213: 
L214: 13
L215: 
L216: 14
L217: 
L218: 15
L219: 
L220: 16
L221: 
L222: 17
L223: 
L224: 18
L225: 
L226: 19
L227: 
L228: 20
L229: 
L230: 21
L231: 
L232: 22
L233: 
L234: 23
L235: 
L236: 24
L237: 
L238: 25
L239: 
L240: 26
L241: 
L242: 27
L243: 
L244: 28
L245: 
L246: 29
L247: 
L248: 30
L249: 
L250: 31
L251: 
L252: 32
L253: 
L254: 33
L255: 
L256: 34
L257: 
L258: 35
L259: 
L260: 36
L261: 
L262: 37
L263: 
L264: 38
L265: 
L266: 39
L267: 
L268: 40
L269: 
L270: 41
L271: 
L272: 42
L273: 
L274: 43
L275: 
L276: 44
L277: 
L278: 45
L279: 
L280: 46
L281: 
L282: 47
L283: 
L284: 48
L285: 
L286: 49
L287: 
L288: 50
L289: 
L290: 51
L291: 
L292: 52
L293: 
L294: 53
L295: 
L296: 54
L297: 
L298: 55
L299: 
L300: 56
L301: 
L302: 57
L303: 
L304: 58
L305: 
L306: 59
L307: 
L308: 60
L309: 
L310: 61
L311: 
L312: 62
L313: 
L314: 63
L315: 
L316: 64
L317: 
L318: 65
L319: 
L320: 66
L321: 
L322: 67
L323: 
L324: 68
L325: 
L326: 69
L327: 
L328: 70
L329: 
L330: 71
L331: 
L332: 72
L333: 
L334: 73
L335: 
L336: 74
L337: 
L338: 75
L339: 
L340: 76
L341: 
L342: 77
L343: 
L344: 78
L345: 
L346: 79
L347: 
L348: 80
L349: 
L350: 81
L351: 
L352: 82
L353: 
L354: 83
L355: 
L356: 84
L357: 
L358: 85
L359: 
L360: 86
L361: 
L362: 87
L363: 
L364: 88
L365: 89
L366: 
L367: 90
L368: 
L369: 91
L370: 
L371: 92
L372: 
L373: 93
L374: 
L375: 94
L376: 
L377: 95
L378: 
L379: 96
L380: 
L381: 97
L382: 
L383: 98
L384: 
L385: 99
L386: 
L387: 100
L388: 
L389: 101
L390: 
L391: 102
L392: 
L393: 103
L394: 
L395: 104
L396: 
L397: 105
L398: 
L399: 106
L400: 
L401: 107
L402: 
L403: 108
L404: 
L405: 109
L406: 
L407: 110
L408: 
L409: 111
L410: 
L411: 112
L412: 
L413: 113
L414: 
L415: 114
L416: 
L417: 115
L418: 
L419: 116
L420: 
L421: 117
L422: 
L423: 118
L424: 
L425: 119
L426: 
L427: 120
L428: 
L429: 121
L430: 
L431: 122
L432: 
L433: 123
L434: 
L435: 124
L436: 
L437: 125
L438: 
L439: 126
L440: 
L441: 127
L442: 
L443: 128
L444: 
L445: 129
L446: 
L447: 130
L448: 
L449: 131
L450: 
L451: 132
L452: 
L453: 133
L454: 
L455: 134
L456: 
L457: 135
L458: 
L459: 136
L460: 
L461: 137
L462: 
L463: 138
L464: 
L465: 139
L466: 
L467: 140
L468: 
L469: 141
L470: 
L471: 142
L472: 
L473: 143
L474: 
L475: 144
L476: 
L477: 145
L478: 
L479: 146
L480: 
L481: 147
L482: 
L483: 148
L484: 
L485: 149
L486: 
L487: 150
L488: 
L489: 151
L490: 
L491: 152
L492: 
L493: 153
L494: 
L495: 154
L496: 
L497: 155
L498: 
L499: 156
L500: 
L501: 157
L502: 
L503: 158
L504: 
L505: 159
L506: 
L507: 160
L508: 
L509: 161
L510: 
L511: 162
L512: 
L513: 163
L514: 
L515: 164
L516: 
L517: 165
L518: 
L519: 166
L520: 
L521: 167
L522: 
L523: 168
L524: 
L525: 169
L526: 
L527: 170
L528: 
L529: 171
L530: 
L531: 172
L532: 
L533: 173
L534: 
L535: 174
L536: 
L537: 175
L538: 
L539: 176
L540: 
L541: 177
L542: 
L543: 178
L544: 
L545: 179
L546: 
L547: 180
L548: 
L549: 181
L550: 
L551: 182
L552: 
L553: 183
L554: 
L555: 184
L556: 
L557: 185
L558: 
L559: 186
L560: 
L561: 187
L562: 
L563: 188
L564: 
L565: 189
L566: 
L567: 190
L568: 
L569: 191
L570: 
L571: 192
L572: 193
L573: 
L574: 194
L575: 
L576: 195
L577: 
L578: 196
L579: 
L580: 197
L581: 
L582: 198
L583: 
L584: 199
L585: 
L586: 200
L587: 
L588: 201
L589: 
L590: 202
L591: 
L592: 203
L593: 
L594: 204
L595: 
L596: 205
L597: 
L598: 206
L599: 
L600: 207
L601: 
L602: 208
L603: 
L604: 209
L605: 
L606: 210
L607: 
L608: 211
L609: 
L610: 212
L611: 
L612: 213
L613: 
L614: 214
L615: 
L616: 215
L617: 
L618: 216
L619: 
L620: 217
L621: 
L622: 218
L623: 
L624: 219
L625: 
L626: 220
L627: 
L628: 221
L629: 
L630: 222
L631: 
L632: 223
L633: 
L634: 224
L635: 
L636: 225
L637: 
L638: 226
L639: 
L640: 227
L641: 
L642: 228
L643: 
L644: 229
L645: 
L646: 230
L647: 
L648: 231
L649: 
L650: 232
L651: 
L652: 233
L653: 
L654: 234
L655: 
L656: 235
L657: 
L658: 236
L659: 
L660: 237
L661: 
L662: 238
L663: 
L664: 239
L665: 
L666: 240
L667: 
L668: 241
L669: 
L670: 242
L671: 
L672: 243
L673: 
L674: 244
L675: 
L676: 245
L677: 
L678: 246
L679: 
L680: 247
L681: 
L682: 248
L683: 
L684: 249
L685: 
L686: 250
L687: 
L688: 251
L689: 
L690: 252
L691: 
L692: 253
L693: 
L694: 254
L695: 
L696: 255
L697: 
L698: 256
L699: 
L700: 257
L701: 
L702: 258
L703: 
L704: 259
L705: 
L706: 260
L707: 
L708: 261
L709: 
L710: 262
L711: 
L712: 263
L713: 
L714: 264
L715: 
L716: 265
L717: 
L718: 266
L719: 
L720: 267
L721: 
L722: 268
L723: 
L724: 269
L725: 
L726: 270
L727: 
L728: 271
L729: 
L730: 272
L731: 
L732: 273
L733: 
L734: 274
L735: 
L736: 275
L737: 
L738: 276
L739: 
L740: 277
L741: 
L742: 278
L743: 
L744: 279
L745: 
L746: 280
L747: 
L748: 281
L749: 
L750: 282
L751: 
L752: 283
L753: 
L754: 284
L755: 
L756: 285
L757: 
L758: 286
L759: 
L760: 287
L761: 
L762: 288
L763: 
L764: 289
L765: 
L766: 290
L767: 
L768: 291
L769: 
L770: 292
L771: 
L772: 293
L773: 
L774: 294
L775: 295
L776: 
L777: 296
L778: 
L779: 297
L780: 
L781: 298
L782: 
L783: 299
L784: 
L785: 300
L786: 
L787: 301
L788: 
L789: 302
L790: 
L791: 303
L792: 
L793: 304
L794: 
L795: 305
L796: 
L797: 306
L798: 
L799: 307
L800: 
L801: 308
L802: 
L803: 309
L804: 
L805: 310
L806: 
L807: 311
L808: 
L809: 312
L810: 
L811: 313
L812: 
L813: 314
L814: 
L815: 315
L816: 
L817: 316
L818: 
L819: 317
L820: 
L821: 318
L822: 
L823: 319
L824: 
L825: 320
L826: 
L827: 321
L828: 
L829: 322
L830: 
L831: 323
L832: 
L833: 324
L834: 
L835: 325
L836: 
L837: 326
L838: 
L839: 327
L840: 
L841: 328
L842: 
L843: 329
L844: 
L845: 330
L846: 
L847: 331
L848: 
L849: 332
L850: 
L851: 333
L852: 
L853: 334
L854: 
L855: 335
L856: 
L857: 336
L858: 
L859: 337
L860: 
L861: 338
L862: 
L863: 339
L864: 
L865: 340
L866: 
L867: 341
L868: 
L869: 342
L870: 
L871: 343
L872: 
L873: 344
L874: 
L875: 345
L876: 
L877: 346
L878: 
L879: 347
L880: 
L881: 348
L882: 
L883: 349
L884: 
L885: 350
L886: 
L887: 351
L888: 
L889: 352
L890: 
L891: 353
L892: 
L893: 354
L894: 
L895: 355
L896: 
L897: 356
L898: 
L899: 357
L900: 
L901: 358
L902: 
L903: 359
L904: 
L905: 360
L906: 
L907: 361
L908: 
L909: 362
L910: 
L911: 363
L912: 
L913: 364
L914: 
L915: 365
L916: 
L917: 366
L918: 
L919: 367
L920: 
L921: 368
L922: 
L923: 369
L924: 
L925: 370
L926: 
L927: 371
L928: 
L929: 372
L930: 
L931: 373
L932: 
L933: 374
L934: 
L935: 375
L936: 
L937: 376
L938: 
L939: 377
L940: 
L941: 378
L942: 
L943: 379
L944: 
L945: 380
L946: 
L947: 381
L948: 
L949: 382
L950: 
L951: 383
L952: 
L953: 384
L954: 
L955: 385
L956: 
L957: 386
L958: 
L959: 387
L960: 
L961: 388
L962: 
L963: 389
L964: 
L965: 390
L966: 
L967: 391
L968: 
L969: 392
L970: 
L971: 393
L972: 
L973: 394
L974: 
L975: 395
L976: 
L977: 396
L978: 397
L979: 
L980: 398
L981: 
L982: 399
L983: 
L984: 400
L985: 
L986: 401
L987: 
L988: 402
L989: 
L990: 403
L991: 
L992: 404
L993: 
L994: 405
L995: 
L996: 406
L997: 
L998: 407
L999: 
L1000: 408
L1001: 
L1002: 409
L1003: 
L1004: 410
L1005: 
L1006: 411
L1007: 
L1008: 412
L1009: 
L1010: 413
L1011: 
L1012: 414
L1013: 
L1014: 415
L1015: 
L1016: 416
L1017: 
L1018: 417
L1019: 
L1020: 418
L1021: 
L1022: 419
L1023: 
L1024: 420
L1025: 
L1026: 421
L1027: 
L1028: 422
L1029: 
L1030: 423
L1031: 
L1032: 424
L1033: 
L1034: 425
L1035: 
L1036: 426
L1037: 
L1038: 427
L1039: 
L1040: 428
L1041: 
L1042: 429
L1043: 
L1044: 430
L1045: 
L1046: 431
L1047: 
L1048: 432
L1049: 
L1050: 433
L1051: 
L1052: 434
L1053: 
L1054: 435
L1055: 
L1056: 436
L1057: 
L1058: 437
L1059: 
L1060: 438
L1061: 
L1062: 439
L1063: 
L1064: 440
L1065: 
L1066: 441
L1067: 
L1068: 442
L1069: 
L1070: 443
L1071: 
L1072: 444
L1073: 
L1074: 445
L1075: 
L1076: 446
L1077: 
L1078: 447
L1079: 
L1080: 448
L1081: 
L1082: 449
L1083: 
L1084: 450
L1085: 
L1086: 451
L1087: 
L1088: 452
L1089: 
L1090: 453
L1091: 
L1092: 454
L1093: 
L1094: 455
L1095: 
L1096: 456
L1097: 
L1098: 457
L1099: 
L1100: 458
L1101: 
L1102: 459
L1103: 
L1104: 460
L1105: 
L1106: 461
L1107: 
L1108: 462
L1109: 
L1110: 463
L1111: 
L1112: 464
L1113: 
L1114: 465
L1115: 
L1116: 466
L1117: 
L1118: 467
L1119: 
L1120: 468
L1121: 
L1122: 469
L1123: 
L1124: 470
L1125: 
L1126: 471
L1127: 
L1128: 472
L1129: 
L1130: 473
L1131: 
L1132: 474
L1133: 
L1134: 475
L1135: 
L1136: 476
L1137: 
L1138: 477
L1139: 
L1140: 478
L1141: 
L1142: 479
L1143: 
L1144: 480
L1145: 
L1146: 481
L1147: 
L1148: 482
L1149: 
L1150: 483
L1151: 
L1152: 484
L1153: 
L1154: 485
L1155: 
L1156: 486
L1157: 
L1158: 487
L1159: 
L1160: 488
L1161: 
L1162: 489
L1163: 
L1164: 490
L1165: 
L1166: 491
L1167: 
L1168: 492
L1169: 
L1170: 493
L1171: 
L1172: 494
L1173: 
L1174: 495
L1175: 
L1176: 496
L1177: 
L1178: 497
L1179: 
L1180: 498
L1181: 499
L1182: 
L1183: 500
L1184: 
L1185: 501
L1186: 
L1187: 502
L1188: 
L1189: 503
L1190: 
L1191: 504
L1192: 
L1193: 505
L1194: 
L1195: 506
L1196: 
L1197: 507
L1198: 
L1199: 508
L1200: 
L1201: 509
L1202: 
L1203: 510
L1204: 
L1205: 511
L1206: 
L1207: 512
L1208: 
L1209: 513
L1210: 
L1211: 514
L1212: 
L1213: 515
L1214: 
L1215: 516
L1216: 
L1217: 517
L1218: 
L1219: 518
L1220: 
L1221: 519
L1222: 
L1223: 520
L1224: 
L1225: 521
L1226: 
L1227: 522
L1228: 
L1229: 523
L1230: 
L1231: 524
L1232: 
L1233: 525
L1234: 
L1235: 526
L1236: 
L1237: 527
L1238: 
L1239: 528
L1240: 
L1241: 529
L1242: 
L1243: 530
L1244: 
L1245: 531
L1246: 
L1247: 532
L1248: 
L1249: 533
L1250: 
L1251: 534
L1252: 
L1253: 535
L1254: 
L1255: 536
L1256: 
L1257: 537
L1258: 
L1259: 538
L1260: 
L1261: 539
L1262: 
L1263: 540
L1264: 
L1265: 541
L1266: 
L1267: 542
L1268: 
L1269: 543
L1270: 
L1271: 544
L1272: 
L1273: 545
L1274: 
L1275: 546
L1276: 
L1277: 547
L1278: 
L1279: 548
L1280: 
L1281: 549
L1282: 
L1283: 550
L1284: 
L1285: 551
L1286: 
L1287: 552
L1288: 
L1289: 553
L1290: 
L1291: 554
L1292: 
L1293: 555
L1294: 
L1295: 556
L1296: 
L1297: 557
L1298: 
L1299: 558
L1300: 
L1301: 559
L1302: 
L1303: 560
L1304: 
L1305: 561
L1306: 
L1307: 562
L1308: 
L1309: 563
L1310: 
L1311: 564
L1312: 
L1313: 565
L1314: 
L1315: 566
L1316: 
L1317: 567
L1318: 
L1319: 568
L1320: 
L1321: 569
L1322: 
L1323: 570
L1324: 
L1325: 571
L1326: 
L1327: 572
L1328: 
L1329: 573
L1330: 
L1331: 574
L1332: 
L1333: 575
L1334: 
L1335: 576
L1336: 
L1337: 577
L1338: 
L1339: 578
L1340: 
L1341: 579
L1342: 
L1343: 580
L1344: 
L1345: 581
L1346: 
L1347: 582
L1348: 
L1349: 583
L1350: 
L1351: 584
L1352: 
L1353: 585
L1354: 
L1355: 586
L1356: 
L1357: 587
L1358: 
L1359: 588
L1360: 
L1361: 589
L1362: 
L1363: 590
L1364: 
L1365: 591
L1366: 
L1367: 592
L1368: 
L1369: 593
L1370: 
L1371: 594
L1372: 
L1373: 595
L1374: 
L1375: 596
L1376: 
</excerpt>
</source>
<source kind="search">
<title>9faf317eff5ef76aff7addfbd0360f380e803026 - external/github.com/llvm/llvm-project - Git at Google</title>
<location>https://chromium.googlesource.com/external/github.com/llvm/llvm-project/%2B/9faf317eff5ef76aff7addfbd0360f380e803026</location>
<excerpt>citeturn1search2 [wordlim: 200] Published: last month; Crawled: last month;     [clang-tidy] Normalize windows line filter paths (#217038) ...     git.exe diff -U0 main -- . | python clang-tidy-diff.py -p1 -path .\build&quot; ...     before matching the compilation database. ...     it run in a nested directory to exercise the issue

chromium/external/github.com/llvm/llvm-project/9faf317eff5ef76aff7addfbd0360f380e803026

commit
    

9faf317eff5ef76aff7addfbd0360f380e803026

[log]

author
    

Chris Apple &lt;cja-private@pm.me&gt;

Sat Sep 05 00:05:04 2026

committer
    

GitHub &lt;noreply@github.com&gt;

Sat Sep 05 00:05:04 2026

tree
    

5110e7c7bd06c1a00712c921da230f17786e9027

parent
    

2cbdbc9ad7ff40457023c8f353161069df8eb57f [diff]
    
    [clang-tidy] Normalize windows line filter paths (#217038)
    
    `git | clang-tidy-diff.py` emits line-filter paths with forward slashes,
    while Windows compilation databases use a mix of forwards and backwards
    slashes. These paths are then silently rejected (and no report is
    emitted).
    
    Reproduce on windows via:
    ```
    git.exe diff -U0 main -- . | python clang-tidy-diff.py -p1 -path .\build&quot;
    ```
    
    Git will produce a path like:
    ```
    my/source/file.cpp
    ```
    
    The compilation database has files with entries like this:
    ```
      &quot;file&quot;: &quot;C:\\dev\\repo\\my\\source\\file.cpp&quot;,
      &quot;output&quot;: &quot;my\\source\\CMakeFiles\\source.dir\\file.cpp.obj&quot;
    ```
    
    Clang tidy tries to match these paths, but fails on the slash
    comparison.
    
    
    Do a few things to fix this:
    * Normalize filter paths with `llvm::sys::path::convert_to_slash()`
    before matching the compilation database. This is a no-op on posix, but
    converts windows forward slashes to backwards.
    * Normalize `Filter.Name` paths when parsed
    * Write a couple more unit tests for windows specific paths that expose
    this behavior
    * Enable another UNSUPPORTED test for windows clang-tidy-diff (and make
    it run in a nested directory to exercise the issue
    
    Fixes https://github.com/llvm/llvm-project/issues/112038.

  * clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp[diff]
  * clang-tools-extra/clang-tidy/ClangTidyOptions.cpp[diff]
  * clang-tools-extra/docs/ReleaseNotes.md[diff]
</excerpt>
</source>
<source kind="search">
<title>[llvm-branch-commits] [clang-tools-extra] [clang-tidy] Normalize windows line filter paths (#217038) (PR #221500)</title>
<location>https://www.mail-archive.com/llvm-branch-commits%40lists.llvm.org/msg91801.html</location>
<excerpt>citeturn0search0 [wordlim: 200] Published: last month; Crawled: last month;     Subject: [PATCH] [clang-tidy] Normalize windows line filter paths (#217038)
    
    `git | clang-tidy-diff.py` emits line-filter paths with forward slashes, ...     * Normalize filter paths with `llvm::sys::path::convert_to_slash()` ...      #include &quot;llvm/Support/Regex.h&quot;
    
    &gt;From 48718953e78be555defdaa65f9af154f6a4aea00 Mon Sep 17 00:00:00 2001
    From: Chris Apple &lt;[email protected]&gt;
    Date: Fri, 4 Sep 2026 17:05:04 -0700
    Subject: [PATCH] [clang-tidy] Normalize windows line filter paths (#217038)
    
    `git | clang-tidy-diff.py` emits line-filter paths with forward slashes,
    while Windows compilation databases use a mix of forwards and backwards
    slashes. These paths are then silently rejected (and no report is
    emitted).
    
    Reproduce on windows via:
    ```
    git.exe diff -U0 main -- . | python clang-tidy-diff.py -p1 -path .\build&quot;
    ```
    
    Git will produce a path like:
    ```
    my/source/file.cpp
    ```
    
    The compilation database has files with entries like this:
    ```
      &quot;file&quot;: &quot;C:\\dev\\repo\\my\\source\\file.cpp&quot;,
      &quot;output&quot;: &quot;my\\source\\CMakeFiles\\source.dir\\file.cpp.obj&quot;
    ```
    
    Clang tidy tries to match these paths, but fails on the slash
    comparison.
    
    Do a few things to fix this:
    * Normalize filter paths with `llvm::sys::path::convert_to_slash()`
    before matching the compilation database. This is a no-op on posix, but
    converts windows forward slashes to backwards.
    * Normalize `Filter.Name` paths when parsed
    * Write a couple more unit tests for windows specific paths that expose
    this behavior
    * Enable another UNSUPPORTED test for windows clang-tidy-diff (and make
    it run in a nested directory to exercise the issue
    
    Fixes https://github.com/llvm/llvm-project/issues/112038.
    ---
     .../ClangTidyDiagnosticConsumer.cpp           |  5 +-
     .../clang-tidy/ClangTidyOptions.cpp           |  7 +-
     clang-tools-extra/docs/ReleaseNotes.rst       |  5 ++
     .../infrastructure/clang-tidy-diff.cpp        | 16 ++---
     .../ClangTidyDiagnosticConsumerTest.cpp       | 70 +++++++++++++++++++
                                     clang::tidy::ClangTidyGlobalOptions &amp;Options) {
       llvm::yaml::Input Input(LineFilter);
       Input &gt;&gt; Options.LineFilter;
    -  return Input.error();
    +  if (const std::error_code &amp;Error = Input.error())
    +    return Error;
    +
    +  for (FileFilter &amp;Filter : Options.LineFilter)
    +    Filter.Name = llvm::sys::path::convert_to_slash(Filter.Name);
    +  return {};
     }
     
     llvm::ErrorOr&lt;ClangTidyOptions&gt;
    diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
    b/clang-tools-extra/docs/ReleaseNotes.rst
    index 697f13f99f617..c58e57e1e99d4 100644
    --- a/clang-tools-extra/docs/ReleaseNotes.rst
    +++ b/clang-tools-extra/docs/ReleaseNotes.rst
    @@ -322,6 +322,11 @@ Improvements to clang-tidy
       checks are `clang-diagnostic-*` ones. This allows using
       :program:`clang-tidy` purely as a frontend to Clang&#39;s builtin warnings.
     
    +- On Windows, :program:`clang-tidy` will now better match mixes of forwards and
    +  backwards slashes when using the `--line-filter` option. This also improves
    +  piping from :program:`git` to :program:`clang-tidy-diff.py`, where slashes
    +  will now be automatically normalized.
    +
     New checks
     ^^^^^^^^^^
     
    diff --git 
    a/clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-diff.cpp 
    b/clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-diff.cpp
    index 43b7d781e6a7a..a5311adaaf190 100644
    --- a/clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-diff.cpp
    +++ b/clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-diff.cpp
    @@ -1,13 +1,13 @@
    -// UNSUPPORTED: system-windows
    -// RUN: sed &#39;s/placeholder_for_f/f/&#39; %s &gt; %t.cpp
    -// RUN: clang-tidy -checks=-*,modernize-use-override %t.cpp -- -std=c++11 | 
</excerpt>
</source>
<source kind="search">
<title>Extra Clang Tools 24.0.0git (In-Progress) Release Notes - Extra Clang Tools</title>
<location>https://clang.llvm.org/extra/ReleaseNotes.html</location>
<excerpt>citeturn0search1 [wordlim: 200] Crawled: yesterday;   * On Windows, clang-tidy will now better match mixes of forwards and backwards slashes when using the `--line-filter` option. ...   * Fixed a crash in clang-tidy when `HeaderFileExtensions` or `ImplementationFileExtensions` contains an invalid entry, such as one with a leading dot. ...   * New llvm-invalid-regex-pattern check.

### Improvements to clang-doc#

### Improvements to clang-query#

### Improvements to clang-tidy#

  * Improved check_clang_tidy.py by adding support of `-std=cXX-or-earlier` values, mirroring the existing `-std=cXX-or-later`. New construct expands to the given standard and every earlier one.

  * On Windows, clang-tidy will now better match mixes of forwards and backwards slashes when using the `--line-filter` option. This also improves piping from git to clang-tidy-diff.py, where slashes will now be automatically normalized.

  * Fixed a crash in clang-tidy when `HeaderFileExtensions` or `ImplementationFileExtensions` contains an invalid entry, such as one with a leading dot. The invalid option is now reported as a warning.

#### New checks#

  * New llvm-invalid-regex-pattern check.

Detects malformed regex patterns defined in a single string literal.

  * New modernize-use-if-consteval check.

Replaces direct `std::is_constant_evaluated()` checks in `if` statements with C++23’s `if consteval` syntax.
</excerpt>
</source>
<omitted_sources count="64">Additional source records were omitted from this bounded result.</omitted_sources>
</source_evidence>

Citations:

- 1: https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
- 2: https://chromium.googlesource.com/external/github.com/llvm/llvm-project/%2B/9faf317eff5ef76aff7addfbd0360f380e803026?utm_source=openai

Script executed:

set -eu
printf '%s\n' '--- changed config and hook with line numbers ---'
nl -ba cuda_core/.clang-tidy | sed -n '60,72p'
nl -ba cuda_core/build_hooks.py | sed -n '730,770p'
printf '%s\n' '--- clang-tidy dependency declarations ---'
rg -n -i -F --glob 'pyproject.toml' --glob 'requirements*.txt' --glob '*.lock' -e 'clang-tidy' -e 'clang_tidy' . || test "$?" -eq 1
printf '%s\n' '--- relevant hook callers ---'
rg -n -F --glob '*.py' -e 'check_with_clang_tidy' -e 'compile_command' cuda_core

Repository: NVIDIA/cuda-python

Length of output: 3667


Web query:

LLVM clang-tidy HeaderFilterRegex implementation Windows path normalization source ClangTidyDiagnosticConsumer.cpp HeaderFilterRegex

Result:

<source_evidence>
<source kind="search">
<title>llvm-project/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp at main · llvm/llvm-project · GitHub</title>
<location>https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp</location>
<excerpt>citeturn0search0 [wordlim: 200] Crawled: last week; llvm::Regex *ClangTidyDiagnosticConsumer::getExcludeHeaderFilter() {
Level, (Description + &quot; [&quot; + CheckName + &quot;]&quot;).str());

CheckNamesByDiagnosticID.try_emplace(ID, CheckName);

return DiagEngine-&gt;Report(Loc, ID);

}

DiagnosticBuilder ClangTidyContext::diag(

StringRef CheckName, StringRef Description,

DiagnosticIDs::Level Level /* = DiagnosticIDs::Warning*/) {

const unsigned ID = DiagEngine-&gt;getDiagnosticIDs()-&gt;getCustomDiagID(

Level, (Description + &quot; [&quot; + CheckName + &quot;]&quot;).str());

CheckNamesByDiagnosticID.try_emplace(ID, CheckName);

return DiagEngine-&gt;Report(ID);

}

DiagnosticBuilder ClangTidyContext::diag(const tooling::Diagnostic &amp;Error) {

SourceManager &amp;SM = DiagEngine-&gt;getSourceManager();

FileManager &amp;FM = SM.getFileManager();

const FileEntryRef File =

llvm::cantFail(FM.getFileRef(Error.Message.FilePath));

const FileID ID = SM.getOrCreateFileID(File, SrcMgr::C_User);

const SourceLocation FileStartLoc = SM.getLocForStartOfFile(ID);

const SourceLocation Loc = FileStartLoc.getLocWithOffset(

static_cast&lt;SourceLocation::IntTy&gt;(Error.Message.FileOffset));

return diag(Error.DiagnosticName, Loc, Error.Message.Message,

static_cast&lt;DiagnosticIDs::Level&gt;(Error.DiagLevel));

}

DiagnosticBuilder ClangTidyContext::configurationDiag(

StringRef Message,

DiagnosticIDs::Level Level /* = DiagnosticIDs::Warning*/) {

return diag(&quot;clang-tidy-config&quot;, Message, Level);

}

bool ClangTidyContext::shouldSuppressDiagnostic(

DiagnosticsEngine::Level DiagLevel, const Diagnostic &amp;Info,

SmallVectorImpl&lt;tooling::Diagnostic&gt; &amp;NoLintErrors, bool AllowIO,

bool EnableNoLintBlocks) {

const std::string CheckName = getCheckName(Info.getID());

return NoLintHandler.shouldSuppress(DiagLevel, Info, CheckName, NoLintErrors,

AllowIO, EnableNoLintBlocks);

}

void ClangTidyContext::setSourceManager(SourceManager *SourceMgr) {

DiagEngine-&gt;setSourceManager(SourceMgr);

}

static bool parseFileExtensions(llvm::ArrayRef&lt;std::string&gt; AllFileExtensions,

FileExtensionsSet &amp;FileExtensions) {

FileExtensions.clear();

for (const StringRef Suffix : AllFileExtensions) {

StringRef Extension = Suffix.trim();

if (!llvm::all_of(Extension, isAlphanumeric))

return false;

FileExtensions.insert(Extension);

}

return true;

}

void ClangTidyContext::setCurrentFile(StringRef File) {

CurrentFile = std::string(File);

CurrentOptions = getOptionsForFile(CurrentFile);

CheckFilter = std::make_unique&lt;CachedGlobList&gt;(

StringRef(getOptions().Checks.value_or(&quot;&quot;)));

WarningAsErrorFilter = std::make_unique&lt;CachedGlobList&gt;(

StringRef(getOptions().WarningsAsErrors.value_or(&quot;&quot;)));

static const std::vector&lt;std::string&gt; EmptyFileExtensions;

if (!parseFileExtensions(getOptions().HeaderFileExtensions

? *getOptions().HeaderFileExtensions

: EmptyFileExtensions,

HeaderFileExtensions))

this-&gt;configurationDiag(&quot;Invalid header file extensions&quot;);

if (!parseFileExtensions(getOptions().ImplementationFileExtensions

? *getOptions().ImplementationFileExtensions

: EmptyFileExtensions,

ImplementationFileExtensions))

this-&gt;configurationDiag(&quot;Invalid implementation file extensions&quot;);

}

void ClangTidyContext::setASTContext(ASTContext *Context) {

DiagEngine-&gt;SetArgToStringFn(&amp;FormatASTNodeDiagnosticArgument, Context);

LangOpts = Context-&gt;getLangOpts();

void ClangTidyDiagnosticConsumer::forwardDiagnostic(const Diagnostic &amp;Info) {

// Acquire a diagnostic ID also in the external diagnostics engine.

const auto DiagLevelAndFormatString =

Context.getDiagLevelAndFormatString(Info.getID(), Info.getLocation());

const unsigned ExternalID =

ExternalDiagEngine-&gt;getDiagnosticIDs()-&gt;getCustomDiagID(

DiagLevelAndFormatString.first, DiagLevelAndFormatString.second);

// Forward the details.

const auto Builder =

ExternalDiagEngine-&gt;Report(Info.getLocation(), ExternalID);

for (const FixItHint &amp;Hint : Info.getFixItHints())

Builder &lt;&lt; Hint;

for (const auto Range : Info.getRanges())

Builder &lt;&lt; Range;

for (unsigned Index = 0; Index &lt; Info.getNumArgs(); ++Index) {

const DiagnosticsEngine::ArgumentKind Kind = Info.getArgKind(Index);

switch (Kind) {

case DiagnosticsEngine::ak_std_string:

Builder &lt;&lt; Info.getArgStdStr(Index);

break;

case DiagnosticsEngine::ak_c_string:

Builder &lt;&lt; Info.getArgCStr(Index);

break;

case DiagnosticsEngine::ak_sint:

Builder &lt;&lt; Info.getArgSInt(Index);
Builder &lt;&lt; reinterpret_cast&lt;AttributeCommonInfo *&gt;(Info.getRawArg(Index));

break;

case DiagnosticsEngine::ak_addrspace:

Builder &lt;&lt; static_cast&lt;LangAS&gt;(Info.getRawArg(Index));

break;

case DiagnosticsEngine::ak_expr:

Builder &lt;&lt; reinterpret_cast&lt;const Expr *&gt;(Info.getRawArg(Index));

}

}

}

void ClangTidyDiagnosticConsumer::checkFilters(SourceLocation Location,

unsigned DiagnosticID,

const SourceManager &amp;Sources) {

// Invalid location may mean a diagnostic in a command line, don&#39;t skip these.

if (!Location.isValid()) {

LastErrorRelatesToUserCode = true;

LastErrorPassesLineFilter = true;

return;

}

if (!Context.getOptions().SystemHeaders.value_or(false)) {

if (Context.isCompilerDiagnostic(DiagnosticID)) {

if (Context.DiagEngine-&gt;getDiagnosticIDs()-&gt;shouldSuppressAsSystemWarning(

DiagnosticID, Location, *Context.DiagEngine))

return;

} else {

if (Sources.isInSystemHeader(Location) ||

Sources.isInSystemMacro(Location))

return;

}

}

// FIXME: We start with a conservative approach here, but the actual type of

// location needed depends on the check (in particular, where this check wants

// to apply fixes).

const FileID FID = Sources.getDecomposedExpansionLoc(Location).first;

OptionalFileEntryRef File = Sources.getFileEntryRefForID(FID);

// -DMACRO definitions on the command line have locations in a virtual buffer

// that doesn&#39;t have a FileEntry. Don&#39;t skip these as well.

if (!File) {

LastErrorRelatesToUserCode = true;

LastErrorPassesLineFilter = true;

return;

}

const StringRef FileName(File-&gt;getName());

LastErrorRelatesToUserCode = LastErrorRelatesToUserCode ||

Sources.isInMainFile(Location) ||

(getHeaderFilter()-&gt;match(FileName) &amp;&amp;

!getExcludeHeaderFilter()-&gt;match(FileName));

const unsigned LineNumber = Sources.getExpansionLineNumber(Location);

LastErrorPassesLineFilter =

LastErrorPassesLineFilter || passesLineFilter(FileName, LineNumber);

}

llvm::Regex *ClangTidyDiagnosticConsumer::getHeaderFilter() {

if (!HeaderFilter)

HeaderFilter = std::make_unique&lt;llvm::Regex&gt;(

Context.getOptions().HeaderFilterRegex.value_or(&quot;&quot;));

return HeaderFilter.get();

}

llvm::Regex *ClangTidyDiagnosticConsumer::getExcludeHeaderFilter() {

if (!ExcludeHeaderFilter)

ExcludeHeaderFilter = std::make_unique&lt;llvm::Regex&gt;(

switch (Type) {

case ET_Begin:

Priority = {Begin, Type, -End, -ErrorSize, ErrorId};

break;

case ET_Insert:

Priority = {Begin, Type, -End, ErrorSize, ErrorId};

break;

case ET_End:

Priority = {End, Type, -Begin, ErrorSize, ErrorId};

break;

}

}

bool operator&lt;(const Event &amp;Other) const {

return Priority &lt; Other.Priority;

}

// Determines if this event is the begin or the end of an interval.

EventType Type;

// The index of the error to which the interval that generated this event

// belongs.

unsigned ErrorId;

// The events will be sorted based on this field.

std::tuple&lt;unsigned, EventType, int, int, unsigned&gt; Priority;

};

// Compute error sizes.

std::vector&lt;int&gt; Sizes;

std::vector&lt;

std::pair&lt;ClangTidyError *, llvm::StringMap&lt;tooling::Replacements&gt; *&gt;&gt;

ErrorFixes;

for (auto &amp;Error : Errors)

if (const auto *Fix = getFixIt(Error, GetFixesFromNotes))

ErrorFixes.emplace_back(

&amp;Error, const_cast&lt;llvm::StringMap&lt;tooling::Replacements&gt; *&gt;(Fix));

for (const auto &amp;ErrorAndFix : ErrorFixes) {

int Size = 0;

for (const auto &amp;FileAndReplaces : *ErrorAndFix.second)

for (const auto &amp;Replace : FileAndReplaces.second)

Size += Replace.getLength();

Sizes.push_back(Size);

}

// Build events from error intervals.

llvm::StringMap&lt;std::vector&lt;Event&gt;&gt; FileEvents;

for (unsigned I = 0; I &lt; ErrorFixes.size(); ++I) {

for (const auto &amp;FileAndReplace : *ErrorFixes[I].second) {

for (const auto &amp;Replace : FileAndReplace.second) {

const unsigned Begin = Replace.getOffset();

const unsigned End = Begin + Replace.getLength();

auto &amp;Events = FileEvents[Replace.getFilePath()];

if (Begin == End) {

Events.emplace_back(Begin, End, Event::ET_Insert, I, Sizes[I]);

} else {

Events.emplace_back(Begin, End, Event::ET_Begin, I, Sizes[I]);

Events.emplace_back(Begin, End, Event::ET_End, I, Sizes[I]);

}

}

}

}

llvm::BitVector Apply(ErrorFixes.size(), true);

for (auto &amp;FileAndEvents : FileEvents) {

std::vector&lt;Event&gt; &amp;Events = FileAndEvents.second;

// Sweep.

</excerpt>
</source>
<source kind="search">
<title>clang-tools: ClangTidyDiagnosticConsumer.cpp Source File</title>
<location>https://clang.llvm.org/extra/doxygen/ClangTidyDiagnosticConsumer_8cpp_source.html</location>
<excerpt>citeturn0search3 [wordlim: 200] Crawled: last week; 386 void ClangTidyDiagnosticConsumer::EndSourceFile() { ... 635 llvm::Regex *ClangTidyDiagnosticConsumer::getExcludeHeaderFilter() { ... Definition ClangTidyDiagnosticConsumer.cpp:298

488 bool ClangTidyDiagnosticConsumer::passesLineFilter(StringRef FileName,

489 unsigned LineNumber) const {

490 if (Context.getGlobalOptions().LineFilter.empty())

491 return true;

492 const std::string NormalizedFileName =

493 llvm::sys::path::convert_to_slash(FileName);

494 for (const FileFilter &amp;Filter : Context.getGlobalOptions().LineFilter) {

495 if (StringRef(NormalizedFileName).ends_with(Filter.Name)) {

496 if (Filter.LineRanges.empty())

497 return true;

498 return llvm::any_of(

499 Filter.LineRanges, [&amp;](const FileFilter::LineRange &amp;Range) {

500 return Range.first &lt;= LineNumber &amp;&amp; LineNumber &lt;= Range.second;

501 });

502 }

503 }

504 return false;

505}

507 void ClangTidyDiagnosticConsumer::forwardDiagnostic(const Diagnostic &amp;Info) {

508 // Acquire a diagnostic ID also in the external diagnostics engine.

509 const auto DiagLevelAndFormatString =

510 Context.getDiagLevelAndFormatString(Info.getID(), Info.getLocation());
File) {

612 LastErrorRelatesToUserCode = true;

613 LastErrorPassesLineFilter = true;

614 return;

615 }

616

617 const StringRef FileName(File-&gt;getName());

618 LastErrorRelatesToUserCode = LastErrorRelatesToUserCode ||

619 Sources.isInMainFile(Location) ||

620 (getHeaderFilter()-&gt;match(FileName) &amp;&amp;

621 !getExcludeHeaderFilter()-&gt;match(FileName));

622

623 const unsigned LineNumber = Sources.getExpansionLineNumber(Location);

624 LastErrorPassesLineFilter =

625 LastErrorPassesLineFilter || passesLineFilter(FileName, LineNumber);

626}

627

628 llvm::Regex *ClangTidyDiagnosticConsumer::getHeaderFilter() {

629 if (!HeaderFilter)

630 HeaderFilter = std::make_unique&lt;llvm::Regex&gt;(

631 Context.getOptions().HeaderFilterRegex.value_or(&quot;&quot;));

632 return HeaderFilter.get();

633}

634

635 llvm::Regex *ClangTidyDiagnosticConsumer::getExcludeHeaderFilter() {

636 if (!ExcludeHeaderFilter)

637 ExcludeHeaderFilter = std::make_unique&lt;llvm::Regex&gt;(

638 Context.getOptions().ExcludeHeaderFilterRegex.value_or(&quot;&quot;));

639 return ExcludeHeaderFilter.get();

640}
</excerpt>
</source>
<source kind="search">
<title>clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp - llvm-project - Git at Google</title>
<location>https://llvm.googlesource.com/llvm-project/%2B/cc54129b983799e1aaea77aa0ff3040dc30cbc8c/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp</location>
<excerpt>citeturn0search1 [wordlim: 200] Crawled: 3 weeks ago;  | ExcludeHeaderFilter = std::make_unique&lt;llvm::Regex&gt;( ...  | void ClangTidyDiagnosticConsumer::finalizeLastError() {
 | bool RemoveIncompatibleErrors, bool GetFixesFromNotes,
 | bool EnableNolintBlocks)
 | : Context(Ctx), ExternalDiagEngine(ExternalDiagEngine),
 | RemoveIncompatibleErrors(RemoveIncompatibleErrors),
 | GetFixesFromNotes(GetFixesFromNotes),
 | EnableNolintBlocks(EnableNolintBlocks) {
 | 
 | if (Context.getOptions().HeaderFilterRegex &amp;&amp;
 | !Context.getOptions().HeaderFilterRegex-&gt;empty())
 | HeaderFilter =
 | std::make_unique&lt;llvm::Regex&gt;(*Context.getOptions().HeaderFilterRegex);
 | 
 | if (Context.getOptions().ExcludeHeaderFilterRegex &amp;&amp;
 | !Context.getOptions().ExcludeHeaderFilterRegex-&gt;empty())
 | ExcludeHeaderFilter = std::make_unique&lt;llvm::Regex&gt;(
 | *Context.getOptions().ExcludeHeaderFilterRegex);
 | }
 | 
 | void ClangTidyDiagnosticConsumer::finalizeLastError() {
 | if (!Errors.empty()) {
 | ClangTidyError &amp;Error = Errors.back();
 | if (Error.DiagnosticName == &quot;clang-tidy-config&quot;) {
 | // Never ignore these.
 | } else if (!Context.isCheckEnabled(Error.DiagnosticName) &amp;&amp;
 | Error.DiagLevel != ClangTidyError::Error) {
 | ++Context.Stats.ErrorsIgnoredCheckFilter;
 | Errors.pop_back();
 | } else if (!LastErrorRelatesToUserCode) {
 | ++Context.Stats.ErrorsIgnoredNonUserCode;
 | Errors.pop_back();
 | } else if (!LastErrorPassesLineFilter) {
 | ++Context.Stats.ErrorsIgnoredLineFilter;
 | Errors.pop_back();
 | } else {
 | ++Context.Stats.ErrorsDisplayed;
 | }
 | }
 | LastErrorRelatesToUserCode = false;
 | LastErrorPassesLineFilter = false;
 | }
 | 
 | namespace clang::tidy {
 | 
 | const llvm::StringMap&lt;tooling::Replacements&gt; *
 | getFixIt(const tooling::Diagnostic &amp;Diagnostic, bool AnyFix) {
 | if (!Diagnostic.Message.Fix.empty())
 | return &amp;Diagnostic.Message.Fix;
 | if (!AnyFix)
 | return nullptr;
 | const llvm::StringMap&lt;tooling::Replacements&gt; *Result = nullptr;
 | for (const auto &amp;Note : Diagnostic.Notes) {
 | if (!Note.Fix.empty()) {
 | if (Result)
 | // We have 2 different fixes in notes, bail out.
 | return nullptr;
 | Result = &amp;Note.Fix;
</excerpt>
</source>
<source kind="search">
<title>[clang-tidy] -line-filter only works with windows path separators on Windows · Issue #112038 · llvm/llvm-project · GitHub</title>
<location>GitHub issue 112038 in llvm/llvm-project (link omitted to avoid creating a cross-reference)</location>
<excerpt>citeturn0search2 [wordlim: 200] Published: 2.0 years ago; Crawled: last month; llvm-project/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp ... I got it to work by using windows path separators (that had to be escaped), i.e. `src\\subfolder\\myfile.cpp` instead of `src/subfolder/myfile.cpp`. (even when using MINGW64/Git bash that is included in Git for Windows, this solution is neccessary) ... to join this conversation on GitHub.
To ensure unique file names in the filter, I wanted to use paths with folders (instead of `myfile.cpp` use `src/subfolder/myfile.cpp`. I saw in the source that `endswith` is used on the file name (which I assume is a relative or absolute file path).

llvm-project/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Line 468 in 58d9703

 | if (FileName.ends_with(Filter.Name)) {

I got it to work by using windows path separators (that had to be escaped), i.e. `src\\subfolder\\myfile.cpp` instead of `src/subfolder/myfile.cpp`. (even when using MINGW64/Git bash that is included in Git for Windows, this solution is neccessary)

`-line-filter=&#39;[{&quot;name&quot;:&quot;subfolder\\myfile.cpp&quot;,&quot;lines&quot;:[[10,35]]}]&#39;`

This is a problem because I want to use `clang-tidy-diff.py`. It does work by modifying `clang-tidy-diff.py`

from
`lines_by_file.setdefault(filename, []).append([start_line, end_line])`
to
`lines_by_file.setdefault(filename.replace(&quot;/&quot;, &quot;\\&quot;), []).append([start_line, end_line])`

but it doesn&#39;t feel right that clang-tidy can&#39;t handle this internally.

The example usage of `clang-tidy-diff.py` is with git diff, which outputs unix path separators `/`.


## Activity

to join this conversation on GitHub. Already have an account? Sign in to comment

## Metadata

## Metadata

### Assignees

No one assigned

### Labels

clang-tidyenhancementImproving things as opposed to bug fixing, e.g. new or missing featureImproving things as opposed to bug fixing, e.g. new or missing feature

### Type

No type

### Projects

  * LLVM Release Status

Status

Done

Show more project fields

### Milestone

  * LLVM 23.x ReleaseNo due date

### Relationships

None yet

### Development

No branches or pull requests</excerpt>
</source>
<source kind="search">
<title>⚙ D34654 Allow passing a regex for headers to exclude from clang-tidy</title>
<location>https://reviews.llvm.org/D34654</location>
<excerpt>citeturn0search4 [wordlim: 200] Published: 9.3 years ago; Crawled: 2.9 years ago; ClangTidyDiagnosticConsumer.cpp ... llvm::Regex *ClangTidyDiagnosticConsumer::getExcludeHeaderFilter() {
std::unique_ptr&lt;llvm::Regex&gt; ExcludeHeaderFilter;
bool LastErrorRelatesToUserCode; bool LastErrorRelatesToUserCode;
bool LastErrorPassesLineFilter; bool LastErrorPassesLineFilter;
bool LastErrorWasIgnored; bool LastErrorWasIgnored;
}; };
} // end namespace tidy } // end namespace tidy
} // end namespace clang } // end namespace clang
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYDIAGNOSTICCONSUMER_H #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYDIAGNOSTICCONSUMER_H

# clang-tidy/ClangTidyDiagnosticConsumer.cpp

Show First 20 Lines • Show All 467 Lines • ▼ Show 20 Lines if (!File) {
LastErrorRelatesToUserCode = true; LastErrorRelatesToUserCode = true;
LastErrorPassesLineFilter = true; LastErrorPassesLineFilter = true;
return; return;
} }
StringRef FileName(File-&gt;getName()); StringRef FileName(File-&gt;getName());
LastErrorRelatesToUserCode = LastErrorRelatesToUserCode || LastErrorRelatesToUserCode = LastErrorRelatesToUserCode ||
Sources.isInMainFile(Location) || Sources.isInMainFile(Location) ||
</excerpt>
</source>
<omitted_sources count="25">Additional source records were omitted from this bounded result.</omitted_sources>
</source_evidence>

Citations:

- 1: https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp?utm_source=openai
- 2: https://clang.llvm.org/extra/doxygen/ClangTidyDiagnosticConsumer_8cpp_source.html?utm_source=openai
- 3: https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp?utm_source=openai

Web query:

llvmorg-22.1.8 ClangTidyDiagnosticConsumer.cpp HeaderFilterRegex File->getName Windows path separator FileEntry getName

Result:

<source_evidence>
<source kind="find_in_page">
<title>llvm-project/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp at llvmorg-22.1.8 · llvm/llvm-project · GitHub</title>
<location>https://github.com/llvm/llvm-project/blob/llvmorg-22.1.8/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp</location>
<excerpt>citeturn2view1 [wordlim: 200] Crawled: today; Content type: text/html; Source: find({&quot;ref_id&quot;:&quot;turn1view0&quot;,&quot;pattern&quot;:&quot;HeaderFilter-&gt;match&quot;}); Total lines: 3269
No matching text found for &quot;HeaderFilter-&gt;match&quot;</excerpt>
</source>
<source kind="find_in_page">
<title>llvm-project/llvm/include/llvm/Support/Path.h at llvmorg-22.1.8 · llvm/llvm-project · GitHub</title>
<location>https://github.com/llvm/llvm-project/blob/llvmorg-22.1.8/llvm/include/llvm/Support/Path.h</location>
<excerpt>citeturn2view2 [wordlim: 200] Crawled: today; Content type: text/html; Source: find({&quot;ref_id&quot;:&quot;turn1view1&quot;,&quot;pattern&quot;:&quot;convert_to_slash&quot;}); Total lines: 2342
L1785: Style style = Style::native);
L1786: 
L1787: /// Convert path to the native form in place. This is used to give paths to
L1788: 
L1789: /// users and operating system calls in the platform&#39;s normal way. For example,
L1790: 
L1791: /// on Windows all &#39;/&#39; are converted to &#39;\&#39;.
L1792: 
L1793: ///
L1794: 
L1795: /// @param path A path that is transformed to native format.
L1796: 
L1797: LLVM_ABI void native(SmallVectorImpl&lt;char&gt; &amp;path, Style style = Style::native);
L1798: 
L1799: /// For Windows path styles, convert path to use the preferred path separators.
L1800: 
L1801: /// For other styles, do nothing.
L1802: 
L1803: ///
L1804: /// @param path A path that is transformed to preferred format.
L1805: 
L1806: inline void make_preferred(SmallVectorImpl&lt;char&gt; &amp;path,
L1807: 
L1808: Style style = Style::native) {
L1809: 
L1810: if (!is_style_windows(style))
L1811: 
L1812: return;
L1813: 
L1814: native(path, style);
L1815: 
L1816: }
L1817: 
L1818: /// Replaces backslashes with slashes if Windows.
L1819: 
L1820: ///
L1821: 
L1822: /// @param path processed path
L1823: 
L1824: /// @result The result of replacing backslashes with forward slashes if Windows.
L1825: 
L1826: /// On Unix, this function is a no-op because backslashes are valid path
L1827: 
L1828: /// chracters.
L1829: LLVM_ABI std::string convert_to_slash(StringRef path,
L1830: 
L1831: Style style = Style::native);
L1832: 
L1833: /// @}
L1834: 
L1835: /// @name Lexical Observers
L1836: 
L1837: /// @{
L1838: 
L1839: /// Get root name.
L1840: 
L1841: ///
L1842: 
L1843: /// @code
L1844: 
L1845: /// //net/hello =&gt; //net
L1846: 
L1847: /// c:/hello =&gt; c: (on Windows, on other platforms nothing)
L1848: 
L1849: /// /hello =&gt; &lt;empty&gt;
L1850: 
L1851: /// @endcode
L1852: 
L1853: ///
L1854: 
L1855: /// @param path Input path.
L1856: 
L1857: /// @result The root name of \a path if it has one, otherwise &quot;&quot;.
L1858: 
L1859: LLVM_ABI StringRef root_name(StringRef path LLVM_LIFETIME_BOUND,
L1860: 
L1861: Style style = Style::native);
L1862: /// Get root directory.
L1863: 
L1864: ///
L1865: 
L1866: /// @code
L1867: 
L1868: /// /goo/hello =&gt; /
L1869: 
L1870: /// c:/hello =&gt; /
L1871: 
L1872: /// d/file.txt =&gt; &lt;empty&gt;
L1873: 
L1874: /// @endcode
L1875: 
L1876: ///
L1877: 
L1878: /// @param path Input path.
L1879: 
L1880: /// @result The root directory of \a path if it has one, otherwise
L1881: 
L1882: /// &quot;&quot;.
L1883: 
L1884: LLVM_ABI StringRef root_directory(StringRef path LLVM_LIFETIME_BOUND,
L1885: 
L1886: Style style = Style::native);
L1887: 
L1888: /// Get root path.
L1889: 
L1890: ///
L1891: 
L1892: /// Equivalent to root_name + root_directory.
L1893: 
L1894: ///
L1895: 
L1896: /// @param path Input path.
L1897: 
L1898: /// @result The root path of \a path if it has one, otherwise &quot;&quot;.
L1899: LLVM_ABI StringRef root_path(StringRef path LLVM_LIFETIME_BOUND,
L1900: 
L1901: Style style = Style::native);
L1902: 
L1903: /// Get relative path.
L1904: 
L1905: ///
L1906: 
L1907: /// @code
L1908: 
L1909: /// C:\hello\world =&gt; hello\world
L1910: 
L1911: /// foo/bar =&gt; foo/bar
L1912: 
L1913: /// /foo/bar =&gt; foo/bar
L1914: 
L1915: /// @endcode
L1916: 
L1917: ///
L1918: 
L1919: /// @param path Input path.
L1920: 
L1921: /// @result The path starting after root_path if one exists, otherwise &quot;&quot;.
L1922: 
L1923: LLVM_ABI StringRef relative_path(StringRef path LLVM_LIFETIME_BOUND,
L1924: 
L1925: Style style = Style::native);
L1926: 
L1927: /// Get parent path.
L1928: 
L1929: ///
L1930: 
L1931: /// @code
L1932: 
L1933: /// / =&gt; &lt;empty&gt;
L1934: /// /foo =&gt; /
L1935: 
L1936: /// foo/../bar =&gt; foo/..
L1937: 
L1938: /// @endcode
L1939: 
L1940: ///
L1941: 
L1942: /// @param path Input path.
L1943: 
L1944: /// @result The parent path of \a path if one exists, otherwise &quot;&quot;.
L1945: 
L1946: LLVM_ABI StringRef parent_path(StringRef path LLVM_LIFETIME_BOUND,
L1947: 
L1948: Style style = Style::native);
L1949: 
L1950: /// Get filename.
L1951: 
L1952: ///
L1953: 
L1954: /// @code
L1955: 
L1956: /// /foo.txt =&gt; foo.txt
L1957: 
L1958: /// . =&gt; .
L1959: 
L1960: /// .. =&gt; ..
L1961: 
L1962: /// / =&gt; /
L1963: 
L1964: /// @endcode
L1965: 
L1966: ///
L1967: 
L1968: /// @param path Input path.
L1969: 
L1970: /// @result The filename part of \a path. This is defined as the last component
L1971: /// of \a path. Similar to the POSIX &quot;basename&quot; utility.
L1972: 
L1973: LLVM_ABI StringRef filename(StringRef path LLVM_LIFETIME_BOUND,
L1974: 
L1975: Style style = Style::native);
L1976: 
L1977: /// Get stem.
L1978: 
L1979: ///
L1980: 
L1981: /// If filename contains a dot but not solely one or two dots, result is the
L1982: 
L1983: /// substring of filename ending at (but not including) the last dot. Otherwise
L1984: 
L1985: /// it is filename.
L1986: 
L1987: ///
L1988: 
L1989: /// @code
L1990: 
L1991: /// /foo/bar.txt =&gt; bar
L1992: 
L1993: /// /foo/bar =&gt; bar
L1994: 
L1995: /// /foo/.txt =&gt; &lt;empty&gt;
L1996: 
L1997: /// /foo/. =&gt; .
L1998: 
L1999: /// /foo/.. =&gt; ..
L2000: 
L2001: /// @endcode
L2002: 
L2003: ///
L2004: /// @param path Input path.
L2005: 
L2006: /// @result The stem of \a path.
L2007: 
L2008: LLVM_ABI StringRef stem(StringRef path LLVM_LIFETIME_BOUND,
L2009: 
L2010: Style style = Style::native);
L2011: 
L2012: /// Get extension.
L2013: 
L2014: ///
L2015: 
</excerpt>
</source>
<source kind="find_in_page">
<title>llvm-project/clang/include/clang/Basic/FileManager.h at llvmorg-22.1.8 · llvm/llvm-project · GitHub</title>
<location>https://github.com/llvm/llvm-project/blob/llvmorg-22.1.8/clang/include/clang/Basic/FileManager.h</location>
<excerpt>citeturn2view3 [wordlim: 200] Crawled: today; Content type: text/html; Source: find({&quot;ref_id&quot;:&quot;turn1view2&quot;,&quot;pattern&quot;:&quot;getName() const&quot;}); Total lines: 1385
No matching text found for &quot;getName() const&quot;</excerpt>
</source>
<source kind="open_page">
<title>llvm-project/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp at llvmorg-22.1.8 · llvm/llvm-project · GitHub</title>
<location>https://github.com/llvm/llvm-project/blob/llvmorg-22.1.8/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp</location>
<excerpt>citeturn1view0 [wordlim: 200] Crawled: last week; Content type: text/html; Source: open({&quot;ref_id&quot;:&quot;https://github.com/llvm/llvm-project/blob/llvmorg-22.1.8/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp&quot;,&quot;lineno&quot;:null}); Total lines: 3290
L0: 【0†Skip to content】
L1: ## Navigation Menu
L2: 
L3: 【1†Sign in】
L4: 
L5: Appearance settings
L6: 
L7:   * Platform
L8: 
L9:     * AI CODE CREATION
L10:       * 【2†GitHub CopilotWrite better code with AI】
L11:       * 【3†GitHub Copilot appDirect agents from issue to merge】
L12:       * 【4†MCP RegistryIntegrate external tools】
L13: 
L14:     * DEVELOPER WORKFLOWS
L15:       * 【5†ActionsAutomate any workflow】
L16:       * 【6†CodespacesInstant dev environments】
L17:       * 【7†IssuesPlan and track work】
L18:       * 【8†Code ReviewManage code changes】
L19:       * 【9†Code QualityEnforce quality at merge】
L20:     * APPLICATION SECURITY
L21:       * 【10†GitHub Advanced SecurityFind and fix vulnerabilities】
L22:       * 【11†Code securitySecure your code as you build】
L23:       * 【12†Secret protectionStop leaks before they start】
L24: 
L25:     * EXPLORE
L26:       * 【13†Why GitHub】
L27:       * 【14†Documentation†docs.github.com】
L28:       * 【15†Blog†github.blog】
L29:       * 【16†Changelog†github.blog】
L30:       * 【17†Marketplace】
L31: 
L32: 【18†View all features】
L33: 
L34:   * Solutions
L35:     * BY COMPANY SIZE
L36:       * 【19†Enterprises】
L37:       * 【20†Small and medium teams】
L38:       * 【21†Startups】
L39:       * 【22†Nonprofits】
L40: 
L41:     * BY USE CASE
L42:       * 【23†App Modernization】
L43:       * 【24†DevSecOps】
L44:       * 【25†DevOps】
L45:       * 【26†CI/CD】
L46:       * 【27†View all use cases】
L47: 
L48:     * BY INDUSTRY
L49:       * 【28†Healthcare】
L50:       * 【29†Financial services】
L51:       * 【30†Manufacturing】
L52:       * 【31†Government】
L53:       * 【32†View all industries】
L54: 
L55: 【33†View all solutions】
L56: 
L57:   * Resources
L58:     * EXPLORE BY TOPIC
L59:       * 【34†AI】
L60:       * 【35†Software Development】
L61:       * 【36†DevOps】
L62:       * 【37†Security】
L63:       * 【38†View all topics】
L64: 
L65:     * EXPLORE BY TYPE
L66:       * 【39†Customer stories】
L67:       * 【40†Events &amp; webinars】
L68:       * 【41†Ebooks &amp; reports】
L69:       * 【42†Business insights】
L70:       * 【43†GitHub Skills†skills.github.com】
L71:     * SUPPORT &amp; SERVICES
L72:       * 【14†Documentation†docs.github.com】
L73:       * 【44†Customer support†support.github.com】
L74:       * 【45†Community forum】
L75:       * 【46†Trust center】
L76:       * 【47†Partners】
L77: 
L78: 【48†View all resources】
L79: 
L80:   * Open Source
L81: 
L82:     * COMMUNITY
L83:       * 【49†GitHub SponsorsFund open source developers】
L84:     * PROGRAMS
L85:       * 【50†Security Lab†securitylab.github.com】
L86:       * 【51†Maintainer Community†maintainers.github.com】
L87:       * 【52†GitHub Stars†stars.github.com】
L88:       * 【53†Archive Program†archiveprogram.github.com】
L89: 
L90:     * REPOSITORIES
L91:       * 【54†Topics】
L92:       * 【55†Trending】
L93:       * 【56†Collections】
L94: 
L95:   * Enterprise
L96: 
L97:     * ENTERPRISE SOLUTIONS
L98:       * 【19†Enterprise platformAI-powered developer platform】
L99:     * AVAILABLE ADD-ONS
L100:       * 【10†GitHub Advanced SecurityEnterprise-grade security features】
L101:       * 【57†Copilot for BusinessEnterprise-grade AI features】
L102:       * 【58†Premium SupportEnterprise-grade 24/7 support】
L103: 
L104:   * 【59†Pricing】
L105: 
L106: Search`/`
L107: 
L108: 【1†Sign in】
L109: 
L110: 【60†Sign up】
L111: 
L112: Appearance settings
L113: You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
L114: 
L115:   1. 【61†llvm】
L116:   2. 【62†llvm-project】
L117: ## Repository navigation
L118: 
L119:   *   * 【62†Code】
L120:   * 【63†Issues5k+ (5k+)】
L121:   * 【64†Pull requests5k+ (5k+)】
L122:   * 【65†Actions】
L123:   * 【66†Security and quality】
L124:   * 【67†Insights】
L125: 
L126: More items
L127: 
L128: ## Files Expand file tree
L129: 
L130: llvmorg-22.1.8
L131: 
L132: ## Breadcrumbs
L133: 
L134:   1. 【68†llvm-project】
L135:   2. /【69†clang-tools-extra】
L136:   3. /【70†clang-tidy】
L137: 
L138: /
L139: 
L140: # ClangTidyDiagnosticConsumer.cpp
L141: 
L142: Copy path
L143: 
L144: [Input: Go to file]
L145: 
L146: Blame More file actions
L147: 
L148: Blame More file actions
L149: 
L150: ## Latest commit
L151: 
L152: 
L153: 
L154: ## History
L155: 
L156: History
L157: 
L158: llvmorg-22.1.8
L159: ## Breadcrumbs
L160: 
L161:   1. 【68†llvm-project】
L162:   2. /【69†clang-tools-extra】
L163:   3. /【70†clang-tidy】
L164: 
L165: /
L166: 
L167: # ClangTidyDiagnosticConsumer.cpp
L168: 
L169: Copy path
L170: 
L171: Top
L172: ## File metadata and controls
L173: 
L174:   * Code
L175: 
L176:   * Blame
L177: 
L178: 835 lines (749 loc) · 31.8 KB
L179: 
L180: 【71†Raw】
L181: 
L182: Copy raw file
L183: 
L184: Download raw file
L185: 
L186: Open symbols panel
L187: 
L188: Edit and raw actions
L189: 
L190: 1
L191: 
L192: 2
L193: 
L194: 3
L195: 
L196: 4
L197: 
L198: 5
L199: 
L200: 6
L201: 
L202: 7
L203: 
L204: 8
L205: 
L206: 9
L207: 
L208: 10
L209: 
L210: 11
L211: 
L212: 12
L213: 
L214: 13
L215: 
L216: 14
L217: 
L218: 15
L219: 
L220: 16
L221: 
L222: 17
L223: 
L224: 18
L225: 
L226: 19
L227: 
L228: 20
L229: 
L230: 21
L231: 
L232: 22
L233: 
L234: 23
L235: 
L236: 24
L237: 
L238: 25
L239: 
L240: 26
L241: 
L242: 27
L243: 
L244: 28
L245: 
L246: 29
L247: 
L248: 30
L249: 
L250: 31
L251: 
L252: 32
L253: 
L254: 33
L255: 
L256: 34
L257: 
L258: 35
L259: 
L260: 36
L261: 
L262: 37
L263: 
L264: 38
L265: 
L266: 39
L267: 
L268: 40
L269: 
L270: 41
L271: 
L272: 42
L273: 
L274: 43
L275: 
L276: 44
L277: 
L278: 45
L279: 
L280: 46
L281: 
L282: 47
L283: 
L284: 48
L285: 
L286: 49
L287: 
L288: 50
L289: 
L290: 51
L291: 
L292: 52
L293: 
L294: 53
L295: 
L296: 54
L297: 
L298: 55
L299: 
L300: 56
L301: 
L302: 57
L303: 
L304: 58
L305: 
L306: 59
L307: 
L308: 60
L309: 
L310: 61
L311: 
L312: 62
L313: 
L314: 63
L315: 
L316: 64
L317: 
L318: 65
L319: 
L320: 66
L321: 
L322: 67
L323: 
L324: 68
L325: 
L326: 69
L327: 
L328: 70
L329: 
L330: 71
L331: 
L332: 72
L333: 
L334: 73
L335: 
L336: 74
L337: 
L338: 75
L339: 
L340: 76
L341: 
L342: 77
L343: 
L344: 78
L345: 
L346: 79
L347: 
L348: 80
L349: 
L350: 81
L351: 
L352: 82
L353: 
L354: 83
L355: 
L356: 84
L357: 
L358: 85
L359: 
L360: 86
L361: 
L362: 87
L363: 
L364: 88
</excerpt>
</source>
<source kind="open_page">
<title>llvm-project/llvm/include/llvm/Support/Path.h at llvmorg-22.1.8 · llvm/llvm-project · GitHub</title>
<location>https://github.com/llvm/llvm-project/blob/llvmorg-22.1.8/llvm/include/llvm/Support/Path.h</location>
<excerpt>citeturn1view1 [wordlim: 200] Crawled: today; Content type: text/html; Source: open({&quot;ref_id&quot;:&quot;https://github.com/llvm/llvm-project/blob/llvmorg-22.1.8/llvm/include/llvm/Support/Path.h&quot;,&quot;lineno&quot;:null}); Total lines: 2342
L0: 【0†Skip to content】
L1: ## Navigation Menu
L2: 
L3:   * Products
L4: 
L5:     *       * 【1†GitHubRepository hosting, code review, and collaboration】
L6:       * 【2†CopilotAI coding agent for tasks, projects and automated work】
L7: 
L8:     * Build &amp; Ship
L9:       * 【3†ActionsCI/CD and automation】
L10:       * 【4†Code QualityQuality analysis, fixes, and enforcement】
L11:       * 【5†CodespacesCloud development environments】
L12: 
L13:     * Secure
L14:       * 【6†Code SecurityVulnerability detection and remediation】
L15:       * 【7†Secret ProtectionSecret scanning and leak prevention】
L16: 【8†All Features】
L17: 
L18:   * Developers
L19: 
L20:     * Learn
L21:       * 【9†Documentation†docs.github.com】
L22:       * 【10†Training†learn.github.com】
L23:       * 【11†Certifications†learn.github.com】
L24: 
L25:     * Build
L26:       * 【12†Build with Copilot】
L27:       * 【13†Customize Copilot†docs.github.com】
L28:       * 【14†Integrations】
L29: 
L30:     * Explore
L31:       * 【15†Trending repos】
L32:       * 【16†GitHub Sponsors】
L33:       * 【17†Events】
L34:     *       * 【18†ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.†github.blog】
L35: 
L36:   * Businesses
L37: 
L38:     * By Stage
L39:       * 【19†Enterprises】
L40:       * 【20†Team】
L41:       * 【21†Startups】
L42:       * 【22†Nonprofits】
L43: 
L44:     * By Industry
L45:       * 【23†Healthcare】
L46:       * 【24†Financial services】
L47:       * 【25†Manufacturing】
L48:       * 【26†Government】
L49:       * 【27†See all industries】
L50:     * Evaluate GitHub
L51:       * 【28†Why GitHub】
L52:       * 【29†Customer Stories】
L53:       * 【30†Business insights】
L54:       * 【31†Trust Center】
L55: 
L56:     * Add-ons
L57:       * 【32†GitHub Advanced SecurityEnterprise-grade code security】
L58:       * 【33†Copilot for businessEnterprise-grade AI features】
L59:       * 【34†Premium SupportEnterprise-grade 24/7 support】
L60: 
L61:   * Resources
L62:     * Learn &amp; Connect
L63:       * 【9†Documentation†docs.github.com】
L64:       * 【35†Resource center】
L65:       * 【36†Blog†github.blog】
L66:       * 【17†Events &amp; webinars】
L67:       * 【37†Community Forum】
L68:       * 【29†Customer Stories】
L69:       * 【14†Integrations】
L70: 
L71:     * Support
L72:       * 【38†Customer support†help.github.com】
L73:       * 【10†Training†learn.github.com】
L74:       * 【39†GitHub Status†www.githubstatus.com】
L75: 
L76:     * Company
L77:       * 【40†About】
L78:       * 【41†Partners】
L79:       * 【18†Changelog†github.blog】
L80:     *       * 【42†GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.†githubuniverse.com】
L81: 
L82:   * 【43†Pricing】
L83: 
L84: Search`/`
L85: 
L86: 【44†Sign in】
L87: 
L88: 【45†Sign up】
L89: 
L90: Appearance settings
L91: 
L92: You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
L93: 
L94:   1. 【46†llvm】
L95:   2. 【47†llvm-project】
L96: ## Repository navigation
L97: 
L98:   *   * 【47†Code】
L99:   * 【48†Issues5k+ (5k+)】
L100:   * 【49†Pull requests5k+ (5k+)】
L101:   * 【50†Actions】
L102:   * 【51†Security and quality】
L103:   * 【52†Insights】
L104: 
L105: More items
L106: 
L107: ## Files Expand file tree
L108: 
L109: llvmorg-22.1.8
L110: 
L111: ## Breadcrumbs
L112: 
L113:   1. 【53†llvm-project】
L114:   2. /【54†llvm】
L115:   3. /【55†include】
L116:   4. /【56†llvm】
L117:   5. /【57†Support】
L118: 
L119: /
L120: 
L121: # Path.h
L122: 
L123: Copy path
L124: 
L125: [Input: Go to file]
L126: 
L127: Blame More file actions
L128: 
L129: Blame More file actions
L130: 
L131: ## Latest commit
L132: 
L133: 
L134: 
L135: ## History
L136: 
L137: History
L138: 
L139: llvmorg-22.1.8
L140: ## Breadcrumbs
L141: 
L142:   1. 【53†llvm-project】
L143:   2. /【54†llvm】
L144:   3. /【55†include】
L145:   4. /【56†llvm】
L146:   5. /【57†Support】
L147: 
L148: /
L149: 
L150: # Path.h
L151: 
L152: Copy path
L153: 
L154: Top
L155: ## File metadata and controls
L156: 
L157:   * Code
L158: 
L159:   * Blame
L160: 
L161: 585 lines (523 loc) · 19.7 KB
L162: 
L163: 【58†Raw】
L164: 
L165: Copy raw file
L166: 
L167: Download raw file
L168: 
L169: Open symbols panel
L170: 
L171: Edit and raw actions
L172: 
L173: 1
L174: 
L175: 2
L176: 
L177: 3
L178: 
L179: 4
L180: 
L181: 5
L182: 
L183: 6
L184: 
L185: 7
L186: 
L187: 8
L188: 
L189: 9
L190: 
L191: 10
L192: 
L193: 11
L194: 
L195: 12
L196: 
L197: 13
L198: 
L199: 14
L200: 
L201: 15
L202: 
L203: 16
L204: 
L205: 17
L206: 
L207: 18
L208: 
L209: 19
L210: 
L211: 20
L212: 
L213: 21
L214: 
L215: 22
L216: 
L217: 23
L218: 
L219: 24
L220: 
L221: 25
L222: 
L223: 26
L224: 
L225: 27
L226: 
L227: 28
L228: 
L229: 29
L230: 
L231: 30
L232: 
L233: 31
L234: 
L235: 32
L236: 
L237: 33
L238: 
L239: 34
L240: 
L241: 35
L242: 
L243: 36
L244: 
L245: 37
L246: 
L247: 38
L248: 
L249: 39
L250: 
L251: 40
L252: 
L253: 41
L254: 
L255: 42
L256: 
L257: 43
L258: 
L259: 44
L260: 
L261: 45
L262: 
L263: 46
L264: 
L265: 47
L266: 
L267: 48
L268: 
L269: 49
L270: 
L271: 50
L272: 
L273: 51
L274: 
L275: 52
L276: 
L277: 53
L278: 
L279: 54
L280: 
L281: 55
L282: 
L283: 56
L284: 
L285: 57
L286: 
L287: 58
L288: 
L289: 59
L290: 
L291: 60
L292: 
L293: 61
L294: 
L295: 62
L296: 
L297: 63
L298: 
L299: 64
L300: 
L301: 65
L302: 
L303: 66
L304: 
L305: 67
L306: 
L307: 68
L308: 
L309: 69
L310: 
L311: 70
L312: 
L313: 71
L314: 
L315: 72
L316: 
L317: 73
L318: 
L319: 74
L320: 
L321: 75
L322: 
L323: 76
L324: 
L325: 77
L326: 
L327: 78
L328: 
L329: 79
L330: 
L331: 80
L332: 
L333: 81
L334: 
L335: 82
L336: 
L337: 83
L338: 
L339: 84
L340: 
L341: 85
L342: 
L343: 86
L344: 
L345: 87
L346: 
L347: 88
L348: 89
L349: 
L350: 90
L351: 
L352: 91
L353: 
L354: 92
L355: 
L356: 93
L357: 
L358: 94
L359: 
L360: 95
L361: 
L362: 96
L363: 
L364: 97
L365: 
L366: 98
L367: 
L368: 99
L369: 
L370: 100
L371: 
L372: 101
L373: 
L374: 102
L375: 
L376: 103
L377: 
L378: 104
L379: 
L380: 105
L381: 
L382: 106
L383: 
L384: 107
L385: 
L386: 108
L387: 
</excerpt>
</source>
<omitted_sources count="29">Additional source records were omitted from this bounded result.</omitted_sources>
</source_evidence>

Citations:

- 1: https://github.com/llvm/llvm-project/blob/llvmorg-22.1.8/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
- 2: https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp?utm_source=openai
- 3: https://github.com/llvm/llvm-project/blob/llvmorg-22.1.8/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Web query:

llvmorg-22.1.8 clang FileEntry getName FileManager Windows native path separator source

Result:

<source_evidence>
<source kind="find_in_page">
<title>llvm-project/clang/include/clang/Basic/FileEntry.h at llvmorg-22.1.8 · llvm/llvm-project · GitHub</title>
<location>https://github.com/llvm/llvm-project/blob/llvmorg-22.1.8/clang/include/clang/Basic/FileEntry.h</location>
<excerpt>citeturn2view1 [wordlim: 200] Crawled: today; Content type: text/html; Source: find({&quot;ref_id&quot;:&quot;turn1view0&quot;,&quot;pattern&quot;:&quot;The name of this FileEntry&quot;}); Total lines: 1477
L959: #include &lt;utility&gt;
L960: 
L961: namespace llvm {
L962: 
L963: class MemoryBuffer;
L964: 
L965: namespace vfs {
L966: 
L967: class File;
L968: 
L969: } // namespace vfs
L970: 
L971: } // namespace llvm
L972: 
L973: namespace clang {
L974: 
L975: class FileEntryRef;
L976: 
L977: namespace optional_detail {
L978: 
L979: /// Forward declare a template specialization for OptionalStorage.
L980: 
L981: template &lt;&gt; class OptionalStorage&lt;clang::FileEntryRef&gt;;
L982: 
L983: } // namespace optional_detail
L984: 
L985: class FileEntry;
L986: 
L987: /// A reference to a \c FileEntry that includes the name of the file as it was
L988: 
L989: /// accessed by the FileManager&#39;s client.
L990: class FileEntryRef {
L991: 
L992: public:
L993: 
L994: /// The name of this FileEntry. If a VFS uses &#39;use-external-name&#39;, this is
L995: 
L996: /// the redirected name. See getRequestedName().
L997: 
L998: StringRef getName() const { return getBaseMapEntry().first(); }
L999: 
L1000: /// The name of this FileEntry, as originally requested without applying any
L1001: 
L1002: /// remappings for VFS &#39;use-external-name&#39;.
L1003: 
L1004: ///
L1005: 
L1006: /// FIXME: this should be the semantics of getName(). See comment in
L1007: 
L1008: /// FileManager::getFileRef().
L1009: StringRef getNameAsRequested() const { return ME-&gt;first(); }
L1010: 
L1011: const FileEntry &amp;getFileEntry() const {
L1012: 
L1013: return *cast&lt;FileEntry *&gt;(getBaseMapEntry().second-&gt;V);
L1014: 
L1015: }
L1016: 
L1017: // This function is used if the buffer size needs to be increased
L1018: 
L1019: // due to potential z/OS EBCDIC -&gt; UTF-8 conversion
L1020: 
L1021: inline void updateFileEntryBufferSize(unsigned BufferSize);
L1022: 
L1023: DirectoryEntryRef getDir() const { return ME-&gt;second-&gt;Dir; }
L1024: 
L1025: inline off_t getSize() const;
L1026: 
L1027: inline unsigned getUID() const;
L1028: inline const llvm::sys::fs::UniqueID &amp;getUniqueID() const;
L1029: 
L1030: inline time_t getModificationTime() const;
L1031: 
L1032: inline bool isNamedPipe() const;
L1033: 
L1034: inline bool isDeviceFile() const;
L1035: 
L1036: inline void closeFile() const;
L1037: 
L1038: /// Check if the underlying FileEntry is the same, intentially ignoring
L1039: 
L1040: /// whether the file was referenced with the same spelling of the filename.
L1041: 
L1042: friend bool operator==(const FileEntryRef &amp;LHS, const FileEntryRef &amp;RHS) {
L1043: 
L1044: return &amp;LHS.getFileEntry() == &amp;RHS.getFileEntry();
L1045: 
L1046: }
L1047: friend bool operator==(const FileEntry *LHS, const FileEntryRef &amp;RHS) {
L1048: 
L1049: return LHS == &amp;RHS.getFileEntry();
L1050: 
L1051: }
L1052: 
L1053: friend bool operator==(const FileEntryRef &amp;LHS, const FileEntry *RHS) {
L1054: 
L1055: return &amp;LHS.getFileEntry() == RHS;
L1056: 
L1057: }
L1058: 
L1059: friend bool operator!=(const FileEntryRef &amp;LHS, const FileEntryRef &amp;RHS) {
L1060: 
L1061: return !(LHS == RHS);
L1062: 
L1063: }
L1064: 
L1065: friend bool operator!=(const FileEntry *LHS, const FileEntryRef &amp;RHS) {
L1066: 
L1067: return !(LHS == RHS);
L1068: 
L1069: }
L1070: 
L1071: friend bool operator!=(const FileEntryRef &amp;LHS, const FileEntry *RHS) {
L1072: return !(LHS == RHS);
L1073: 
L1074: }
L1075: 
L1076: /// Hash code is based on the FileEntry, not the specific named reference,
L1077: 
L1078: /// just like operator==.
L1079: 
L1080: friend llvm::hash_code hash_value(FileEntryRef Ref) {
L1081: 
L1082: return llvm::hash_value(&amp;Ref.getFileEntry());
L1083: 
L1084: }
L1085: 
L1086: struct MapValue;
L1087: 
L1088: /// Type used in the StringMap.
L1089: 
L1090: using MapEntry = llvm::StringMapEntry&lt;llvm::ErrorOr&lt;MapValue&gt;&gt;;
L1091: 
L1092: /// Type stored in the StringMap.
L1093: 
L1094: struct MapValue {
L1095: 
L1096: /// The pointer at another MapEntry is used when the FileManager should
L1097: /// silently forward from one name to another, which occurs in Redirecting
L1098: 
L1099: /// VFSs that use external names. In that case, the \c FileEntryRef
L1100: 
L1101: /// returned by the \c FileManager will have the external name, and not the
L1102: 
L1103: /// name that was used to lookup the file.
L1104: 
L1105: llvm::PointerUnion&lt;FileEntry *, const MapEntry *&gt; V;
L1106: 
L1107: /// Directory the file was found in.
L1108: 
L1109: DirectoryEntryRef Dir;
L1110: 
L1111: MapValue() = delete;
L1112: 
L1113: MapValue(FileEntry &amp;FE, DirectoryEntryRef Dir) : V(&amp;FE), Dir(Dir) {}
</excerpt>
</source>
<source kind="find_in_page">
<title>llvm-project/clang/lib/Basic/FileManager.cpp at llvmorg-22.1.8 · llvm/llvm-project · GitHub</title>
<location>https://github.com/llvm/llvm-project/blob/llvmorg-22.1.8/clang/lib/Basic/FileManager.cpp</location>
<excerpt>citeturn2view3 [wordlim: 200] Crawled: today; Content type: text/html; Source: find({&quot;ref_id&quot;:&quot;turn1view1&quot;,&quot;pattern&quot;:&quot;FileEntryRef::getName&quot;}); Total lines: 2707
L2037: // - Switch the meaning of `FileEntryRef::getName()` to get the requested
L2038: 
L2039: // name, not the external name. Once that sticks, revert callers that
L2040: 
L2041: // want the requested name back to calling `getName()`.
L2042: 
L2043: // - Update the VFS to always return the requested name. This could also
L2044: 
L2045: // return the external name, or just have an API to request it
L2046: 
L2047: // lazily. The latter has the benefit of making accesses of the
L2048: 
L2049: // external path easily tracked, but may also require extra work than
L2050: 
L2051: // just returning up front.
L2052: // - (Optionally) Add an API to VFS to get the external filename lazily
L2053: 
L2054: // and update `FileManager::getExternalPath()` to use it instead. This
L2055: 
L2056: // has the benefit of making such accesses easily tracked, though isn&#39;t
L2057: 
L2058: // necessarily required (and could cause extra work than just adding to
L2059: 
L2060: // eg. `vfs::Status` up front).
L2061: 
L2062: auto &amp;Redirection =
L2063: 
L2064: *SeenFileEntries
L2065: 
L2066: .insert({Status.getName(), FileEntryRef::MapValue(*UFE, DirInfo)})
L2067: 
L2068: .first;
L2069: 
L2070: assert(isa&lt;FileEntry *&gt;(Redirection.second-&gt;V) &amp;&amp;
</excerpt>
</source>
<source kind="find_in_page">
<title>llvm-project/llvm/lib/Support/Path.cpp at llvmorg-22.1.8 · llvm/llvm-project · GitHub</title>
<location>https://github.com/llvm/llvm-project/blob/llvmorg-22.1.8/llvm/lib/Support/Path.cpp</location>
<excerpt>citeturn2view4 [wordlim: 200] Crawled: today; Content type: text/html; Source: find({&quot;ref_id&quot;:&quot;turn1view2&quot;,&quot;pattern&quot;:&quot;void native&quot;}); Total lines: 3775
L3002: StringRef NewPrefix, Style style) {
L3003: 
L3004: if (OldPrefix.empty() &amp;&amp; NewPrefix.empty())
L3005: 
L3006: return false;
L3007: 
L3029: Path.swap(NewPath);
L3030: 
L3031: return true;
L3032: 
L3033: }
L3034: 
L3035: void native(const Twine &amp;path, SmallVectorImpl&lt;char&gt; &amp;result, Style style) {
L3036: 
L3037: assert((!path.isSingleStringRef() ||
L3038: 
L3039: path.getSingleStringRef().data() != result.data()) &amp;&amp;
L3040: 
L3041: &quot;path and result are not allowed to overlap!&quot;);
L3042: 
L3043: // Clear result.
L3044: 
L3045: result.clear();
L3046: 
L3047: path.toVector(result);
L3048: 
L3049: native(result, style);
L3050: 
L3051: }
L3052: 
L3053: void native(SmallVectorImpl&lt;char&gt; &amp;Path, Style style) {
L3054: 
L3055: if (Path.empty())
L3056: 
L3057: return;
L3058: 
L3059: if (is_style_windows(style)) {
L3060: 
L3061: for (char &amp;Ch : Path)
L3062: if (is_separator(Ch, style))
L3063: 
L3064: Ch = preferred_separator(style);
L3065: 
L3066: if (Path[0] == &#39;~&#39; &amp;&amp; (Path.size() == 1 || is_separator(Path[1], style))) {
L3067: 
L3068: SmallString&lt;128&gt; PathHome;
L3069: 
L3070: home_directory(PathHome);
L3071: 
L3072: PathHome.append(Path.begin() + 1, Path.end());
L3073: 
L3074: Path = PathHome;
L3075: 
L3076: }
L3077: 
L3078: } else {
L3079: 
L3080: llvm::replace(Path, &#39;\\&#39;, &#39;/&#39;);
L3081: 
L3082: }
L3083: 
L3084: }
L3085: 
L3086: std::string convert_to_slash(StringRef path, Style style) {
L3087: 
L3088: if (is_style_posix(style))
L3089: 
L3090: return std::string(path);
L3091: 
L3092: std::string s = path.str();
L3093: 
L3094: llvm::replace(s, &#39;\\&#39;, &#39;/&#39;);
L3095: 
L3096: return s;
L3097: 
L3098: }
</excerpt>
</source>
<source kind="open_page">
<title>llvm-project/clang/include/clang/Basic/FileEntry.h at llvmorg-22.1.8 · llvm/llvm-project · GitHub</title>
<location>https://github.com/llvm/llvm-project/blob/llvmorg-22.1.8/clang/include/clang/Basic/FileEntry.h</location>
<excerpt>citeturn1view0 [wordlim: 200] Crawled: today; Content type: text/html; Source: open({&quot;ref_id&quot;:&quot;https://github.com/llvm/llvm-project/blob/llvmorg-22.1.8/clang/include/clang/Basic/FileEntry.h&quot;,&quot;lineno&quot;:null}); Total lines: 1477
L0: 【0†Skip to content】
L1: ## Navigation Menu
L2: 
L3:   * Products
L4: 
L5:     *       * 【1†GitHubRepository hosting, code review, and collaboration】
L6:       * 【2†CopilotAI coding agent for tasks, projects and automated work】
L7: 
L8:     * Build &amp; Ship
L9:       * 【3†ActionsCI/CD and automation】
L10:       * 【4†Code QualityQuality analysis, fixes, and enforcement】
L11:       * 【5†CodespacesCloud development environments】
L12: 
L13:     * Secure
L14:       * 【6†Code SecurityVulnerability detection and remediation】
L15:       * 【7†Secret ProtectionSecret scanning and leak prevention】
L16: 【8†All Features】
L17: 
L18:   * Developers
L19: 
L20:     * Learn
L21:       * 【9†Documentation†docs.github.com】
L22:       * 【10†Training†learn.github.com】
L23:       * 【11†Certifications†learn.github.com】
L24: 
L25:     * Build
L26:       * 【12†Build with Copilot】
L27:       * 【13†Customize Copilot†docs.github.com】
L28:       * 【14†Integrations】
L29: 
L30:     * Explore
L31:       * 【15†Trending repos】
L32:       * 【16†GitHub Sponsors】
L33:       * 【17†Events】
L34:     *       * 【18†ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.†github.blog】
L35: 
L36:   * Businesses
L37: 
L38:     * By Stage
L39:       * 【19†Enterprises】
L40:       * 【20†Team】
L41:       * 【21†Startups】
L42:       * 【22†Nonprofits】
L43: 
L44:     * By Industry
L45:       * 【23†Healthcare】
L46:       * 【24†Financial services】
L47:       * 【25†Manufacturing】
L48:       * 【26†Government】
L49:       * 【27†See all industries】
L50:     * Evaluate GitHub
L51:       * 【28†Why GitHub】
L52:       * 【29†Customer Stories】
L53:       * 【30†Business insights】
L54:       * 【31†Trust Center】
L55: 
L56:     * Add-ons
L57:       * 【32†GitHub Advanced SecurityEnterprise-grade code security】
L58:       * 【33†Copilot for businessEnterprise-grade AI features】
L59:       * 【34†Premium SupportEnterprise-grade 24/7 support】
L60: 
L61:   * Resources
L62:     * Learn &amp; Connect
L63:       * 【9†Documentation†docs.github.com】
L64:       * 【35†Resource center】
L65:       * 【36†Blog†github.blog】
L66:       * 【17†Events &amp; webinars】
L67:       * 【37†Community Forum】
L68:       * 【29†Customer Stories】
L69:       * 【14†Integrations】
L70: 
L71:     * Support
L72:       * 【38†Customer support†help.github.com】
L73:       * 【10†Training†learn.github.com】
L74:       * 【39†GitHub Status†www.githubstatus.com】
L75: 
L76:     * Company
L77:       * 【40†About】
L78:       * 【41†Partners】
L79:       * 【18†Changelog†github.blog】
L80:     *       * 【42†GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.†githubuniverse.com】
L81: 
L82:   * 【43†Pricing】
L83: 
L84: Search`/`
L85: 
L86: 【44†Sign in】
L87: 
L88: 【45†Sign up】
L89: 
L90: Appearance settings
L91: 
L92: You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
L93: 
L94:   1. 【46†llvm】
L95:   2. 【47†llvm-project】
L96: ## Repository navigation
L97: 
L98:   *   * 【47†Code】
L99:   * 【48†Issues5k+ (5k+)】
L100:   * 【49†Pull requests5k+ (5k+)】
L101:   * 【50†Actions】
L102:   * 【51†Security and quality】
L103:   * 【52†Insights】
L104: 
L105: More items
L106: 
L107: ## Files Expand file tree
L108: 
L109: llvmorg-22.1.8
L110: 
L111: ## Breadcrumbs
L112: 
L113:   1. 【53†llvm-project】
L114:   2. /【54†clang】
L115:   3. /【55†include】
L116:   4. /【56†clang】
L117:   5. /【57†Basic】
L118: 
L119: /
L120: 
L121: # FileEntry.h
L122: 
L123: Copy path
L124: 
L125: [Input: Go to file]
L126: 
L127: Blame More file actions
L128: 
L129: Blame More file actions
L130: 
L131: ## Latest commit
L132: 
L133: 
L134: 
L135: ## History
L136: 
L137: History
L138: 
L139: llvmorg-22.1.8
L140: ## Breadcrumbs
L141: 
L142:   1. 【53†llvm-project】
L143:   2. /【54†clang】
L144:   3. /【55†include】
L145:   4. /【56†clang】
L146:   5. /【57†Basic】
L147: 
L148: /
L149: 
L150: # FileEntry.h
L151: 
L152: Copy path
L153: 
L154: Top
L155: ## File metadata and controls
L156: 
L157:   * Code
L158: 
L159:   * Blame
L160: 
L161: 371 lines (295 loc) · 12 KB
L162: 
L163: 【58†Raw】
L164: 
L165: Copy raw file
L166: 
L167: Download raw file
L168: 
L169: Open symbols panel
L170: 
L171: Edit and raw actions
L172: 
L173: 1
L174: 
L175: 2
L176: 
L177: 3
L178: 
L179: 4
L180: 
L181: 5
L182: 
L183: 6
L184: 
L185: 7
L186: 
L187: 8
L188: 
L189: 9
L190: 
L191: 10
L192: 
L193: 11
L194: 
L195: 12
L196: 
L197: 13
L198: 
L199: 14
L200: 
L201: 15
L202: 
L203: 16
L204: 
L205: 17
L206: 
L207: 18
L208: 
L209: 19
L210: 
L211: 20
L212: 
L213: 21
L214: 
L215: 22
L216: 
L217: 23
L218: 
L219: 24
L220: 
L221: 25
L222: 
L223: 26
L224: 
L225: 27
L226: 
L227: 28
L228: 
L229: 29
L230: 
L231: 30
L232: 
L233: 31
L234: 
L235: 32
L236: 
L237: 33
L238: 
L239: 34
L240: 
L241: 35
L242: 
L243: 36
L244: 
L245: 37
L246: 
L247: 38
L248: 
L249: 39
L250: 
L251: 40
L252: 
L253: 41
L254: 
L255: 42
L256: 
L257: 43
L258: 
L259: 44
L260: 
L261: 45
L262: 
L263: 46
L264: 
L265: 47
L266: 
L267: 48
L268: 
L269: 49
L270: 
L271: 50
L272: 
L273: 51
L274: 
L275: 52
L276: 
L277: 53
L278: 
L279: 54
L280: 
L281: 55
L282: 
L283: 56
L284: 
L285: 57
L286: 
L287: 58
L288: 
L289: 59
L290: 
L291: 60
L292: 
L293: 61
L294: 
L295: 62
L296: 
L297: 63
L298: 
L299: 64
L300: 
L301: 65
L302: 
L303: 66
L304: 
L305: 67
L306: 
L307: 68
L308: 
L309: 69
L310: 
L311: 70
L312: 
L313: 71
L314: 
L315: 72
L316: 
L317: 73
L318: 
L319: 74
L320: 
L321: 75
L322: 
L323: 76
L324: 
L325: 77
L326: 
L327: 78
L328: 
L329: 79
L330: 
L331: 80
L332: 
L333: 81
L334: 
L335: 82
L336: 
L337: 83
L338: 
L339: 84
L340: 
L341: 85
L342: 
L343: 86
L344: 
L345: 87
L346: 
L347: 88
</excerpt>
</source>
<source kind="open_page">
<title>llvm-project/clang/lib/Basic/FileManager.cpp at llvmorg-22.1.8 · llvm/llvm-project · GitHub</title>
<location>https://github.com/llvm/llvm-project/blob/llvmorg-22.1.8/clang/lib/Basic/FileManager.cpp</location>
<excerpt>citeturn1view1 [wordlim: 200] Crawled: today; Content type: text/html; Source: open({&quot;ref_id&quot;:&quot;https://github.com/llvm/llvm-project/blob/llvmorg-22.1.8/clang/lib/Basic/FileManager.cpp&quot;,&quot;lineno&quot;:null}); Total lines: 2707
L0: 【0†Skip to content】
L1: ## Navigation Menu
L2: 
L3:   * Products
L4: 
L5:     *       * 【1†GitHubRepository hosting, code review, and collaboration】
L6:       * 【2†CopilotAI coding agent for tasks, projects and automated work】
L7: 
L8:     * Build &amp; Ship
L9:       * 【3†ActionsCI/CD and automation】
L10:       * 【4†Code QualityQuality analysis, fixes, and enforcement】
L11:       * 【5†CodespacesCloud development environments】
L12: 
L13:     * Secure
L14:       * 【6†Code SecurityVulnerability detection and remediation】
L15:       * 【7†Secret ProtectionSecret scanning and leak prevention】
L16: 【8†All Features】
L17: 
L18:   * Developers
L19: 
L20:     * Learn
L21:       * 【9†Documentation†docs.github.com】
L22:       * 【10†Training†learn.github.com】
L23:       * 【11†Certifications†learn.github.com】
L24: 
L25:     * Build
L26:       * 【12†Build with Copilot】
L27:       * 【13†Customize Copilot†docs.github.com】
L28:       * 【14†Integrations】
L29: 
L30:     * Explore
L31:       * 【15†Trending repos】
L32:       * 【16†GitHub Sponsors】
L33:       * 【17†Events】
L34:     *       * 【18†ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.†github.blog】
L35: 
L36:   * Businesses
L37: 
L38:     * By Stage
L39:       * 【19†Enterprises】
L40:       * 【20†Team】
L41:       * 【21†Startups】
L42:       * 【22†Nonprofits】
L43: 
L44:     * By Industry
L45:       * 【23†Healthcare】
L46:       * 【24†Financial services】
L47:       * 【25†Manufacturing】
L48:       * 【26†Government】
L49:       * 【27†See all industries】
L50:     * Evaluate GitHub
L51:       * 【28†Why GitHub】
L52:       * 【29†Customer Stories】
L53:       * 【30†Business insights】
L54:       * 【31†Trust Center】
L55: 
L56:     * Add-ons
L57:       * 【32†GitHub Advanced SecurityEnterprise-grade code security】
L58:       * 【33†Copilot for businessEnterprise-grade AI features】
L59:       * 【34†Premium SupportEnterprise-grade 24/7 support】
L60: 
L61:   * Resources
L62:     * Learn &amp; Connect
L63:       * 【9†Documentation†docs.github.com】
L64:       * 【35†Resource center】
L65:       * 【36†Blog†github.blog】
L66:       * 【17†Events &amp; webinars】
L67:       * 【37†Community Forum】
L68:       * 【29†Customer Stories】
L69:       * 【14†Integrations】
L70: 
L71:     * Support
L72:       * 【38†Customer support†help.github.com】
L73:       * 【10†Training†learn.github.com】
L74:       * 【39†GitHub Status†www.githubstatus.com】
L75: 
L76:     * Company
L77:       * 【40†About】
L78:       * 【41†Partners】
L79:       * 【18†Changelog†github.blog】
L80:     *       * 【42†GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.†githubuniverse.com】
L81: 
L82:   * 【43†Pricing】
L83: 
L84: Search`/`
L85: 
L86: 【44†Sign in】
L87: 
L88: 【45†Sign up】
L89: 
L90: Appearance settings
L91: 
L92: You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
L93: 
L94:   1. 【46†llvm】
L95:   2. 【47†llvm-project】
L96: ## Repository navigation
L97: 
L98:   *   * 【47†Code】
L99:   * 【48†Issues5k+ (5k+)】
L100:   * 【49†Pull requests5k+ (5k+)】
L101:   * 【50†Actions】
L102:   * 【51†Security and quality】
L103:   * 【52†Insights】
L104: 
L105: More items
L106: 
L107: ## Files Expand file tree
L108: 
L109: llvmorg-22.1.8
L110: 
L111: ## Breadcrumbs
L112: 
L113:   1. 【53†llvm-project】
L114:   2. /【54†clang】
L115:   3. /【55†lib】
L116:   4. /【56†Basic】
L117: 
L118: /
L119: 
L120: # FileManager.cpp
L121: 
L122: Copy path
L123: 
L124: [Input: Go to file]
L125: 
L126: Blame More file actions
L127: 
L128: Blame More file actions
L129: 
L130: ## Latest commit
L131: 
L132: 
L133: 
L134: ## History
L135: 
L136: History
L137: 
L138: llvmorg-22.1.8
L139: ## Breadcrumbs
L140: 
L141:   1. 【53†llvm-project】
L142:   2. /【54†clang】
L143:   3. /【55†lib】
L144:   4. /【56†Basic】
L145: 
L146: /
L147: 
L148: # FileManager.cpp
L149: 
L150: Copy path
L151: 
L152: Top
L153: ## File metadata and controls
L154: 
L155:   * Code
L156: 
L157:   * Blame
L158: 
L159: 695 lines (602 loc) · 26.7 KB
L160: 
L161: 【57†Raw】
L162: 
L163: Copy raw file
L164: 
L165: Download raw file
L166: 
L167: Open symbols panel
L168: 
L169: Edit and raw actions
L170: 
L171: 1
L172: 
L173: 2
L174: 
L175: 3
L176: 
L177: 4
L178: 
L179: 5
L180: 
L181: 6
L182: 
L183: 7
L184: 
L185: 8
L186: 
L187: 9
L188: 
L189: 10
L190: 
L191: 11
L192: 
L193: 12
L194: 
L195: 13
L196: 
L197: 14
L198: 
L199: 15
L200: 
L201: 16
L202: 
L203: 17
L204: 
L205: 18
L206: 
L207: 19
L208: 
L209: 20
L210: 
L211: 21
L212: 
L213: 22
L214: 
L215: 23
L216: 
L217: 24
L218: 
L219: 25
L220: 
L221: 26
L222: 
L223: 27
L224: 
L225: 28
L226: 
L227: 29
L228: 
L229: 30
L230: 
L231: 31
L232: 
L233: 32
L234: 
L235: 33
L236: 
L237: 34
L238: 
L239: 35
L240: 
L241: 36
L242: 
L243: 37
L244: 
L245: 38
L246: 
L247: 39
L248: 
L249: 40
L250: 
L251: 41
L252: 
L253: 42
L254: 
L255: 43
L256: 
L257: 44
L258: 
L259: 45
L260: 
L261: 46
L262: 
L263: 47
L264: 
L265: 48
L266: 
L267: 49
L268: 
L269: 50
L270: 
L271: 51
L272: 
L273: 52
L274: 
L275: 53
L276: 
L277: 54
L278: 
L279: 55
L280: 
L281: 56
L282: 
L283: 57
L284: 
L285: 58
L286: 
L287: 59
L288: 
L289: 60
L290: 
L291: 61
L292: 
L293: 62
L294: 
L295: 63
L296: 
L297: 64
L298: 
L299: 65
L300: 
L301: 66
L302: 
L303: 67
L304: 
L305: 68
L306: 
L307: 69
L308: 
L309: 70
L310: 
L311: 71
L312: 
L313: 72
L314: 
L315: 73
L316: 
L317: 74
L318: 
L319: 75
L320: 
L321: 76
L322: 
L323: 77
L324: 
L325: 78
L326: 
L327: 79
L328: 
L329: 80
L330: 
L331: 81
L332: 
L333: 82
L334: 
L335: 83
L336: 
L337: 84
L338: 
L339: 85
L340: 
L341: 86
L342: 
L343: 87
L344: 
L345: 88
</excerpt>
</source>
<omitted_sources count="25">Additional source records were omitted from this bounded result.</omitted_sources>
</source_evidence>

Citations:

- 1: https://github.com/llvm/llvm-project/blob/llvmorg-22.1.8/clang/include/clang/Basic/FileEntry.h
- 2: https://github.com/llvm/llvm-project/blob/llvmorg-22.1.8/clang/lib/Basic/FileManager.cpp
- 3: https://github.com/llvm/llvm-project/blob/llvmorg-22.1.8/llvm/lib/Support/Path.cpp

Script executed:

nl -ba cuda_core/setup.py | sed -n '88,112p'

Repository: NVIDIA/cuda-python

Length of output: 1259


important: Match native Windows separators in HeaderFilterRegex.

clang-tidy==22.1.8 matches HeaderFilterRegex against FileEntryRef::getName() without path normalization. Native Windows paths can use backslashes, but this regex matches only forward slashes. Diagnostics from project headers can therefore be filtered out during Windows builds.

Suggested fix
-HeaderFilterRegex: 'cuda/core/_(cpp|include)/'
+HeaderFilterRegex: 'cuda[/\\]core[/\\]_(cpp|include)[/\\]'
Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
CheckOptions:
# Records whose members are all public (the *Box and guard structs) are plain
# data holders; only a mix of public and private members is flagged.
misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: true
WarningsAsErrors: '*'
# Only report diagnostics for our own headers, not CUDA/CPython/libstdc++.
HeaderFilterRegex: 'cuda/core/_(cpp|include)/'
ExcludeHeaderFilterRegex: 'cuda/core/_include/(dlpack|aoti_shim)\.h'
CheckOptions:
# Records whose members are all public (the *Box and guard structs) are plain
# data holders; only a mix of public and private members is flagged.
misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: true
WarningsAsErrors: '*'
# Only report diagnostics for our own headers, not CUDA/CPython/libstdc++.
HeaderFilterRegex: 'cuda[/\\]core[/\\]_(cpp|include)[/\\]'
ExcludeHeaderFilterRegex: 'cuda/core/_include/(dlpack|aoti_shim)\.h'

2 changes: 2 additions & 0 deletions cuda_core/MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ recursive-include cuda/core *.pyx *.pxd *.pxi *.pyi
recursive-include cuda/core/_cpp *.cpp *.h *.hpp
recursive-include cuda/core/_include *.h *.hpp *.def
include build_hooks.py
# configuration of the clang-tidy run in the build
include .clang-tidy
include cuda/core/py.typed
include NOTICE
# package-local shared PEP 517 helper
Expand Down
54 changes: 54 additions & 0 deletions cuda_core/build_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import importlib.util
import os
import re
import subprocess
import sys
import tempfile
import zipfile
Expand Down Expand Up @@ -704,6 +705,59 @@ def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
return wheel_name


def _find_clang_tidy() -> str:
"""The clang-tidy executable of the clang-tidy wheel in the build environment.

The wheel is a build-system requirement in pyproject.toml.

It is located through the wheel's ``clang_tidy`` package, never PATH, so a
system clang-tidy cannot be picked up. Raises RuntimeError when the wheel is
not installed.
"""
spec = importlib.util.find_spec("clang_tidy")
if spec is not None and spec.submodule_search_locations is not None:
exe = "clang-tidy"
if sys.platform == "win32":
exe = "clang-tidy.exe"
for base in spec.submodule_search_locations:
candidate = Path(base) / "data" / "bin" / exe
if candidate.is_file():
return str(candidate)
raise RuntimeError(
"The clang-tidy build requirement of pyproject.toml is not installed. Isolated builds install it "
"automatically. For other builds, install the pinned version of it."
)


def _is_handwritten_cpp(path) -> bool:
"""Whether path is a handwritten C++ source, not a Cython-generated one."""
path = Path(path)
return path.suffix == ".cpp" and path.resolve().is_relative_to(_PACKAGE_DIR / "_cpp")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

important: Resolve the package directory before comparing paths. If the checkout is accessed through a symlink, path.resolve() uses the physical path but _PACKAGE_DIR retains the symlink path. Every handwritten source then fails this comparison, so the build silently skips clang-tidy. Resolve both paths before comparing them.



def check_with_clang_tidy(compile_command) -> None:
"""Run clang-tidy on the handwritten .cpp that a compiler command line compiles.

``compile_command`` is the exact command that setuptools is about to spawn,
so clang-tidy sees the same compiler, include directories, macros and
flags as the build. Commands that do not compile a handwritten source are
ignored. The configuration is cuda_core/.clang-tidy, which turns every
finding into an error. Raises RuntimeError with the findings.
"""
sources = [arg for arg in compile_command if _is_handwritten_cpp(arg)]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Functional Correctness · Quick win

Supported by static analysis

Script executed:

sed -n '80,120p' cuda_core/setup.py
sed -n '700,765p' cuda_core/build_hooks.py
rg -n '/Tp' $(python -c "import setuptools,os;print(os.path.dirname(setuptools.__file__))")/_distutils | head

Repository: NVIDIA/cuda-python

Length of output: 4915


important: Recognize MSVC /Tp source arguments.

MSVC compile commands pass each C++ source as /Tp<path>. _is_handwritten_cpp(arg) receives that full string, so it rejects every MSVC compile command. check_with_clang_tidy then returns early, and Windows builds skip clang-tidy.

Strip the /Tp prefix before matching, and pass the stripped path to clang-tidy as the source.

🐛 Suggested fix
+def _source_path(arg) -> str:
+    """The source path of a compiler argument. MSVC passes sources as /Tp<path>."""
+    return arg[len("/Tp"):] if arg.startswith("/Tp") else arg
+
+
 def check_with_clang_tidy(compile_command) -> None:
@@
-    sources = [arg for arg in compile_command if _is_handwritten_cpp(arg)]
+    sources = [src for src in map(_source_path, compile_command) if _is_handwritten_cpp(src)]

if not sources:
return
(source,) = sources
config = Path(__file__).resolve().parent / ".clang-tidy"
result = subprocess.run( # noqa: S603
[_find_clang_tidy(), f"--config-file={config}", "--quiet", source, "--", *compile_command],
capture_output=True,
text=True,
)
if result.returncode != 0:
raise RuntimeError(f"clang-tidy reported errors in {source}:\n{result.stdout}{result.stderr}")


def _get_cuda_bindings_require():
"""The cuda-bindings build requirement for isolated builds.

Expand Down
4 changes: 2 additions & 2 deletions cuda_core/cuda/core/_cpp/rt/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ struct GreenCtxBox {
CUgreenCtx resource;
};

static const ContextBox *
const ContextBox *
get_box(const ContextHandle &h) noexcept
{
const CUcontext *p = h.get();
return reinterpret_cast<const ContextBox *>(reinterpret_cast<const char *>(p) - offsetof(ContextBox, resource));
}

// See REGISTRY_DESIGN.md (Level 1: Driver Handle -> Resource Handle)
static HandleRegistry<CUcontext, ContextHandle> context_registry;
HandleRegistry<CUcontext, ContextHandle> context_registry;

// Create a context handle reference, with optional green context as source.
ContextHandle
Expand Down
2 changes: 1 addition & 1 deletion cuda_core/cuda/core/_cpp/rt/context_scope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ cleanup_in_context(
}
std::invoke(std::forward<AfterCleanup>(after_cleanup));
if (status != CUDA_SUCCESS || restore != CUDA_SUCCESS) {
char operation_name[160];
char operation_name[kOperationNameSize];
format_operation(operation_name, sizeof(operation_name), name, handle);
if (status != CUDA_SUCCESS) {
report_cuda_error(operation_name, status, detail);
Expand Down
2 changes: 1 addition & 1 deletion cuda_core/cuda/core/_cpp/rt/driver_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace cuda_core::rt {

// The pointers. Null until ensure_fn_table() fills the table. See driver_api.hpp.
#define CUDA_CORE_DEFINE_DRIVER_FN(name, introduced) decltype(&name) p_##name = nullptr;
#define CUDA_CORE_DEFINE_DRIVER_FN(name, introduced) decltype(&(name)) p_##name = nullptr;
CUDA_CORE_DRIVER_FUNCTIONS(CUDA_CORE_DEFINE_DRIVER_FN)
#undef CUDA_CORE_DEFINE_DRIVER_FN

Expand Down
4 changes: 2 additions & 2 deletions cuda_core/cuda/core/_cpp/rt/driver_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ namespace cuda_core::rt {
X(cuStreamIsCapturing, 10000) \
X(cuThreadExchangeStreamCaptureMode, 10010)

#define CUDA_CORE_DECLARE_DRIVER_FN(name, introduced) extern decltype(&name) p_##name;
#define CUDA_CORE_DECLARE_DRIVER_FN(name, introduced) extern decltype(&(name)) p_##name;
CUDA_CORE_DRIVER_FUNCTIONS(CUDA_CORE_DECLARE_DRIVER_FN)
#undef CUDA_CORE_DECLARE_DRIVER_FN

Expand Down Expand Up @@ -229,7 +229,7 @@ struct Unavailable;
template <class R, class... A>
struct Unavailable<R (*)(A...)> {
static R
call(A...) noexcept
call(A... /*unused*/) noexcept
{
return UnavailableStatus<R>::value;
}
Expand Down
10 changes: 5 additions & 5 deletions cuda_core/cuda/core/_cpp/rt/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ namespace {
// Thread-local detail attached to the next raised CUDAError with a matching
// status (see take_last_error_detail()). Written only by propagating helpers.
// The taken copy stays valid until the next take on the same thread.
thread_local char last_error_detail[512] = {0};
thread_local char taken_error_detail[512] = {0};
thread_local char last_error_detail[kErrorMessageSize] = {0};
thread_local char taken_error_detail[kErrorMessageSize] = {0};
thread_local CUresult last_error_detail_status = CUDA_SUCCESS;
} // namespace

Expand Down Expand Up @@ -66,7 +66,7 @@ format_operation(char *buffer, size_t size, const char *operation, unsigned long
void
report_status_code(const char *operation, long code) noexcept
{
char message[256];
char message[kErrorMessageSize];
std::snprintf(message, sizeof(message), "%s failed (status %ld)", operation, code);
report_message(message);
}
Expand All @@ -80,7 +80,7 @@ report_cuda_error(const char *operation, CUresult status, const char *detail) no
if (status == CUDA_SUCCESS || status == CUDA_ERROR_DEINITIALIZED) {
return;
}
char message[512];
char message[kErrorMessageSize];
format_cuda_error(message, sizeof(message), operation, status, detail);
report_message(message);
}
Expand Down Expand Up @@ -122,7 +122,7 @@ note_context_not_restored(CUcontext previous, CUresult operation_status, CUresul
if (DRIVER_CALL(cuCtxGetCurrent, &current) != CUDA_SUCCESS) {
current = nullptr;
}
char cause[128] = {0};
char cause[kErrorMessageSize] = {0};
if (operation_status != CUDA_SUCCESS) {
const char *error_name = nullptr;
if (DRIVER_CALL(cuGetErrorName, restore_status, &error_name) == CUDA_SUCCESS) {
Expand Down
8 changes: 8 additions & 0 deletions cuda_core/cuda/core/_cpp/rt/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@
#pragma once

#include <cuda.h>
#include <cstddef>

namespace cuda_core::rt {

// Sizes of the stack buffers that format error text. Messages are truncated by
// snprintf, never overrun.
constexpr std::size_t kOperationNameSize = 160; // "<call> (handle 0x...)" from format_operation()
constexpr std::size_t kErrorMessageSize = 512; // a full error message or error detail
// A message that embeds one error message after some fixed text.
constexpr std::size_t kNestedMessageSize = kErrorMessageSize + (kErrorMessageSize / 2);

// ============================================================================
// Thread-local error handling
// ============================================================================
Expand Down
11 changes: 6 additions & 5 deletions cuda_core/cuda/core/_cpp/rt/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ struct GraphBox : GraphBoxBase {
GraphAttachmentMap attachments; // Non-owning attachment index.
HandleRegistry<CUgraphNode, GraphNodeHandle> node_handles;

// Not noexcept: the std::map and HandleRegistry members allocate.
GraphBox(
CUgraph resource_, GraphHierarchy *hierarchy_, GraphBox *parent_ = nullptr, CUgraphNode owner_node_ = nullptr
) noexcept
)
: GraphBoxBase{resource_}, hierarchy(hierarchy_), parent(parent_), owner_node(owner_node_)
{
}
Expand All @@ -106,7 +107,7 @@ struct GraphHierarchy {

// See REGISTRY_DESIGN.md (Level 1: Driver Handle -> Resource Handle)
using GraphRegistry = HandleRegistry<CUgraph, GraphHandle>;
static GraphRegistry graph_registry;
GraphRegistry graph_registry;

// Immutable resource owners for one version of a graph node's parameters.
// Inheriting DeferredCleanupItem lets CUDA's user-object destructor enqueue
Expand Down Expand Up @@ -140,7 +141,7 @@ free_deleter(const void *p) noexcept
GraphBox *
get_box(const GraphHandle &h) noexcept
{
auto *value = reinterpret_cast<const GraphBoxBase *>(h.get());
const auto *value = reinterpret_cast<const GraphBoxBase *>(h.get());
return const_cast<GraphBox *>(static_cast<const GraphBox *>(value));
}

Expand Down Expand Up @@ -254,7 +255,7 @@ struct PreparedAttachmentState {
explicit PreparedAttachmentState(GraphHandle h_graph_) : h_graph(std::move(h_graph_)) {}
};

void
static void
rollback_prepared_attachment(PreparedAttachmentState *state) noexcept
{
if (!state) {
Expand Down Expand Up @@ -389,7 +390,7 @@ graph_prepare_child_graph_update(
return CUDA_SUCCESS;
}

void
static void
publish_child_graph_update(PreparedChildGraphUpdateState &state, GraphHandle *out_child)
{
GraphBox *parent = get_box(state.h_parent);
Expand Down
4 changes: 2 additions & 2 deletions cuda_core/cuda/core/_cpp/rt/graph_exec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct ExecAttachmentStaging {
if (!h_source || !accumulator) {
return CUDA_SUCCESS;
}
const CUuserObject object = accumulator->object;
CUuserObject object = accumulator->object;
const GraphHandle source = std::move(h_source);
accumulator = nullptr;
GILReleaseGuard gil;
Expand Down Expand Up @@ -154,7 +154,7 @@ struct PreparedExecAttachmentState {
}
};

void
static void
rollback_prepared_exec_attachment(PreparedExecAttachmentState *state) noexcept
{
if (!state) {
Expand Down
Loading
Loading