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

97 Коммитов

Автор SHA1 Сообщение Дата
Douglas Gregor e1d918e9fe Compare the predefines buffer in the PCH file with the predefines
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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68838 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10 23:10:45 +00:00
Chris Lattner 531cc83556 do a dance with predefines, and finally enable reading of macros from
PCH.  This works now, except for limitations not being able to do things
with identifiers.  The basic example in the testcase works though.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68832 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10 22:13:17 +00:00
Chris Lattner 42d42b5b84 add support for reading macros. This does all the reading (with a bunch of
fixme's, e.g. for tokens with identifiers) but does not actually install
them.  Some details with the predefines buffer needs to be sorted out first.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68828 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10 21:41:48 +00:00
Douglas Gregor 2bec0410d2 Encode the target triple in the PCH file, and check that target triple when using the PCH file
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68824 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10 21:16:55 +00:00
Douglas Gregor 0a0428e96c Implement serialization/deserialization of LangOptions in the PCH
file. When de-serializing LangOptions, we check that the
currently-provided language options are consistent with the options
used to compile the PCH file. If they are not, we emit a diagnostic
and ignore the PCH file.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68820 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10 20:39:37 +00:00
Chris Lattner d14f27053c add a new PP_MACRO_NAME hack so that I can test object-like macros.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68803 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10 18:22:18 +00:00
Chris Lattner df961c28f8 emit tokens, constify the Preprocessor passed down into PCH writer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68798 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10 18:08:30 +00:00
Chris Lattner 7c5d24efcd emit function-like and object-like macros to the PCH file.
Note that we don't do anything useful with identifier infos yet
and don't emit the tokens that the macros are defined to.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68797 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10 18:00:12 +00:00
Douglas Gregor f1202511ee Add PCH sources to CMake build files
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68794 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10 17:28:42 +00:00
Douglas Gregor 8038d5182b Various minor fixes to PCH reading and writing, with general
cleanup. Aside from a minor tweak to the PCH file format, no
functionality change. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68793 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10 17:25:41 +00:00
Chris Lattner f04ad69fed improve punctuation
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68791 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10 17:16:57 +00:00
Chris Lattner 0b1fb98801 Arrange for the preprocessor to be passed down into the PCH writer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68790 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10 17:15:23 +00:00
Douglas Gregor 14f79002e5 PCH serialization/deserialization of the source manager. With this
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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68758 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10 03:52:48 +00:00
Douglas Gregor 2cf2634ffd Implementation of pre-compiled headers (PCH) based on lazy
de-serialization of abstract syntax trees.

PCH support serializes the contents of the abstract syntax tree (AST)
to a bitstream. When the PCH file is read, declarations are serialized
as-needed. For example, a declaration of a variable "x" will be
deserialized only when its VarDecl can be found by a client, e.g.,
based on name lookup for "x" or traversing the entire contents of the
owner of "x".

This commit provides the framework for serialization and (lazy)
deserialization, along with support for variable and typedef
declarations (along with several kinds of types). More
declarations/types, along with important auxiliary structures (source
manager, preprocessor, etc.), will follow.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68732 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-09 22:27:44 +00:00
Ted Kremenek f076339c67 Fix output of ranges in analyzer plist files.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68437 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-05 02:08:28 +00:00
Douglas Gregor 26df2f0958 Add a new command-line option "-fixit-at=file:line:column" that only
applies fix-its to error messages that occur at that specific location
in the program. 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68342 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-02 19:05:20 +00:00
Douglas Gregor de4bf6a632 Provide FIX-IT notes to describe what fix-it is doing behind the
scenes, using the underlying diagnostic client to format the
messages.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68324 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-02 17:13:00 +00:00
Douglas Gregor 837a406c66 Some cleanups to the fix-it rewriter. Thanks, Chris
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68322 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-02 16:34:42 +00:00
Ted Kremenek 7db0a94675 Also "flatten" PathLocations fed to the HTMLDiagnosticClient. We need a better
long-term strategy, but this should work for now.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68297 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-02 05:17:38 +00:00
Ted Kremenek 96a69267fc Hack: Add 'PathDiagnostic::flattenLocations()'. Because PlistDiagnosticClient
can use a PathLocation after any reference Stmts are reclaimed,
flattenLocation() converts those references to statements to source ranges.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68292 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-02 05:13:24 +00:00
Douglas Gregor 261034861d Clean up -fixit output slightly
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68278 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-02 03:14:12 +00:00
Douglas Gregor 558cb56caf Introduce a "-fixit" mode to clang-cc that applies code-modification hints.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68268 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-02 01:08:08 +00:00
Ted Kremenek 67f4964975 For plist diagnostics, use the extensive PathDiagnostic generation algorithm.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68264 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-02 00:44:18 +00:00
Ted Kremenek 5fb5dfb664 - Changed PathDiagnosticPiece::getLocation() to return a PathDiagnosticLocation
instead of a FullSourceLoc. This resulted in a bunch of small edits in various
  clients.
- Updated BugReporter to include an alternate PathDiagnostic generation
  algorithm for PathDiagnosticClients desiring more control-flow pieces.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68193 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-01 06:13:56 +00:00
Ted Kremenek 7dc8664a54 Allow two codepaths for PathDiagnostic generation. This patch mainly consists of
refactoring to make this possible (no functionality change).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68141 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-31 20:22:36 +00:00
Ted Kremenek b0b6f726ab Properly escape special characters in <string>'s in plist file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67924 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-28 06:40:54 +00:00
Ted Kremenek f48fbc6cb1 analyzer plist: For PathDiagnosticControlFlowPieces, now output an array of
start-end points, where start and end are source ranges.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67847 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-27 15:53:20 +00:00
Ted Kremenek ca1bada92c Emit aggregate "location" for PathDiagnostic to plist. This fixes <rdar://problem/6729558>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67845 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-27 15:31:11 +00:00
Ted Kremenek babdd7b56d BugReporter:
- Added an internal helper class 'PathDiagnosticBuilder' which now bundles the
  'ExecutionContinues' methods.
- Added preliminary diagnostics for short-circuit '&&' and '||'


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67822 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-27 05:06:10 +00:00
Mike Stump a43a21ef14 Really fix cmake style builds.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67633 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-24 17:52:34 +00:00
Ted Kremenek 61dc71ab04 Plist diagnostics: distinguish between regular and extended messages for "events".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67269 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-19 00:42:56 +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
Chris Lattner 1fbee5d028 implement a new -fprint-source-range-info option, which
defaults to off.  When enabled, it emits range info along
with the file/line/col information for a diagnostic.  This
allows tools that textually parse the output of clang to know
where the ranges are, even if they span multiple lines.  For 
example, with:

$ clang exprs.c -fprint-source-range-info

We now produce:

exprs.c:21:11:{21:12-21:13}: warning: use of unary operator that may be intended as compound assignment (+=)
      var =+ 5;  // expected-warning {{use of unary operator that may be intended as compound assignment (+=)}}
          ^~
exprs.c:22:11:{22:12-22:13}: warning: use of unary operator that may be intended as compound assignment (-=)
      var =- 5;  // expected-warning {{use of unary operator that may be intended as compound assignment (-=)}}
          ^~
exprs.c:36:13:{36:3-36:12}: error: assignment to cast is illegal, lvalue casts are not supported
  (float*)X = P;   // expected-error {{assignment to cast is illegal, lvalue casts are not supported}}
  ~~~~~~~~~ ^
exprs.c:41:4:{41:3-41:4}: error: called object type 'int' is not a function or function pointer
  X();  // expected-error {{called object type 'int' is not a function or function pointer}}
  ~^
exprs.c:45:15:{45:8-45:14}{45:17-45:24}: error: invalid operands to binary expression ('int *' and '_Complex float')
   P = (P-42) + Gamma*4;  // expected-error {{invalid operands to binary expression ('int *' and '_Complex float')}}
       ~~~~~~ ^ ~~~~~~~
exprs.c:61:7:{61:16-61:22}: error: invalid application of '__alignof' to bitfield
  R = __alignof(P->x);  // expected-error {{invalid application of '__alignof' to bitfield}} expected-warning {{extension used}}
      ^        ~~~~~~

Note the range info after the column in the initial diagnostic.

This is obviously really annoying if you're not a tool parsing the 
output of clang, which is why it is off by default.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66862 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-13 01:08:23 +00:00
Ted Kremenek 082cb8d7bd PathDiagnostics:
- PathDiagnosticControlFlowPiece now consists of a "start" and "end" location
  to indicating the branch location and where the branch goes.

BugReporter:
- Updated BugReporter to construct PathDiagnosticControlFlowPiece objects with
  "end" locations.

PlistDiagnostics:
- Plists now contain the bug "type" (not just bug "category")
- Plists now encode control-flow pieces differently than events; now the
  "start" and "end" locations are recorded


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66818 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-12 18:41:53 +00:00
Douglas Gregor df667e71b1 Extend the notion of active template instantiations to include the
context of a template-id for which we need to instantiate default
template arguments.

In the TextDiagnosticPrinter, don't suppress the caret diagnostic if
we are producing a non-note diagnostic that follows a note diagnostic
with the same location, because notes are (conceptually) a part of the
warning or error that comes before them.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66572 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-10 20:44:00 +00:00
Ted Kremenek 0e5c8d4ca6 BugReporter:
- Group control flow and event PathDiagnosticPieces into PathDiagnosticMacroPieces.
- Afterwards, eliminate any PathDiagnosticMacroPieces from a PathDiagnostic that
  contain no informative events.

HTMLDiagnostics:
- Use new information about PathDiagnosticMacroPieces to specially format
  message bubbles for macro expansions containing interesting events.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66524 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-10 05:16:17 +00:00
Ted Kremenek 0008683bee Handle "Macro" PathDiagnosticPiece kind when getting string identifier.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66518 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-10 02:49:29 +00:00
Chris Lattner cd1148b614 generalize the "end of line" checking logic to stop at any \0 at the
end of line instead of just the end of buffer.  Scratch buffers contain
embedded \0's between tokens which are logic line separators.  If a 
normal text buffer contains \0's, it doesn't make a lot of sense to include
them in the caret diag output anyway.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66374 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-08 08:11:22 +00:00
Ted Kremenek 4e25ee3b12 Resize message bubble back to original size.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65892 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-02 23:06:15 +00:00
Ted Kremenek 80bae763da Adjust HTML message bubbles to utilize information from PathDiagnosticPiece::Kind.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65891 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-02 23:05:40 +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
Ted Kremenek ae3487f787 Plist diagnostics now include PathDiagnostPiece::Kind.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65878 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-02 21:44:02 +00:00
Ted Kremenek 2f10398814 Update HTML diagnostics to honor the different between 'event' and 'control-flow' diagnostics.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65877 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-02 21:42:01 +00:00
Chris Lattner 7b5b5b4409 fix PR2639
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65869 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-02 20:58:48 +00:00
Daniel Dunbar 4ad19bf5b9 Fix name.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65865 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-02 19:50:00 +00:00
Ted Kremenek 3d7f2bc5a5 For now, do not output the 'DisplayHint' in plist files.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65861 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-02 19:40:15 +00:00
Daniel Dunbar e1bd4e6d7c Rename lib/Driver (etc) to lib/Frontend in prep for the *actual*
driver taking lib/Driver.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65811 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-02 06:16:29 +00:00