summaryrefslogtreecommitdiff
path: root/include/clang/Lex/MacroArgs.h
Commit message (Collapse)AuthorAgeFilesLines
* Remove cache for macro arg stringizationReid Kleckner2019-07-301-10/+0
| | | | | | | | | | | | | | | | | | | Summary: The cache recorded the wrong expansion location for all but the first stringization. It seems uncommon to stringize the same macro argument multiple times, so this cache doesn't seem that important. Fixes PR39942 Reviewers: vsk, rsmith Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65428 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@367337 91177308-0d34-0410-b5e6-96231b3b80d8
* [c++20] Implement tweaked __VA_OPT__ rules from P1042R1:Richard Smith2019-05-041-6/+7
| | | | | | | | | | * __VA_OPT__ is expanded if the *expanded* __VA_ARGS__ is non-empty, not if the original argument contained no tokens. * Placemarkers at the start and end of __VA_OPT__ are retained just long enough to paste them with adjacent ## operators. We never paste "across" a discarded placemarker. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@359964 91177308-0d34-0410-b5e6-96231b3b80d8
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove trailing spaceFangrui Song2018-07-301-6/+6
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338291 91177308-0d34-0410-b5e6-96231b3b80d8
* [c++2a] Implement P0306 __VA_OPT__ (Comma omission and comma deletion)Faisal Vali2017-10-151-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements an extension to the preprocessor: __VA_OPT__(contents) --> which expands into its contents if variadic arguments are supplied to the parent macro, or behaves as an empty token if none. - Currently this feature is only enabled for C++2a (this could be enabled, with some careful tweaks, for other dialects with the appropriate extension or compatibility warnings) - The patch was reviewed here: https://reviews.llvm.org/D35782 and asides from the above (and moving some of the definition and expansion recognition logic into the corresponding state machines), I believe I incorporated all of Richard's suggestions. A few technicalities (most of which were clarified through private correspondence between rsmith, hubert and thomas) are worth mentioning. Given: #define F(a,...) a #__VA_OPT__(a ## a) a ## __VA_OPT__(__VA_ARGS__) - The call F(,) Does not supply any tokens for the variadic arguments and hence VA_OPT behaves as a placeholder. - When expanding VA_OPT (for e.g. F(,1) token pasting occurs eagerly within its contents if the contents need to be stringified. - A hash or a hashhash prior to VA_OPT does not inhibit expansion of arguments if they are the first token within VA_OPT. - When a variadic argument is supplied, argument substitution occurs within the contents as does stringification - and these resulting tokens are inserted back into the macro expansions token stream just prior to the entire stream being rescanned and concatenated. See wg21.link/P0306 for further details on the feature. Acknowledgment: This patch would have been poorer if not for Richard Smith's usual thoughtful analysis and feedback. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315840 91177308-0d34-0410-b5e6-96231b3b80d8
* [NFC] Remove superfluous parameter Faisal Vali2017-09-301-1/+1
| | | | | | | | - MacroArgs already knows the maximum number of arguments that can be supplied to the macro. No need to pass MacroInfo (information about the macro definition) to the call to getPreExpArgument (which by the way might benefit from being called getExpandedArgument() ?) for it to compute the number of arguments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314593 91177308-0d34-0410-b5e6-96231b3b80d8
* [NFC] Modernize MacroArgs using TrailingObjectsFaisal Vali2017-09-281-1/+5
| | | | | | | Refactor MacroArgs to use TrailingObjects when creating a variably sized object on the heap to store the unexpanded tokens immediately after the MacroArgs object. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314372 91177308-0d34-0410-b5e6-96231b3b80d8
* [Preprocessor]Correct Macro-Arg allocation of StringifiedArguments, Erich Keane2017-06-141-7/+9
| | | | | | | | | | | | | | | | | | | | | | correct getNumArguments StringifiedArguments is allocated (resized) based on the size the getNumArguments function. However, this function ACTUALLY currently returns the amount of total UnexpArgTokens which is minimum the same as the new implementation of getNumMacroArguments, since empty/omitted arguments result in 1 UnexpArgToken, and included ones at minimum include 2 (1 for the arg itself, 1 for eof). This patch renames the otherwise unused getNumArguments to be more clear that it is the number of arguments that the Macro expects, and thus the maximum number that can be stringified. This patch also replaces the explicit memset (which results in value instantiation of the new tokens, PLUS clearing the memory) with brace initialization. Differential Revision: https://reviews.llvm.org/D32046 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305425 91177308-0d34-0410-b5e6-96231b3b80d8
* Make headers self-contained.Benjamin Kramer2016-02-021-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259490 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove empty non-virtual destructors or mark them =default when non-publicBenjamin Kramer2015-04-111-1/+2
| | | | | | These add no value but can make a class non-trivially copyable. NFC. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234689 91177308-0d34-0410-b5e6-96231b3b80d8
* Header guard canonicalization, clang part.Benjamin Kramer2014-08-131-2/+2
| | | | | | Modifications made by clang-tidy with minor tweaks. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215557 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Use 'nullptr'Craig Topper2014-05-061-2/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208063 91177308-0d34-0410-b5e6-96231b3b80d8
* [Preprocessor] For the MacroExpands preprocessor callback, also pass the ↵Argyrios Kyrtzidis2013-05-031-0/+125
MacroArgs object that provides information about the argument tokens for a function macro. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181065 91177308-0d34-0410-b5e6-96231b3b80d8