summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParsePragma.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [MS] Make #pragma pack use PragmaStack<> class.Denis Zobnin2016-04-291-20/+17
| | | | | | | | | | | | | | | Make implementation of #pragma pack consistent with other "stack" pragmas. Use PragmaStack<> class instead of old representation of internal stack. Don't change compiler's behavior. TODO: 1. Introduce diagnostics on popping named slots from pragma stacks. Reviewer: rnk Differential revision: http://reviews.llvm.org/D19727 llvm-svn: 268085
* Recommit "[MS] Improved implementation of stack pragmas (vtordisp, *_seg)"Denis Zobnin2016-04-291-9/+9
| | | | | | | | | | | | | | | | | | | | | | Slightly updated version, double-checked build and tests. Improve implementation of MS pragmas that use stack + compatibility fixes. This patch: 1. Changes implementation of #pragma vtordisp to use PragmaStack class that other stack pragmas use; 2. Fixes "#pragma vtordisp()" behavior - it shouldn't affect the stack; 3. Supports "save-restore" of pragma stacks on enter / exit a C++ method body, as MSVC does. TODO: 1. Change implementation of #pragma pack to use the same approach; 2. Introduce diagnostics on popping named stack slots, as MSVC does. Reviewers: rnk, thakis Differential revision: http://reviews.llvm.org/D19361 llvm-svn: 268029
* Revert "[MS] Improved implementation of MS stack pragmas (vtordisp, *_seg)"Denis Zobnin2016-04-281-9/+9
| | | | | | This reverts commit r267866. llvm-svn: 267870
* [MS] Improved implementation of MS stack pragmas (vtordisp, *_seg)Denis Zobnin2016-04-281-9/+9
| | | | | | | | | | | Rework implementation of several MS pragmas that use internal stack: vtordisp, {bss|code|const|data}_seg. This patch: 1. Makes #pragma vtordisp use PragmaStack class as *_seg pragmas do; 2. Fixes "#pragma vtordisp()" behavior: it shouldn't affect stack; 3. Saves/restores the stacks on enter/exit a C++ method body. llvm-svn: 267866
* [Parse] Reuse OptionUnroll rather than matching it again. NFCAdam Nemet2016-04-191-2/+1
| | | | llvm-svn: 266829
* [Parse] Use StringSwitch to improve readability. NFCAdam Nemet2016-04-191-4/+8
| | | | | | | | A subsequent patch will propose a "distribute" loop hint. Similarly to unroll, this does not have a "assume_safety" argument either so this condition will get more complex. llvm-svn: 266827
* Serialize `pragma ms_struct` state.Nico Weber2016-03-021-6/+5
| | | | | | | | | | | pragma ms_struct has an effect on struct decls, and the effect is serialized correctly already. But the "is ms_struct currently on" state wasn't before this change. This uses the same approach as `pragma clang optimize`: When writing a module, the state isn't serialized, only when writing a pch file. llvm-svn: 262539
* Serialize `#pragma detect_mismatch`.Nico Weber2016-03-021-4/+4
| | | | | | | This is like r262493, but for pragma detect_mismatch instead of pragma comment. The two pragmas have similar behavior, so use the same approach for both. llvm-svn: 262506
* Serialize `#pragma comment`.Nico Weber2016-03-021-11/+12
| | | | | | | | | | | | | | `#pragma comment` was handled by Sema calling a function on ASTConsumer, and CodeGen then implementing this function and writing things to its output. Instead, introduce a PragmaCommentDecl AST node and hang one off the TranslationUnitDecl for every `#pragma comment` line, and then use the regular serialization machinery. (Since PragmaCommentDecl has codegen relevance, it's eagerly deserialized.) http://reviews.llvm.org/D17799 llvm-svn: 262493
* Simplify EnterTokenStream API to make it more robust for memory managementDavid Blaikie2016-02-091-82/+56
| | | | | | | | | | | | | | | While this won't help fix things like the bug that r260219 addressed, it seems like good tidy up to have anyway. (it might be nice if "makeArrayRef" always produced a MutableArrayRef & let it decay to an ArrayRef when needed - then I'd use that for the MutableArrayRefs in this patch) If we had std::dynarray I'd use that instead of unique_ptr+size_t, ideally (but then it'd have to be threaded down through the Preprocessor all the way - no idea how painful that would be) llvm-svn: 260246
* Improve AST dumping:Richard Smith2016-01-121-0/+8
| | | | | | | | 1) When dumping a declaration that declares a name for a type, also dump the named type. 2) Add a #pragma clang __debug dump X, that dumps the lookup results for X in the current context. llvm-svn: 257529
* Put global classes into the appropriate namespace.Benjamin Kramer2015-10-281-0/+4
| | | | | | | Most of the cases belong into an anonymous namespace. No functionality change intended. llvm-svn: 251514
* Parse and ignore #pragma runtime_checks in MS extensions mode (PR25138)Hans Wennborg2015-10-121-0/+8
| | | | | | We already silently ignore the /RTC, which controls the same functionality. llvm-svn: 250099
* Add new llvm.loop.unroll.enable metadata for use with "#pragma unroll".Mark Heffernan2015-08-101-9/+12
| | | | | | | | | | | | | | | | | | | | | | This change adds the new unroll metadata "llvm.loop.unroll.enable" which directs the optimizer to unroll a loop fully if the trip count is known at compile time, and unroll partially if the trip count is not known at compile time. This differs from "llvm.loop.unroll.full" which explicitly does not unroll a loop if the trip count is not known at compile time With this change "#pragma unroll" generates "llvm.loop.unroll.enable" rather than "llvm.loop.unroll.full" metadata. This changes the semantics of "#pragma unroll" slightly to mean "unroll aggressively (fully or partially)" rather than "unroll fully or not at all". The motivating example for this change was some internal code with a loop marked with "#pragma unroll" which only sometimes had a compile-time trip count depending on template magic. When the trip count was a compile-time constant, everything works as expected and the loop is fully unrolled. However, when the trip count was not a compile-time constant the "#pragma unroll" explicitly disabled unrolling of the loop(!). Removing "#pragma unroll" caused the loop to be unrolled partially which was desirable from a performance perspective. llvm-svn: 244467
* [Parse] ArrayRefize PragmaLoopHintInfo. No functionality change.Benjamin Kramer2015-08-051-10/+4
| | | | llvm-svn: 244024
* Add assume_safety option for pragma loop vectorize and interleave.Tyler Nowicki2015-06-111-3/+6
| | | | | | | | Specifying #pragma clang loop vectorize(assume_safety) on a loop adds the mem.parallel_loop_access metadata to each load/store operation in the loop. This metadata tells loop access analysis (LAA) to skip memory dependency checking. llvm-svn: 239572
* Correct Loop Hint Diagnostic MessageTyler Nowicki2015-06-081-3/+4
| | | | | | When pragma clang loop unroll() is specified without an argument the diagnostic message should inform that user that 'full' and 'disable' are valid arguments (not 'enable'). llvm-svn: 239363
* [OPENMP] Allow use of macros in OpenMP directives/clauses.Alexey Bataev2015-05-051-1/+1
| | | | llvm-svn: 236493
* Adds a warning for unrecognized argument to #pragma comment() on PS4.Yunzhong Gao2015-03-231-8/+16
| | | | | | | | | | | PS4 target recognizes the #pragma comment() syntax as in -fms-extensions, but only handles the case of #pragma comment(lib). This patch adds a warning if any other arguments are encountered. This patch also refactors the code in ParsePragma.cpp a little bit to make it more obvious that some codes are being shared between -fms-extensions and PS4. llvm-svn: 233015
* Parse: Don't assume tokens have a lengthDavid Majnemer2015-03-191-1/+22
| | | | | | | Don't crash if the last token in a bad inline method body is an annotation token. llvm-svn: 232694
* Enable pragma comment processing for PS4. Original patch by Yunzhong Gao!Alex Rosenberg2015-01-281-0/+6
| | | | llvm-svn: 227336
* Parse: Ignore "long" and "short" in #pragma sectionDavid Majnemer2014-10-221-1/+15
| | | | | | This fixes PR21337. llvm-svn: 220429
* MS Compat: mark globals emitted in read-only sections constHans Wennborg2014-10-161-13/+14
| | | | | | | | | | | | | | | | | | | | They cannot be written to, so marking them const makes sense and may improve optimisation. As a side-effect, SectionInfos has to be moved from Sema to ASTContext. It also fixes this problem, that occurs when compiling ATL: warning LNK4254: section 'ATL' (C0000040) merged into '.rdata' (40000040) with different attributes The ATL headers are putting variables in a special section that's marked read-only. However, Clang currently can't model that read-onlyness in the IR. But, by making the variables const, the section does become read-only, and the linker warning is avoided. Differential Revision: http://reviews.llvm.org/D5812 llvm-svn: 219960
* Fixed a problem in r19589.Tyler Nowicki2014-10-121-2/+2
| | | | | | Several systems failed to compile the array allocation of the TokenArray. llvm-svn: 219590
* Allow constant expressions in pragma loop hints.Tyler Nowicki2014-10-121-47/+96
| | | | | | | | Previously loop hints such as #pragma loop vectorize_width(#) required a constant. This patch allows a constant expression to be used as well. Such as a non-type template parameter or an expression (2 * c + 1). Reviewed by Richard Smith llvm-svn: 219589
* Parse: Don't attempt to act on #pragma init_seg when not targeting MSVCDavid Majnemer2014-08-141-0/+6
| | | | | | | | | | It doesn't really make sense to try and do stuff with #pragma init_seg when targeting non-Microsoft platforms; notions like library vs user initializers don't exist for other targets. This fixes PR20639. llvm-svn: 215618
* Initializing the loop hint option token again.Aaron Ballman2014-08-011-0/+1
| | | | llvm-svn: 214504
* Initializing the loop hint option token.Aaron Ballman2014-08-011-1/+3
| | | | llvm-svn: 214502
* Loop hint pragmas sometimes do not contain an identifier option (such as ↵Aaron Ballman2014-07-311-1/+5
| | | | | | | | #pragma unroll(4)). Check explicitly that the token we stored was an identifier. Amends r214432 llvm-svn: 214446
* Add a state variable to the loop hint attribute.Tyler Nowicki2014-07-311-42/+70
| | | | | | | | | | This patch is necessary to support constant expressions which replaces the integer value in the loop hint attribute with an expression. The integer value was also storing the pragma’s state for options like vectorize(enable/disable) and the pragma unroll and nounroll directive. The state variable is introduced to hold the state of those options/pragmas. This moves the validation of the state (keywords) from SemaStmtAttr handler to the loop hint annotation token handler. Resubmit with changes to try to fix the build-bot issue. Reviewed by Aaron Ballman llvm-svn: 214432
* Revert r214333, "Add a state variable to the loop hint attribute."NAKAMURA Takumi2014-07-311-69/+42
| | | | | | It brought undefined behavior. llvm-svn: 214376
* Add a state variable to the loop hint attribute.Tyler Nowicki2014-07-301-42/+69
| | | | | | | | This patch is necessary to support constant expressions which replaces the integer value in the loop hint attribute with an expression. The integer value was also storing the pragma’s state for options like vectorize(enable/disable) and the pragma unroll and nounroll directive. The state variable is introduced to hold the state of those options/pragmas. This moves the validation of the state (keywords) from SemaStmtAttr handler to the loop hint annotation token handler. Reviewed by Aaron Ballman llvm-svn: 214333
* Add support for #pragma nounroll.Mark Heffernan2014-07-241-9/+22
| | | | llvm-svn: 213885
* In unroll pragma syntax and loop hint metadata, change "enable" forms to a ↵Mark Heffernan2014-07-231-7/+12
| | | | | | new form using the string "full". llvm-svn: 213771
* -fms-extensions: Implement half of #pragma init_segReid Kleckner2014-07-221-4/+53
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This pragma is very rare. We could *hypothetically* lower some uses of it down to @llvm.global_ctors, but given that GlobalOpt isn't able to optimize prioritized global ctors today, there's really no point. If we wanted to do this in the future, I would check if the section used in the pragma started with ".CRT$XC" and had up to two characters after it. Those two characters could form the 16-bit initialization priority that we support in @llvm.global_ctors. We would have to teach LLVM to lower prioritized global ctors on COFF as well. This should let us compile some silly uses of this pragma in WebKit / Blink. Reviewers: rsmith, majnemer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4549 llvm-svn: 213593
* Add support for '#pragma unroll'.Mark Heffernan2014-07-211-54/+158
| | | | llvm-svn: 213574
* Fix parsing certain kinds of strings in the MS section pragmasReid Kleckner2014-07-181-50/+99
| | | | | | | | | We were crashing on the relevant test case inputs. Also, refactor this code a bit so we can report failure and slurp the pragma tokens without returning a diagnostic id. This is more consistent with the rest of the parser and sema code. llvm-svn: 213337
* Fix PR20069: bad loop pragma arguments crash FEEli Bendersky2014-06-191-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes a crash when handling malformed arguments to loop pragmas such as: "#pragma clang loop vectorize(()". Essentially any argument which is not an identifier or constant resulted in a crash. This patch also changes a couple of the error messages which weren't quite correct. New behavior with this patch vs old behavior: #pragma clang loop vectorize(1) OLD: error: missing keyword; expected 'enable' or 'disable' NEW: error: invalid argument; expected 'enable' or 'disable' #pragma clang loop vectorize() OLD: error: expected ')' NEW: error: missing argument to loop pragma 'vectorize' #pragma clang loop vectorize_width(bad) OLD: error: missing value; expected a positive integer value NEW: error: invalid argument; expected a positive integer value #pragma clang loop vectorize(bad) OLD: invalid keyword 'bad'; expected 'enable' or 'disable' NEW: error: invalid argument; expected 'enable' or 'disable' http://reviews.llvm.org/D4197 Patch by Mark Heffernan llvm-svn: 211292
* Hide the concept of diagnostic levels from lex, parse and semaAlp Toker2014-06-151-3/+2
| | | | | | | | | | | | | | | | The compilation pipeline doesn't actually need to know about the high-level concept of diagnostic mappings, and hiding the final computed level presents several simplifications and other potential benefits. The only exceptions are opportunistic checks to see whether expensive code paths can be avoided for diagnostics that are guaranteed to be ignored at a certain SourceLocation. This commit formalizes that invariant by introducing and using DiagnosticsEngine::isIgnored() in place of individual level checks throughout lex, parse and sema. llvm-svn: 211005
* First commit. Modified FIXME comment.Tyler Nowicki2014-06-131-2/+2
| | | | llvm-svn: 210918
* DiagnosticsEngine: update severity setters to new terminologyAlp Toker2014-06-121-3/+2
| | | | llvm-svn: 210764
* Complete the switch from mappings to declarative diagnostic severitiesAlp Toker2014-06-121-1/+1
| | | | | | | | | This begins to address cognitive dissonance caused by treating the Note diagnostic level as a severity in the diagnostic engine. No change in functionality. llvm-svn: 210758
* Add loop unroll pragma supportEli Bendersky2014-06-111-3/+18
| | | | | | | | http://reviews.llvm.org/D4089 Patch by Mark Heffernan. llvm-svn: 210667
* Fix DOS-style newlines.Eli Bendersky2014-06-061-187/+187
| | | | | | | | | A previous patch r210330 (and possibly another) introduced DOS-style newlines into a UNIX newline formatted file. Patch by Mark Heffernan (http://reviews.llvm.org/D4046) llvm-svn: 210369
* Adding a new #pragma for the vectorize and interleave optimization hints.Aaron Ballman2014-06-061-33/+187
| | | | | | Patch thanks to Tyler Nowicki! llvm-svn: 210330
* Implemented support for "pragma clang optimize on/off", based on attribute ↵Dario Domizioli2014-05-231-0/+53
| | | | | | | | | | | | | | | | 'optnone'. This patch implements support for selectively disabling optimizations on a range of function definitions through a pragma. The implementation is that all function definitions in the range are decorated with attribute 'optnone'. #pragma clang optimize off // All function definitions in here are decorated with 'optnone'. #pragma clang optimize on // Compilation resumes as normal. llvm-svn: 209510
* [C++11] Use 'nullptr'. Parser edition.Craig Topper2014-05-211-3/+3
| | | | llvm-svn: 209275
* [MS-ABI] Add support for #pragma section and related pragmasWarren Hunt2014-04-081-9/+188
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for the msvc pragmas section, bss_seg, code_seg, const_seg and data_seg as well as support for __declspec(allocate()). Additionally it corrects semantics and adds diagnostics for __attribute__((section())) and the interaction between the attribute and the msvc pragmas and declspec. In general conflicts should now be well diganosed within and among these features. In supporting the pragmas new machinery for uniform lexing for msvc pragmas was introduced. The new machinery always lexes the entire pragma and stores it on an annotation token. The parser is responsible for parsing the pragma when the handling the annotation token. There is a known outstanding bug in this implementation in C mode. Because these attributes and pragmas apply _only_ to definitions, we process them at the time we detect a definition. Due to tentative definitions in C, we end up processing the definition late. This means that in C mode, everything that ends up in a BSS section will end up in the _last_ BSS section rather than the one that was live at the time of tentative definition, even if that turns out to be the point of actual definition. This issue is not known to impact anything as of yet because we are not aware of a clear use or use case for #pragma bss_seg but should be fixed at some point. Differential Revision=http://reviews.llvm.org/D3065#inline-16241 llvm-svn: 205810
* -fms-extensions: Error out on #pragma init_segReid Kleckner2014-04-031-0/+18
| | | | | | | | | | | | | By ignoring this pragma with a warning, we're essentially miscompiling the user's program. WebKit / Blink use this pragma to disable dynamic initialization and finalization of some static data, and running the dtors crashes the program. Error out for now, so that /fallback compiles the TU correctly with MSVC. This pragma should be implemented some time this month, and we can remove this hack. llvm-svn: 205554
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-121-32/+32
| | | | | | class. llvm-svn: 203641
OpenPOWER on IntegriCloud