Commit Graph

89 Commits

Author SHA1 Message Date
Daniel Dunbar d02cb1dc2b Driver: Basic argument parsing.
- Add Driver::ParseArgStrings.
 - Store values directly in CommaJoinedArg to support simple access.
 - Add FlagArg class.

llvm-svn: 66142
2009-03-05 06:38:47 +00:00
Daniel Dunbar 458b6982d4 Driver: Implement Option::accept methods.
llvm-svn: 66106
2009-03-04 23:22:02 +00:00
Daniel Dunbar b7396f10b9 Driver: Fix off by one in ParseOneArg; this code is ugly but will be
replaced anyway.

llvm-svn: 66101
2009-03-04 23:03:35 +00:00
Daniel Dunbar 135837e046 Driver: Add Arg::dump and SeparateArg stubs.
llvm-svn: 66100
2009-03-04 23:02:50 +00:00
Daniel Dunbar d9621da5ae Driver: Add OptTable::ParseOneArg.
llvm-svn: 66090
2009-03-04 22:41:37 +00:00
Daniel Dunbar 16b9fd447a Driver: Add ArgList::{append, getArgString}
llvm-svn: 66089
2009-03-04 22:40:08 +00:00
Daniel Dunbar 9333fc656d Driver: Stub out Arg implementations.
llvm-svn: 66088
2009-03-04 22:37:52 +00:00
Daniel Dunbar a59194cd10 Driver: Option's need to know their ID.
- Also, add Input and Unknown opts to OptTable.

llvm-svn: 66079
2009-03-04 21:53:04 +00:00
Daniel Dunbar f49bc318ed Driver: Add Option flags.
llvm-svn: 66067
2009-03-04 21:05:23 +00:00
Daniel Dunbar 53bbc31ebd Driver: Tweak Option::accept interface.
llvm-svn: 66066
2009-03-04 20:53:00 +00:00
Daniel Dunbar b2cd66bf4d Driver: Sink Driver/Compilation into clang::driver namespace.
- Add OptTable instance to Driver.

llvm-svn: 66063
2009-03-04 20:49:20 +00:00
Daniel Dunbar 3e2cbc3161 Driver: Add ArgList implementation.
llvm-svn: 66037
2009-03-04 17:10:42 +00:00
Daniel Dunbar 5637208a88 Driver: More Option implementation.
- Add Options.def file, collects option information.

 - Actual option instantiation is handled lazily by OptTable to allow
   the driver to not need to instantiate all options.

 - cast<> support for Option, other minor tweaks.

llvm-svn: 66028
2009-03-04 08:33:23 +00:00
Daniel Dunbar b2da933989 Sketch Driver Option classes.
llvm-svn: 65933
2009-03-03 05:55:11 +00:00
Daniel Dunbar 544ecd14b6 Stub out some structure for C++ driver.
llvm-svn: 65867
2009-03-02 19:59:07 +00:00
Daniel Dunbar 51adf5824e Rename lib/Driver (etc) to lib/Frontend in prep for the *actual*
driver taking lib/Driver.

llvm-svn: 65811
2009-03-02 06:16:29 +00:00
Douglas Gregor 87f95b0a6a Introduce code modification hints into the diagnostics system. When we
know how to recover from an error, we can attach a hint to the
diagnostic that states how to modify the code, which can be one of:

  - Insert some new code (a text string) at a particular source
    location
  - Remove the code within a given range
  - Replace the code within a given range with some new code (a text
    string)

Right now, we use these hints to annotate diagnostic information. For
example, if one uses the '>>' in a template argument in C++98, as in
this code:

  template<int I> class B { };
  B<1000 >> 2> *b1;

we'll warn that the behavior will change in C++0x. The fix is to
insert parenthese, so we use code insertion annotations to illustrate
where the parentheses go:

test.cpp:10:10: warning: use of right-shift operator ('>>') in template
argument will require parentheses in C++0x
  B<1000 >> 2> *b1;
         ^
    (        )


Use of these annotations is partially implemented for HTML
diagnostics, but it's not (yet) producing valid HTML, which may be
related to PR2386, so it has been #if 0'd out.

In this future, we could consider hooking this mechanism up to the
rewriter to actually try to fix these problems during compilation (or,
after a compilation whose only errors have fixes). For now, however, I
suggest that we use these code modification hints whenever we can, so
that we get better diagnostics now and will have better coverage when
we find better ways to use this information.

This also fixes PR3410 by placing the complaint about missing tokens
just after the previous token (rather than at the location of the next
token).

llvm-svn: 65570
2009-02-26 21:00:50 +00:00
Chris Lattner d92f1bfa11 add c++ search path for GCC 4.2, PR3668, patch by Pawel Worach!
llvm-svn: 65462
2009-02-25 18:06:37 +00:00
Chris Lattner 464ceb4ec8 map source ranges through macro expansions. Before:
t.m:5:2: error: invalid operands to binary expression ('typeof(P)' (aka 'struct mystruct') and 'typeof(F)' (aka 'float'))
 MAX(P, F);
 ^~~~~~~~~
