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

348 Коммитов

Автор SHA1 Сообщение Дата
Chris Lattner f1538de183 The individual pieces of an invalid paste as still candidates for expansion.
This matters in assembler mode, where this is silently allowed.
This fixes rdar://6709206.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67539 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-23 17:32:45 +00:00
Ted Kremenek 22f0d09298 PTHManager::Create():
- Make the Diagnostic::Level for PTH errors to be specified by the caller

clang (driver):
- Set the PTHManager diagnostic level to "Diagnostic::Error" for -include-pth
  (a hard error) and Diagnostic::Warning for -token-cache (we can still
  proceed).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67462 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-22 06:42:39 +00:00
Ted Kremenek 783bb7494c Add back warning about a PTH file not containing any identifiers, but don't make
it a hard error.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67424 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-21 00:25:09 +00:00
Ted Kremenek 8fbc44d540 Allow PTH files with no identifiers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67423 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-21 00:15:11 +00:00
Chris Lattner f2e880a99c rename the <predefines> buffer to <built-in> to solve PR3849.
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;
^



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67396 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-20 20:16:10 +00:00
Ted Kremenek 1d20197cb9 PTHManager::Create() now creates a PTHManager even if the PTH file contains no
cached tokens. This is for use with -include-pth.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67385 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-20 17:54:25 +00:00
Chris Lattner 33328642a7 pass LangOptions into TargetInfo::getTargetDefines, so that targets
can have language-specific defines.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67375 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-20 15:52:06 +00:00
Ted Kremenek 6822863401 Add PTHManager::getOriginalSourceFile(), a method that returns the name of the
original source file (if any) that was used to generate the PTH cache.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67343 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-19 22:19:30 +00:00
Chris Lattner 33ab3f6c7e silence some errors that should not apply to .S files on code like:
''
   '
 '



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67237 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-18 21:10:12 +00:00
Chris Lattner 42aa16cccb 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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67236 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-18 21:00:25 +00:00
Chris Lattner e91e93225d properly form a full token for # before calling HandleDirective.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67235 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-18 20:58:27 +00:00
Chris Lattner 5f607c4b75 This is not considered a preprocessor directive in .S files:
# 4 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67233 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-18 20:41:10 +00:00
Chris Lattner 48be3801ca constructs like:
#define Y X ## .
Y

are ok in .S files.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67231 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-18 20:31:57 +00:00
Daniel Dunbar 99c7622d1f Fix -E mismatch; an identifier followed by a numeric constant does not
require a space (to avoid concatenation) if the numeric constant had a
leading period.
 - PR3819.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67163 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-18 03:32:24 +00:00
Gabor Greif d7ee349f1d typo
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67081 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-17 11:39:38 +00:00
Douglas Gregor a393e9eedc Build system changes to use TableGen to generate the various
diagnostics. This builds on the patch that Sebastian committed and
then revert. Major differences are:

  - We don't remove or use the current ".def" files. Instead, for now,
    we just make sure that we're building the ".inc" files.
  - Fixed CMake makefiles to run TableGen and build the ".inc" files
    when needed. Tested with both the Xcode and Makefile generators
    provided by CMake, so it should be solid.
  - Fixed normal makefiles to handle out-of-source builds that involve
    the ".inc" files.

