aboutsummaryrefslogtreecommitdiff
path: root/clang
AgeCommit message (Collapse)AuthorFilesLines
2024-02-28[InstallAPI] add missing link to clangASTCyndy Ishida1-0/+1
Appeases bots.
2024-02-28[clang] Refactor target attribute mangling. (#81893)Alexandros Lamprineas4-95/+118
Before this patch all of the 'target', 'target_version' and 'target_clones' attributes were sharing a common mangling logic across different targets. However we would like to differenciate this logic, therefore I have moved the default path to ABIInfo and provided overrides for AArch64. This way we can resolve feature aliases without affecting the name mangling. The PR #80540 demonstrates a motivating case.
2024-02-28[InstallAPI] Hookup Input files & basic ASTVisitor (#82552)Cyndy Ishida12-8/+472
This patch takes in json files as input to determine that header files to process, and in which order, to pass along for CC1 invocations. This patch also includes an ASTVisitor to collect simple global variables.
2024-02-28[Headers][X86] Make brief descriptions briefer (#82422)Paul T Robinson6-188/+201
In Sony's document processing, the first "paragraph" of the description is duplicated into a Brief Description section. Add paragraph breaks to make those brief descriptions less verbose. In fmaintrin.h we were including the \code blocks, which are inappropriate for a brief description. While I was in there, change \code to \code{.operation} which the Intel document processing wants.
2024-02-28[clang][Interp] Note UB when converting Inf to integerTimm Bäder2-1/+10
The F.isFinite() check here was introduced back when the first floating point implementation was pushed, but I don't think it's necessary and it fixes the attached test case.
2024-02-28[clang][Interp] Ignore ArrayDecay ops for null pointersTimm Bäder2-1/+3
Just don't do anything and let later operations handle the diagnostics.
2024-02-28[clang][Interp] Remove now faulty assertionTimm Bäder2-1/+6
We can call getBase() for pointers where Base != Offset as well, for example when we've added a constant to the Offset.
2024-02-28Revert "[clang][analyzer] StreamChecker: Model getc, vfscanf, putc, vfprintf ↵Balazs Benics6-105/+5
(#82476)" This reverts commit ffe7049b543adb9739261d28a60d4a47a00aa2e0. This commit breaks on e.g. arm: Example: https://lab.llvm.org/buildbot/#/builders/245/builds/21177/steps/5/logs/FAIL__Clang__stream_c ``` ******************** TEST 'Clang :: Analysis/stream.c' FAILED ******************** Exit Code: 1 Command Output (stderr): -- RUN: at line 1: /home/tcwg-buildbot/worker/clang-armv8-quick/stage1/bin/clang -cc1 -internal-isystem /home/tcwg-buildbot/worker/clang-armv8-quick/stage1/lib/clang/19/include -nostdsysteminc -analyze -analyzer-constraints=range -setup-static-analyzer -analyzer-checker=core,alpha.unix.Stream,debug.ExprInspection -verify /home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/Analysis/stream.c + /home/tcwg-buildbot/worker/clang-armv8-quick/stage1/bin/clang -cc1 -internal-isystem /home/tcwg-buildbot/worker/clang-armv8-quick/stage1/lib/clang/19/include -nostdsysteminc -analyze -analyzer-constraints=range -setup-static-analyzer -analyzer-checker=core,alpha.unix.Stream,debug.ExprInspection -verify /home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/Analysis/stream.c error: 'expected-warning' diagnostics expected but not seen: File /home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/Analysis/stream.c Line 147: Stream pointer might be NULL File /home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/Analysis/stream.c Line 153: Stream pointer might be NULL error: 'expected-warning' diagnostics seen but not expected: File /home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/Analysis/stream.c Line 148: Stream pointer might be NULL [alpha.unix.Stream] File /home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/Analysis/stream.c Line 154: Stream pointer might be NULL [alpha.unix.Stream] 4 errors generated. -- ******************** ```
2024-02-28[clang] Fix -Wunused-variable in CGCall.cpp (NFC)Jie Fu1-4/+6
llvm-project/clang/lib/CodeGen/CGCall.cpp:3226:24: error: unused variable 'StructSize' [-Werror,-Wunused-variable] llvm::TypeSize StructSize = CGM.getDataLayout().getTypeAllocSize(STy); ^ llvm-project/clang/lib/CodeGen/CGCall.cpp:3227:24: error: unused variable 'PtrElementSize' [-Werror,-Wunused-variable] llvm::TypeSize PtrElementSize = ^ llvm-project/clang/lib/CodeGen/CGCall.cpp:5313:24: error: unused variable 'SrcTypeSize' [-Werror,-Wunused-variable] llvm::TypeSize SrcTypeSize = ^ llvm-project/clang/lib/CodeGen/CGCall.cpp:5315:24: error: unused variable 'DstTypeSize' [-Werror,-Wunused-variable] llvm::TypeSize DstTypeSize = CGM.getDataLayout().getTypeAllocSize(STy); ^ 4 errors generated.
2024-02-28[LLVM][TypeSize] Remove default constructor. (#82810)Paul Walker1-9/+6
2024-02-28[clang] remove (clang::)ast_matchers:: namespace from AST matcher args for ↵Julian Schmidt3-16/+16
docs (#81437) When parsing the ASTMatchers.h file, a matcher could specify an argument that is a matcher using the not needed namespace `(clang::)ast_matchers::`. Change the argument parsing in dump_ast_matchers.py to remove those namespaces such that when parameters with these namespaces slip through, the namespaces will be not be shown in the matchers reference, like it is done with the `internal` namespace. Additionally, remove the not needed namespaces from arguments in ASTMatchers.h.
2024-02-28[clang][analyzer] StreamChecker: Model getc, vfscanf, putc, vfprintf (#82476)Alejandro Álvarez Ayllón6-5/+105
Model `getc` and `putc` as equivalent to `fgetc` and `fputc` respectively. Model `vfscanf` and `vfprintf` as `fscanf` and `fprintf`, except that `vfscanf` can not invalidate the parameters due to the indirection via a `va_list`. Nevertheless, we can still track EOF and errors as for `fscanf`.
2024-02-28[-Wunsafe-buffer-usage][NFC] clang-format UnsafeBufferUsage.cpp (#82027)jkorous-apple1-130/+129
2024-02-28[clang][Interp][NFC] Convert test to verify=expected,both styleTimm Bäder1-104/+52
2024-02-28[clang][Interp] Toplevel destructors may failTimm Bäder5-22/+59
We used to run them, but not check if they failed. If they do, the expression is invalid, even if we already have a result. I do have a suspicion that we need to manually call destroyLocals() in more places (everywhere basically?), but I'll wait with that until I have a reproducer at hand.
2024-02-27[alpha.webkit.UncountedCallArgsChecker] Allow a variable declaration in a ↵Ryosuke Niwa2-2/+23
trivial function. (#82291)
2024-02-27[Driver] Allow -fbasic-block-address-map for AArch64 ELF (#82662)Daniel Hoekwater2-4/+5
Emitting the basic block address map with `-fbasic-block-sections=labels` is allowed for AArch64 ELF since 7eaf94fefa1250fc8a46982cea8ce99abacae11f. Allow doing so with `-fbasic-block-address-map`.
2024-02-27Revert "[CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version ↵Alexander Yermolovich2-9/+3
5." (#83214) Reverts llvm/llvm-project#82840
2024-02-27Revert "[HIP] fix host min/max in header (#82956)"Yaxun (Sam) Liu1-66/+6
This reverts commit 55783bd0f9cfc30aa93c718919dab5419d86a2c6. Due to regressions in hipCUB. hipCUB/hipcub/include/hipcub/backend/rocprim/device/device_spmv.hpp:142:33: error: call to 'min' is ambiguous https://github.com/ROCm/hipCUB/blob/develop/hipcub/include/hipcub/backend/rocprim/device/device_spmv.hpp#L142 The ambuguity seems due to missing min(int, unsigned int). Previously, there is only min(int, int). After the change, there are min(int, int) and min(unsigned int, unsigned int), therefore there is ambiguity.
2024-02-27[clang] Extend define-target-os-macros to support XROS. (#82833)rohit-rao2-2/+49
Updates the extension feature `define-target-os-macros` to support the recently-added XROS target (TARGET_OS_VISION).
2024-02-27[TBAA] Handle bitfields when generating !tbaa.struct metadata. (#82922)Florian Hahn4-18/+43
At the moment, clang generates what I believe are incorrect !tbaa.struct fields for named bitfields. At the moment, the base type size is used for named bifields (e.g. sizeof(int)) instead of the bifield width per field. This results in overalpping fields in !tbaa.struct metadata. This causes incorrect results when extracting individual copied fields from !tbaa.struct as in added in dc85719d5. This patch fixes that by skipping by combining adjacent bitfields in fields with correct sizes. Fixes https://github.com/llvm/llvm-project/issues/82586
2024-02-27[Clang] [Sema] Handle placeholders in '.*' expressions (#83103)Sirraide3-5/+40
When analysing whether we should handle a binary expression as an overloaded operator call or a builtin operator, we were calling `checkPlaceholderForOverload()`, which takes care of any placeholders that are not overload sets—which would usually make sense since those need to be handled as part of overload resolution. Unfortunately, we were also doing that for `.*`, which is not overloadable, and then proceeding to create a builtin operator anyway, which would crash if the RHS happened to be an unresolved overload set (due hitting an assertion in `CreateBuiltinBinOp()`—specifically, in one of its callees—in the `.*` case that makes sure its arguments aren’t placeholders). This pr instead makes it so we check for *all* placeholders early if the operator is `.*`. It’s worth noting that, 1. In the `.*` case, we now additionally also check for *any* placeholders (not just non-overload-sets) in the LHS; this shouldn’t make a difference, however—at least I couldn’t think of a way to trigger the assertion with an overload set as the LHS of `.*`; it is worth noting that the assertion in question would also complain if the LHS happened to be of placeholder type, though. 2. There is another case in which we also don’t perform overload resolution—namely `=` if the LHS is not of class or enumeration type after handling non-overload-set placeholders—as in the `.*` case, but similarly to 1., I first couldn’t think of a way of getting this case to crash, and secondly, `CreateBuiltinBinOp()` doesn’t seem to care about placeholders in the LHS or RHS in the `=` case (from what I can tell, it, or rather one of its callees, only checks that the LHS is not a pseudo-object type, but those will have already been handled by the call to `checkPlaceholderForOverload()` by the time we get to this function), so I don’t think this case suffers from the same problem. This fixes #53815. --------- Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
2024-02-27[clang] Update -Wformat warnings for fixed-point format specifiers (#82855)PiJoules6-3/+306
ISO/IEC TR 18037 defines %r, %R, %k, and %K for fixed point format specifiers. -Wformat should not warn on these when they are provided.
2024-02-27[llvm-ar][Archive] Use getDefaultTargetTriple instead of host triple for the ↵Jacek Caban1-1/+1
fallback archive format. (#82888)
2024-02-27[clang][Interp] Ignore unnamed bitfields when checking initTimm Bäder2-0/+25
Unnamed bitfields need to be ignored here.
2024-02-27[clang][Interp] Handle PseudoObjectExprsTimm Bäder3-0/+258
Evaluate all the semantic expressions.
2024-02-27[clang][Interp] Fix local lvalue compound literalsTimm Bäder4-6/+52
Same fix we had for global ones: leave a pointer on the stack.
2024-02-27[HIP] fix host min/max in header (#82956)Yaxun (Sam) Liu1-6/+66
CUDA defines min/max functions for host in global namespace. HIP header needs to define them too to be compatible. Currently only min/max(int, int) is defined. This causes wrong result for arguments that are out of range for int. This patch defines host min/max functions to be compatible with CUDA. Also allows users to define `__HIP_NO_HOST_MIN_MAX_IN_GLOBAL_NAMESPACE__` to disable host max/min in global namespace. min/max functions with mixed signed/unsigned integer parameters are not defined unless `__HIP_DEFINE_MIXED_HOST_MIN_MAX__` is defined. Fixes: SWDEV-446564
2024-02-27[clang][Interp][NFC] Rename InitPtr{,Pop} to FinishInit{,Pop}Timm Bäder5-13/+13
The old name clashes with the Init opcode.
2024-02-27[CLANG][DWARF] Do not emit -ggnu-pubnames for split dwarf version 5. (#82840)Alexander Yermolovich2-3/+9
When -gsplit-dwarf is passed in clang emmmits -ggnu-pubnames which results in .debug_gnu_pubnames/..debug_gnu_pubtypes being generated. This is used by GDB, but not by LLDB. Changed so that these sections are not emitted for LLDB tuning.
2024-02-27[Clang][Sema] Fix missing warning when comparing mismatched enums in … ↵Kupa-Martin9-13/+84
(#81418) …C mode Factored logic from `CheckImplicitConversion` into new methods `Expr::getEnumConstantDecl` and `Expr::getEnumCoercedType` for use in `checkEnumArithmeticConversions`. Fix #29217
2024-02-27[NFC][HLSL] Fix broken test (#83062)Natalie Chouinard1-3/+3
Noticed while implementing #82536 that this test was also missing the call the FileCheck.
2024-02-27[clang-format] Add AlignConsecutiveTableGenDefinitions option. (#83008)Hirofumi Nakamura6-1/+180
To align TableGen consecutive definitions.
2024-02-27[clang][Interp][NFC] Remove leftover commentsTimm Bäder1-3/+0
2024-02-27[clang][dataflow] Remove deprecated `ValueModel::merge()` function. (#82602)martinboehme2-35/+4
I'm not aware of any remaining overrides of this function. While I'm here, change an outdated comment in DataflowAnalysis.h that still referred to `merge()`. I've made the comment more general, referring simply to `ValueModel`, as we shouldn't really be repeating the documentation of that class here anyway.
2024-02-26MIPS: Fix asm constraints "f" and "r" for softfloat (#79116)YunQiang Su3-1/+23
This include 2 fixes: 1. Disallow 'f' for softfloat. 2. Allow 'r' for softfloat. Currently, 'f' is accpeted by clang, then LLVM meets an internal error. 'r' is rejected by LLVM by: couldn't allocate input reg for constraint 'r'. Fixes: #64241, #63632 --------- Co-authored-by: Fangrui Song <i@maskray.me>
2024-02-26[clang-format][NFC] Skip ObjCHeaderStyleGuesser for empty code (#82957)Owen Pan1-1/+1
2024-02-27[APINotes] Fix a few accidental refactoring artifactsEgor Zhdan2-4/+5
This fixes a few breakages introduced during upstreaming.
2024-02-26[TBAA] Add !tbaa.struct test with unnamed bitfields.Florian Hahn1-0/+20
Extra tests with unnamed bitfields for https://github.com/llvm/llvm-project/pull/82922.
2024-02-26[clang] Fixes inf loop parsing fixed point literal (#83071)PiJoules2-3/+24
Clang was incorrectly finding the start of the exponent in a fixed point hex literal. It would unconditionally find the first `e/E/p/P` in a constant regardless of if it were hex or not and parser the remaining digits as an APInt. In a debug build, this would be caught by an assertion, but in a release build, the assertion is removed and we'd end up in an infinite loop. Fixes #83050
2024-02-26[InstrProf] Single byte counters in coverage (#75425)gulfemsavrun11-81/+594
This patch inserts 1-byte counters instead of an 8-byte counters into llvm profiles for source-based code coverage. The origial idea was proposed as block-cov for PGO, and this patch repurposes that idea for coverage: https://groups.google.com/g/llvm-dev/c/r03Z6JoN7d4 The current 8-byte counters mechanism add counters to minimal regions, and infer the counters in the remaining regions via adding or subtracting counters. For example, it infers the counter in the if.else region by subtracting the counters between if.entry and if.then regions in an if statement. Whenever there is a control-flow merge, it adds the counters from all the incoming regions. However, we are not going to be able to infer counters by subtracting two execution counts when using single-byte counters. Therefore, this patch conservatively inserts additional counters for the cases where we need to add or subtract counters. RFC: https://discourse.llvm.org/t/rfc-single-byte-counters-for-source-based-code-coverage/75685
2024-02-26[HLSL] Fix casting asserts (#82827)Farzon Lotfi3-8/+52
There are two issues here. first `ICK_Floating_Integral` were always defaulting to `CK_FloatingToIntegral` for vectors regardless of direction of cast. Check was scalar only so added a vec float check to the conditional. Second issue was float to int casts were resolving to ICK_Integral_Promotion when they need to be resolving to CK_FloatingToIntegral. This was fixed by changing the ordering of conversion checks. This fixes #82826
2024-02-26[clang] Implement __builtin_popcountg (#82359)OverMighty7-2/+120
Fixes #82058.
2024-02-26[Clang][Sema] Fix crash when MS dependent base class lookup occurs in an ↵Krystian Stasiowski3-1/+10
incomplete context (#83024) When compiling the following with `-fms-compatibility`: ``` template<typename T> struct C; // Test lookup with incomplete lookup context template<typename T> auto C<T>::f() -> decltype(x) { } ``` An assert fails because `CXXRecordDecl::hasAnyDependentBases` is called on an incomplete class. This patch ensures we don't perform unqualified lookup into dependent base classes when the lookup context is incomplete.
2024-02-26[flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. (#82832)Slava Zakharin1-6/+9
Follow-up for #81971 to fix the disabled LIT test and add LIT tests for lowering of the added math intrinsics.
2024-02-26[Driver] Improve error when a compiler-rt library is not found (#81037)Fangrui Song32-104/+114
BSD, Linux, and z/OS enable `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR` by default. When a compiler-rt library is not found, we currently report an incorrect filename `libclang_rt.XXX-$arch.a` ``` % /tmp/Debug/bin/clang++ a.cc -fsanitize=address -o a ld.lld: error: cannot open /tmp/Debug/lib/clang/19/lib/linux/libclang_rt.asan-x86_64.a: No such file or directory clang++: error: linker command failed with exit code 1 (use -v to see invocation) ``` With this change, we will correctly report: ``` % /tmp/Debug/bin/clang++ a.cc -fsanitize=address -o a ld.lld: error: cannot open /tmp/Debug/lib/clang/19/lib/x86_64-unknown-linux-gnu/libclang_rt.asan.a: No such file or directory clang++: error: linker command failed with exit code 1 (use -v to see invocation) ``` Link: https://discourse.llvm.org/t/runtime-directory-fallback/76860
2024-02-26Thread safety analysis: provide printSCFG definition. (#80277)Haojian Wu2-2/+4
I called this function when investigating the issue (https://github.com/llvm/llvm-project/issues/78131), and I was surprised to see the definition is commented out. I think it makes sense to provide the definition even though the implementation is not stable.
2024-02-26[clang][Interp] Pick the right APInt constructor on WindowsTimm Bäder1-3/+4
The second parameter needs to be a uint64_t and nothing else. This broke windows builders, see https://github.com/llvm/llvm-project/commit/264d828ea6399c31c210b67a050fbf084634da6a
2024-02-26[HLSL] Implementation of dot intrinsic (#81190)Farzon Lotfi10-8/+698
This change implements https://github.com/llvm/llvm-project/issues/70073 HLSL has a dot intrinsic defined here: https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-dot The intrinsic itself is defined as a HLSL_LANG LangBuiltin in Builtins.td. This is used to associate all the dot product typdef defined hlsl_intrinsics.h with a single intrinsic check in CGBuiltin.cpp & SemaChecking.cpp. In IntrinsicsDirectX.td we define the llvmIR for the dot product. A few goals were in mind for this IR. First it should operate on only vectors. Second the return type should be the vector element type. Third the second parameter vector should be of the same size as the first parameter. Finally `a dot b` should be the same as `b dot a`. In CGBuiltin.cpp hlsl has built on top of existing clang intrinsics via EmitBuiltinExpr. Dot product though is language specific intrinsic and so is guarded behind getLangOpts().HLSL. The call chain looks like this: EmitBuiltinExpr -> EmitHLSLBuiltinExp EmitHLSLBuiltinExp dot product intrinsics makes a destinction between vectors and scalars. This is because HLSL supports dot product on scalars which simplifies down to multiply. Sema.h & SemaChecking.cpp saw the addition of CheckHLSLBuiltinFunctionCall, a language specific semantic validation that can be expanded for other hlsl specific intrinsics. Fixes #70073
2024-02-26clang serialization unittests: fix some leaks (#82773)Krasimir Georgiev2-4/+16
No functional changes intended. Fixes some leaks found by running under asan with `--gtest_repeat=2`.