aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/Sema.cpp
AgeCommit message (Collapse)AuthorFilesLines
2021-02-03PR44325 (and duplicates): don't issue -Wzero-as-null-pointer-constantRichard Smith1-0/+7
when rewriting 'a < b' as '(a <=> b) < 0'. It's pretty common for comparison category types to use a pointer or pointer-to-member type as their '0' parameter.
2021-01-25[OpenCL] Refactor of targets OpenCL option settingsAnton Zabaznov1-1/+1
Currently, there is some refactoring needed in existing interface of OpenCL option settings to support OpenCL C 3.0. The problem is that OpenCL extensions and features are not only determined by the target platform but also by the OpenCL version. Also, there are core extensions/features which are supported unconditionally in specific OpenCL C version. In fact, these rules are not being followed for all targets. For example, there are some targets (as nvptx and r600) which don't support OpenCL C 2.0 core features (nvptx.languageOptsOpenCL.cl, r600.languageOptsOpenCL.cl). After the change there will be explicit differentiation between optional core and core OpenCL features which allows giving diagnostics if target doesn't support any of necessary core features for specific OpenCL version. This patch also eliminates `OpenCLOptions` instance duplication from `TargetOptions`. `OpenCLOptions` instance should take place in `Sema` as it's going to be modified during parsing. Removing this duplication will also allow to generally simplify `OpenCLOptions` class for parsing purposes. Reviewed By: Anastasia Differential Revision: https://reviews.llvm.org/D92277
2021-01-20[EXTINT][OMP] Fix _ExtInt type checking in device codeErich Keane1-1/+11
_ExtInt gets stuck in the device-type-checking for __int128 if it is between 65 and 128 bits inclusive. Anything larger or smaller was permitted despite this, so this is simply enabling 65-128 bit _ExtInts. _ExtInt is supported on all our current ABIs, but we stil use the hasExtIntType in the target info to differentiate here so that it can be disabled.
2021-01-13[Frontend] Add pragma align natural and sort out pragma pack stack effectXiangling Liao1-1/+2
- Implemente the natural align for XL on AIX - Sort out pragma pack stack effect - Add -fxl-pragma-stack option to enable XL on AIX pragma stack effect Differential Revision: https://reviews.llvm.org/D87702
2021-01-08[NFC] Renaming PackStack to AlignPackStackXiangling Liao1-6/+7
This patch renames PackStack and related variable names to also contain align across Clang. As it is right now, Clang already uses one stack to record the information from both #pragma align and #pragma pack. Leaving it as PackStack is confusing, and could cause people to ignore #pragma align when developing code that interacts with PackStack. Differential Revision: https://reviews.llvm.org/D93901
2021-01-04Revert "[NFC, Refactor] Modernize StorageClass from Specifiers.h to a scoped ↵Thorsten Schütt1-2/+2
enum (II)" This reverts commit efc82c4ad2bcb256a4f4c20238d08cd3afba4d2d.
2021-01-04[NFC, Refactor] Modernize StorageClass from Specifiers.h to a scoped enum (II)Thorsten Schütt1-2/+2
Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D93765
2020-12-15[PowerPC] Enable paired vector type and intrinsics when MMA is disabledBaptiste Saleil1-2/+7
This patch enables the Clang type __vector_pair and its associated LLVM intrinsics even when MMA is disabled. With this patch, the type is now controlled by the PPC paired-vector-memops option. The builtins and intrinsics will be renamed to drop the mma prefix in another patch. Differential Revision: https://reviews.llvm.org/D91819
2020-12-10Ensure that we don't leave behind "InstantiatingSpecialization" entriesRichard Smith1-0/+3
after destroying an InstantiatingTemplate object. This previously caused us to (silently!) bail out of class template instantiation, thinking we'd produced an error, in some corner cases.
2020-12-07[clang] Add a new nullability annotation for swift async: _Nullable_resultErik Pilkington1-1/+2
_Nullable_result generally like _Nullable, except when being imported into a swift async method. rdar://70106409 Differential revision: https://reviews.llvm.org/D92495
2020-12-07Fix missing error for use of 128-bit integer inside SPIR64 device code.Jennifer Yu1-1/+3
Emit error for use of 128-bit integer inside device code had been already implemented in https://reviews.llvm.org/D74387. However, the error is not emitted for SPIR64, because for SPIR64, hasInt128Type return true. hasInt128Type: is also used to control generation of certain 128-bit predefined macros, initializer predefined 128-bit integer types and build 128-bit ArithmeticTypes. Except predefined macros, only the device target is considered, since error only emit when 128-bit integer is used inside device code, the host target (auxtarget) also needs to be considered. The change address: 1. (SPIR.h) Correct hasInt128Type() for SPIR targets. 2. Sema.cpp and SemaOverload.cpp: Add additional check to consider host target(auxtarget) when call to hasInt128Type. So that __int128_t and __int128() are allowed to avoid error when they used outside device code. 3. SemaType.cpp: add check for SYCLIsDevice to delay the error message. The error will be emitted if the use of 128-bit integer in the device code. Reviewed By: Johannes Doerfert and Aaron Ballman Differential Revision: https://reviews.llvm.org/D92439
2020-11-17[clang][NFC] Use SmallString instead of SmallVector<charNathan James1-1/+1
Simplifies code in some places and is more explicit about what is being used. No additional includes were added here so no impact on compile time.
2020-10-28[Clang][PowerPC] Add __vector_pair and __vector_quad typesBaptiste Saleil1-0/+7
Define the __vector_pair and __vector_quad types that are used to manipulate the new accumulator registers introduced by MMA on PowerPC. Because these two types are specific to PowerPC, they are defined in a separate new file so it will be easier to add other PowerPC specific types if we need to in the future. Differential Revision: https://reviews.llvm.org/D81508
2020-10-19Recommit "[CUDA][HIP] Defer overloading resolution diagnostics for host ↵Yaxun (Sam) Liu1-13/+52
device functions" This recommits 7f1f89ec8d9944559042bb6d3b1132eabe3409de and 40df06cdafc010002fc9cfe1dda73d689b7d27a6 with bug fixes for memory sanitizer failure and Tensile build failure.
2020-09-24Revert "Recommit "[CUDA][HIP] Defer overloading resolution diagnostics for ↵Reid Kleckner1-52/+13
host device functions"" This reverts commit e39da8ab6a286ac777d5fe7799f1eb782cf99938. This depends on a change that needs additional design review and needs to be reverted.
2020-09-24Recommit "[CUDA][HIP] Defer overloading resolution diagnostics for host ↵Yaxun (Sam) Liu1-13/+52
device functions" This recommits 7f1f89ec8d9944559042bb6d3b1132eabe3409de and 40df06cdafc010002fc9cfe1dda73d689b7d27a6 after fixing memory sanitizer failure.
2020-09-17Revert "[CUDA][HIP] Defer overloading resolution diagnostics for host device ↵Yaxun (Sam) Liu1-52/+13
functions" This reverts commit 7f1f89ec8d9944559042bb6d3b1132eabe3409de. This reverts commit 40df06cdafc010002fc9cfe1dda73d689b7d27a6.
2020-09-17[CUDA][HIP] Defer overloading resolution diagnostics for host device functionsYaxun (Sam) Liu1-13/+52
In CUDA/HIP a function may become implicit host device function by pragma or constexpr. A host device function is checked in both host and device compilation. However it may be emitted only on host or device side, therefore the diagnostics should be deferred until it is known to be emitted. Currently clang is only able to defer certain diagnostics. This causes false alarms and limits the usefulness of host device functions. This patch lets clang defer all overloading resolution diagnostics for host device functions. An option -fgpu-defer-diag is added to control this behavior. By default it is off. It is NFC for other languages. Differential Revision: https://reviews.llvm.org/D84364
2020-09-14[AST][FPEnv] Keep FP options in trailing storage of CastExprSerge Pavlov1-1/+2
This is recommit of 6c8041aa0f, reverted in de044f7562 because of some fails. Original commit message is below. This change allow a CastExpr to have optional FPOptionsOverride object, stored in trailing storage. Of all cast nodes only ImplicitCastExpr, CStyleCastExpr, CXXFunctionalCastExpr and CXXStaticCastExpr are allowed to have FPOptions. Differential Revision: https://reviews.llvm.org/D85960
2020-09-12Revert "[AST][FPEnv] Keep FP options in trailing storage of CastExpr"Serge Pavlov1-2/+1
This reverts commit 6c8041aa0ffed827636935e59c489b1e390c8542. It caused some fails on buildbots.
2020-09-12[AST][FPEnv] Keep FP options in trailing storage of CastExprSerge Pavlov1-1/+2
This change allow a CastExpr to have optional FPOptionsOverride object, stored in trailing storage. Of all cast nodes only ImplicitCastExpr, CStyleCastExpr, CXXFunctionalCastExpr and CXXStaticCastExpr are allowed to have FPOptions. Differential Revision: https://reviews.llvm.org/D85960
2020-08-19[OPENMP]Fix PR47158, case 2: do not report host-only functions in unused ↵Alexey Bataev1-1/+2
function in device mode. If the function is not marked exlicitly as declare target and it calls function(s), marked as declare target device_type(host), these host-only functions should not be dignosed as used in device mode, if the caller function is not used in device mode too. Differential Revision: https://reviews.llvm.org/D86164
2020-08-16Replace setter named 'getAsOpaqueInt' with a real getter.Richard Smith1-2/+3
Clean up a bunch of places where the opaque forms of FPOptions and FPOptionsOverride were being used inappropriately.
2020-07-28[clang] Pass the NamedDecl* instead of the DeclarationName into many ↵Bruno Ricci1-12/+11
diagnostics. Background: ----------- There are two related argument types which can be sent into a diagnostic to display the name of an entity: DeclarationName (ak_declarationname) or NamedDecl* (ak_nameddecl) (there is also ak_identifierinfo for IdentifierInfo*, but we are not concerned with it here). A DeclarationName in a diagnostic will just be streamed to the output, which will directly result in a call to DeclarationName::print. A NamedDecl* in a diagnostic will also ultimately result in a call to DeclarationName::print, but with two customisation points along the way: The first customisation point is NamedDecl::getNameForDiagnostic which is overloaded by FunctionDecl, ClassTemplateSpecializationDecl and VarTemplateSpecializationDecl to print the template arguments, if any. The second customisation point is NamedDecl::printName. By default it just streams the stored DeclarationName into the output but it can be customised to provide a user-friendly name for an entity. It is currently overloaded by DecompositionDecl and MSGuidDecl. What this patch does: --------------------- For many diagnostics a DeclarationName is used instead of the NamedDecl*. This bypasses the two customisation points mentioned above. This patches fix this for diagnostics in Sema.cpp, SemaCast.cpp, SemaChecking.cpp, SemaDecl.cpp, SemaDeclAttr.cpp, SemaDecl.cpp, SemaOverload.cpp and SemaStmt.cpp. I have only modified diagnostics where I could construct a test-case which demonstrates that the change is appropriate (either with this patch or the next one). Reviewed By: erichkeane, aaron.ballman Differential Revision: https://reviews.llvm.org/D84656
2020-07-22[AST][RecoveryExpr] Error-dependent expression should not be treat as a ↵Haojian Wu1-2/+4
nullptr pointer constant. If an expression is contains-error and its type is unknown (dependent), we don't treat it as a null pointer constant. Fix a recovery-ast crash on C. Differential Revision: https://reviews.llvm.org/D84222
2020-07-20Upgrade SmallSets of pointer-like types to SmallPtrSetBenjamin Kramer1-3/+3
This is slightly more efficient. NFC.
2020-06-27Reland D81869 "Modify FPFeatures to use delta not absolute settings"Melanie Blower1-3/+2
This reverts commit defd43a5b393bb63a902042adf578081b03b171d. with correction to solve msan report To solve https://bugs.llvm.org/show_bug.cgi?id=46166 where the floating point settings in PCH files aren't compatible, rewrite FPFeatures to use a delta in the settings rather than absolute settings. With this patch, these floating point options can be benign. Reviewers: rjmccall Differential Revision: https://reviews.llvm.org/D81869
2020-06-26Revert "Revert "Revert "Modify FPFeatures to use delta not absolute settings"""Melanie Blower1-2/+3
This reverts commit 9518763d710bfbbf9315fa88972c55898be44a0e. Memory sanitizer fails in CGFPOptionsRAII::CGFPOptionsRAII dtor
2020-06-26Revert "Revert "Modify FPFeatures to use delta not absolute settings""Melanie Blower1-3/+2
This reverts commit b55d723ed61052b77e720dcffecac43abe873186. Reapply Modify FPFeatures to use delta not absolute settings To solve https://bugs.llvm.org/show_bug.cgi?id=46166 where the floating point settings in PCH files aren't compatible, rewrite FPFeatures to use a delta in the settings rather than absolute settings. With this patch, these floating point options can be benign. Reviewers: rjmccall Differential Revision: https://reviews.llvm.org/D81869
2020-06-26Revert "Modify FPFeatures to use delta not absolute settings"Melanie Blower1-2/+3
This reverts commit 3a748cbf86cea3844fada04eeff4cc64b01f67e0. I'm reverting this commit because I forgot to format the commit message propertly. Sorry for the thrash.
2020-06-26Modify FPFeatures to use delta not absolute settingsMelanie Blower1-3/+2
2020-06-21add option to instantiate templates already in the PCHLuboš Luňák1-0/+5
Add -fpch-instantiate-templates which makes template instantiations be performed already in the PCH instead of it being done in every single file that uses the PCH (but every single file will still do it as well in order to handle its own instantiations). I can see 20-30% build time saved with the few tests I've tried. The change may reorder compiler output and also generated code, but should be generally safe and produce functionally identical code. There are some rare cases that do not compile with it, such as test/PCH/pch-instantiate-templates-forward-decl.cpp. If template instantiation bailed out instead of reporting the error, these instantiations could even be postponed, which would make them work. Enable this by default for clang-cl. MSVC creates PCHs by compiling them using an empty .cpp file, which means templates are instantiated while building the PCH and so the .h needs to be self-contained, making test/PCH/pch-instantiate-templates-forward-decl.cpp to fail with MSVC anyway. So the option being enabled for clang-cl matches this. Differential Revision: https://reviews.llvm.org/D69585
2020-06-08Remove improper uses of DiagnosticErrorTrap and hasErrorOccurred.Richard Smith1-1/+1
DiagnosticErrorTrap is usually inappropriate because it indicates whether an error message was rendered in a given region (and is therefore affected by -ferror-limit and by suppression of errors if we see an invalid declaration). hasErrorOccurred() is usually inappropriate because it indicates whethere an "error:" message was displayed, regardless of whether the message was a warning promoted to an error, and therefore depends on things like -Werror that are usually irrelevant. Where applicable, CodeSynthesisContexts are used to attach notes to the first diagnostic produced in a region of code, isnstead of using an error trap and then attaching a note to whichever diagnostic happened to be produced last (or suppressing the note if the final diagnostic is a disabled warning!). This is mostly NFC.
2020-05-30[OpenMP][SYCL] Do not crash on attempt to diagnose unsupported type useMariya Podchishchaeva1-0/+3
Summary: Do not ask size of type if it is dependent. ASTContext doesn't seem expecting this. Reviewers: jdoerfert, ABataev, bader Reviewed By: ABataev Subscribers: yaxunl, guansong, ebevhan, Anastasia, sstefan1, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D80829
2020-05-29[OpenMP][SYCL] Improve diagnosing of unsupported types usageMariya Podchishchaeva1-0/+46
Summary: Diagnostic is emitted if some declaration of unsupported type declaration is used inside device code. Memcpy operations for structs containing member with unsupported type are allowed. Fixed crash on attempt to emit diagnostic outside of the functions. The approach is generalized between SYCL and OpenMP. CUDA/OMP deferred diagnostic interface is going to be used for SYCL device. Reviewers: rsmith, rjmccall, ABataev, erichkeane, bader, jdoerfert, aaron.ballman Reviewed By: jdoerfert Subscribers: guansong, sstefan1, yaxunl, mgorny, bader, ebevhan, Anastasia, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D74387
2020-05-21Fix DeferredDiagnosticsEmitter for bug#45987Yaxun (Sam) Liu1-1/+1
InOMPDeviceContext may be greater than 1. It needs to be clamp to 0 and 1 to be used as index for DoneMap.
2020-05-04Reapply "Add support for #pragma float_control" with buildbot fixesMelanie Blower1-1/+2
Add support for #pragma float_control Reviewers: rjmccall, erichkeane, sepavloff Differential Revision: https://reviews.llvm.org/D72841 This reverts commit fce82c0ed310174fe48e2402ac731b6340098389.
2020-05-01Revert "Reapply "Add support for #pragma float_control" with improvements to"Melanie Blower1-2/+1
This reverts commit 69aacaf699922ffe0450f567e21208c10c84731f.
2020-05-01Reapply "Add support for #pragma float_control" with improvements toMelanie Blower1-1/+2
test cases Add support for #pragma float_control Reviewers: rjmccall, erichkeane, sepavloff Differential Revision: https://reviews.llvm.org/D72841 This reverts commit 85dc033caccaa6ab919d57f9759290be41240146, and makes corrections to the test cases that failed on buildbots.
2020-05-01Revert "Add support for #pragma float_control"Melanie Blower1-2/+1
This reverts commit 4f1e9a17e9d28bdfd035313c96b3a5d4c91a7733. due to fail on buildbot, sorry for the noise
2020-05-01Add support for #pragma float_controlMelanie Blower1-1/+2
Reviewers: rjmccall, erichkeane, sepavloff Differential Revision: https://reviews.llvm.org/D72841
2020-04-16[NFC] Rename Sema.FPFeatures to CurFPFeatures and accessor to getCurFPFeaturesMelanie Blower1-1/+1
2020-04-11Simplify string joins. NFCI.Benjamin Kramer1-9/+1
2020-04-06[NFC] Minor fix for deferred diagnostics emitterYaxun (Sam) Liu1-2/+1
Differential Revision: https://reviews.llvm.org/D77028
2020-04-06Speed up deferred diagnostic emitterYaxun (Sam) Liu1-51/+100
Move function emitDeferredDiags from Sema to DeferredDiagsEmitter since it is only used by DeferredDiagsEmitter. Also skip visited functions to avoid exponential compile time. Differential Revision: https://reviews.llvm.org/D77028
2020-04-01Fix infinite recursion in deferred diag emitterYaxun (Sam) Liu1-36/+53
Currently deferred diagnostic emitter checks variable decl in DeclRefExpr, which causes infinite recursion for cases like long a = (long)&a;. Deferred diagnostic emitter does not need check variable decls in DeclRefExpr since reference of a variable does not cause emission of functions directly or indirectly. Therefore there is no need to check variable decls in DeclRefExpr. Differential Revision: https://reviews.llvm.org/D76937
2020-03-23recommit 1b978ddba05c [CUDA][HIP][OpenMP] Emit deferred diagnostics by a ↵Yaxun (Sam) Liu1-81/+96
post-parsing AST travese Differential Revision: https://reviews.llvm.org/D70172
2020-02-27Avoid SourceManager.h include in RawCommentList.h, add missing incsReid Kleckner1-0/+1
SourceManager.h includes FileManager.h, which is expensive due to dependencies on LLVM FS headers. Remove dead BeforeThanCompare specialization. Sink ASTContext::addComment to cpp file. This reduces the time to compile a file that does nothing but include ASTContext.h from ~3.4s to ~2.8s for me. Saves these includes: 219 - ../clang/include/clang/Basic/SourceManager.h 204 - ../clang/include/clang/Basic/FileSystemOptions.h 204 - ../clang/include/clang/Basic/FileManager.h 165 - ../llvm/include/llvm/Support/VirtualFileSystem.h 164 - ../llvm/include/llvm/Support/SourceMgr.h 164 - ../llvm/include/llvm/Support/SMLoc.h 161 - ../llvm/include/llvm/Support/Path.h 141 - ../llvm/include/llvm/ADT/BitVector.h 128 - ../llvm/include/llvm/Support/MemoryBuffer.h 124 - ../llvm/include/llvm/Support/FileSystem.h 124 - ../llvm/include/llvm/Support/Chrono.h 124 - .../MSVCSTL/include/stack 122 - ../llvm/include/llvm-c/Types.h 122 - ../llvm/include/llvm/Support/NativeFormatting.h 122 - ../llvm/include/llvm/Support/FormatProviders.h 122 - ../llvm/include/llvm/Support/CBindingWrapping.h 122 - .../MSVCSTL/include/xtimec.h 122 - .../MSVCSTL/include/ratio 122 - .../MSVCSTL/include/chrono 121 - ../llvm/include/llvm/Support/FormatVariadicDetails.h 118 - ../llvm/include/llvm/Support/MD5.h 109 - .../MSVCSTL/include/deque 105 - ../llvm/include/llvm/Support/Host.h 105 - ../llvm/include/llvm/Support/Endian.h Reviewed By: aaron.ballman, hans Differential Revision: https://reviews.llvm.org/D75279
2020-02-18Revert "[CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST ↵Yaxun (Sam) Liu1-110/+75
travese" This reverts commit 1b978ddba05cb15e22b4e75adb5e7362ad861987.
2020-02-16[CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST traveseYaxun (Sam) Liu1-75/+110
This patch removes the explicit call graph for CUDA/HIP/OpenMP deferred diagnostics generated during parsing since it is error prone due to incomplete information about function declarations during parsing. In stead, this patch does a post-parsing AST traverse and emits deferred diagnostics based on the use graph implicitly generated during the traverse. Differential Revision: https://reviews.llvm.org/D70172