[clang] [Clang] add typo correction for unknown attribute names (PR #140629)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clang-ppc64le-rhel` running on `ppc64le-clang-rhel-test` while building `clang` at step 5 "build-unified-tree". Full details are available at: https://lab.llvm.org/buildbot/#/builders/145/builds/7176 Here is the relevant piece of the build log for the reference ``` Step 5 (build-unified-tree) failure: build (failure) ... 58.602 [2157/192/4196] Building CXX object tools/clang/lib/Lex/CMakeFiles/obj.clangLex.dir/DependencyDirectivesScanner.cpp.o 58.674 [2156/192/4197] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Stack.cpp.o 59.263 [2155/192/4198] Building CXX object tools/clang/lib/Lex/CMakeFiles/obj.clangLex.dir/PPCallbacks.cpp.o 59.278 [2154/192/4199] Building CXX object tools/clang/lib/Lex/CMakeFiles/obj.clangLex.dir/PPConditionalDirectiveRecord.cpp.o 59.350 [2153/192/4200] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/TargetID.cpp.o 61.493 [2152/192/4201] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Builtins.cpp.o 62.171 [2151/192/4202] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/ParsedAttrInfo.cpp.o 62.238 [2150/192/4203] Building CXX object tools/clang/lib/Lex/CMakeFiles/obj.clangLex.dir/PreprocessingRecord.cpp.o 62.387 [2149/192/4204] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/ARC.cpp.o 62.509 [2148/192/4205] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o FAILED: tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o ccache /home/buildbots/llvm-external-buildbots/clang.19.1.7/bin/clang++ --gcc-toolchain=/gcc-toolchain/usr -DCLANG_EXPORTS -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/tools/clang/lib/Basic -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang/lib/Basic -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/tools/clang/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -std=c++17 -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o -MF tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o.d -o tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o -c /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang/lib/Basic/Attributes.cpp /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang/lib/Basic/Attributes.cpp:238:9: error: 'ATTR_SCOPE_SCOPE' macro redefined [-Werror,-Wmacro-redefined] 238 | #define ATTR_SCOPE_SCOPE(SCOPE_NAME) SCOPE_NAME, | ^ /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/tools/clang/include/clang/Basic/AttributeSpellingList.inc:528:9: note: previous definition is here 528 | #define ATTR_SCOPE_SCOPE(SCOPE_NAME) SCOPE_NAME | ^ 1 error generated. 63.102 [2148/191/4206] Building CXX object tools/clang/lib/Analysis/CMakeFiles/obj.clangAnalysis.dir/CocoaConventions.cpp.o 63.194 [2148/190/4207] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/SimpleTypoCorrection.cpp.o 63.758 [2148/189/4208] Building CXX object tools/clang/lib/Lex/CMakeFiles/obj.clangLex.dir/TokenConcatenation.cpp.o 63.868 [2148/188/4209] Building CXX object tools/clang/lib/Lex/CMakeFiles/obj.clangLex.dir/PreprocessorLexer.cpp.o 63.935 [2148/187/4210] Building CXX object tools/clang/lib/Lex/CMakeFiles/obj.clangLex.dir/MacroArgs.cpp.o 64.571 [2148/186/4211] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/StackExhaustionHandler.cpp.o 64.710 [2148/185/4212] Building CXX object tools/clang/lib/Lex
[clang] [Clang] add typo correction for unknown attribute names (PR #140629)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `sanitizer-ppc64le-linux` running on `ppc64le-sanitizer` while building `clang` at step 2 "annotate". Full details are available at: https://lab.llvm.org/buildbot/#/builders/72/builds/11402 Here is the relevant piece of the build log for the reference ``` Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure) ... [3330/4221] Building CXX object tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/SPIRV.cpp.o [3331/4221] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTConsumer.cpp.o [3332/4221] Building CXX object tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/DragonFly.cpp.o [/4221] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/M68k.cpp.o [3334/4221] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/InterpolatingCompilationDatabase.cpp.o [3335/4221] Building CXX object tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/Haiku.cpp.o [3336/4221] Building CXX object tools/clang/lib/Format/CMakeFiles/obj.clangFormat.dir/AffectedRangeManager.cpp.o [3337/4221] Building CXX object tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/AMDGPUOpenMP.cpp.o [3338/4221] Building CXX object tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/CrossWindows.cpp.o [3339/4221] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o FAILED: tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o CCACHE_CPP2=yes CCACHE_HASHDIR=yes CCACHE_SLOPPINESS=pch_defines,time_macros /usr/bin/ccache /home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm_build0/bin/clang++ -DCLANG_EXPORTS -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/tools/clang/lib/Basic -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/clang/lib/Basic -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/clang/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/tools/clang/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -std=c++17 -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o -MF tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o.d -o tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o -c /home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/clang/lib/Basic/Attributes.cpp /home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/clang/lib/Basic/Attributes.cpp:238:9: error: 'ATTR_SCOPE_SCOPE' macro redefined [-Werror,-Wmacro-redefined] 238 | #define ATTR_SCOPE_SCOPE(SCOPE_NAME) SCOPE_NAME, | ^ /home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/tools/clang/include/clang/Basic/AttributeSpellingList.inc:528:9: note: previous definition is here 528 | #define ATTR_SCOPE_SCOPE(SCOPE_NAME) SCOPE_NAME | ^ 1 error generated. [3340/4221] Building CXX object tools/clang/lib/Lex/CMakeFiles/obj.clangLex.dir/MacroInfo.cpp.o [3341/4221] Building CXX object tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/UEFI.cpp.o [3342/4221] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/FixIt.cpp.o [3343/4221] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/DiagnosticRenderer.cpp.o [3344/4221] Building CXX object tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/Compilation.cpp.o [3345/4221] Building CXX object tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolCh
[clang] [Clang] add typo correction for unknown attribute names (PR #140629)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `sanitizer-x86_64-linux-android` running on `sanitizer-buildbot-android` while building `clang` at step 2 "annotate". Full details are available at: https://lab.llvm.org/buildbot/#/builders/186/builds/9245 Here is the relevant piece of the build log for the reference ``` Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure) ... [3589/5523] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/FileSystemStatCache.cpp.o [3590/5523] Building X86GenSubtargetInfo.inc... [3591/5523] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/LangOptions.cpp.o [3592/5523] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/LangStandards.cpp.o [3593/5523] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/MakeSupport.cpp.o [3594/5523] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Module.cpp.o [3595/5523] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/ObjCRuntime.cpp.o [3596/5523] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/OffloadArch.cpp.o [3597/5523] Building CXX object tools/clang/lib/Lex/CMakeFiles/obj.clangLex.dir/DependencyDirectivesScanner.cpp.o [3598/5523] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o FAILED: tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o CCACHE_CPP2=yes CCACHE_HASHDIR=yes CCACHE_SLOPPINESS=pch_defines,time_macros /usr/bin/ccache /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build0/bin/clang++ -DCLANG_EXPORTS -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/tools/clang/lib/Basic -I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/clang/lib/Basic -I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/clang/include -I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/tools/clang/include -I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/include -I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -std=c++17 -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o -MF tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o.d -o tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o -c /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/clang/lib/Basic/Attributes.cpp /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/clang/lib/Basic/Attributes.cpp:238:9: error: 'ATTR_SCOPE_SCOPE' macro redefined [-Werror,-Wmacro-redefined] 238 | #define ATTR_SCOPE_SCOPE(SCOPE_NAME) SCOPE_NAME, | ^ /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/tools/clang/include/clang/Basic/AttributeSpellingList.inc:528:9: note: previous definition is here 528 | #define ATTR_SCOPE_SCOPE(SCOPE_NAME) SCOPE_NAME | ^ 1 error generated. [3599/5523] Building X86GenInstrInfo.inc... [3600/5523] Building CXX object tools/clang/lib/APINotes/CMakeFiles/obj.clangAPINotes.dir/APINotesManager.cpp.o [3601/5523] Building CXX object tools/clang/lib/Lex/CMakeFiles/obj.clangLex.dir/InitHeaderSearch.cpp.o [3602/5523] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/OpenCLOptions.cpp.o [3603/5523] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Builtins.cpp.o [3604/5523] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/OpenMPKinds.cpp.o [3605/5523] Building CXX object tools/clang/lib/Lex/CMakeFiles/obj.clangLex.dir/LiteralSupport.cpp.o [3606/5523] Building CXX object tools/clang/lib/Lex/CMakeFiles/obj.clangLex.dir/Lexer.cpp.o [3607/5523] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Diagnostic.cpp.o [3608/5523] Buil
[clang] [Clang] add typo correction for unknown attribute names (PR #140629)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `ppc64le-lld-multistage-test` running on `ppc64le-lld-multistage-test` while building `clang` at step 12 "build-stage2-unified-tree". Full details are available at: https://lab.llvm.org/buildbot/#/builders/168/builds/12358 Here is the relevant piece of the build log for the reference ``` Step 12 (build-stage2-unified-tree) failure: build (failure) ... 193.958 [1575/1154/3841] Building CXX object lib/ExecutionEngine/JITLink/CMakeFiles/LLVMJITLink.dir/aarch32.cpp.o 193.998 [1574/1154/3842] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/Xtensa.cpp.o 194.030 [1573/1154/3843] Building CXX object tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/GlobalModuleIndex.cpp.o 194.059 [1572/1154/3844] Building CXX object tools/clang/lib/ExtractAPI/CMakeFiles/obj.clangExtractAPI.dir/TypedefUnderlyingTypeResolver.cpp.o 194.088 [1571/1154/3845] Building CXX object lib/ExecutionEngine/Orc/CMakeFiles/LLVMOrcJIT.dir/MachO.cpp.o 194.118 [1570/1154/3846] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/ProfileList.cpp.o 194.430 [1569/1154/3847] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/VE.cpp.o 194.480 [1568/1154/3848] Building CXX object lib/Target/SystemZ/MCTargetDesc/CMakeFiles/LLVMSystemZDesc.dir/SystemZHLASMAsmStreamer.cpp.o 194.640 [1567/1154/3849] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Builtins.cpp.o 194.670 [1566/1154/3850] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o FAILED: tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o ccache /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/install/stage1/bin/clang++ -DCLANG_EXPORTS -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage2/tools/clang/lib/Basic -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/clang/lib/Basic -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/clang/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage2/tools/clang/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage2/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wno-unnecessary-virtual-specifier -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -std=c++17 -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o -MF tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o.d -o tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o -c /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/clang/lib/Basic/Attributes.cpp /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/clang/lib/Basic/Attributes.cpp:238:9: error: 'ATTR_SCOPE_SCOPE' macro redefined [-Werror,-Wmacro-redefined] 238 | #define ATTR_SCOPE_SCOPE(SCOPE_NAME) SCOPE_NAME, | ^ /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage2/tools/clang/include/clang/Basic/AttributeSpellingList.inc:528:9: note: previous definition is here 528 | #define ATTR_SCOPE_SCOPE(SCOPE_NAME) SCOPE_NAME | ^ 1 error generated. 194.672 [1566/1153/3851] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/NVPTX.cpp.o 194.675 [1566/1152/3852] Building CXX object lib/Target/Hexagon/CMakeFiles/LLVMHexagonCodeGen.dir/HexagonCFGOptimizer.cpp.o 194.750 [1566/1151/3853] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/SystemZ.cpp.o 194.753 [1566/1150/3854] Building CXX object lib/ExecutionEngine/JITLink/CMakeFiles/LLVMJITLink.dir/JITL
[clang] [Clang] add typo correction for unknown attribute names (PR #140629)
https://github.com/a-tarasyuk closed https://github.com/llvm/llvm-project/pull/140629 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] add typo correction for unknown attribute names (PR #140629)
https://github.com/a-tarasyuk updated
https://github.com/llvm/llvm-project/pull/140629
>From 5b8f0635fdddc87ea326a3b1b47191ab9bf23c0f Mon Sep 17 00:00:00 2001
From: Oleksandr Tarasiuk
Date: Tue, 20 May 2025 00:38:43 +0300
Subject: [PATCH 1/4] [Clang] add typo correction for unknown attribute names
---
clang/docs/ReleaseNotes.rst | 2 +
.../include/clang/Basic/AttributeCommonInfo.h | 5 +
clang/include/clang/Basic/Attributes.h| 4 +
clang/include/clang/Basic/CMakeLists.txt | 6 +
.../clang/Basic/DiagnosticCommonKinds.td | 2 +
.../clang/Basic/SimpleTypoCorrection.h| 35
clang/include/clang/Sema/Sema.h | 2 +
clang/lib/AST/CommentSema.cpp | 97 +++
clang/lib/Basic/Attributes.cpp| 153 --
clang/lib/Basic/CMakeLists.txt| 1 +
clang/lib/Basic/SimpleTypoCorrection.cpp | 52 ++
clang/lib/Sema/SemaDeclAttr.cpp | 18 ++-
clang/lib/Sema/SemaType.cpp | 4 +-
clang/test/Parser/cxx0x-attributes.cpp| 2 +-
clang/test/Sema/attr-c2x.c| 4 +-
clang/test/Sema/unknown-attributes.c | 16 +-
clang/test/SemaCXX/cxx11-gnu-attrs.cpp| 2 +-
clang/utils/TableGen/ClangAttrEmitter.cpp | 27
clang/utils/TableGen/TableGen.cpp | 6 +
clang/utils/TableGen/TableGenBackends.h | 2 +
20 files changed, 307 insertions(+), 133 deletions(-)
create mode 100644 clang/include/clang/Basic/SimpleTypoCorrection.h
create mode 100644 clang/lib/Basic/SimpleTypoCorrection.cpp
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ac9baf229b489..deee00128c1fa 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -561,6 +561,8 @@ Improvements to Clang's diagnostics
- Fixed a crash when checking a ``__thread``-specified variable declaration
with a dependent type in C++. (#GH140509)
+- Clang now suggests corrections for unknown attribute names.
+
Improvements to Clang's time-trace
--
diff --git a/clang/include/clang/Basic/AttributeCommonInfo.h
b/clang/include/clang/Basic/AttributeCommonInfo.h
index 6db7b53317e7d..b4b8345b4ed40 100644
--- a/clang/include/clang/Basic/AttributeCommonInfo.h
+++ b/clang/include/clang/Basic/AttributeCommonInfo.h
@@ -21,6 +21,8 @@ namespace clang {
class ASTRecordWriter;
class IdentifierInfo;
+class LangOptions;
+class TargetInfo;
class AttributeCommonInfo {
public:
@@ -196,6 +198,9 @@ class AttributeCommonInfo {
/// with surrounding underscores removed as appropriate (e.g.
/// __gnu__::__attr__ will be normalized to gnu::attr).
std::string getNormalizedFullName() const;
+ std::optional
+ getCorrectedFullName(const TargetInfo &Target,
+ const LangOptions &LangOpts) const;
SourceRange getNormalizedRange() const;
bool isDeclspecAttribute() const { return SyntaxUsed == AS_Declspec; }
diff --git a/clang/include/clang/Basic/Attributes.h
b/clang/include/clang/Basic/Attributes.h
index 99bb668fe32d0..9cf6fb3d89019 100644
--- a/clang/include/clang/Basic/Attributes.h
+++ b/clang/include/clang/Basic/Attributes.h
@@ -19,6 +19,10 @@ class TargetInfo;
/// Return the version number associated with the attribute if we
/// recognize and implement the attribute specified by the given information.
+int hasAttribute(AttributeCommonInfo::Syntax Syntax, llvm::StringRef ScopeName,
+ llvm::StringRef AttrName, const TargetInfo &Target,
+ const LangOptions &LangOpts, bool CheckPlugins);
+
int hasAttribute(AttributeCommonInfo::Syntax Syntax,
const IdentifierInfo *Scope, const IdentifierInfo *Attr,
const TargetInfo &Target, const LangOptions &LangOpts);
diff --git a/clang/include/clang/Basic/CMakeLists.txt
b/clang/include/clang/Basic/CMakeLists.txt
index 265ea1fc06494..1873878e2e46b 100644
--- a/clang/include/clang/Basic/CMakeLists.txt
+++ b/clang/include/clang/Basic/CMakeLists.txt
@@ -79,6 +79,12 @@ clang_tablegen(CXX11AttributeInfo.inc
-gen-cxx11-attribute-info
TARGET CXX11AttributeInfo
)
+ clang_tablegen(AttributeSpellingList.inc -gen-attribute-spelling-list
+ -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
+ SOURCE Attr.td
+ TARGET AttributeSpellingList
+ )
+
clang_tablegen(Builtins.inc -gen-clang-builtins
SOURCE Builtins.td
TARGET ClangBuiltins)
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index e4d94fefbbf3d..0bd8a423c393e 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -181,6 +181,8 @@ def err_opencl_unknown_type_specifier : Error<
def warn_unknown_attribute_ignored : Warning<
"unknown attribute %0 ignored">, InGroup;
+def warn_unknown_attribute_ignored_suggestion : Warning<
+ "unknown attribute
[clang] [Clang] add typo correction for unknown attribute names (PR #140629)
https://github.com/a-tarasyuk updated
https://github.com/llvm/llvm-project/pull/140629
>From 5b8f0635fdddc87ea326a3b1b47191ab9bf23c0f Mon Sep 17 00:00:00 2001
From: Oleksandr Tarasiuk
Date: Tue, 20 May 2025 00:38:43 +0300
Subject: [PATCH 1/4] [Clang] add typo correction for unknown attribute names
---
clang/docs/ReleaseNotes.rst | 2 +
.../include/clang/Basic/AttributeCommonInfo.h | 5 +
clang/include/clang/Basic/Attributes.h| 4 +
clang/include/clang/Basic/CMakeLists.txt | 6 +
.../clang/Basic/DiagnosticCommonKinds.td | 2 +
.../clang/Basic/SimpleTypoCorrection.h| 35
clang/include/clang/Sema/Sema.h | 2 +
clang/lib/AST/CommentSema.cpp | 97 +++
clang/lib/Basic/Attributes.cpp| 153 --
clang/lib/Basic/CMakeLists.txt| 1 +
clang/lib/Basic/SimpleTypoCorrection.cpp | 52 ++
clang/lib/Sema/SemaDeclAttr.cpp | 18 ++-
clang/lib/Sema/SemaType.cpp | 4 +-
clang/test/Parser/cxx0x-attributes.cpp| 2 +-
clang/test/Sema/attr-c2x.c| 4 +-
clang/test/Sema/unknown-attributes.c | 16 +-
clang/test/SemaCXX/cxx11-gnu-attrs.cpp| 2 +-
clang/utils/TableGen/ClangAttrEmitter.cpp | 27
clang/utils/TableGen/TableGen.cpp | 6 +
clang/utils/TableGen/TableGenBackends.h | 2 +
20 files changed, 307 insertions(+), 133 deletions(-)
create mode 100644 clang/include/clang/Basic/SimpleTypoCorrection.h
create mode 100644 clang/lib/Basic/SimpleTypoCorrection.cpp
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ac9baf229b489..deee00128c1fa 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -561,6 +561,8 @@ Improvements to Clang's diagnostics
- Fixed a crash when checking a ``__thread``-specified variable declaration
with a dependent type in C++. (#GH140509)
+- Clang now suggests corrections for unknown attribute names.
+
Improvements to Clang's time-trace
--
diff --git a/clang/include/clang/Basic/AttributeCommonInfo.h
b/clang/include/clang/Basic/AttributeCommonInfo.h
index 6db7b53317e7d..b4b8345b4ed40 100644
--- a/clang/include/clang/Basic/AttributeCommonInfo.h
+++ b/clang/include/clang/Basic/AttributeCommonInfo.h
@@ -21,6 +21,8 @@ namespace clang {
class ASTRecordWriter;
class IdentifierInfo;
+class LangOptions;
+class TargetInfo;
class AttributeCommonInfo {
public:
@@ -196,6 +198,9 @@ class AttributeCommonInfo {
/// with surrounding underscores removed as appropriate (e.g.
/// __gnu__::__attr__ will be normalized to gnu::attr).
std::string getNormalizedFullName() const;
+ std::optional
+ getCorrectedFullName(const TargetInfo &Target,
+ const LangOptions &LangOpts) const;
SourceRange getNormalizedRange() const;
bool isDeclspecAttribute() const { return SyntaxUsed == AS_Declspec; }
diff --git a/clang/include/clang/Basic/Attributes.h
b/clang/include/clang/Basic/Attributes.h
index 99bb668fe32d0..9cf6fb3d89019 100644
--- a/clang/include/clang/Basic/Attributes.h
+++ b/clang/include/clang/Basic/Attributes.h
@@ -19,6 +19,10 @@ class TargetInfo;
/// Return the version number associated with the attribute if we
/// recognize and implement the attribute specified by the given information.
+int hasAttribute(AttributeCommonInfo::Syntax Syntax, llvm::StringRef ScopeName,
+ llvm::StringRef AttrName, const TargetInfo &Target,
+ const LangOptions &LangOpts, bool CheckPlugins);
+
int hasAttribute(AttributeCommonInfo::Syntax Syntax,
const IdentifierInfo *Scope, const IdentifierInfo *Attr,
const TargetInfo &Target, const LangOptions &LangOpts);
diff --git a/clang/include/clang/Basic/CMakeLists.txt
b/clang/include/clang/Basic/CMakeLists.txt
index 265ea1fc06494..1873878e2e46b 100644
--- a/clang/include/clang/Basic/CMakeLists.txt
+++ b/clang/include/clang/Basic/CMakeLists.txt
@@ -79,6 +79,12 @@ clang_tablegen(CXX11AttributeInfo.inc
-gen-cxx11-attribute-info
TARGET CXX11AttributeInfo
)
+ clang_tablegen(AttributeSpellingList.inc -gen-attribute-spelling-list
+ -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
+ SOURCE Attr.td
+ TARGET AttributeSpellingList
+ )
+
clang_tablegen(Builtins.inc -gen-clang-builtins
SOURCE Builtins.td
TARGET ClangBuiltins)
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index e4d94fefbbf3d..0bd8a423c393e 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -181,6 +181,8 @@ def err_opencl_unknown_type_specifier : Error<
def warn_unknown_attribute_ignored : Warning<
"unknown attribute %0 ignored">, InGroup;
+def warn_unknown_attribute_ignored_suggestion : Warning<
+ "unknown attribute
[clang] [Clang] add typo correction for unknown attribute names (PR #140629)
https://github.com/erichkeane approved this pull request. Thought I'd already +1ed! with teh copyright headers, this LGTM. https://github.com/llvm/llvm-project/pull/140629 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] add typo correction for unknown attribute names (PR #140629)
https://github.com/a-tarasyuk updated
https://github.com/llvm/llvm-project/pull/140629
>From 5b8f0635fdddc87ea326a3b1b47191ab9bf23c0f Mon Sep 17 00:00:00 2001
From: Oleksandr Tarasiuk
Date: Tue, 20 May 2025 00:38:43 +0300
Subject: [PATCH 1/3] [Clang] add typo correction for unknown attribute names
---
clang/docs/ReleaseNotes.rst | 2 +
.../include/clang/Basic/AttributeCommonInfo.h | 5 +
clang/include/clang/Basic/Attributes.h| 4 +
clang/include/clang/Basic/CMakeLists.txt | 6 +
.../clang/Basic/DiagnosticCommonKinds.td | 2 +
.../clang/Basic/SimpleTypoCorrection.h| 35
clang/include/clang/Sema/Sema.h | 2 +
clang/lib/AST/CommentSema.cpp | 97 +++
clang/lib/Basic/Attributes.cpp| 153 --
clang/lib/Basic/CMakeLists.txt| 1 +
clang/lib/Basic/SimpleTypoCorrection.cpp | 52 ++
clang/lib/Sema/SemaDeclAttr.cpp | 18 ++-
clang/lib/Sema/SemaType.cpp | 4 +-
clang/test/Parser/cxx0x-attributes.cpp| 2 +-
clang/test/Sema/attr-c2x.c| 4 +-
clang/test/Sema/unknown-attributes.c | 16 +-
clang/test/SemaCXX/cxx11-gnu-attrs.cpp| 2 +-
clang/utils/TableGen/ClangAttrEmitter.cpp | 27
clang/utils/TableGen/TableGen.cpp | 6 +
clang/utils/TableGen/TableGenBackends.h | 2 +
20 files changed, 307 insertions(+), 133 deletions(-)
create mode 100644 clang/include/clang/Basic/SimpleTypoCorrection.h
create mode 100644 clang/lib/Basic/SimpleTypoCorrection.cpp
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ac9baf229b489..deee00128c1fa 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -561,6 +561,8 @@ Improvements to Clang's diagnostics
- Fixed a crash when checking a ``__thread``-specified variable declaration
with a dependent type in C++. (#GH140509)
+- Clang now suggests corrections for unknown attribute names.
+
Improvements to Clang's time-trace
--
diff --git a/clang/include/clang/Basic/AttributeCommonInfo.h
b/clang/include/clang/Basic/AttributeCommonInfo.h
index 6db7b53317e7d..b4b8345b4ed40 100644
--- a/clang/include/clang/Basic/AttributeCommonInfo.h
+++ b/clang/include/clang/Basic/AttributeCommonInfo.h
@@ -21,6 +21,8 @@ namespace clang {
class ASTRecordWriter;
class IdentifierInfo;
+class LangOptions;
+class TargetInfo;
class AttributeCommonInfo {
public:
@@ -196,6 +198,9 @@ class AttributeCommonInfo {
/// with surrounding underscores removed as appropriate (e.g.
/// __gnu__::__attr__ will be normalized to gnu::attr).
std::string getNormalizedFullName() const;
+ std::optional
+ getCorrectedFullName(const TargetInfo &Target,
+ const LangOptions &LangOpts) const;
SourceRange getNormalizedRange() const;
bool isDeclspecAttribute() const { return SyntaxUsed == AS_Declspec; }
diff --git a/clang/include/clang/Basic/Attributes.h
b/clang/include/clang/Basic/Attributes.h
index 99bb668fe32d0..9cf6fb3d89019 100644
--- a/clang/include/clang/Basic/Attributes.h
+++ b/clang/include/clang/Basic/Attributes.h
@@ -19,6 +19,10 @@ class TargetInfo;
/// Return the version number associated with the attribute if we
/// recognize and implement the attribute specified by the given information.
+int hasAttribute(AttributeCommonInfo::Syntax Syntax, llvm::StringRef ScopeName,
+ llvm::StringRef AttrName, const TargetInfo &Target,
+ const LangOptions &LangOpts, bool CheckPlugins);
+
int hasAttribute(AttributeCommonInfo::Syntax Syntax,
const IdentifierInfo *Scope, const IdentifierInfo *Attr,
const TargetInfo &Target, const LangOptions &LangOpts);
diff --git a/clang/include/clang/Basic/CMakeLists.txt
b/clang/include/clang/Basic/CMakeLists.txt
index 265ea1fc06494..1873878e2e46b 100644
--- a/clang/include/clang/Basic/CMakeLists.txt
+++ b/clang/include/clang/Basic/CMakeLists.txt
@@ -79,6 +79,12 @@ clang_tablegen(CXX11AttributeInfo.inc
-gen-cxx11-attribute-info
TARGET CXX11AttributeInfo
)
+ clang_tablegen(AttributeSpellingList.inc -gen-attribute-spelling-list
+ -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
+ SOURCE Attr.td
+ TARGET AttributeSpellingList
+ )
+
clang_tablegen(Builtins.inc -gen-clang-builtins
SOURCE Builtins.td
TARGET ClangBuiltins)
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index e4d94fefbbf3d..0bd8a423c393e 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -181,6 +181,8 @@ def err_opencl_unknown_type_specifier : Error<
def warn_unknown_attribute_ignored : Warning<
"unknown attribute %0 ignored">, InGroup;
+def warn_unknown_attribute_ignored_suggestion : Warning<
+ "unknown attribute
[clang] [Clang] add typo correction for unknown attribute names (PR #140629)
@@ -203,10 +221,47 @@ unsigned
AttributeCommonInfo::calculateAttributeSpellingListIndex() const {
// attribute spell list index matching code.
auto Syntax = static_cast(getSyntax());
StringRef ScopeName = normalizeAttrScopeName(getScopeName(), Syntax);
- StringRef Name = normalizeAttrName(getAttrName(), ScopeName, Syntax);
-
+ StringRef Name =
+ normalizeAttrName(getAttrName()->getName(), ScopeName, Syntax);
AttributeCommonInfo::Scope ComputedScope =
getScopeFromNormalizedScopeName(ScopeName);
#include "clang/Sema/AttrSpellingListIndex.inc"
}
+
+#include "clang/Basic/AttributeSpellingList.inc"
a-tarasyuk wrote:
Thanks for the feedback. I've changed to use _general approach_
https://github.com/llvm/llvm-project/pull/140629
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] add typo correction for unknown attribute names (PR #140629)
@@ -203,10 +221,47 @@ unsigned
AttributeCommonInfo::calculateAttributeSpellingListIndex() const {
// attribute spell list index matching code.
auto Syntax = static_cast(getSyntax());
StringRef ScopeName = normalizeAttrScopeName(getScopeName(), Syntax);
- StringRef Name = normalizeAttrName(getAttrName(), ScopeName, Syntax);
-
+ StringRef Name =
+ normalizeAttrName(getAttrName()->getName(), ScopeName, Syntax);
AttributeCommonInfo::Scope ComputedScope =
getScopeFromNormalizedScopeName(ScopeName);
#include "clang/Sema/AttrSpellingListIndex.inc"
}
+
+#include "clang/Basic/AttributeSpellingList.inc"
AaronBallman wrote:
It's hard to understand what's going on here because the tablegen hides the
fact that this is introducing new declarations. I think a more general approach
would be:
```
#define NAME(X) X
static constexpr const char *AttrSpellingList[] = {
#include "clang/Basic/AttributeSpellingList.inc"
};
#undef NAME
#define SCOPE(X) X
static constexpr const char *AttrScopeSpellingList[] = {
#include "clang/Basic/AttributeSpellingList.inc"
};
#undef SCOPE
```
WDYT?
https://github.com/llvm/llvm-project/pull/140629
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] add typo correction for unknown attribute names (PR #140629)
https://github.com/a-tarasyuk updated
https://github.com/llvm/llvm-project/pull/140629
>From 5b8f0635fdddc87ea326a3b1b47191ab9bf23c0f Mon Sep 17 00:00:00 2001
From: Oleksandr Tarasiuk
Date: Tue, 20 May 2025 00:38:43 +0300
Subject: [PATCH 1/2] [Clang] add typo correction for unknown attribute names
---
clang/docs/ReleaseNotes.rst | 2 +
.../include/clang/Basic/AttributeCommonInfo.h | 5 +
clang/include/clang/Basic/Attributes.h| 4 +
clang/include/clang/Basic/CMakeLists.txt | 6 +
.../clang/Basic/DiagnosticCommonKinds.td | 2 +
.../clang/Basic/SimpleTypoCorrection.h| 35
clang/include/clang/Sema/Sema.h | 2 +
clang/lib/AST/CommentSema.cpp | 97 +++
clang/lib/Basic/Attributes.cpp| 153 --
clang/lib/Basic/CMakeLists.txt| 1 +
clang/lib/Basic/SimpleTypoCorrection.cpp | 52 ++
clang/lib/Sema/SemaDeclAttr.cpp | 18 ++-
clang/lib/Sema/SemaType.cpp | 4 +-
clang/test/Parser/cxx0x-attributes.cpp| 2 +-
clang/test/Sema/attr-c2x.c| 4 +-
clang/test/Sema/unknown-attributes.c | 16 +-
clang/test/SemaCXX/cxx11-gnu-attrs.cpp| 2 +-
clang/utils/TableGen/ClangAttrEmitter.cpp | 27
clang/utils/TableGen/TableGen.cpp | 6 +
clang/utils/TableGen/TableGenBackends.h | 2 +
20 files changed, 307 insertions(+), 133 deletions(-)
create mode 100644 clang/include/clang/Basic/SimpleTypoCorrection.h
create mode 100644 clang/lib/Basic/SimpleTypoCorrection.cpp
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ac9baf229b489..deee00128c1fa 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -561,6 +561,8 @@ Improvements to Clang's diagnostics
- Fixed a crash when checking a ``__thread``-specified variable declaration
with a dependent type in C++. (#GH140509)
+- Clang now suggests corrections for unknown attribute names.
+
Improvements to Clang's time-trace
--
diff --git a/clang/include/clang/Basic/AttributeCommonInfo.h
b/clang/include/clang/Basic/AttributeCommonInfo.h
index 6db7b53317e7d..b4b8345b4ed40 100644
--- a/clang/include/clang/Basic/AttributeCommonInfo.h
+++ b/clang/include/clang/Basic/AttributeCommonInfo.h
@@ -21,6 +21,8 @@ namespace clang {
class ASTRecordWriter;
class IdentifierInfo;
+class LangOptions;
+class TargetInfo;
class AttributeCommonInfo {
public:
@@ -196,6 +198,9 @@ class AttributeCommonInfo {
/// with surrounding underscores removed as appropriate (e.g.
/// __gnu__::__attr__ will be normalized to gnu::attr).
std::string getNormalizedFullName() const;
+ std::optional
+ getCorrectedFullName(const TargetInfo &Target,
+ const LangOptions &LangOpts) const;
SourceRange getNormalizedRange() const;
bool isDeclspecAttribute() const { return SyntaxUsed == AS_Declspec; }
diff --git a/clang/include/clang/Basic/Attributes.h
b/clang/include/clang/Basic/Attributes.h
index 99bb668fe32d0..9cf6fb3d89019 100644
--- a/clang/include/clang/Basic/Attributes.h
+++ b/clang/include/clang/Basic/Attributes.h
@@ -19,6 +19,10 @@ class TargetInfo;
/// Return the version number associated with the attribute if we
/// recognize and implement the attribute specified by the given information.
+int hasAttribute(AttributeCommonInfo::Syntax Syntax, llvm::StringRef ScopeName,
+ llvm::StringRef AttrName, const TargetInfo &Target,
+ const LangOptions &LangOpts, bool CheckPlugins);
+
int hasAttribute(AttributeCommonInfo::Syntax Syntax,
const IdentifierInfo *Scope, const IdentifierInfo *Attr,
const TargetInfo &Target, const LangOptions &LangOpts);
diff --git a/clang/include/clang/Basic/CMakeLists.txt
b/clang/include/clang/Basic/CMakeLists.txt
index 265ea1fc06494..1873878e2e46b 100644
--- a/clang/include/clang/Basic/CMakeLists.txt
+++ b/clang/include/clang/Basic/CMakeLists.txt
@@ -79,6 +79,12 @@ clang_tablegen(CXX11AttributeInfo.inc
-gen-cxx11-attribute-info
TARGET CXX11AttributeInfo
)
+ clang_tablegen(AttributeSpellingList.inc -gen-attribute-spelling-list
+ -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
+ SOURCE Attr.td
+ TARGET AttributeSpellingList
+ )
+
clang_tablegen(Builtins.inc -gen-clang-builtins
SOURCE Builtins.td
TARGET ClangBuiltins)
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index e4d94fefbbf3d..0bd8a423c393e 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -181,6 +181,8 @@ def err_opencl_unknown_type_specifier : Error<
def warn_unknown_attribute_ignored : Warning<
"unknown attribute %0 ignored">, InGroup;
+def warn_unknown_attribute_ignored_suggestion : Warning<
+ "unknown attribute
[clang] [Clang] add typo correction for unknown attribute names (PR #140629)
github-actions[bot] wrote:
:warning: C/C++ code formatter, clang-format found issues in your code.
:warning:
You can test this locally with the following command:
``bash
git-clang-format --diff HEAD~1 HEAD --extensions h,cpp,c --
clang/include/clang/Basic/SimpleTypoCorrection.h
clang/lib/Basic/SimpleTypoCorrection.cpp
clang/include/clang/Basic/AttributeCommonInfo.h
clang/include/clang/Basic/Attributes.h clang/include/clang/Sema/Sema.h
clang/lib/AST/CommentSema.cpp clang/lib/Basic/Attributes.cpp
clang/lib/Sema/SemaDeclAttr.cpp clang/lib/Sema/SemaType.cpp
clang/test/Parser/cxx0x-attributes.cpp clang/test/Sema/attr-c2x.c
clang/test/Sema/unknown-attributes.c clang/test/SemaCXX/cxx11-gnu-attrs.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp clang/utils/TableGen/TableGen.cpp
clang/utils/TableGen/TableGenBackends.h
``
View the diff from clang-format here.
``diff
diff --git a/clang/lib/Basic/SimpleTypoCorrection.cpp
b/clang/lib/Basic/SimpleTypoCorrection.cpp
index c98b89d9f..86b86eeea 100644
--- a/clang/lib/Basic/SimpleTypoCorrection.cpp
+++ b/clang/lib/Basic/SimpleTypoCorrection.cpp
@@ -37,9 +37,7 @@ void SimpleTypoCorrection::add(const IdentifierInfo
*Candidate) {
add(Candidate->getName());
}
-unsigned SimpleTypoCorrection::getCorrectionIndex() const {
- return BestIndex;
-}
+unsigned SimpleTypoCorrection::getCorrectionIndex() const { return BestIndex; }
std::optional SimpleTypoCorrection::getCorrection() const {
if (hasCorrection())
``
https://github.com/llvm/llvm-project/pull/140629
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] add typo correction for unknown attribute names (PR #140629)
llvmbot wrote:
@llvm/pr-subscribers-clang
Author: Oleksandr T. (a-tarasyuk)
Changes
This patch enhances Clang's diagnosis for unknown attributes by providing typo
correction suggestions for known attributes.
```cpp
[[gmu::deprected]] // expected-warning {{unknown attribute 'gmu::deprected'
ignored; did you mean 'gnu::deprecated'?}}
int f1(void) {
return 0;
}
[[deprected]] // expected-warning {{unknown attribute 'deprected' ignored; did
you mean 'deprecated'?}}
int f2(void) {
return 0;
}
```
---
Patch is 30.20 KiB, truncated to 20.00 KiB below, full version:
https://github.com/llvm/llvm-project/pull/140629.diff
20 Files Affected:
- (modified) clang/docs/ReleaseNotes.rst (+2)
- (modified) clang/include/clang/Basic/AttributeCommonInfo.h (+5)
- (modified) clang/include/clang/Basic/Attributes.h (+4)
- (modified) clang/include/clang/Basic/CMakeLists.txt (+6)
- (modified) clang/include/clang/Basic/DiagnosticCommonKinds.td (+2)
- (added) clang/include/clang/Basic/SimpleTypoCorrection.h (+35)
- (modified) clang/include/clang/Sema/Sema.h (+2)
- (modified) clang/lib/AST/CommentSema.cpp (+26-71)
- (modified) clang/lib/Basic/Attributes.cpp (+104-49)
- (modified) clang/lib/Basic/CMakeLists.txt (+1)
- (added) clang/lib/Basic/SimpleTypoCorrection.cpp (+52)
- (modified) clang/lib/Sema/SemaDeclAttr.cpp (+15-3)
- (modified) clang/lib/Sema/SemaType.cpp (+1-3)
- (modified) clang/test/Parser/cxx0x-attributes.cpp (+1-1)
- (modified) clang/test/Sema/attr-c2x.c (+2-2)
- (modified) clang/test/Sema/unknown-attributes.c (+13-3)
- (modified) clang/test/SemaCXX/cxx11-gnu-attrs.cpp (+1-1)
- (modified) clang/utils/TableGen/ClangAttrEmitter.cpp (+27)
- (modified) clang/utils/TableGen/TableGen.cpp (+6)
- (modified) clang/utils/TableGen/TableGenBackends.h (+2)
``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ac9baf229b489..deee00128c1fa 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -561,6 +561,8 @@ Improvements to Clang's diagnostics
- Fixed a crash when checking a ``__thread``-specified variable declaration
with a dependent type in C++. (#GH140509)
+- Clang now suggests corrections for unknown attribute names.
+
Improvements to Clang's time-trace
--
diff --git a/clang/include/clang/Basic/AttributeCommonInfo.h
b/clang/include/clang/Basic/AttributeCommonInfo.h
index 6db7b53317e7d..b4b8345b4ed40 100644
--- a/clang/include/clang/Basic/AttributeCommonInfo.h
+++ b/clang/include/clang/Basic/AttributeCommonInfo.h
@@ -21,6 +21,8 @@ namespace clang {
class ASTRecordWriter;
class IdentifierInfo;
+class LangOptions;
+class TargetInfo;
class AttributeCommonInfo {
public:
@@ -196,6 +198,9 @@ class AttributeCommonInfo {
/// with surrounding underscores removed as appropriate (e.g.
/// __gnu__::__attr__ will be normalized to gnu::attr).
std::string getNormalizedFullName() const;
+ std::optional
+ getCorrectedFullName(const TargetInfo &Target,
+ const LangOptions &LangOpts) const;
SourceRange getNormalizedRange() const;
bool isDeclspecAttribute() const { return SyntaxUsed == AS_Declspec; }
diff --git a/clang/include/clang/Basic/Attributes.h
b/clang/include/clang/Basic/Attributes.h
index 99bb668fe32d0..9cf6fb3d89019 100644
--- a/clang/include/clang/Basic/Attributes.h
+++ b/clang/include/clang/Basic/Attributes.h
@@ -19,6 +19,10 @@ class TargetInfo;
/// Return the version number associated with the attribute if we
/// recognize and implement the attribute specified by the given information.
+int hasAttribute(AttributeCommonInfo::Syntax Syntax, llvm::StringRef ScopeName,
+ llvm::StringRef AttrName, const TargetInfo &Target,
+ const LangOptions &LangOpts, bool CheckPlugins);
+
int hasAttribute(AttributeCommonInfo::Syntax Syntax,
const IdentifierInfo *Scope, const IdentifierInfo *Attr,
const TargetInfo &Target, const LangOptions &LangOpts);
diff --git a/clang/include/clang/Basic/CMakeLists.txt
b/clang/include/clang/Basic/CMakeLists.txt
index 265ea1fc06494..1873878e2e46b 100644
--- a/clang/include/clang/Basic/CMakeLists.txt
+++ b/clang/include/clang/Basic/CMakeLists.txt
@@ -79,6 +79,12 @@ clang_tablegen(CXX11AttributeInfo.inc
-gen-cxx11-attribute-info
TARGET CXX11AttributeInfo
)
+ clang_tablegen(AttributeSpellingList.inc -gen-attribute-spelling-list
+ -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
+ SOURCE Attr.td
+ TARGET AttributeSpellingList
+ )
+
clang_tablegen(Builtins.inc -gen-clang-builtins
SOURCE Builtins.td
TARGET ClangBuiltins)
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index e4d94fefbbf3d..0bd8a423c393e 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -181,6 +181,8 @@ def err_opencl_unknown_type_specifier : Err
[clang] [Clang] add typo correction for unknown attribute names (PR #140629)
https://github.com/a-tarasyuk created
https://github.com/llvm/llvm-project/pull/140629
This patch enhances Clang's diagnosis for unknown attributes by providing typo
correction suggestions for known attributes.
```cpp
[[gmu::deprected]] // expected-warning {{unknown attribute 'gmu::deprected'
ignored; did you mean 'gnu::deprecated'?}}
int f1(void) {
return 0;
}
[[deprected]] // expected-warning {{unknown attribute 'deprected' ignored; did
you mean 'deprecated'?}}
int f2(void) {
return 0;
}
```
>From 5b8f0635fdddc87ea326a3b1b47191ab9bf23c0f Mon Sep 17 00:00:00 2001
From: Oleksandr Tarasiuk
Date: Tue, 20 May 2025 00:38:43 +0300
Subject: [PATCH] [Clang] add typo correction for unknown attribute names
---
clang/docs/ReleaseNotes.rst | 2 +
.../include/clang/Basic/AttributeCommonInfo.h | 5 +
clang/include/clang/Basic/Attributes.h| 4 +
clang/include/clang/Basic/CMakeLists.txt | 6 +
.../clang/Basic/DiagnosticCommonKinds.td | 2 +
.../clang/Basic/SimpleTypoCorrection.h| 35
clang/include/clang/Sema/Sema.h | 2 +
clang/lib/AST/CommentSema.cpp | 97 +++
clang/lib/Basic/Attributes.cpp| 153 --
clang/lib/Basic/CMakeLists.txt| 1 +
clang/lib/Basic/SimpleTypoCorrection.cpp | 52 ++
clang/lib/Sema/SemaDeclAttr.cpp | 18 ++-
clang/lib/Sema/SemaType.cpp | 4 +-
clang/test/Parser/cxx0x-attributes.cpp| 2 +-
clang/test/Sema/attr-c2x.c| 4 +-
clang/test/Sema/unknown-attributes.c | 16 +-
clang/test/SemaCXX/cxx11-gnu-attrs.cpp| 2 +-
clang/utils/TableGen/ClangAttrEmitter.cpp | 27
clang/utils/TableGen/TableGen.cpp | 6 +
clang/utils/TableGen/TableGenBackends.h | 2 +
20 files changed, 307 insertions(+), 133 deletions(-)
create mode 100644 clang/include/clang/Basic/SimpleTypoCorrection.h
create mode 100644 clang/lib/Basic/SimpleTypoCorrection.cpp
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ac9baf229b489..deee00128c1fa 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -561,6 +561,8 @@ Improvements to Clang's diagnostics
- Fixed a crash when checking a ``__thread``-specified variable declaration
with a dependent type in C++. (#GH140509)
+- Clang now suggests corrections for unknown attribute names.
+
Improvements to Clang's time-trace
--
diff --git a/clang/include/clang/Basic/AttributeCommonInfo.h
b/clang/include/clang/Basic/AttributeCommonInfo.h
index 6db7b53317e7d..b4b8345b4ed40 100644
--- a/clang/include/clang/Basic/AttributeCommonInfo.h
+++ b/clang/include/clang/Basic/AttributeCommonInfo.h
@@ -21,6 +21,8 @@ namespace clang {
class ASTRecordWriter;
class IdentifierInfo;
+class LangOptions;
+class TargetInfo;
class AttributeCommonInfo {
public:
@@ -196,6 +198,9 @@ class AttributeCommonInfo {
/// with surrounding underscores removed as appropriate (e.g.
/// __gnu__::__attr__ will be normalized to gnu::attr).
std::string getNormalizedFullName() const;
+ std::optional
+ getCorrectedFullName(const TargetInfo &Target,
+ const LangOptions &LangOpts) const;
SourceRange getNormalizedRange() const;
bool isDeclspecAttribute() const { return SyntaxUsed == AS_Declspec; }
diff --git a/clang/include/clang/Basic/Attributes.h
b/clang/include/clang/Basic/Attributes.h
index 99bb668fe32d0..9cf6fb3d89019 100644
--- a/clang/include/clang/Basic/Attributes.h
+++ b/clang/include/clang/Basic/Attributes.h
@@ -19,6 +19,10 @@ class TargetInfo;
/// Return the version number associated with the attribute if we
/// recognize and implement the attribute specified by the given information.
+int hasAttribute(AttributeCommonInfo::Syntax Syntax, llvm::StringRef ScopeName,
+ llvm::StringRef AttrName, const TargetInfo &Target,
+ const LangOptions &LangOpts, bool CheckPlugins);
+
int hasAttribute(AttributeCommonInfo::Syntax Syntax,
const IdentifierInfo *Scope, const IdentifierInfo *Attr,
const TargetInfo &Target, const LangOptions &LangOpts);
diff --git a/clang/include/clang/Basic/CMakeLists.txt
b/clang/include/clang/Basic/CMakeLists.txt
index 265ea1fc06494..1873878e2e46b 100644
--- a/clang/include/clang/Basic/CMakeLists.txt
+++ b/clang/include/clang/Basic/CMakeLists.txt
@@ -79,6 +79,12 @@ clang_tablegen(CXX11AttributeInfo.inc
-gen-cxx11-attribute-info
TARGET CXX11AttributeInfo
)
+ clang_tablegen(AttributeSpellingList.inc -gen-attribute-spelling-list
+ -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
+ SOURCE Attr.td
+ TARGET AttributeSpellingList
+ )
+
clang_tablegen(Builtins.inc -gen-clang-builtins
SOURCE Builtins.td
TARGET ClangBuiltins)
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td
b/clang/include/clang/Basic/Diag
