Граф коммитов

110 Коммитов

Автор SHA1 Сообщение Дата
Douglas Gregor ecdcb883cb Extend the preprocessing record and libclang with support for
inclusion directives, keeping track of every #include, #import,
etc. in the translation unit. We keep track of the source location and
kind of the inclusion, how the file name was spelled, and the
underlying file to which the inclusion resolved.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116952 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-20 22:00:55 +00:00
Ted Kremenek 9714a2385c Really^2 fix <rdar://problem/8361834>, this time without crashing.
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116869 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-19 22:15:20 +00:00
Ted Kremenek 52a4ff6eae Revert most of r116862. It isn't quite the right fix for a memory leak in Preprocessor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116864 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-19 21:40:34 +00:00
Ted Kremenek ea35f7775f Really fix: <rdar://problem/8361834> MacroInfo::AddTokenToBody() leaks memory
The problem was not the management of MacroInfo objects, but that when we recycle them
via the MICache the memory of the underlying SmallVector (within MacroInfo) was not getting
released.  This is because objects stashed into MICache simply are reused with a placement
new, and never have their destructor called.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116862 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-19 21:30:15 +00:00
Ted Kremenek af8fa25c0d Simplify lifetime management of MacroInfo objects in Preprocessor by having 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>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116842 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-19 18:16:54 +00:00
Douglas Gregor 80c60f7284 When we parse a pragma, keep track of how that pragma was originally
spelled (#pragma, _Pragma, __pragma). In -E mode, use that information
to add appropriate newlines when translating _Pragma and __pragma into
#pragma, like GCC does. Fixes <rdar://problem/8412013>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113553 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-09 22:45:38 +00:00
Douglas Gregor 1fbb447e9d Implement preprocessor code completion where a macro name is expected,
e.g., after #ifdef/#ifndef or #undef, or inside a defined <macroname>
expression in a preprocessor conditional.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111954 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-24 20:21:13 +00:00
Douglas Gregor f44e854ed1 Introduce basic code-completion support for preprocessor directives,
e.g., after a "#" we'll suggest #if, #ifdef, etc.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111943 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-24 19:08:16 +00:00
Eli Friedman a7e6845660 Detabify.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111768 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-22 01:00:03 +00:00
Chris Lattner 2c1ab9079c no need to pass bumppointer allocator into macroinfo::destroy
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111364 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-18 16:08:51 +00:00
Chris Lattner f47724bf78 Implement #pragma push_macro, patch by Francois Pichet!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111234 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-17 15:55:45 +00:00
Douglas Gregor 2d474ba9e8 Don't emit end-of-file diagnostics like "unterminated conditional" or
"unterminated string" when we're performing code completion.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110933 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-12 17:04:55 +00:00
Douglas Gregor 10fe93d57c Revert r110440, the fix for PR4897. Chris claims to have a better way.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110544 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-08 07:49:23 +00:00
Benjamin Kramer 2f05449fa1 Push location through the MacroUndefined PPCallback and use it to print #undefs in -dD mode. (PR7818)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110523 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-07 22:27:00 +00:00
Douglas Gregor 91db30ad4a Fix the #include search path when reading from stdin, from Jon Simons!
Fixes PR4897.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110440 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-06 12:06:13 +00:00
Chris Lattner e127a0d801 push some source location information down through the compiler,
into ContentCache::getBuffer.  This allows it to produce 
diagnostics on the broken #include line instead of without a 
location.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101939 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-20 20:35:58 +00:00
Chris Lattner 6fbe3ebeae add a PPCallback handler for a skipped #include, patch by
Zhanyong Wan!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101813 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-19 20:44:31 +00:00
Chris Lattner 86d0ef7430 Improve line marker directive locations, patch by Jordy Rose
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101226 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-14 04:28:50 +00:00
Douglas Gregor 849b243d40 Reinstate my CodeModificationHint -> FixItHint renaming patch, without
the C-only "optimization".


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100022 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31 17:46:05 +00:00
Douglas Gregor 275313cbb0 Revert r100008, which inexplicably breaks the clang-i686-darwin10 builder
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100018 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31 17:25:35 +00:00
Douglas Gregor d0ebe080ee Rename CodeModificationHint to FixItHint, since we've been using the
term "fix-it" everywhere and even *I* get tired of long names
sometimes. No functionality change.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100008 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31 15:31:50 +00:00
Douglas Gregor 453091cc20 Audit all Preprocessor::getSpelling() callers, improving failure
recovery for those that need it.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98689 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-16 22:30:13 +00:00
Douglas Gregor a543016fe0 Audit all callers of SourceManager::getCharacterData(); update some of
them to recover more gracefully on failure.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98672 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-16 20:46:42 +00:00
Kovarththanan Rajaratnam 193575455e Use SmallString instead of SmallVector
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98436 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-13 10:17:05 +00:00
Benjamin Kramer ddeea56443 Add an overload of Preprocessor::getSpelling which takes a SmallVector and
returns a StringRef. Use it to simplify some repetitive code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97322 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-27 13:44:12 +00:00
Chris Lattner 13d283d6a2 Fix PR6282: the include guard optimization cannot happen if the
guard macro is already defined for the first occurrence of the
header.  If it is, the body will be skipped and not be properly
analyzed for the include guard optimization.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95972 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-12 08:03:27 +00:00
Chris Lattner f45b646244 revert my patch for rdar://7520940 that warns when a published header
is #included with "foo.h" style syntax instead of framework syntax.
It produced too much noise.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94120 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 00:14:44 +00:00
Chris Lattner 2c6b193d57 simplify the code for skipping in a #if 0 block. The CurLexer
pointer is always non-null because the PTH case exits earlier
in the method.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93794 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 22:33:01 +00:00
Chris Lattner a139481e62 stringref'ize a bunch of filename handling logic. Much
nicer than passing around two const char*'s.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93094 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 01:35:12 +00:00
Chris Lattner c1abafc4fa clarify comment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93084 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 00:35:27 +00:00
Chris Lattner 804f652719 implement rdar://7520940: published framework headers should
import other headers within the same framework with the full
framework path, not with a relative include.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93083 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 00:24:58 +00:00
Benjamin Kramer b939a4e8b4 Convert to StringRef, avoid a memcpy in the common case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92357 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 13:32:38 +00:00
Chris Lattner 1d9c54df56 formatting changes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91263 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-14 04:54:40 +00:00
Daniel Dunbar 63ceaa32a2 Change Preprocessor::EnterSourceFile to make ErrorStr non-optional, clients should be forced to deal with error conditions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90700 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-06 09:19:12 +00:00
Chris Lattner 39d9841ed4 pass the reason for failure up from MemoryBuffer and report it
in diagnostics when we fail to open a file.  This allows us to
report things like:

$ clang test.c -I.
test.c:2:10: fatal error: error opening file './foo.h': Permission denied
#include "foo.h"
         ^



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90276 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-01 22:52:33 +00:00
Chris Lattner 6e2901407b Fix PR5633 by making the preprocessor handle the case where we can
stat a file but where mmaping it fails.  In this case, we emit an
error like:
t.c:1:10: fatal error: error opening file '../../foo.h'

instead of "cannot find file".



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90110 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-30 04:18:44 +00:00
John Thompson a28cc090f2 Re-arranged some internal functions for coming __has_include changes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85589 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-30 13:49:06 +00:00
Daniel Dunbar e013d685c6 Move clients to use IdentifierInfo::getNameStart() instead of getName()
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84436 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-18 20:26:12 +00:00
Mike Stump 1eb4433ac4 Remove tabs, and whitespace cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81346 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-09 15:08:12 +00:00
Daniel Dunbar 3d399a0101 There is no need to value initialize this array.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75517 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-13 21:48:50 +00:00
Chris Lattner 3240469102 Fix a couple of bugs:
1. When we accept "#garbage" in asm-with-cpp mode, change the token kind
   of the # to unknown so that the preprocessor won't try to process it as
   a real #.  This fixes a crash on the attached example
2. Fix macro definition extents processing to handle #foo at the end of a
   macro to say the definition ends with the foo, not the #.

This is a follow-on fix to r72283, and rdar://6916026


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72388 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-25 17:16:10 +00:00
Daniel Dunbar c25d805895 In assembler-with-cpp mode, don't error on '#' (stringize) operator applied to
non-argument names, pass the tokens through.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72283 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-22 21:35:34 +00:00
Jay Foad beaaccd8e2 Use v.data() instead of &v[0] when SmallVector v might be empty.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72210 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-21 09:52:38 +00:00
Chris Lattner 2451b528fe improve MacroInfo to track the source range of the macro definition,
patch by Alexei Svitkine!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69659 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21 04:46:33 +00:00
Chris Lattner 41c17473e3 add a preprocessor callback function for #undef, patch by
Alexei Svitkine!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69656 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21 03:42:09 +00:00
Chris Lattner 8fde5978a6 Fix PR4006, incorrect handling of __VA_ARGS__ when it was the first token
in a function-like macro body.  This has the added bonus of moving some
function-like macro specific code out of the object-like macro codepath.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69530 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19 18:26:34 +00:00
Chris Lattner dc8c90da15 more fun with line markers: the digit string is required to be interpreted
as decimal, even if it starts with 0.  Also, since things like 0x1 are
completely illegal, don't even bother using numericliteralparser for them.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69454 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 18:35:15 +00:00
Chris Lattner bc81682756 second half of PR3940: #line requires simple digit sequence.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69422 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 06:38:24 +00:00
Chris Lattner 6272bcfe5d enforce requirements imposed by C90 6.8 TC1, fixing PR3919.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69415 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 02:23:25 +00:00
Chris Lattner 8fe00e783e Fix PR3938 by taking into account C99 6.10p4.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69413 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 01:34:22 +00:00