Commit Graph

534 Commits

Author SHA1 Message Date
Chris Lattner 93ddf80eb7 don't inform comment handlers about comments in #if 0 blocks,
doing so invalidates the file guard optimization and is not
in the spirit of "#if 0" because it is supposed to completely
skip everything, even if it isn't lexically valid. Patch by
Abramo Bagnara!

llvm-svn: 95253
2010-02-03 21:06:21 +00:00
Ted Kremenek db4b7710f7 Fix subtle bug in Preprocessor::AdvanceToTokenCharacter(): use '+=' instead of '='.
llvm-svn: 94830
2010-01-29 19:38:24 +00:00
Benjamin Kramer b925f7707e Use raw_ostreams in Preprocessor::ExpandBuiltinMacro. Still not nice but less fragile than the old code.
llvm-svn: 94679
2010-01-27 16:38:22 +00:00
Douglas Gregor 64213261b4 Fix typo in comment
llvm-svn: 94576
2010-01-26 19:43:43 +00:00
Chris Lattner 0bcc858a2b -fno-rtti is now the default.
llvm-svn: 94379
2010-01-24 20:43:31 +00:00
Fariborz Jahanian 8c6c0b6a1f ui64, etc. are valid VS suffixes.
Fixes radar 7562363.

llvm-svn: 94224
2010-01-22 21:36:53 +00:00
Douglas Gregor 562c1f9365 Teach CIndex's cursor visitor to restrict its traversal to a specific
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
2010-01-22 19:49:59 +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 87d0208c41 allow the HandlerComment callback to push tokens into the
preprocessor.  This could be used by an OpenMP implementation
or something.  Patch by Abramo Bagnara!

llvm-svn: 93795
2010-01-18 22:35:47 +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
Alexis Hunt af4e28d897 Add a bunch more feature-checking macros for C++0x features. Some of these are
disabled with the intent that users can start with them now and not have to change
a thing to have them work when we implement the features.

llvm-svn: 93312
2010-01-13 08:31:49 +00:00
Chris Lattner 21d9b9a948 add a TODO for a perf improvement in LexIdentifier.
llvm-svn: 93141
2010-01-11 02:38:50 +00:00
Alexis Hunt 91b78382b5 Do not parse hexadecimal floating point literals in C++0x mode because they are
incompatible with user-defined literals, specifically with the following form:

  0x1p+1

The preprocessing-number token extends only as far as the 'p'; the '+' is not
included. Previously we could get away with this extension as p was an invalid
suffix, but now with user-defined literals, 'p' might well be a valid suffix
and we are forced to consider it as such.

This patch also adds a warning in non-0x C++ modes telling the user that
this extension is incompatible with C++0x that is enabled by default
(previously and with other languages, we warn only with a compliance
option such as -pedantic).

llvm-svn: 93135
2010-01-10 23:37:56 +00:00
Benjamin Kramer 307c2c7ebc Simplify code. No functionality change.
llvm-svn: 93114
2010-01-10 09:51:00 +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 60fbd641ad Simplify with StringSwitch.
llvm-svn: 93064
2010-01-09 18:53:11 +00:00
Douglas Gregor 9882a5aac6 Teach Preprocessor::macro_begin/macro_end to lazily load all macro
definitions from a precompiled header. This ensures that
code-completion with macro names behaves the same with or without
precompiled headers.

llvm-svn: 92497
2010-01-04 19:18:44 +00:00
Benjamin Kramer d77adb5b1c Avoid an unnecessary copy of Predefines. getMemBufferCopy does the null termination for us.
llvm-svn: 92358
2009-12-31 15:33:09 +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 9e0005f445 use best-fit instead of first-fit when reusing a MacroArgs object,
this speeds up Eonly on the testcase in PR5888 from 30.5s to 0.85s

llvm-svn: 92203
2009-12-28 06:36:46 +00:00
Chris Lattner 394f589e73 The PreExpArgTokens array is indexed with an argument #,
not a token number.  Fix the reserve logic to get the right
amount of space.

llvm-svn: 92202
2009-12-28 06:17:16 +00:00
John McCall 53b93a091e Diagnose out-of-bounds floating-point constants. Fixes rdar://problem/6974641
llvm-svn: 92127
2009-12-24 09:08:04 +00:00
Chris Lattner 43c8be526d comment tweak
llvm-svn: 92055
2009-12-23 21:29:53 +00:00
Chris Lattner 3859c74b32 fix the microsoft "charify" extension to return the charified token
as a character literal, not a string literal.  This might fix
rdar://7486575