I'll send a separate patch to the list with Sebastian's changes that
eliminate the use of the .def files.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67058 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-16 23:06:59 +00:00
Anders Carlsson 76b1c842c3 (Hopefully) instantiate dependent array types correctly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67032 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-15 20:12:13 +00:00
Chris Lattner 836040f9ea make Preprocessor::Diags be a pointer instead of a reference.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66955 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-13 21:17:43 +00:00
Chris Lattner 7f549dfd7b use accessor instead of poking ivar directly
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66954 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-13 21:17:23 +00:00
Chris Lattner ba9eee3264 add a callback for macro expansion, based on a patch by Paolo Bolzoni!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66799 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-12 17:31:43 +00:00
Chris Lattner 8d4a9d37fd fix PR3768, Clang does -D__STDC_HOSTED__=1, even if -ffreestanding is passed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66474 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-09 21:50:12 +00:00
Chris Lattner 688a248e03 fix PR3764 - A redefinition of a pre-processor macro fails
Redefinition checking should ignore the leading whitespace and
start of line flags on the first token of an expansion.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66442 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-09 20:33:32 +00:00
Chris Lattner 2bc69bdb29 add \n characters to the scratch buffer *before* returned tokens.
This prevents caret diagnostics from the scratch buffer from 
including other tokens in the scratch buffer that occurred beforei
them.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66375 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-08 08:16:41 +00:00
Chris Lattner 1fa495304c simplify some logic by making ScratchBuffer handle the application of trailing
\0's to created tokens instead of making all clients do it.  No functionality
change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66373 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-08 08:08:45 +00:00
Mike Stump 2ace928d27 Fix warnings in build on clang-x86_64-freebsd buildbot.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66344 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-07 18:35:41 +00:00
Chris Lattner b627c8d683 #import is not considered an extension for ObjC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66246 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-06 04:28:03 +00:00
Chris Lattner 32fca722dd make the token lexer allocate its temporary token buffers for
preexpanded macro arguments from the preprocessor's bump pointer.
This reduces # mallocs from 12444 to 11792.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66025 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-04 06:50:57 +00:00
Chris Lattner 3daed52a57 improve compatibility with GCC 4.4, patch by Michel Salim (PR3697)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65884 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-02 22:20:04 +00:00
Douglas Gregor b2fb6de907 Clean up and document code modification hints.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65641 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-27 17:53:17 +00:00
Chris Lattner dbb1ecc32c fix some sema problems with wide strings and hook up basic codegen for them.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65582 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-26 23:01:51 +00:00
Ted Kremenek d578569d50 Move PTHStatCache within the anonymous namespace.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65348 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-23 23:27:54 +00:00
Chris Lattner 685befeb5f switch the macroinfo argument lists from being allocated off the heap
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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65195 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-20 22:46:43 +00:00
Chris Lattner cf29e0716b detemplatify setArgumentList and some other cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65187 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-20 22:31:31 +00:00
Chris Lattner 0301b3ff13 require the MAcroInfo objects are explcitly destroyed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65179 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-20 22:19:20 +00:00
Ted Kremenek 640f552ace Fix another PTH warning that should not be a note.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65072 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-19 22:14:49 +00:00
Ted Kremenek 395c59c690 Make PTH warnings actual warnings instead of 'notes'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65071 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-19 22:13:40 +00:00
Chris Lattner b66158c299 fix PR3609, emit:
t.c:1:10: error: missing terminating '>' character
#include <stdio.h
         ^

instead of:

t.c:1:10: error: missing terminating " character
#include <stdio.h
         ^



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65052 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-19 18:29:56 +00:00
Chris Lattner 719e61573f Next step toward making string diagnostics correct: handle
escapes in the string for subtoken positioning.  This gives
us working examples like:

t.m:5:16: warning: field width should have type 'int', but argument has type 'unsigned int'
  printf("\n\n%*d", (unsigned) 1, 1);
               ^    ~~~~~~~~~~~~

where before the caret pointed two spaces to the left.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64940 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 19:21:10 +00:00
Chris Lattner 6dcf63e920 update comment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64939 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 18:56:29 +00:00
Chris Lattner 2197c96354 Fix some issues handling sub-token locations that come from macro expansions.
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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64936 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 18:52:52 +00:00
Fariborz Jahanian 2639e4f884 define __OBJC2__ for objc's nonfragile abi.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64642 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-16 18:28:48 +00:00
Chris Lattner cfdff38e8e Add support for deprecated members of RecordDecls (e.g. struct fields).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64634 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-16 17:07:21 +00:00
Chris Lattner 6678133b8c add a new SourceManager::getInstantiationRange helper method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64606 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-15 21:26:50 +00:00
Chris Lattner 081927bbab fix PR3579: __LINE__ expands to the presumed location of the
*end* of a macro instantiation, not the start of it.  This is
really all about bug-for-bug compatibility with GCC, but not
doing this breaks the FreeBSD kernel.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64604 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-15 21:06:39 +00:00
Chris Lattner e7fb48466a track "just a little more" location information for macro instantiations.
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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64601 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-15 20:52:18 +00:00
Chris Lattner 67116083e7 add an assertion from Alexei Svitkine!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64503 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 23:06:48 +00:00
Chris Lattner 6ad474f82f Give TargetInfo a new IntPtrType to hold the intptr_t type for
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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64495 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 22:28:55 +00:00
Ted Kremenek ad6ce5cb0e PTH: Cache directory and negative 'stat' calls. This gives us a 1% performance improvement on Cocoa.h (fsyntax-only+PTH).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64490 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 22:07:44 +00:00
Chris Lattner 05db4278ec Fix rdar://6562329, a static analyzer crash Ted noticed on
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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64480 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 19:33:24 +00:00
Ted Kremenek a4b44dd9d3 Add some boilerplate to the PTH file to prepare for the caching of stats for directories (and negative stats too).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64477 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-13 19:13:46 +00:00