t.m:1:78: note: instantiated from:
#define MAX(A,B)    ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
                                                                             ^

(no ranges on the second diagnostics)

After:

t.m:5:2: error: invalid operands to binary expression ('typeof(P)' (aka 'struct mystruct') and 'typeof(F)' (aka 'float'))
 MAX(P, F);
 ^~~~~~~~~
t.m:1:78: note: instantiated from:
#define MAX(A,B)    ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
                                                                         ~~~ ^ ~~~

(ranges!)

llvm-svn: 65090
2009-02-20 00:25:28 +00:00
Chris Lattner 1973d84625 refactor, pass ranges down instead of the whole
DiagnosticInfo.

llvm-svn: 65088
2009-02-20 00:18:51 +00:00
Chris Lattner 06ef388a61 fix a bug introduced in my previous patch: moving clang headers to the
"after" group instead of the system group makes it so #include <limits.h>
picks up the *system* limits.h file before clang's.  This causes a failure
on linux and is definitely not what we want.

llvm-svn: 65026
2009-02-19 06:48:28 +00:00
Chris Lattner 45d26bd00d PR3614: "ignoring nonexistent directory" should print the -isysroot
mapped path, not the requested path.

llvm-svn: 65009
2009-02-19 04:48:57 +00:00
Ted Kremenek ea3a9e270c HTMLDiagnostics: Always display diagnostics *below* the line in question.
llvm-svn: 64959
2009-02-18 22:10:00 +00:00
Chris Lattner 24eb28bcf8 tidy up
llvm-svn: 64934
2009-02-18 18:50:45 +00:00
Chris Lattner 970f245439 stop searching GCC install directories for standard C headers (but
keep searching for C++ headers when in C++ mode).  In theory clang
should be able to find all of its own headers now.  If not, the
CPATH or C_INCLUDE_PATH environment variables can be specified to
add a include path.

llvm-svn: 64862
2009-02-18 00:25:15 +00:00
Ben Laurie 54a06ce437 Handle fatal errors.
llvm-svn: 64770
2009-02-17 17:32:22 +00:00
Chris Lattner 7b60a164b1 As an experimental hack, emit "instantiated from" information in
diagnostics.  I'm not sure I want to keep this, but hey, it's easy
and could be useful or something, even if guarded by a 
-fshow-me-tons-of-details option.  A silly example is:

#define A B
#define C A
#define D C

int y = D;

We now emit:

t.c:11:9: error: use of undeclared identifier 'B'
int y = D;
        ^
t.c:9:11: note: instantiated from:
#define D C
          ^
t.c:8:11: note: instantiated from:
#define C A
          ^
t.c:7:11: note: instantiated from:
#define A B
          ^

A more useful example is from tgmath:

t.c:4:9: error: no matching function for call to '__tg_acos'
 return acos(x);
        ^~~~~~~
/Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:51:17: note: instantiated from:
#define acos(x) __tg_acos(x)
                ^
... candidate set follows ...

This does not yet print ranges in instantiation info, (e.g. highlighting the
range "__tg_acos(x)" in the last example), but that could be added if we 
decide this is a good idea :).

Thoughts and bug reports welcome!

llvm-svn: 64761
2009-02-17 08:44:50 +00:00
Chris Lattner 5abfe97bf1 sink a call to getInstantiationLoc to eliminate an assertion.
llvm-svn: 64755
2009-02-17 07:54:55 +00:00
Chris Lattner d22603cef0 break down EmitCaretDiagnostic to use more primitive calls.
llvm-svn: 64754
2009-02-17 07:51:53 +00:00
Chris Lattner 2cf68c1e96 split caret diagnostic printing out into its own function.
llvm-svn: 64751
2009-02-17 07:38:37 +00:00
Chris Lattner 11a2a433b2 simplify some code.
llvm-svn: 64750
2009-02-17 07:34:34 +00:00
Chris Lattner b42700f555 If a source range comes through a function-like macro expansion,
highlight the arguments to the macro as well as the identifier.

Before:

t.c:3:9: error: no matching function for call to '__tg_acos'; candidates are:
 return acos(x);
        ^~~~

after:

t.c:3:9: error: no matching function for call to '__tg_acos'; candidates are:
 return acos(x);
        ^~~~~~~

llvm-svn: 64743
2009-02-17 05:19:10 +00:00
Chris Lattner 24c911e25a use some references to simplify code.
llvm-svn: 64063
2009-02-08 01:00:10 +00:00
Chris Lattner bf20a9a57d Genericize the existing logic for removing duplicate header dirs to apply
the "system dirs win over user dirs" logic to framework and headermap
search locations as well as normal directories.  This means that
clang t.m -F/System/Library/Frameworks  will treat /System/Library/Frameworks
as a system directory not a user directory.  If you use -v, the difference is:

Before:
ignoring nonexistent directory "/usr/libdata/gcc41"
ignoring duplicate framework "/System/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:

