summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/Preprocessor.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* The __weak and __strong defines are common to all darwin targetsChris Lattner2009-04-071-8/+2
| | | | | | | | | | | and are even set in C mode. As such, move them to Targets.cpp. __OBJC_GC__ is also darwin specific, but seems reasonable to always define it when in objc-gc mode. This fixes rdar://6761450 llvm-svn: 68494
* Define __OPTIMIZE__ and __OPTIMIZE_SIZE__ if the -O[12] and -Os flags are ↵Anders Carlsson2009-04-061-0/+5
| | | | | | passed to the compiler. llvm-svn: 68450
* Put back __OBJC2__ definition.Fariborz Jahanian2009-03-261-4/+0
| | | | llvm-svn: 67802
* - Minor change to dump of ivar layout map.Fariborz Jahanian2009-03-261-0/+4
| | | | | | | | - Temporarily undef'ed __OBJC2__ in nonfragile objc abi mode as it was forcing ivar synthesis in a certain project which clang does not yet support. llvm-svn: 67766
* change the __VERSION__ string to be more sensible. It would be useful to ↵Chris Lattner2009-03-241-2/+1
| | | | | | include the clang version # too. llvm-svn: 67619
* rename the <predefines> buffer to <built-in> to solve PR3849.Chris Lattner2009-03-201-4/+11
| | | | | | | | | | | | | | Add a #include directive around the command line buffer so that diagnostics generated from -include directives get diagnostics like: In file included from <built-in>:98: In file included from <command line>:3: ./t.h:2:1: warning: type specifier missing, defaults to 'int' b; ^ llvm-svn: 67396
* pass LangOptions into TargetInfo::getTargetDefines, so that targetsChris Lattner2009-03-201-1/+1
| | | | | | can have language-specific defines. llvm-svn: 67375
* (Hopefully) instantiate dependent array types correctly.Anders Carlsson2009-03-151-0/+3
| | | | llvm-svn: 67032
* make Preprocessor::Diags be a pointer instead of a reference.Chris Lattner2009-03-131-1/+1
| | | | llvm-svn: 66955
* fix PR3768, Clang does -D__STDC_HOSTED__=1, even if -ffreestanding is passed.Chris Lattner2009-03-091-1/+5
| | | | llvm-svn: 66474
* Fix warnings in build on clang-x86_64-freebsd buildbot.Mike Stump2009-03-071-1/+1
| | | | llvm-svn: 66344
* improve compatibility with GCC 4.4, patch by Michel Salim (PR3697)Chris Lattner2009-03-021-0/+1
| | | | llvm-svn: 65884
* Clean up and document code modification hints.Douglas Gregor2009-02-271-1/+19
| | | | llvm-svn: 65641
* switch the macroinfo argument lists from being allocated off the heapChris Lattner2009-02-201-1/+1
| | | | | | | | | to being allocated from the same bumpptr that the MacroInfo objects themselves are. This speeds up -Eonly cocoa.h pth by ~4%, fsyntax-only is barely measurable. llvm-svn: 65195
* detemplatify setArgumentList and some other cleanups.Chris Lattner2009-02-201-1/+0
| | | | llvm-svn: 65187
* require the MAcroInfo objects are explcitly destroyed.Chris Lattner2009-02-201-0/+1
| | | | llvm-svn: 65179
* update comment.Chris Lattner2009-02-181-5/+1
| | | | llvm-svn: 64939
* Fix some issues handling sub-token locations that come from macro expansions.Chris Lattner2009-02-181-1/+1
| | | | | | | | | | | | | | | We now emit: t.m:6:15: warning: field width should have type 'int', but argument has type 'unsigned int' printf(STR, (unsigned) 1, 1); ^ ~~~~~~~~~~~~ t.m:3:18: note: instantiated from: #define STR "abc%*ddef" ^ which has the correct location in the string literal in the note line. llvm-svn: 64936
* define __OBJC2__ for objc's nonfragile abi.Fariborz Jahanian2009-02-161-0/+2
| | | | llvm-svn: 64642
* Add support for deprecated members of RecordDecls (e.g. struct fields).Chris Lattner2009-02-161-2/+0
| | | | llvm-svn: 64634
* track "just a little more" location information for macro instantiations.Chris Lattner2009-02-151-1/+2
| | | | | | | | | | | | Now instead of just tracking the expansion history, also track the full range of the macro that got replaced. For object-like macros, this doesn't change anything. For _Pragma and function-like macros, this means we track the locations of the ')'. This is required for PR3579 because apparently GCC uses the line of the ')' of a function-like macro as the location to expand __LINE__ to. llvm-svn: 64601
* Give TargetInfo a new IntPtrType to hold the intptr_t type forChris Lattner2009-02-131-0/+1
| | | | | | | | | | a target. Make Preprocessor.cpp define a new __INTPTR_TYPE__ macro based on this. On linux/32, set intptr_t to int, instead of long. This fixes PR3563. llvm-svn: 64495
* Fix rdar://6562329, a static analyzer crash Ted noticed on Chris Lattner2009-02-131-1/+4
| | | | | | | | | | | | | | wine sources. This was happening because HighlightMacros was calling EnterMainFile multiple times on the same preprocessor object and getting an assert due to the new #line stuff (the file in question was bison output with #line directives). The fix for this is to not reenter the file. Instead, relex the tokens in raw mode, swizzle them a bit and repreprocess the token stream. An added bonus of this is that rewrite macros will now hilight the macro definition as well as its uses. Woo. llvm-svn: 64480
* PTH: Cache stat information for files in the PTH file. Hook up FileManagerTed Kremenek2009-02-121-0/+6
| | | | | | | | | | | | | to use this stat information in the PTH file using a 'StatSysCallCache' object. Performance impact (Cocoa.h, PTH): - number of stat calls reduces from 1230 to 425 - fsyntax-only: time improves by 4.2% We can reduce the number of stat calls to almost zero by caching negative stat calls and directory stat calls in the PTH file as well. llvm-svn: 64353
* Export __INT8_TYPE__ / __INT16_TYPE__ / __INT32_TYPE__ / __INT64_TYPE__Chris Lattner2009-02-061-8/+29
| | | | | | | in a gcc 4.5 compatible way so that stdint.h can follow the compiler's notion of types. llvm-svn: 63976
* -funsigned-char sets __CHAR_UNSIGNED__Chris Lattner2009-02-061-0/+3
| | | | llvm-svn: 63942
* Add an implementation of -dM that follows GCC closely enough to permitChris Lattner2009-02-061-1/+1
| | | | | | | diffing the output of: clang -dM -o - -E -x c foo.c | sort llvm-svn: 63926
* get __WCHAR_TYPE__ from the targetinfo hookChris Lattner2009-02-061-4/+4
| | | | llvm-svn: 63920
* simplify and refactor a bunch of type definition code in PreprocessorChris Lattner2009-02-061-60/+13
| | | | | | predefines buffer initialization. llvm-svn: 63919
* remove some ad-hocery and use DefineTypeSize for more things.Chris Lattner2009-02-061-27/+7
| | | | | | Now you too can have a 47 bit long long! llvm-svn: 63918
* refactor some code into a DefineTypeSize function.Chris Lattner2009-02-061-6/+21
| | | | llvm-svn: 63917
OpenPOWER on IntegriCloud