Douglas Gregor
d26129a98a
Fix the #include search path when reading from stdin, from Jon Simons!
...
Fixes PR4897.
llvm-svn: 110440
2010-08-06 12:06:13 +00:00
Chris Lattner
fb24a3a4ec
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.
llvm-svn: 101939
2010-04-20 20:35:58 +00:00
Chris Lattner
72286d6129
add a PPCallback handler for a skipped #include, patch by
...
Zhanyong Wan!
llvm-svn: 101813
2010-04-19 20:44:31 +00:00
Chris Lattner
c745cec17c
Improve line marker directive locations, patch by Jordy Rose
...
llvm-svn: 101226
2010-04-14 04:28:50 +00:00
Douglas Gregor
a771f46c82
Reinstate my CodeModificationHint -> FixItHint renaming patch, without
...
the C-only "optimization".
llvm-svn: 100022
2010-03-31 17:46:05 +00:00
Douglas Gregor
30e631862f
Revert r100008, which inexplicably breaks the clang-i686-darwin10 builder
...
llvm-svn: 100018
2010-03-31 17:25:35 +00:00
Douglas Gregor
3baad0d4f7
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.
llvm-svn: 100008
2010-03-31 15:31:50 +00:00
Douglas Gregor
dc970f0866
Audit all Preprocessor::getSpelling() callers, improving failure
...
recovery for those that need it.
llvm-svn: 98689
2010-03-16 22:30:13 +00:00
Douglas Gregor
42fe858cd6
Audit all callers of SourceManager::getCharacterData(); update some of
...
them to recover more gracefully on failure.
llvm-svn: 98672
2010-03-16 20:46:42 +00:00
Kovarththanan Rajaratnam
ba2c65277a
Use SmallString instead of SmallVector
...
llvm-svn: 98436
2010-03-13 10:17:05 +00:00
Benjamin Kramer
0a1abd4088
Add an overload of Preprocessor::getSpelling which takes a SmallVector and
...
returns a StringRef. Use it to simplify some repetitive code.
llvm-svn: 97322
2010-02-27 13:44:12 +00:00
Chris Lattner
aa1cccbbef
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.
llvm-svn: 95972
2010-02-12 08:03:27 +00:00
Chris Lattner
fde85356c6
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.
llvm-svn: 94120
2010-01-22 00:14:44 +00:00
Chris Lattner
f406b2402d
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.
llvm-svn: 93794
2010-01-18 22:33:01 +00:00
Chris Lattner
d081f8c851
stringref'ize a bunch of filename handling logic. Much
...
nicer than passing around two const char*'s.
llvm-svn: 93094
2010-01-10 01:35:12 +00:00
Chris Lattner
abcbb7c05b
clarify comment.
...
llvm-svn: 93084
2010-01-10 00:35:27 +00:00
Chris Lattner
2ceb625f59
implement rdar://7520940: published framework headers should
...
import other headers within the same framework with the full
framework path, not with a relative include.
llvm-svn: 93083
2010-01-10 00:24:58 +00:00
Benjamin Kramer
14488464be
Convert to StringRef, avoid a memcpy in the common case.
...
llvm-svn: 92357
2009-12-31 13:32:38 +00:00
Chris Lattner
8cf1f935c2
formatting changes.
...
llvm-svn: 91263
2009-12-14 04:54:40 +00:00
Daniel Dunbar
1776679e71
Change Preprocessor::EnterSourceFile to make ErrorStr non-optional, clients should be forced to deal with error conditions.
...
llvm-svn: 90700
2009-12-06 09:19:12 +00:00
Chris Lattner
ed3b360290
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"
^
llvm-svn: 90276
2009-12-01 22:52:33 +00:00
Chris Lattner
710bb87147
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".
llvm-svn: 90110
2009-11-30 04:18:44 +00:00
John Thompson
b535352681
Re-arranged some internal functions for coming __has_include changes.
...
llvm-svn: 85589
2009-10-30 13:49:06 +00:00
Daniel Dunbar
2c422dc9ca
Move clients to use IdentifierInfo::getNameStart() instead of getName()
...
llvm-svn: 84436
2009-10-18 20:26:12 +00:00
Mike Stump
11289f4280
Remove tabs, and whitespace cleanups.
...
llvm-svn: 81346
2009-09-09 15:08:12 +00:00
Daniel Dunbar
48b4d1e27e
There is no need to value initialize this array.
...
llvm-svn: 75517
2009-07-13 21:48:50 +00:00
Chris Lattner
83bd8281e5
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
llvm-svn: 72388
2009-05-25 17:16:10 +00:00
Daniel Dunbar
0721c2c155
In assembler-with-cpp mode, don't error on '#' (stringize) operator applied to
...
non-argument names, pass the tokens through.
llvm-svn: 72283
2009-05-22 21:35:34 +00:00
Jay Foad
7d0479f2c2
Use v.data() instead of &v[0] when SmallVector v might be empty.
...
llvm-svn: 72210
2009-05-21 09:52:38 +00:00
Chris Lattner
d6e97af74a
improve MacroInfo to track the source range of the macro definition,
...
patch by Alexei Svitkine!
llvm-svn: 69659
2009-04-21 04:46:33 +00:00
Chris Lattner
cd6d4b105a
add a preprocessor callback function for #undef, patch by
...
Alexei Svitkine!
llvm-svn: 69656
2009-04-21 03:42:09 +00:00
Chris Lattner
249c38bb02
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.
llvm-svn: 69530
2009-04-19 18:26:34 +00:00
Chris Lattner
d66f172ab1
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.
llvm-svn: 69454
2009-04-18 18:35:15 +00:00
Chris Lattner
5ca5d40cf4
second half of PR3940: #line requires simple digit sequence.
...
llvm-svn: 69422
2009-04-18 06:38:24 +00:00
Chris Lattner
2425bcb49a
enforce requirements imposed by C90 6.8 TC1, fixing PR3919.
...
llvm-svn: 69415
2009-04-18 02:23:25 +00:00
Chris Lattner
bc63de144f
Fix PR3938 by taking into account C99 6.10p4.
...
llvm-svn: 69413
2009-04-18 01:34:22 +00:00
Chris Lattner
b40289b2b8
Fix two problems from PR3916, and one problem I noticed while hacking
...
on the code.
llvm-svn: 69404
2009-04-17 23:56:52 +00:00
Chris Lattner
ca556cb3e3
implement PR3940: #line numbers not fully checked
...
llvm-svn: 69403
2009-04-17 23:37:49 +00:00
Chris Lattner
0003c27f5e
#line is allowed to have macros that expand to nothing after them.
...
llvm-svn: 69401
2009-04-17 23:30:53 +00:00
Chris Lattner
825676afdf
Offer a fixit hint for our warning about tokens at the end of a directive:
...
t.c:3:8: warning: extra tokens at end of #endif directive
#endif foo
^
//
Don't do this in strict-C89 mode because bcpl comments aren't
valid there, and it is too much trouble to analyze whether
C block comments are safe.
llvm-svn: 69024
2009-04-14 05:15:20 +00:00
Chris Lattner
ce2ab6f425
Fix the #import / #include_next "extra tokens at end of #foo directive"
...
Warning to properly report that it is an import/include_next instead of
claiming it is a #include.
llvm-svn: 69023
2009-04-14 05:07:49 +00:00
Daniel Dunbar
2cba6be499
Fix assertion failure in PTH when tokens followed a closing #endif.
...
- Ted, please check.
- Missing test case because PTH won't reliably cache the tokens in a
test case. *cough*
llvm-svn: 68966
2009-04-13 17:57:49 +00:00
Chris Lattner
928e9096cb
add a ppcallback hook for macro definitions.
...
llvm-svn: 68883
2009-04-12 01:39:54 +00:00
Chris Lattner
e01d82b81f
finish the implementation of -imacros. The driver still needs to be hooked up.
...
llvm-svn: 68640
2009-04-08 20:53:24 +00:00
Chris Lattner
58a1eb0ba0
reject the #__include_macros directive unless it comes from the
...
predefines buffer.
llvm-svn: 68627
2009-04-08 18:46:40 +00:00
Chris Lattner
14a7f39733
Add initial support for -imacros. Right now it has the same semantics as
...
-include, but that will be fixed soon.
llvm-svn: 68625
2009-04-08 18:24:34 +00:00
Chris Lattner
839150e0d2
push line markers through -E mode.
...
llvm-svn: 67854
2009-03-27 17:13:49 +00:00
Chris Lattner
2d17ab783b
when preprocessing a .S file, unknown directives should just be passed through,
...
and the token after the # should be expanded if it is not a valid directive.
This allows us to transform things like:
#define FOO BAR
# FOO
into # BAR, even though FOO is not normally expanded for directives.
This should fix PR3833
llvm-svn: 67236
2009-03-18 21:00:25 +00:00
Chris Lattner
5eb8ae2453
This is not considered a preprocessor directive in .S files:
...
# 4
llvm-svn: 67233
2009-03-18 20:41:10 +00:00
Chris Lattner
80c21df8ea
use accessor instead of poking ivar directly
...
llvm-svn: 66954
2009-03-13 21:17:23 +00:00