summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/Preprocessor.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* StringRefize Preprocessor::getIdentifierInfo.Daniel Dunbar2009-11-051-2/+2
| | | | llvm-svn: 86105
* Kill PreprocessorFactory, which was both morally repugnant and totally unused.Daniel Dunbar2009-11-041-2/+0
| | | | llvm-svn: 86076
* Move clients to use IdentifierInfo::getNameStart() instead of getName()Daniel Dunbar2009-10-181-1/+1
| | | | llvm-svn: 84436
* Add support for a chain of stat caches in the FileManager, rather thanDouglas Gregor2009-10-161-1/+1
| | | | | | | | | only supporting a single stat cache. The immediate benefit of this change is that we can now generate a PCH/AST file when including another PCH file; in the future, the chain of stat caches will likely be useful with multiple levels of PCH files. llvm-svn: 84263
* Replace the -code-completion-dump option with Douglas Gregor2009-09-221-8/+0
| | | | | | | | | | | -code-completion-at=filename:line:column which performs code completion at the specified location by truncating the file at that position and enabling code completion. This approach makes it possible to run multiple tests from a single test file, and gives a more natural command-line interface. llvm-svn: 82571
* Initial implementation of a code-completion interface in Clang. InDouglas Gregor2009-09-171-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | essence, code completion is triggered by a magic "code completion" token produced by the lexer [*], which the parser recognizes at certain points in the grammar. The parser then calls into the Action object with the appropriate CodeCompletionXXX action. Sema implements the CodeCompletionXXX callbacks by performing minimal translation, then forwarding them to a CodeCompletionConsumer subclass, which uses the results of semantic analysis to provide code-completion results. At present, only a single, "printing" code completion consumer is available, for regression testing and debugging. However, the design is meant to permit other code-completion consumers. This initial commit contains two code-completion actions: one for member access, e.g., "x." or "p->", and one for nested-name-specifiers, e.g., "std::". More code-completion actions will follow, along with improved gathering of code-completion results for the various contexts. [*] In the current -code-completion-dump testing/debugging mode, the file is truncated at the completion point and EOF is translated into "code completion". llvm-svn: 82166
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-38/+38
| | | | llvm-svn: 81346
* Replace cerr with errs().Benjamin Kramer2009-08-231-29/+29
| | | | llvm-svn: 79854
* Add support for retrieving the Doxygen comment associated with a givenDouglas Gregor2009-07-021-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | declaration in the AST. The new ASTContext::getCommentForDecl function searches for a comment that is attached to the given declaration, and returns that comment, which may be composed of several comment blocks. Comments are always available in an AST. However, to avoid harming performance, we don't actually parse the comments. Rather, we keep the source ranges of all of the comments within a large, sorted vector, then lazily extract comments via a binary search in that vector only when needed (which never occurs in a "normal" compile). Comments are written to a precompiled header/AST file as a blob of source ranges. That blob is only lazily loaded when one requests a comment for a declaration (this never occurs in a "normal" compile). The indexer testbed now supports comment extraction. When the -point-at location points to a declaration with a Doxygen-style comment, the indexer testbed prints the associated comment block(s). See test/Index/comments.c for an example. Some notes: - We don't actually attempt to parse the comment blocks themselves, beyond identifying them as Doxygen comment blocks to associate them with a declaration. - We won't find comment blocks that aren't adjacent to the declaration, because we start our search based on the location of the declaration. - We don't go through the necessary hops to find, for example, whether some redeclaration of a declaration has comments when our current declaration does not. Similarly, we don't attempt to associate a \param Foo marker in a function body comment with the parameter named Foo (although that is certainly possible). - Verification of my "no performance impact" claims is still "to be done". llvm-svn: 74704
* my refactoring of builtins changed target-specific builtins to only beChris Lattner2009-06-161-1/+1
| | | | | | | | | registered when PCH wasn't being used. We should always install (in BuiltinInfo) information about target-specific builtins, but we shouldn't register any builtin identifier infos. This fixes the build of apps that use PCH and target specific builtins together. llvm-svn: 73492
* Emit keyword extension warning in all modes, not just C99 mode.Eli Friedman2009-04-281-1/+3
| | | | llvm-svn: 70283
* Change Preprocessor::AdvanceToTokenCharacter to stop atChris Lattner2009-04-181-12/+21
| | | | | | | | | | the first real character of a token. For example, advancing to byte 3 of foo\ bar should stop at the b, not the \. llvm-svn: 69484
* fix typoChris Lattner2009-04-181-1/+1
| | | | llvm-svn: 69479
* Change Lexer::MeasureTokenLength to take a LangOptions reference.Chris Lattner2009-04-141-1/+1
| | | | | | | | | | | | | | | | | | This allows it to accurately measure tokens, so that we get: t.cpp:8:13: error: unknown type name 'X' static foo::X P; ~~~~~^ instead of the woefully inferior: t.cpp:8:13: error: unknown type name 'X' static foo::X P; ~~~~ ^ Most of this is just plumbing to push the reference around. llvm-svn: 69099
* implement the microsoft/gnu "__COUNTER__" macro: rdar://4329310Chris Lattner2009-04-131-1/+2
| | | | llvm-svn: 68933
* Compare the predefines buffer in the PCH file with the predefinesDouglas Gregor2009-04-101-4/+0
| | | | | | | | | | | | | | | buffer generated for the current translation unit. If they are different, complain and then ignore the PCH file. This effectively checks for all compilation options that somehow would affect preprocessor state (-D, -U, -include, the dreaded -imacros, etc.). When we do accept the PCH file, throw away the contents of the predefines buffer rather than parsing them, since all of the results of that parsing are already stored in the PCH file. This eliminates the ugliness with the redefinition of __builtin_va_list, among other things. llvm-svn: 68838
* do a dance with predefines, and finally enable reading of macros fromChris Lattner2009-04-101-1/+1
| | | | | | | PCH. This works now, except for limitations not being able to do things with identifiers. The basic example in the testcase works though. llvm-svn: 68832
* move a bunch of code for initializing the predefines buffer out of ↵Chris Lattner2009-04-101-335/+1
| | | | | | | | | | Preprocessor.cpp into clang-cc.cpp. This makes it so clang-cc constructs the *entire* predefines buffer, not just half of it. A bonus of this is that we get to kill a copy of DefineBuiltinMacro. llvm-svn: 68830
* PCH serialization/deserialization of the source manager. With thisDouglas Gregor2009-04-101-0/+4
| | | | | | | | | | | | improvement, source locations read from the PCH file will properly resolve to the source files that were used to build the PCH file itself. Once we have the preprocessor state stored in the PCH file, source locations that refer to macro instantiations that occur in the PCH file should have the appropriate instantiation information. llvm-svn: 68758
* More fixes to builtin preprocessor defines.Daniel Dunbar2009-04-081-2/+18
| | | | | | | | | | | | | | | | | | | | | - Add -static-define option driver can use when __STATIC__ should be defined (instead of __DYNAMIC__). - Don't set __OPTIMIZE_SIZE__ on Os, __OPTIMIZE_SIZE__ is tied to Oz. - Set __NO_INLINE__ following GCC 4.2. - Set __GNU_GNU_INLINE__ or __GNU_STDC_INLINE__ following GCC 4.2. - Set __EXCEPTIONS for Objective-C NonFragile ABI. - Set __STRICT_ANSI__ for standard conforming modes. - I added a clang style test case in utils for this, but its not particularly portable and I don't think it belongs in the test suite. llvm-svn: 68621
* Set __PIC__ (more) correctly.Daniel Dunbar2009-04-081-2/+11
| | | | | | | | | | | - Add -pic-level clang-cc option to specify the value for the define, updated driver to pass this. - Added __pic__ - Added OBJC_ZEROCOST_EXCEPTIONS define while I was here (to match gcc). llvm-svn: 68584
OpenPOWER on IntegriCloud