summaryrefslogtreecommitdiffstats
path: root/llvm/lib/AsmParser/Parser.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [llvm] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-151-4/+4
| | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. llvm-svn: 369013
* 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. llvm-svn: 351636
* [ThinLTO] Parse module summary index from assemblyTeresa Johnson2018-06-261-5/+78
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Adds assembly parsing support for the module summary index (follow on to r333335 which added the assembly writing support). I added support to llvm-as to invoke the index parsing, so that it can create either a bitcode file with a Module and a per-module index, or a combined index without a Module. I will send follow on patches soon to do the following: - add support to tools such as llvm-lto2 to parse the per-module indexes from assembly instead of bitcode when testing the thin link. - verification support. Depends on D47844 and D47842. Reviewers: pcc, dexonsmith, mehdi_amini Subscribers: inglorion, eraman, steven_wu, llvm-commits Differential Revision: https://reviews.llvm.org/D47905 llvm-svn: 335602
* LLParser: add an argument for overriding data layout and do not check alloca ↵Yaxun Liu2018-01-301-16/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | addr space Sometimes users do not specify data layout in LLVM assembly and let llc set the data layout by target triple after loading the LLVM assembly. Currently the parser checks alloca address space no matter whether the LLVM assembly contains data layout definition, which causes false alarm since the default data layout does not contain the correct alloca address space. The parser also calls verifier to check debug info and updating invalid debug info. Currently there is no way to let the verifier to check debug info only. If the verifier finds non-debug-info issues the parser will fail. For llc, the fix is to remove the check of alloca addr space in the parser and disable updating debug info, and defer the updating of debug info and verification to be after setting data layout of the IR by target. For other llvm tools, since they do not override data layout by target but instead can override data layout by a command line option, an argument for overriding data layout is added to the parser. In cases where data layout overriding is necessary for the parser, the data layout can be provided by command line. Differential Revision: https://reviews.llvm.org/D41832 llvm-svn: 323826
* Move the stripping of invalid debug info from the Verifier to AutoUpgrade.Adrian Prantl2017-10-021-11/+13
| | | | | | | | | | | | | | | | | | | | | | | | This came out of a recent discussion on llvm-dev (https://reviews.llvm.org/D38042). Currently the Verifier will strip the debug info metadata from a module if it finds the dbeug info to be malformed. This feature is very valuable since it allows us to improve the Verifier by making it stricter without breaking bcompatibility, but arguable the Verifier pass should not be modifying the IR. This patch moves the stripping of broken debug info into AutoUpgrade (UpgradeDebugInfo to be precise), which is a much better location for this since the stripping of malformed (i.e., produced by older, buggy versions of Clang) is a (harsh) form of AutoUpgrade. This change is mostly NFC in nature, the one big difference is the behavior when LLVM module passes are introducing malformed debug info. Prior to this patch, a NoAsserts build would have printed a warning and stripped the debug info, after this patch the Verifier will report a fatal error. I believe this behavior is actually more desirable anyway. Differential Revision: https://reviews.llvm.org/D38184 llvm-svn: 314699
* [AsmParser] Expose an API to parse a string starting with a type.Quentin Colombet2016-03-081-1/+18
| | | | | | | | | | | | Without actually parsing a type it is difficult to perdict where the type definition ends. In other words, instead of expecting the user of the parser API to hand over only the relevant bits of the string being parsed, take the whole string, parse the type, and get back the number of characters that have been read. This will be used by the MIR testing infrastructure. llvm-svn: 262884
* [AsmParser] Add a function to parse a standalone type.Quentin Colombet2016-03-071-0/+12
| | | | | | | This is useful for MIR serialization. Indeed generic machine instructions must have a type and we don't want to duplicate the logic in the MIParser. llvm-svn: 262868
* AsmParser: Save and restore the parsing state for types using SlotMapping.Alex Lorenz2015-08-211-2/+2
| | | | | | | | | | | | | | | | | | | | | This commit extends the 'SlotMapping' structure and includes mappings for named and numbered types in it. The LLParser is extended accordingly to fill out those mappings at the end of module parsing. This information is useful when we want to parse standalone constant values at a later stage using the 'parseConstantValue' method. The constant values can be constant expressions, which can contain references to types. In order to parse such constant values, we have to restore the internal named and numbered mappings for the types in LLParser, otherwise the parser will report a parsing error. Therefore, this commit also introduces a new method called 'restoreParsingState' to LLParser, which uses the slot mappings to restore some of its internal parsing state. This commit is required to serialize constant value pointers in the machine memory operands for the MIR format. Reviewers: Duncan P. N. Exon Smith llvm-svn: 245740
* AsmParser: Add a function to parse a standalone constant value.Alex Lorenz2015-07-171-0/+12
| | | | | | | | | | | | | | This commit extends the interface provided by the AsmParser library by adding a function that allows the user to parse a standalone contant value. This change is useful for MIR serialization, as it will allow the MIR Parser to parse the constant values in a machine constant pool. Reviewers: Duncan P. N. Exon Smith Differential Revision: http://reviews.llvm.org/D10280 llvm-svn: 242579
* AsmParser: Extend the API to make the global value and metadata node slot ↵Alex Lorenz2015-06-231-8/+12
| | | | | | | | | | | | | | | | | | mappings publicly accessible. This commit creates a new structure called 'SlotMapping' in the AsmParser library. This structure can be passed into the public parsing APIs from the AsmParser library in order to extract the data structures that map from slot numbers to unnamed global values and metadata nodes. This change is useful for MIR Serialization, as the MIR Parser has to lookup the unnamed global values and metadata nodes by their slot numbers. Reviewers: Duncan P. N. Exon Smith Differential Revision: http://reviews.llvm.org/D10551 llvm-svn: 240427
* AsmParser: Require a terminating null character when creating memory buffer.Alex Lorenz2015-05-201-1/+1
| | | | | | | | | | | | | | | This commit modifies the memory buffer creation in the AsmParser library so that it requires a terminating null character. The LLLexer in the AsmParser library checks for EOF only when it sees a null character, thus it would be best to require it when creating a memory buffer so that the memory buffer constructor can verify that a terminating null character is indeed present. Reviewers: Duncan P. N. Exon Smith, Matthias Braun Differential Revision: http://reviews.llvm.org/D9883 llvm-svn: 237833
* Add missing includes. make_unique proliferated everywhere.Benjamin Kramer2015-03-011-0/+1
| | | | llvm-svn: 230909
* Remove std::move that was preventing return value optimization.Richard Trieu2015-01-171-1/+1
| | | | llvm-svn: 226356
* Pass a MemoryBufferRef when we can avoid taking ownership.Rafael Espindola2014-08-261-13/+10
| | | | | | | | | | | | | The attached patch simplifies a few interfaces that don't need to take ownership of a buffer. For example, both parseAssembly and parseBitcodeFile will parse the entire buffer before returning. There is no need to take ownership. Using a MemoryBufferRef makes it obvious in the type signature that there is no ownership transfer. llvm-svn: 216488
* Explicitly pass ownership of the MemoryBuffer to AddNewSourceBuffer using ↵David Blaikie2014-08-211-1/+1
| | | | | | std::unique_ptr llvm-svn: 216223
* Split parseAssembly into parseAssembly and parseAssemblyInto.Rafael Espindola2014-08-191-6/+13
| | | | | | | This should restore the functionality of parsing new code into an existing module without the confusing interface. llvm-svn: 216031
* Modernize the .ll parsing interface.Rafael Espindola2014-08-191-18/+17
| | | | | | | | | | * Use StringRef instead of std::string& * Return a std::unique_ptr<Module> instead of taking an optional module to write to (was not really used). * Use current comment style. * Use current naming convention. llvm-svn: 215989
* These classes only need a StringRef, not a MemoryBuffer.Rafael Espindola2014-08-181-2/+2
| | | | llvm-svn: 215945
* Pass a std::uinque_ptr to ParseAssembly to make the ownership explicit. NFC.Rafael Espindola2014-08-171-10/+9
| | | | llvm-svn: 215852
* Update the MemoryBuffer API to use ErrorOr.Rafael Espindola2014-07-061-4/+5
| | | | llvm-svn: 212405
* ParseIR: don't take ownership of the MemoryBufferAlp Toker2014-06-271-2/+1
| | | | | | | | | | clang was needlessly duplicating whole memory buffer contents in an attempt to satisfy unclear ownership semantics. Let's just hide internal LLVM quirks and present a simple non-owning interface. The public C API preserves previous behaviour for stability. llvm-svn: 211861
* Remove 'using std::errro_code' from lib.Rafael Espindola2014-06-131-2/+1
| | | | llvm-svn: 210871
* Don't use 'using std::error_code' in include/llvm.Rafael Espindola2014-06-121-0/+1
| | | | | | This should make sure that most new uses use the std prefix. llvm-svn: 210835
* Remove system_error.h.Rafael Espindola2014-06-121-1/+1
| | | | | | | This is a minimal change to remove the header. I will remove the occurrences of "using std::error_code" in a followup patch. llvm-svn: 210803
* [C++11] More 'nullptr' conversion. In some cases just using a boolean check ↵Craig Topper2014-04-151-4/+4
| | | | | | instead of comparing to nullptr. llvm-svn: 206252
* Replace OwningPtr<T> with std::unique_ptr<T>.Ahmed Charles2014-03-061-3/+2
| | | | | | | | | | This compiles with no changes to clang/lld/lldb with MSVC and includes overloads to various functions which are used by those projects and llvm which have OwningPtr's as parameters. This should allow out of tree projects some time to move. There are also no changes to libs/Target, which should help out of tree targets have time to move, if necessary. llvm-svn: 203083
* [C++11] Replace OwningPtr::take() with OwningPtr::release().Ahmed Charles2014-03-051-2/+2
| | | | llvm-svn: 202957
* Move the LLVM IR asm writer header files into the IR directory, as theyChandler Carruth2014-01-071-2/+2
| | | | | | | | | | | | | | | | | are part of the core IR library in order to support dumping and other basic functionality. Rename the 'Assembly' include directory to 'AsmParser' to match the library name and the only functionality left their -- printing has been in the core IR library for quite some time. Update all of the #includes to match. All of this started because I wanted to have the layering in good shape before I started adding support for printing LLVM IR using the new pass infrastructure, and commandline support for the new pass infrastructure. llvm-svn: 198688
* keep only the StringRef version of getFileOrSTDIN.Rafael Espindola2013-06-251-1/+1
| | | | llvm-svn: 184826
* Move all of the header files which are involved in modelling the LLVM IRChandler Carruth2013-01-021-1/+1
| | | | | | | | | | | | | | | | | | | | | into their new header subdirectory: include/llvm/IR. This matches the directory structure of lib, and begins to correct a long standing point of file layout clutter in LLVM. There are still more header files to move here, but I wanted to handle them in separate commits to make tracking what files make sense at each layer easier. The only really questionable files here are the target intrinsic tablegen files. But that's a battle I'd rather not fight today. I've updated both CMake and Makefile build systems (I think, and my tests think, but I may have missed something). I've also re-sorted the includes throughout the project. I'll be committing updates to Clang, DragonEgg, and Polly momentarily. llvm-svn: 171366
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-031-2/+2
| | | | | | | | | | | | | | | | | Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] llvm-svn: 169131
* Make SMDiagnostic a little more sane. Instead of passing around ↵Chris Lattner2011-10-161-1/+1
| | | | | | | | note/warning/error as a string, pass it around as an enum. llvm-svn: 142107
* MemoryBuffer now return an error_code and returns a OwningPtr<MemoryBuffer> ↵Michael J. Spencer2010-12-161-4/+3
| | | | | | via an out parm. llvm-svn: 121958
* Support/MemoryBuffer: Replace all uses of std::string *ErrMsg with ↵Michael J. Spencer2010-12-091-3/+4
| | | | | | error_code &ec. And fix clients. llvm-svn: 121379
* Don't print the filename twice in file-not-found errors.Dan Gohman2010-08-041-2/+1
| | | | llvm-svn: 110179
* enhance SMDiagnostic to also maintain a pointer to the SourceMgr.Chris Lattner2010-04-061-2/+2
| | | | | | | Add a simplified constructor for clients that don't have locations like "file not found" errors. llvm-svn: 100538
* Give llvm::SourceMgr the ability to have a client-specifiedChris Lattner2010-04-061-1/+1
| | | | | | diagnostic handler. llvm-svn: 100503
* stringref-ize the MemoryBuffer::get apis. This requiresChris Lattner2010-04-051-1/+1
| | | | | | a co-committed clang patch. llvm-svn: 100485
* Make the parser include the lower level error message in its own errorDan Gohman2010-01-211-1/+2
| | | | | | message, to be more informative. llvm-svn: 94072
* Use MemoryBuffer::getBufferIdentifier() in the AsmPrinter insteadDan Gohman2009-09-081-4/+3
| | | | | | | of requiring a name be passed in. This makes it use "<stdin>" instead of "-" and makes it more consistent with the Bitcode reader. llvm-svn: 81256
* Refactor common code from ParseAssemblyString and ParseAssemblyFile,Dan Gohman2009-09-021-19/+21
| | | | | | to expose a low-level interface for parsing from an existing MemoryBuffer. llvm-svn: 80803
* switch the .ll parser to use SourceMgr.Chris Lattner2009-07-021-8/+13
| | | | llvm-svn: 74735
* switch the .ll parser into SMDiagnostic.Chris Lattner2009-07-021-38/+6
| | | | llvm-svn: 74734
* Make the use of const with respect to LLVMContext sane. Hopefully this is ↵Owen Anderson2009-07-011-2/+2
| | | | | | | | the last time, for the moment, that I will need to make far-reaching changes. llvm-svn: 74655
* Hold the LLVMContext by reference rather than by pointer.Owen Anderson2009-07-011-2/+2
| | | | llvm-svn: 74640
* Add a pointer to the owning LLVMContext to Module. This requires threading ↵Owen Anderson2009-07-011-4/+5
| | | | | | | | | | LLVMContext through a lot of the bitcode reader and ASM parser APIs, as well as supporting it in all of the tools. Patches for Clang and LLVM-GCC to follow. llvm-svn: 74614
* Fix the path to llvm/Assembly/Parser.h in a comment.Dan Gohman2009-01-081-1/+1
| | | | llvm-svn: 61948
* Refactor some parser interfaces to fix PR3278 and a FIXME:Chris Lattner2009-01-041-11/+20
| | | | | | | ParseAssemblyString with a specified module would not parse into the module, it would create and return a new one. llvm-svn: 61635
* Down with trailing whitespace!Misha Brukman2009-01-021-9/+8
| | | | llvm-svn: 61594
* Reimplement the old and horrible bison parser for .ll files with a niceChris Lattner2009-01-021-46/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and clean recursive descent parser. This change has a couple of ramifications: 1. The parser code is about 400 lines shorter (in what we maintain, not including what is autogenerated). 2. The code should be significantly faster than the old code because we don't have to work around bison's poor handling of datatypes with ctors/dtors. This also makes the code much more resistant to memory leaks. 3. We now get caret diagnostics from the .ll parser, woo. 4. The actual diagnostics emited from the parser are completely different so a bunch of testcases had to be updated. 5. I now disallow "%ty = type opaque %ty = type i32". There was no good reason to support this, it was just an accident of the old implementation. I have no reason to think that anyone is actually using this. 6. The syntax for sticking a global variable has changed to make it unambiguous. I don't think anyone is depending on this since only clang supports this and it is not solid yet, so I'm not worried about anything breaking. 7. This gets rid of the last use of bison, and along with it the .cvs files. I'll prune this from the makefiles as a subsequent commit. There are a few minor cleanups that can be done after this commit (suggestions welcome!) but this passes dejagnu testing and is ready for its time in the limelight. llvm-svn: 61558
OpenPOWER on IntegriCloud