After:
ignoring nonexistent directory "/usr/libdata/gcc41"
ignoring duplicate directory "/System/Library/Frameworks"
  as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:

This fixes rdar://6566429.

llvm-svn: 64060
2009-02-08 00:55:22 +00:00
Chris Lattner b05f49e7fd handle fatal errors, rely on warnings to point out missing cases.
llvm-svn: 63913
2009-02-06 03:57:44 +00:00
Torok Edwin c6853c1531 Add Debian gcc 4.3 header search directories.
llvm-svn: 63872
2009-02-05 18:12:45 +00:00
Chris Lattner 88ea93e6b4 lower the interface to getLineNumber like we did for
getColumnNumber.  This fixes a FIXME in 
SourceManager::getPresumedLoc because we now just decompose
the sloc once.

llvm-svn: 63701
2009-02-04 01:06:56 +00:00
Chris Lattner e4ad417664 make SM::getColumnNumber take a predecomposed FileID/offset, which
makes it clear to clients that they have to pick an instantiation
or spelling location before calling it and allows optimization based
on that.

llvm-svn: 63698
2009-02-04 00:55:58 +00:00
Ted Kremenek e9aee88eed Clean up indentation.
llvm-svn: 63551
2009-02-02 21:45:32 +00:00
Chris Lattner 1958677ccf " Attached is a patch for TextDiagnosticPrinter that adds an optional
parameter that allows users to omit the printing of the source
location on a diagnostic. So basically it would omit the "abc.c:5:1: "
at the beginning of the line."

Patch by Alexei Svitkine!

llvm-svn: 63396
2009-01-30 17:41:53 +00:00
Ted Kremenek 5241832d1d Fix TextDiagnosticPrinter::HandleDiagnostic to handle invalid FullSourceLocs that do not have a SourceManager.
llvm-svn: 63230
2009-01-28 20:47:47 +00:00
Chris Lattner f1ca7d3e02 Introduce a new PresumedLoc class to represent the concept of a location
as reported to the user and as manipulated by #line.  This is what __FILE__,
__INCLUDE_LEVEL__, diagnostics and other things should follow (but not 
dependency generation!).  

This patch also includes several cleanups along the way: 

- SourceLocation now has a dump method, and several other places 
  that did similar things now use it.
- I cleaned up some code in AnalysisConsumer, but it should probably be
  simplified further now that NamedDecl is better.
- TextDiagnosticPrinter is now simplified and cleaned up a bit.

This patch is a prerequisite for #line, but does not actually provide 
any #line functionality.

llvm-svn: 63098
2009-01-27 07:57:44 +00:00
Ted Kremenek a3f462e49a PathDiagnostics:
- Add the distinction between the 'bug type' and the 'bug description'

HTMLDiagnostics:
- Output the bug type field as HTML comments

scan-build:
- Use the bug type field instead of the bug description for the HTML table.
- Radar filing now automatically picks up the bug description in the title (addresses <rdar://problem/6265970>)

llvm-svn: 63084
2009-01-27 01:53:39 +00:00
Ted Kremenek 099243aa9e When using -analyzer-output-plist always output a plist file even if it contains no error reports.
llvm-svn: 62871
2009-01-23 20:06:20 +00:00
Ted Kremenek 13747167ca Static Analyzer: When generating plists for errors reports, generate one plist file per translation unit that contains all of the diagnostics.
llvm-svn: 62647
2009-01-21 00:42:24 +00:00
Chris Lattner cbc35ecb04 Rename SourceManager::getCanonicalFileID -> getFileID. There is
no longer such thing as a non-canonical FileID.

llvm-svn: 62499
2009-01-19 07:46:45 +00:00
Chris Lattner 71dc14b9f0 Rename SourceLocation::getFileID to getChunkID, because it returns
the chunk ID not the file ID.  This exposes problems in 
TextDiagnosticPrinter where it should have been using the canonical
file ID but wasn't.  Fix these along the way.

llvm-svn: 62427
2009-01-17 08:45:21 +00:00
Chris Lattner d32480d3db this massive patch introduces a simple new abstraction: it makes
"FileID" a concept that is now enforced by the compiler's type checker
instead of yet-another-random-unsigned floating around.

This is an important distinction from the "FileID" currently tracked by
SourceLocation.  *That* FileID may refer to the start of a file or to a
chunk within it.  The new FileID *only* refers to the file (and its 
#include stack and eventually #line data), it cannot refer to a chunk.

FileID is a completely opaque datatype to all clients, only SourceManager
is allowed to poke and prod it.

llvm-svn: 62407
2009-01-17 06:22:33 +00:00
Chris Lattner 48a8c57936 eliminate FullSourceLoc::getLocation() now that FullSourceLoc
*is* the location.  This eliminates some weird X.getLocation().getLocation()'s.

llvm-svn: 62376
2009-01-16 23:06:35 +00:00
Chris Lattner fcc0a5a3f7 elimiante FullSourceLoc::getCanonicalFileID
llvm-svn: 62374
2009-01-16 22:59:51 +00:00