aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/IdentifierTable.cpp
AgeCommit message (Collapse)AuthorFilesLines
2022-09-21[HLSL] Support cbuffer/tbuffer for hlsl.Xiang Li1-1/+4
This is first part for support cbuffer/tbuffer. The format for cbuffer/tbuffer is BufferType [Name] [: register(b#)] { VariableDeclaration [: packoffset(c#.xyzw)]; ... }; More details at https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-constants New keyword 'cbuffer' and 'tbuffer' are added. New AST node HLSLBufferDecl is added. Build AST for simple cbuffer/tbuffer without attribute support. The special thing is variables declared inside cbuffer is exposed into global scope. So isTransparentContext should return true for HLSLBuffer. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D129883
2022-08-26Fix the lldb test botsAaron Ballman1-19/+23
This addresses an accidental change in behavior from 41667a8b9b624e282e7c08fadf7091223728d1c1 to get the bots back to green. However, I think there's an issue with LLDB assuming it's valid to enable support for keywords in language modes that don't support the keyword (as other parts of Clang are not expecting to be able to do that). This should fix (and others): https://lab.llvm.org/buildbot/#/builders/68/builds/38374
2022-08-26[Basic] Drop header-only dependency from Basic to LexBenjamin Kramer1-0/+1
It's still a bit weird for IdentifierTable to depend on Lex diagnostics, but we can get away with including the enum info that's in Basic already.
2022-08-26Diagnosing the Future KeywordsMuhammad Usman Shahid1-31/+58
The patch diagnoses an identifier as a future keyword if it exists in a future language mode, such as: int restrict; in C modes earlier than C99. We now give a warning to the user that such an identifier is a future keyword. Handles keywords from C as well as C++. Differential Revision: https://reviews.llvm.org/D131683
2022-08-03Fix char8_t in C mode regression from fb65b179Erich Keane1-1/+2
When doing that NFC refactor, I'd messed up how char8_t was reported, which resulted in it being considered a 'future' keyword, without the corresponding diagnostic, which lead to an assert. This patch corrects the char8_t to ONLY be future in C++ mode.
2022-08-03[NFCI] Refactor how KeywordStatus is calculatedErich Keane1-55/+122
The getKeywordStatus function is a horrible mess of inter-dependent 'if' statements that depend significantly on the ORDER of the checks. This patch removes the dependency on order by checking each set-flag only once. It does this by looping through each of the set bits, and checks each individual flag for its effect, then combines them at the end. This might slow down startup performance slightly, as there are only a few hundred keywords, and a vast majority will only get checked 1x still. This patch ALSO removes the KEYWORD_CONCEPTS flag, because it has since become synonymous with C++20. Differential Revision: https://reviews.llvm.org/D131007
2022-05-11[clang] Fix KEYALLYaxun (Sam) Liu1-2/+3
Update KEYALL to cover KEYCUDA. Introduce KEYMAX and a generic way to update KEYALL. Reviewed by: Dan Liew Differential Revision: https://reviews.llvm.org/D125396
2022-05-10[CUDA][HIP] support __noinline__ as keywordYaxun (Sam) Liu1-0/+3
CUDA/HIP programs use __noinline__ like a keyword e.g. __noinline__ void foo() {} since __noinline__ is defined as a macro __attribute__((noinline)) in CUDA/HIP runtime header files. However, gcc and clang supports __attribute__((__noinline__)) the same as __attribute__((noinline)). Some C++ libraries use __attribute__((__noinline__)) in their header files. When CUDA/HIP programs include such header files, clang will emit error about invalid attributes. This patch fixes this issue by supporting __noinline__ as a keyword, so that CUDA/HIP runtime could remove the macro definition. Reviewed by: Aaron Ballman, Artem Belevich Differential Revision: https://reviews.llvm.org/D124866
2022-01-26[CodeCompletion][clangd] Clean __uglified parameter names in completion & hoverSam McCall1-0/+8
Underscore-uglified identifiers are used in standard library implementations to guard against collisions with macros, and they hurt readability considerably. (Consider `push_back(Tp_ &&__value)` vs `push_back(Tp value)`. When we're describing an interface, the exact names of parameters are not critical so we can drop these prefixes. This patch adds a new PrintingPolicy flag that can applies this stripping when recursively printing pieces of AST. We set it in code completion/signature help, and in clangd's hover display. All three features also do a bit of manual poking at names, so fix up those too. Fixes https://github.com/clangd/clangd/issues/736 Differential Revision: https://reviews.llvm.org/D116387
2021-05-27Correct the 'KEYALL' mask.Erich Keane1-1/+1
It should technically be a 1, since we are only setting the first bit.
2021-05-27Reimplement __builtin_unique_stable_name-Erich Keane1-1/+4
The original version of this was reverted, and @rjmcall provided some advice to architect a new solution. This is that solution. This implements a builtin to provide a unique name that is stable across compilations of this TU for the purposes of implementing the library component of the unnamed kernel feature of SYCL. It does this by running the Itanium mangler with a few modifications. Because it is somewhat common to wrap non-kernel-related lambdas in macros that aren't present on the device (such as for logging), this uniquely generates an ID for all lambdas involved in the naming of a kernel. It uses the lambda-mangling number to do this, except replaces this with its own number (starting at 10000 for readabililty reasons) for lambdas used to name a kernel. Additionally, this implements itself as constexpr with a slight catch: if a name would be invalidated by the use of this lambda in a later kernel invocation, it is diagnosed as an error (see the Sema tests). Differential Revision: https://reviews.llvm.org/D103112
2021-05-27Add support for #elifdef and #elifndefAaron Ballman1-0/+2
WG14 adopted N2645 and WG21 EWG has accepted P2334 in principle (still subject to full EWG vote + CWG review + plenary vote), which add support for #elifdef as shorthand for #elif defined and #elifndef as shorthand for #elif !defined. This patch adds support for the new preprocessor directives.
2021-05-04Introduce -Wreserved-identifierserge-sans-paille1-0/+33
Warn when a declaration uses an identifier that doesn't obey the reserved identifier rule from C and/or C++. Differential Revision: https://reviews.llvm.org/D93095
2021-03-15Allow __ieee128 as an alias to __float128 on ppcserge-sans-paille1-0/+3
This matches gcc behavior. Differential Revision: https://reviews.llvm.org/D97846
2020-12-07[clang] Add a new nullability annotation for swift async: _Nullable_resultErik Pilkington1-0/+5
_Nullable_result generally like _Nullable, except when being imported into a swift async method. rdar://70106409 Differential revision: https://reviews.llvm.org/D92495
2020-06-26Revert rGf0bab7875e78e01c149d12302dcc4b6d4c43e25c - "Triple.h - reduce ↵Simon Pilgrim1-1/+0
Twine.h include to forward declarations. NFC." This causes ICEs on the clang-ppc64be buildbots and I've limited ability to triage the problem.
2020-06-26Triple.h - reduce Twine.h include to forward declarations. NFC.Simon Pilgrim1-0/+1
Move include down to a number of other files that had an implicit dependency on the Twine class.
2020-05-07Add static assert to ID Table to make sure aux targets work right.Erich Keane1-0/+7
I discovered that the limit on possible builtins managed by this ObjCOrBuiltin variable is too low when combining large targets, since aux-targets are appended to the targets list. A runtime assert exists for this, however this patch creates a static-assert as well. The logic for said static-assert is to make sure we have the room for the aux-target and target to both be the largest list, which makes sure we have room for all possible combinations. I also incremented the number of bits by 1, since I discovered this currently broken. The current bit-count was 36, so this doesn't increase any size.
2020-04-28Make -fno-char8_t disable the char8_t keyword, even in C++20.Richard Smith1-0/+2
This fixes a regression introduced in r354736, and makes our behavior compatible with that of Clang 8 and GCC.
2020-04-21C++2a -> C++20 in some identifiers; NFC.Aaron Ballman1-5/+5
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-2/+2
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2020-01-24[Concepts] Deprecate -fconcepts-ts, enable Concepts under -std=c++2aSaar Raz1-1/+1
Now with concepts support merged and mostly complete, we do not need -fconcepts-ts (which was also misleading as we were not implementing the TS) and can enable concepts features under C++2a. A warning will be generated if users still attempt to use -fconcepts-ts.
2019-08-14[Sema][ObjC] Fix a -Wformat false positive with localizedStringForKeyErik Pilkington1-0/+15
Only honour format_arg attributes on -[NSBundle localizedStringForKey] when its argument has a format specifier in it, otherwise its likely to just be a key to fetch localized strings. Fixes rdar://23622446 Differential revision: https://reviews.llvm.org/D27165 llvm-svn: 368878
2019-04-11[C++20] Implement context-sensitive header-name lexing and pp-import parsing ↵Richard Smith1-1/+1
in the preprocessor. llvm-svn: 358231
2019-02-23Enable coroutines under -std=c++2a.Richard Smith1-1/+1
llvm-svn: 354736
2019-02-15[MSVC] Recognize `static_assert` keyword in C and C++98Reid Kleckner1-0/+2
Summary: The main effect is that clang now accepts the following conforming C11 code with MSVC headers: #include <assert.h> static_assert(1, "true"); This is a non-conforming extension (the keyword is outside the implementer's namespace), so it is placed under -fms-compatibility instead of -fms-extensions like most MSVC-specific keyword extensions. Normally, in C11, the compiler is supposed to provide the _Static_assert keyword, and assert.h should define static_assert to _Static_assert. However, that is not what MSVC does, and MSVC doesn't even provide _Static_assert. This also has the less important side effect of enabling static_assert in C++98 mode with -fms-compatibility. It's exceptionally difficult to use modern MSVC headers without C++14 even, so this is relatively unimportant. Fixes PR26672 Patch by Andrey Bokhanko! Reviewers: rsmith, thakis Subscribers: cfe-commits, STL_MSFT Differential Revision: https://reviews.llvm.org/D17444 llvm-svn: 354162
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-12-05[Basic] Cleanups in IdentifierInfo following the removal of PTHBruno Ricci1-22/+0
The Entry pointer in IdentifierInfo was only null for IdentifierInfo created from a PTH. Now that PTH support has been removed we can remove some PTH specific code in IdentifierInfo::getLength and IdentifierInfo::getNameStart. Also make the constructor of IdentifierInfo private to make sure that they are only created by IdentifierTable, and move it to the header so that it can be inlined in IdentifierTable::get and IdentifierTable::getOwn. Differential Revision: https://reviews.llvm.org/D54866 Reviewed By: erichkeane llvm-svn: 348384
2018-11-01Fix clang -Wimplicit-fallthrough warnings across llvm, NFCReid Kleckner1-0/+1
This patch should not introduce any behavior changes. It consists of mostly one of two changes: 1. Replacing fall through comments with the LLVM_FALLTHROUGH macro 2. Inserting 'break' before falling through into a case block consisting of only 'break'. We were already using this warning with GCC, but its warning behaves slightly differently. In this patch, the following differences are relevant: 1. GCC recognizes comments that say "fall through" as annotations, clang doesn't 2. GCC doesn't warn on "case N: foo(); default: break;", clang does 3. GCC doesn't warn when the case contains a switch, but falls through the outer case. I will enable the warning separately in a follow-up patch so that it can be cleanly reverted if necessary. Reviewers: alexfh, rsmith, lattner, rtrieu, EricWF, bollu Differential Revision: https://reviews.llvm.org/D53950 llvm-svn: 345882
2018-10-30NFC: Merge KEYOBJC and KEYARCErik Pilkington1-25/+23
We used to only define ARC keywords in -fobjc-arc mode, but now that we define them in ObjC mode, there isn't any reason to keep them seperate. llvm-svn: 345646
2018-10-30NFC: Remove the ObjC1/ObjC2 distinction from clang (and related projects)Erik Pilkington1-8/+5
We haven't supported compiling ObjC1 for a long time (and never will again), so there isn't any reason to keep these separate. This patch replaces LangOpts::ObjC1 and LangOpts::ObjC2 with LangOpts::ObjC. Differential revision: https://reviews.llvm.org/D53547 llvm-svn: 345637
2018-10-16[SystemZ] Actually enable -mzvector keywordsUlrich Weigand1-0/+1
It appears when initially committing the support for the IBM Z vector extension language, one critical line was lost, causing the specific keywords __vector, __bool, and vec_step to not actually be enabled. (Note that this does not affect "vector" and "bool"!) Unfortunately, this was not caught by any tests either. (All existing Z vector tests just use the regular "vector" and "bool" keywords ...) Fixed by adding the missing line and updating the tests. llvm-svn: 344611
2018-09-21[AST] Various optimizations + refactoring in DeclarationName(Table)Bruno Ricci1-15/+14
Introduce the following optimizations in DeclarationName(Table): 1. Store common kinds inline in DeclarationName instead of DeclarationNameExtra. Currently the kind of C++ constructor, destructor, conversion function and overloaded operator names is stored in DeclarationNameExtra. Instead store it inline in DeclarationName. To do this align IdentifierInfo, CXXSpecialName, DeclarationNameExtra and CXXOperatorIdName to 8 bytes so that we can use the lower 3 bits of DeclarationName::Ptr. This is already the case on 64 bits archs anyway. This also allow us to remove DeclarationNameExtra from CXXSpecialName and CXXOperatorIdName, which shave off a pointer from CXXSpecialName. 2. Synchronize the enumerations DeclarationName::NameKind, DeclarationName::StoredNameKind and Selector::IdentifierInfoFlag. This makes DeclarationName::getNameKind much more efficient since we can replace the switch table by a single comparison and an addition. 3. Put the overloaded operator names inline in DeclarationNameTable to remove an indirection. This increase the size of DeclarationNameTable a little bit but this is not important since it is only used in ASTContext, and never copied nor moved from. This also get rid of the last dynamic allocation in DeclarationNameTable. Altogether these optimizations cut the run time of parsing all of Boost by about 0.8%. While we are at it, do the following NFC modifications: 1. Put the internal classes CXXSpecialName, CXXDeductionGuideNameExtra, CXXOperatorIdName, CXXLiteralOperatorIdName and DeclarationNameExtra in a namespace detail since these classes are only meant to be used by DeclarationName and DeclarationNameTable. Make this more explicit by making the members of these classes private and friending DeclarationName(Table). 2. Make DeclarationName::getFETokenInfo a non-template since every users are using it to get a void *. It was supposed to be used with a type to avoid a subsequent static_cast. 3. Change the internal functions DeclarationName::getAs* to castAs* since when we use them we already know the correct kind. This has no external impact since all of these are private. Reviewed By: erichkeane, rjmccall Differential Revision: https://reviews.llvm.org/D52267 llvm-svn: 342729
2018-07-30Remove trailing spaceFangrui Song1-9/+9
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
2018-05-31Add dump method for selectorsAditya Kumar1-0/+2
Differential Revision: https://reviews.llvm.org/D45935 Reviewers: compnerd llvm-svn: 333657
2018-05-23[AST][ObjC] Print implicit property expression that only has a setter ↵Alex Lorenz1-0/+6
without crashing rdar://40447209 llvm-svn: 333046
2018-05-09[OpenCL] Restrict various keywords in OpenCL C++ modeSven van Haastregt1-3/+6
Restrict the following keywords in the OpenCL C++ language mode, according to Sections 2.2 & 2.9 of the OpenCL C++ 1.0 Specification. - dynamic_cast - typeid - register (already restricted in OpenCL C, update the diagnostic) - thread_local - exceptions (try/catch/throw) - access qualifiers read_only, write_only, read_write Support the `__global`, `__local`, `__constant`, `__private`, and `__generic` keywords in OpenCL C++. Leave the unprefixed address space qualifiers such as global available, i.e., do not mark them as reserved keywords in OpenCL C++. libclcxx provides explicit address space pointer classes such as `global_ptr` and `global<T>` that are implemented using the `__`-prefixed qualifiers. Differential Revision: https://reviews.llvm.org/D46022 llvm-svn: 331874
2018-05-09Remove \brief commands from doxygen comments.Adrian Prantl1-6/+6
This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
2018-05-01Implement P0482R2, support for char8_t type.Richard Smith1-7/+9
This is not yet part of any C++ working draft, and so is controlled by the flag -fchar8_t rather than a -std= flag. (The GCC implementation is controlled by a flag with the same name.) This implementation is experimental, and will be removed or revised substantially to match the proposal as it makes its way through the C++ committee. llvm-svn: 331244
2018-04-16Defer adding keywords to the identifier table until after the language ↵Aaron Ballman1-6/+9
options have been loaded from the AST file. This fixes issues with "class" being reported as an identifier in "enum class" because the construct is not present when using default language options. Patch by Johann Klähn. llvm-svn: 330159
2017-11-03[Basic] Fix some Clang-tidy modernize and Include What You Use warnings; ↵Eugene Zelenko1-25/+43
other minor fixes (NFC). llvm-svn: 317381
2017-08-13[c++2a] Treat 'concept' and 'requires' as keywords, add compat warning for ↵Richard Smith1-2/+6
C++17 and before. llvm-svn: 310803
2017-06-03Added missing break.Galina Kistanova1-0/+1
llvm-svn: 304653
2017-04-11[Parser][ObjC++] Improve diagnostics and recovery when C++ keywords are usedAlex Lorenz1-1/+14
as identifiers in Objective-C++ This commit improves the 'expected identifier' errors that are presented when a C++ keyword is used as an identifier in Objective-C++ by mentioning that this is a C++ keyword in the diagnostic message. It also improves the error recovery: the parser will now treat the C++ keywords as identifiers to prevent unrelated parsing errors. rdar://20626062 Differential Revision: https://reviews.llvm.org/D26503 llvm-svn: 299950
2017-03-06[Sema][ObjC] Warn about 'performSelector' calls with selectorsAlex Lorenz1-2/+4
that return record or vector types The performSelector family of methods from Foundation use objc_msgSend to dispatch the selector invocations to objects. However, method calls to methods that return record types might have to use the objc_msgSend_stret as the return value won't find into the register. This is also supported by this sentence from performSelector documentation: "The method should not have a significant return value and should take a single argument of type id, or no arguments". This commit adds a new warning that warns when a selector which corresponds to a method that returns a record type is passed into performSelector. rdar://12056271 Differential Revision: https://reviews.llvm.org/D30174 llvm-svn: 297019
2016-11-04Add some more asserts to clearly indicate that there are special casesChandler Carruth1-2/+4
which guarantee pointers are not null. These all seem to have useful properties and correlations to document, in one case we even had it in a comment but now it will also be an assert. This should prevent PVS-Studio from incorrectly claiming that there are a bunch of potential bugs here. But I feel really strongly that the PVS-Studio warnings that pointed at this code have a far too high false-positive rate to be entirely useful. These are just places where there did seem to be a useful invariant to document and verify with an assert. Several other places in the code were already correct and already have perfectly clear code documenting and validating their invariants, but still ran afoul of PVS-Studio. llvm-svn: 285985
2016-10-20Retire llvm::alignOf in favor of C++11 alignof.Benjamin Kramer1-2/+2
No functionality change intended. llvm-svn: 284730
2016-10-02[coroutines] Rename driver flag -fcoroutines to -fcoroutines-tsGor Nishanov1-1/+1
Summary: Also makes -fcoroutines_ts to be both a Driver and CC1 flag. Patch mostly by EricWF. Reviewers: rnk, cfe-commits, rsmith, EricWF Subscribers: mehdi_amini Differential Revision: https://reviews.llvm.org/D25130 llvm-svn: 283064
2016-07-23Add -fmodules-ts flag to cc1 for the provisional C++ modules TS, and markRichard Smith1-2/+4
'module' and 'import' as keywords when the flag is specified. llvm-svn: 276508
2016-02-05[modules] Separately track whether an identifier's preprocessor information andRichard Smith1-0/+1
name lookup information have changed since deserialization. For a C++ modules build, we do not need to re-emit the identifier into the serialized identifier table if only the name lookup information has changed (and in all cases, we don't need to re-emit the macro information if only the name lookup information has changed). llvm-svn: 259901