summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/Preprocessor.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Introduced raw_identifier token kind.Abramo Bagnara2010-12-221-13/+22
| | | | llvm-svn: 122394
* now the FileManager has a FileSystemOpts ivar, stop threadingChris Lattner2010-11-231-1/+1
| | | | | | | | | FileSystemOpts through a ton of apis, simplifying a lot of code. This also fixes a latent bug in ASTUnit where it would invoke methods on FileManager without creating one in some code paths in cindextext. llvm-svn: 120010
* move getSpelling from Preprocessor to Lexer, which it is more conceptually ↵Chris Lattner2010-11-171-110/+0
| | | | | | related to. llvm-svn: 119479
* move AdvanceToTokenCharacter and getLocForEndOfToken fromChris Lattner2010-11-171-62/+0
| | | | | | Preprocessor to Lexer where they make more sense. llvm-svn: 119474
* add a static version of PP::AdvanceToTokenCharacter.Chris Lattner2010-11-171-5/+8
| | | | llvm-svn: 119472
* add a static form of the efficient PP::getSpelling method.Chris Lattner2010-11-171-2/+4
| | | | llvm-svn: 119469
* Implement -working-directory.Argyrios Kyrtzidis2010-11-031-1/+2
| | | | | | | | | | | | | | | | | | | When -working-directory is passed in command line, file paths are resolved relative to the specified directory. This helps both when using libclang (where we can't require the user to actually change the working directory) and to help reproduce test cases when the reproduction work comes along. --FileSystemOptions is introduced which controls how file system operations are performed (currently it just contains the working directory value if set). --FileSystemOptions are passed around to various interfaces that perform file operations. --Opening & reading the content of files should be done only through FileManager. This is useful in general since file operations will be abstracted in the future for the reproduction mechanism. FileSystemOptions is independent of FileManager so that we can have multiple translation units sharing the same FileManager but with different FileSystemOptions. Addresses rdar://8583824. llvm-svn: 118203
* Really^2 fix <rdar://problem/8361834>, this time without crashing.Ted Kremenek2010-10-191-1/+2
| | | | | | | | | Now MICache is a linked list (per the FIXME), where we tradeoff between MacroInfo objects being in MICache and MIChainHead. MacroInfo objects in the MICache chain are already "Destroy()'ed", so they can be reused. When inserting into MICache, we need to remove them from the regular linked list so that they aren't destroyed more than once. llvm-svn: 116869
* Simplify loop. No functionality change.Ted Kremenek2010-10-191-4/+1
| | | | llvm-svn: 116861
* Simplify lifetime management of MacroInfo objects in Preprocessor by having ↵Ted Kremenek2010-10-191-24/+5
| | | | | | | | | | | | the Preprocessor maintain them in a linked list of allocated MacroInfos. This requires only 1 extra pointer per MacroInfo object, and allows us to blow them away in one place. This fixes an elusive memory leak with MacroInfos (whose exact location I couldn't still figure out despite substantial digging). Fixes <rdar://problem/8361834>. llvm-svn: 116842
* In ~Preprocessor(), also cleanup the MacroInfo objects left-over from stray ↵Ted Kremenek2010-10-191-0/+7
| | | | | | | | "#pragma push_macro" uses. This fixes a potential memory leak. llvm-svn: 116826
* Use getSpelling to get original text of theFariborz Jahanian2010-09-031-3/+1
| | | | | | c++ operator token. (radar 8328250). llvm-svn: 112977
* Patch to allow alternative representation of c++Fariborz Jahanian2010-09-031-1/+3
| | | | | | | operators (and, or, etc.) to be used as selectors to match g++'s behavior. llvm-svn: 112935
* Revert my user-defined literal commits - r1124{58,60,67} pendingAlexis Hunt2010-08-301-18/+8
| | | | | | some issues being sorted out. llvm-svn: 112493
* Implement C++0x user-defined string literals.Alexis Hunt2010-08-291-8/+18
| | | | | | | | | | The extra data stored on user-defined literal Tokens is stored in extra allocated memory, which is managed by the PreprocessorLexer because there isn't a better place to put it that makes sure it gets deallocated, but only after it's used up. My testing has shown no significant slowdown as a result, but independent testing would be appreciated. llvm-svn: 112458
* Tweak wording in an assertion, from dawn@burble.org.Douglas Gregor2010-08-261-1/+1
| | | | llvm-svn: 112182
* Introduce a preprocessor code-completion hook for contexts where weDouglas Gregor2010-08-251-0/+7
| | | | | | | expect "natural" language and should not provide any completions, e.g., comments, string literals, #error. llvm-svn: 112054
* Introduce basic code-completion support for preprocessor directives,Douglas Gregor2010-08-241-3/+6
| | | | | | e.g., after a "#" we'll suggest #if, #ifdef, etc. llvm-svn: 111943
* no need to pass bumppointer allocator into macroinfo::destroyChris Lattner2010-08-181-2/+2
| | | | llvm-svn: 111364
* Random temporary string cleanup.Benjamin Kramer2010-08-111-1/+1
| | | | llvm-svn: 110807
* Introduce basic support for loading a precompiled preamble whileDouglas Gregor2010-07-261-1/+8
| | | | | | | | | | | | | | | | | | | | | | | reparsing an ASTUnit. When saving a preamble, create a buffer larger than the actual file we're working with but fill everything from the end of the preamble to the end of the file with spaces (so the lexer will quickly skip them). When we load the file, create a buffer of the same size, filling it with the file and then spaces. Then, instruct the lexer to start lexing after the preamble, therefore continuing the parse from the spot where the preamble left off. It's now possible to perform a simple preamble build + parse (+ reparse) with ASTUnit. However, one has to disable a bunch of checking in the PCH reader to do so. That part isn't committed; it will likely be handled with some other kind of flag (e.g., -fno-validate-pch). As part of this, fix some issues with null termination of the memory buffers created for the preamble; we were trying to explicitly NULL-terminate them, even though they were also getting implicitly NULL terminated, leading to excess warnings about NULL characters in source files. llvm-svn: 109445
* Modify the pragma handlers to accept and use StringRefs instead of ↵Argyrios Kyrtzidis2010-07-131-1/+1
| | | | | | | | | | | IdentifierInfos. When loading the PCH, IdentifierInfos that are associated with pragmas cause declarations that use these identifiers to be deserialized (e.g. the "clang" pragma causes the "clang" namespace to be loaded). We can avoid this if we just use StringRefs for the pragmas. As a bonus, since we don't have to create and pass IdentifierInfos, the pragma interfaces get a bit more simplified. llvm-svn: 108237
* Fix memory leak in Preprocessor where MacroInfo objects in the MICache ↵Ted Kremenek2010-06-081-0/+8
| | | | | | | | wouldn't have their associated SmallVectors get deallocated. llvm-svn: 105658
* push some source location information down through the compiler,Chris Lattner2010-04-201-5/+3
| | | | | | | | into ContentCache::getBuffer. This allows it to produce diagnostics on the broken #include line instead of without a location. llvm-svn: 101939
* Match MemoryBuffer API changes.Chris Lattner2010-04-051-5/+4
| | | | llvm-svn: 100484
* PPCallbacks: Add hook for reaching the end of the main file, and fix ↵Daniel Dunbar2010-03-231-0/+5
| | | | | | DependencyFile to not do work in its destructor. llvm-svn: 99257
* Make the preprocessing record a PPCallbacks subclass itself,Douglas Gregor2010-03-191-39/+3
| | | | | | | | eliminating the extra PopulatePreprocessingRecord object. This will become useful once we start writing the preprocessing record to precompiled headers. llvm-svn: 98966
* Optionally store a PreprocessingRecord in the preprocessor itself, andDouglas Gregor2010-03-191-0/+45
| | | | | | tie its creation to a CC1 flag -detailed-preprocessing-record. llvm-svn: 98963
* Entering the main source file in the preprocessor can fail if theDouglas Gregor2010-03-171-5/+4
| | | | | | source file has been changed. Handle that failure more gracefully. llvm-svn: 98727
* Audit all callers of SourceManager::getCharacterData(); update some ofDouglas Gregor2010-03-161-2/+3
| | | | | | them to recover more gracefully on failure. llvm-svn: 98672
* Teach the one caller of SourceManager::getMemoryBufferForFile() to cope with ↵Douglas Gregor2010-03-161-2/+3
| | | | | | errors llvm-svn: 98664
* Introduce optional "Invalid" parameters to routines that invoke theDouglas Gregor2010-03-161-9/+26
| | | | | | | | | | | | | SourceManager's getBuffer() and, therefore, could fail, along with Preprocessor::getSpelling(). Use the Invalid parameters in the literal parsers (string, floating point, integral, character) to make them robust against errors that stem from, e.g., PCH files that are not consistent with the underlying file system. I still need to audit every use caller to all of these routines, to determine which ones need specific handling of error conditions. llvm-svn: 98608
* Use SmallString instead of SmallVectorKovarththanan Rajaratnam2010-03-131-23/+23
| | | | llvm-svn: 98436
* Move method out-of-line. I thought this would be a candidate for inlining ↵Benjamin Kramer2010-02-271-1/+18
| | | | | | but I was wrong. llvm-svn: 97330
* Add an overload of Preprocessor::getSpelling which takes a SmallVector andBenjamin Kramer2010-02-271-4/+2
| | | | | | returns a StringRef. Use it to simplify some repetitive code. llvm-svn: 97322
* Fix subtle bug in Preprocessor::AdvanceToTokenCharacter(): use '+=' instead ↵Ted Kremenek2010-01-291-1/+1
| | | | | | of '='. llvm-svn: 94830
* Teach CIndex's cursor visitor to restrict its traversal to a specificDouglas Gregor2010-01-221-11/+7
| | | | | | | | | | | | | | region of interest (if provided). Implement clang_getCursor() in terms of this traversal rather than using the Index library; the unified cursor visitor is more complete, and will be The Way Forward. Minor other tweaks needed to make this work: - Extend Preprocessor::getLocForEndOfToken() to accept an offset from the end, making it easy to move to the last character in the token (rather than just past the end of the token). - In Lexer::MeasureTokenLength(), the length of whitespace is zero. llvm-svn: 94200
* allow the HandlerComment callback to push tokens into theChris Lattner2010-01-181-3/+10
| | | | | | | preprocessor. This could be used by an OpenMP implementation or something. Patch by Abramo Bagnara! llvm-svn: 93795
* Teach Preprocessor::macro_begin/macro_end to lazily load all macroDouglas Gregor2010-01-041-3/+30
| | | | | | | | definitions from a precompiled header. This ensures that code-completion with macro names behaves the same with or without precompiled headers. llvm-svn: 92497
* Avoid an unnecessary copy of Predefines. getMemBufferCopy does the null ↵Benjamin Kramer2009-12-311-12/+3
| | | | | | termination for us. llvm-svn: 92358
* set up the machinery for a MacroArgs cache hanging off Preprocessor.Chris Lattner2009-12-151-1/+6
| | | | | | | | | We creating and free thousands of MacroArgs objects (and the related std::vectors hanging off them) for the testcase in PR5610 even though there are only ~20 live at a time. This doesn't actually use the cache yet. llvm-svn: 91391
* fix typoChris Lattner2009-12-141-1/+1
| | | | llvm-svn: 91343
* Don't expand tabs when computing the offset from the code-completion columnDouglas Gregor2009-12-081-8/+2
| | | | llvm-svn: 90881
* Change Preprocessor::EnterSourceFile to make ErrorStr non-optional, clients ↵Daniel Dunbar2009-12-061-2/+5
| | | | | | should be forced to deal with error conditions. llvm-svn: 90700
* Minor cleanup to the code-completion-point logic suggested by Chris.Douglas Gregor2009-12-031-1/+1
| | | | llvm-svn: 90459
* Extend the source manager with the ability to override the contents ofDouglas Gregor2009-12-021-1/+59
| | | | | | | | | | files with the contents of an arbitrary memory buffer. Use this new functionality to drastically clean up the way in which we handle file truncation for code-completion: all of the truncation/completion logic is now encapsulated in the preprocessor where it belongs (<rdar://problem/7434737>). llvm-svn: 90300
* Add static version of Preprocessor::getSpelling.Daniel Dunbar2009-11-141-2/+12
| | | | llvm-svn: 88732
* Wherein the TargetInfo argument to Preprocessor is made 'const' and propogated.Daniel Dunbar2009-11-131-1/+1
| | | | llvm-svn: 87087
* Allow Preprocessor to take ownership of the HeaderSearch object. I think it ↵Daniel Dunbar2009-11-111-1/+7
| | | | | | should probably always own the header search object, but I'm not sure... llvm-svn: 86882
* Make LookUpIdentifierInfo const. This makes the Identifiers table mutable and isDaniel Dunbar2009-11-051-1/+1
| | | | | | | | | a little fuzzy, but conceptually it's just uniquing the identifier. Chris, please review. I debated splitting into const/non-const versions where the const one propogated constness to the resulting IdentifierInfo*. llvm-svn: 86106
OpenPOWER on IntegriCloud