llvm-svn: 92025
2009-12-23 19:15:27 +00:00
John McCall 230a5d527e Eliminate a completely unnecessary buffer copy when parsing float literals.
llvm-svn: 91974
2009-12-23 01:37:10 +00:00
Chris Lattner 3dfff974ec reimplement r90860, fixing a couple of problems:
1. Don't make a copy of LangOptions every time a lexer is created.
2. Don't make CharInfo global mutable state.
3. Fix the implementation to properly treat ^Z as EOF instead of as
   horizontal whitespace, which matches the semantic implemented by VC++.

llvm-svn: 91586
2009-12-17 05:29:40 +00:00
Chris Lattner 1316249ad2 enable reuse of MacroArgs objects. This is a small (2.5%) win
on PR5610 (2.185 -> 2.130s).  The big issue is that this is making
insanely huge macro argument lists with over a million tokens in it.
The reason that mallco and free are so expensive is that we are 
actually going to the kernel to get it, and switching to a bump 
pointer allocator won't change this in an interesting way.

llvm-svn: 91449
2009-12-15 20:48:12 +00:00
Chris Lattner d19564b109 set up the machinery for a MacroArgs cache hanging off Preprocessor.
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
2009-12-15 01:51:03 +00:00
Chris Lattner ffbf2de1d8 move the VarargsElided member of MacrosArgs to shrink the MacroArgs struct
on 64-bit targets.  Pass Preprocessor into create/destroy methods of MacroArgs
even though it isn't used yet.

llvm-svn: 91345
2009-12-14 22:12:52 +00:00
Chris Lattner d2fa78d0bd fix typo
llvm-svn: 91343
2009-12-14 22:02:43 +00:00
Chris Lattner 7c027ee4c2 teach clang to recover gracefully from conflict markers left in source
files: PR5238.

llvm-svn: 91270
2009-12-14 06:16:57 +00:00
Chris Lattner 4c53c40a4c fix rdar://7466570 - Be more bug compatible with GCC when it comes to
expanding directives withing macro expansions.  This is undefined behavior
according to 6.10.3p11, so we might as well be undefined in ways similar to
GCC.

llvm-svn: 91266
2009-12-14 05:00:18 +00:00
Chris Lattner 8cf1f935c2 formatting changes.
llvm-svn: 91263
2009-12-14 04:54:40 +00:00
Chris Lattner 676268e45a reduce indentation.
llvm-svn: 91262
2009-12-14 04:26:45 +00:00
Douglas Gregor 9291ab6d80 Don't expand tabs when computing the offset from the code-completion column
llvm-svn: 90881
2009-12-08 21:45:46 +00:00
Steve Naroff 04bc01833e Integrate the following from the 'objective-rewrite' branch:
http://llvm.org/viewvc/llvm-project?view=rev&revision=80043

llvm-svn: 90860
2009-12-08 16:38:12 +00:00
Eli Friedman be6f4cffca Get rid of some diagnostics that don't follow our rules for -pedantic
diagnostics (specifically, that any extension in a compiler-reserved namespace
shouldn't trigger a diagnostic).

llvm-svn: 90826
2009-12-08 02:22:26 +00:00
Daniel Dunbar 58ecb2ab51 Unbreak and add test case for r90276, a situation in which getBuffer is expected to fail.
Also, update SourceManager.h doxyments for getBuffer() to reflect reality.

llvm-svn: 90701
2009-12-06 09:19:25 +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 6aab73137a minor tidy.
llvm-svn: 90543
2009-12-04 06:14:03 +00:00
Douglas Gregor 5f49883488 Minor cleanup to the code-completion-point logic suggested by Chris.
llvm-svn: 90459
2009-12-03 17:05:59 +00:00
Ted Kremenek 5ef26fb4fd Add 'has_feature(cxx_exceptions)' to allow code to determine via preprocessor logic if C++ exceptions are enabled.
llvm-svn: 90378
2009-12-03 01:34:15 +00:00
Ted Kremenek c3fe01943f Rename has_feature(rtti) to has_feature(cxx_rtti) for clarity.
llvm-svn: 90376
2009-12-03 01:31:28 +00:00
Ted Kremenek 4bc256ec9d Add "has_feature" support for C++ RTTI.
llvm-svn: 90368
2009-12-03 01:02:35 +00:00
Douglas Gregor 53ad6b94b0 Extend the source manager with the ability to override the contents of
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
2009-12-02 06:49:09 +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
Nuno Lopes 0e5d13e025 remove stall comment
llvm-svn: 90080
2009-11-29 17:07:16 +00:00