History log of /external/clang/lib/Basic/Diagnostic.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
ef8225444452a1486bd721f3285301fe84643b00 21-Jul-2014 Stephen Hines <srhines@google.com> Update Clang for rebase to r212749.

This also fixes a small issue with arm_neon.h not being generated always.

Includes a cherry-pick of:
r213450 - fixes mac-specific header issue
r213126 - removes a default -Bsymbolic on Android

Change-Id: I2a790a0f5d3b2aab11de596fc3a74e7cbc99081d
6bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89 29-May-2014 Stephen Hines <srhines@google.com> Update Clang for 3.5 rebase (r209713).

Change-Id: I8c9133b0f8f776dc915f270b60f94962e771bc83
651f13cea278ec967336033dd032faef0e9fc2ec 24-Apr-2014 Stephen Hines <srhines@google.com> Updated to Clang 3.5a.

Change-Id: I8127eb568f674c2e72635b639a3295381fe8af82
d99990df0b4aca43a0315b2928ff1b8baf704052 04-May-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> Revert r177218.

Per discussion in cfe-commits, asserting may be a better way than introducing a special test flag.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181073 91177308-0d34-0410-b5e6-96231b3b80d8
cc2b653c319599f502425d2c3de29865d47bb9e4 04-May-2013 Douglas Gregor <dgregor@apple.com> Remove DiagnosticConsumer::clone(), a bad idea that is now unused.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181070 91177308-0d34-0410-b5e6-96231b3b80d8
a4a90cabfa15c900016a7cfaea51a6d4e8ebf4db 04-May-2013 Douglas Gregor <dgregor@apple.com> When building a module, forward diagnostics to the outer diagnostic consumer.

Previously, we would clone the current diagnostic consumer to produce
a new diagnostic consumer to use when building a module. The problem
here is that we end up losing diagnostics for important diagnostic
consumers, such as serialized diagnostics (where we'd end up with two
diagnostic consumers writing the same output file). With forwarding,
the diagnostics from all of the different modules being built get
forwarded to the one serialized-diagnostic consumer and are emitted in
a sane way.

Fixes <rdar://problem/13663996>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181067 91177308-0d34-0410-b5e6-96231b3b80d8
363f99d0cd6c00e54dde2bc66a3af234ed805b2c 03-May-2013 Rafael Espindola <rafael.espindola@gmail.com> Initialize WarnOnSpellCheck.

Clang always calls setWarnOnSpellCheck, but we shouldn't require every client to
do so.

Issue noticed by Enea Zaffanella.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181021 91177308-0d34-0410-b5e6-96231b3b80d8
f9067c6b56b7ea89a43c8c2d5a0ca2c8487ea987 24-Feb-2013 Aaron Ballman <aaron@aaronballman.com> Moving initialization into the initializer list and correcting capitalization, as suggested by Chandler.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176001 91177308-0d34-0410-b5e6-96231b3b80d8
6637b0607127f0df5a4f4c8180c02c1e041d4682 19-Feb-2013 Aaron Ballman <aaron@aaronballman.com> Fixing a typo where FixIts was accidentally self-assigning instead of assigning in the parameter Fixits. This fixes several failed assertions with MSVC debug builds.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175483 91177308-0d34-0410-b5e6-96231b3b80d8
3f6f51e28231f65de9c2dd150a2d757b2162cfa3 08-Feb-2013 Jordan Rose <jordan_rose@apple.com> Excise <cctype> from Clang (except clang-tblgen) in favor of CharInfo.h.

Nearly all of these changes are one-to-one replacements; the few that
aren't have to do with custom identifier validation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174768 91177308-0d34-0410-b5e6-96231b3b80d8
566f06311f315087a27e882aafc05cb505912c27 30-Jan-2013 Filipe Cabecinhas <me@filcab.net> Changed to static_cast, due to post-commit review.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173980 91177308-0d34-0410-b5e6-96231b3b80d8
825648a9e2de81f58e425690c2f4bd50404fa433 30-Jan-2013 Filipe Cabecinhas <me@filcab.net> Cast to remove the narrowing conversion error in c++11.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173978 91177308-0d34-0410-b5e6-96231b3b80d8
877761c56d850a6cc5f9246bf248c8a4dc2b0554 30-Jan-2013 Richard Trieu <rtrieu@google.com> Handle passing non-Qualtypes to %diff better. Instead of asserting, fall back
to printing the default case. This is a fix for PR15023.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173965 91177308-0d34-0410-b5e6-96231b3b80d8
cfa88f893915ceb8ae4ce2f17c46c24a4d67502f 12-Jan-2013 Dmitri Gribenko <gribozavr@gmail.com> Remove useless 'llvm::' qualifier from names like StringRef and others that are
brought into 'clang' namespace by clang/Basic/LLVM.h

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172323 91177308-0d34-0410-b5e6-96231b3b80d8
5b9268f26ac53a74d2c504279fe577d988d5615d 20-Dec-2012 Richard Smith <richard-llvm@metafoo.co.uk> Fix code that attempted to produce a diagnostic with one DiagnosticEngine, then
produce a note for that diagnostic either with a different DiagnosticEngine or
after calling DiagnosticEngine::Reset(). That didn't make any sense, and did the
wrong thing if the original diagnostic was suppressed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170636 91177308-0d34-0410-b5e6-96231b3b80d8
12f37e411462b8388eb1309357bd62257debacac 07-Dec-2012 DeLesley Hutchins <delesley@google.com> Fix analysis based warnings so that all warnings are emitted when compiling
with -Werror. Previously, compiling with -Werror would emit only the first
warning in a compilation unit, because clang assumes that once an error occurs,
further analysis is unlikely to return valid results. However, warnings that
have been upgraded to errors should not be treated as "errors" in this sense.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169649 91177308-0d34-0410-b5e6-96231b3b80d8
55fc873017f10f6f566b182b70f6fc22aefa3464 04-Dec-2012 Chandler Carruth <chandlerc@gmail.com> Sort all of Clang's files under 'lib', and fix up the broken headers

This required manually correcting all of the incorrect main-module
headers I could find, and running the new llvm/utils/sort_includes.py
script over the files.

I also manually added quite a few missing headers that were uncovered by
shuffling the order or moving headers up to be main-module-headers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169237 91177308-0d34-0410-b5e6-96231b3b80d8
02c23ebf41ae2f70da0ba7337e05c51fbfe35f7f 24-Oct-2012 Douglas Gregor <dgregor@apple.com> Make DiagnosticOptions intrusively reference-counted, and make sure
the various stakeholders bump up the reference count. In particular,
the diagnostics engine now keeps the DiagnosticOptions object alive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166508 91177308-0d34-0410-b5e6-96231b3b80d8
615a092a511cd2dfe1a5364ebf5f80e55e33034d 22-Sep-2012 Jordan Rose <jordan_rose@apple.com> Use llvm::getOrdinalSuffix to print ordinal numbers in diagnostics.

Just a refactoring of common infrastructure. No intended functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164443 91177308-0d34-0410-b5e6-96231b3b80d8
9e63dc582b3bfb9ab2e80631b5311b070a73dff8 17-Aug-2012 Richard Smith <richard-llvm@metafoo.co.uk> Avoid binding a reference to a dereferenced null pointer, if we try to emit a
diagnostic before we have a source manager.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162070 91177308-0d34-0410-b5e6-96231b3b80d8
c95ad0061f093de2f73b8aab58ff3f0444d0123f 15-Aug-2012 Richard Smith <richard-llvm@metafoo.co.uk> Fix undefined behavior: reference bound to dereferenced null pointer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161899 91177308-0d34-0410-b5e6-96231b3b80d8
00aae5243d965aa7bcee81a39ba0900c7869be21 14-Aug-2012 Richard Smith <richard-llvm@metafoo.co.uk> Fix undefined behavior: don't bind a dereferenced null pointer to a reference.
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161832 91177308-0d34-0410-b5e6-96231b3b80d8
7094dee95f8c915d27097ac18b47d1ef31fd72ed 10-Aug-2012 Joerg Sonnenberger <joerg@bec.de> Add missing cctype includes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161660 91177308-0d34-0410-b5e6-96231b3b80d8
5561977175c04dc2bae53b0f577a5c1ca83b96ff 13-Jul-2012 Richard Trieu <rtrieu@google.com> Modify tree printing mode for template type diffing. If a diagnostic has
multiple %diff's, only print the first tree and fallback to inline printing
for the rest of the diagnostic.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160193 91177308-0d34-0410-b5e6-96231b3b80d8
c6d64a26c28bbeee50e06c94c4f4c08e610327b7 11-Jul-2012 Jordan Rose <jordan_rose@apple.com> Emit -verify diagnostics even when we have a fatal error.

Previously we'd halt at the fatal error as expected, but not actually emit
any -verify-related diagnostics. This lets us catch cases that emit a
/different/ fatal error from the one we expected.

This is implemented by adding a "force emit" mode to DiagnosticBuilder, which
will cause diagnostics to immediately be emitted regardless of current
suppression. Needless to say this should probably be used /very/ sparingly.

Patch by Andy Gibbs! Tests for all of Andy's -verify patches coming soon.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160053 91177308-0d34-0410-b5e6-96231b3b80d8
5409d28b6167032696f4915bb765a6f7db579f3f 10-Jul-2012 Richard Trieu <rtrieu@google.com> Properly update the FormattedArgs vector when the template type diffing falls
back to regular type printing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159976 91177308-0d34-0410-b5e6-96231b3b80d8
529cdf4c2ef0985dd6f4b7b68ab76e6a1a5082d5 29-Jun-2012 Richard Trieu <rtrieu@google.com> Update the %diff modifer to have an alternate string print when a template tree
is selected. This will allow more flexibility when converting diagnostics to
use template type diffing.

Also updated the internal manual and test cases for correctly keeping the bold
attribute and for tree printing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159463 91177308-0d34-0410-b5e6-96231b3b80d8
246b6aa6763de8c617d564ef33123a8f3293a80e 26-Jun-2012 Richard Trieu <rtrieu@google.com> Add template type diffing to Clang. This feature will provide a better
comparison between two templated types when they both appear in a diagnostic.
Type elision will remove indentical template arguments, which can be disabled
with -fno-elide-type. Cyan highlighting is applied to the differing types.

For more formatting, -fdiagnostic-show-template-tree will output the template
type as an indented text tree, with differences appearing inline. Template
tree works with or without type elision.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159216 91177308-0d34-0410-b5e6-96231b3b80d8
d3e8eda9a685e95c29ccea52977c0e32a422e563 15-Jun-2012 James Dennett <jdennett@google.com> Documentation cleanup: delete doc comments from source files where they are
broken duplicates of comments that are in the corresponding header files.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158550 91177308-0d34-0410-b5e6-96231b3b80d8
3054f097f813d19090bdb23645dcd48df71d1a89 13-Mar-2012 Daniel Dunbar <daniel@zuster.org> [Basic] Fix up DiagnosticBuilder::{FlushCounts,Emit} to be inline.

- This is much more important than it appears at first glance...

The intended design of DiagnosticBuilder was that it never escape and that all
its members would get lowered to registers by the compiler. By fixing Emit here,
the compiler can completely eliminate the DiagnosticBuilder object and never
need to push those registers back into it.

Unfortunately, Sema has broken DiagnosticBuilder in other ways (by introducing
SemaDiagnosticBuilder), so we don't get the fill impact of this, but it is still
good for 30k reduction in code size. I'll work on fixing the
SemaDiagnosticBuilder problems next.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152669 91177308-0d34-0410-b5e6-96231b3b80d8
981e279b95f3a71e2268124b1abaae050ec200dc 13-Mar-2012 Daniel Dunbar <daniel@zuster.org> [Basic] Stop using a SmallVector<> for Diagnostic. This drops Clang binary size
by ~%.3/~100k in my build -- simply by eliminating the horrible code bloat coming
from the .clear() of the SmallVector<FixItHint>, which does a std::~string, etc.
- My understanding is we don't ever emit arbitrary numbers of fixits, so I just
moved us to using a statically sized array like we do for arguments and

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152639 91177308-0d34-0410-b5e6-96231b3b80d8
341785ec52f87c0803ba52dc88faac4e136f8593 22-Feb-2012 Bill Wendling <isanbard@gmail.com> More ArrayRef-ification of methods.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151152 91177308-0d34-0410-b5e6-96231b3b80d8
c93dc7889644293e318e19d82830ea2acc45b678 20-Feb-2012 Dylan Noblesmith <nobled@dreamwidth.org> Basic: import IntrusiveRefCntPtr<> into clang namespace

The class name is long enough without the llvm:: added.
Also bring in RefCountedBase and RefCountedBaseVPTR.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150958 91177308-0d34-0410-b5e6-96231b3b80d8
dfaee4922b990fbf33808b91b961dc27df585030 08-Feb-2012 Chad Rosier <mcrosier@apple.com> Fix indentation and an 80-column violation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150010 91177308-0d34-0410-b5e6-96231b3b80d8
d7a3e2c5f61cd4893f95b69a424fe4def3aa0f69 07-Feb-2012 Benjamin Kramer <benny.kra@googlemail.com> Revert my patches which removed Diagnostic.h includes by moving some operator overloads out of line.

This seems to negatively affect compile time onsome ObjC tests
(which use a lot of partial diagnostics I assume). I have to come
up with a way to keep them inline without including Diagnostic.h
everywhere. Now adding a new diagnostic requires a full rebuild
of e.g. the static analyzer which doesn't even use those diagnostics.

This reverts commit 6496bd10dc3a6d5e3266348f08b6e35f8184bc99.
This reverts commit 7af19b817ba964ac560b50c1ed6183235f699789.
This reverts commit fdd15602a42bbe26185978ef1e17019f6d969aa7.
This reverts commit 00bd44d5677783527d7517c1ffe45e4d75a0f56f.
This reverts commit ef9b60ffed980864a8db26ad30344be429e58ff5.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150006 91177308-0d34-0410-b5e6-96231b3b80d8
3f22509ebf91aa96658ca6e5c5c0b926d8d62e34 07-Feb-2012 Chad Rosier <mcrosier@apple.com> In r149662, setDiagnosticMapping was modified to not allow warnings mapped to
MAP_ERROR to be remapped to MAP_WARNING. These new APIs are being added to
allow the diagnostic mapping's "no Werror" bit to be set, and potentially
downgrade anything already mapped to be a warning.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150001 91177308-0d34-0410-b5e6-96231b3b80d8
f7ccbad5d9949e7ddd1cbef43d482553b811e026 05-Feb-2012 Dylan Noblesmith <nobled@dreamwidth.org> Basic: import SmallString<> into clang namespace

(I was going to fix the TODO about DenseMap too, but
that would break self-host right now. See PR11922.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149799 91177308-0d34-0410-b5e6-96231b3b80d8
8fe83e1df954d72c0f4ffc15d20a5222ec151c21 04-Feb-2012 Benjamin Kramer <benny.kra@googlemail.com> Move a method from IdentifierTable.h out of line and remove the SmallString include.

Fix all the transitive include users.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149783 91177308-0d34-0410-b5e6-96231b3b80d8
ef9b60ffed980864a8db26ad30344be429e58ff5 04-Feb-2012 Benjamin Kramer <benny.kra@googlemail.com> Move Storage and StorageAllocator out of the PartialDiagnostic class so we can forward declare them.

Let ASTContext allocate the storage in its BumpPtrAllocator.
This will help us remove ASTContext's depedency on PartialDiagnostic.h soon.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149780 91177308-0d34-0410-b5e6-96231b3b80d8
cbf46a0b2bb2b47d6e13437e0d52cc583c5ce539 03-Feb-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Change the fixed array of FixitHints to a SmallVector to lift off
the limit on the number of fixits.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149676 91177308-0d34-0410-b5e6-96231b3b80d8
7a0a31ce0cd38147bfe853f71a3f7261444ddf4c 03-Feb-2012 Chad Rosier <mcrosier@apple.com> [frontend] Don't allow a mapping to a warning override an error/fatal mapping.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149662 91177308-0d34-0410-b5e6-96231b3b80d8
82e6411d004064a29f03a3ea8b8919f297bfa843 28-Jan-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> DiagnosticsEngine::setMappingToAllDiagnostics() does not need to return bool,
caught by Chad.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149173 91177308-0d34-0410-b5e6-96231b3b80d8
11583c757bac6ce5c342f2eb572055dd2619a657 27-Jan-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Due to a bug, -Wno-everything works like -Weverything. Fix the bug by having
-Wno-everything remap all warnings to ignored.

We can now use "-Wno-everything -W<warning>" to ignore all warnings except
specific ones.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149121 91177308-0d34-0410-b5e6-96231b3b80d8
99ba9e3bd70671f3441fb974895f226a83ce0e66 20-Dec-2011 David Blaikie <dblaikie@gmail.com> Unweaken vtables as per http://llvm.org/docs/CodingStandards.html#ll_virtual_anch

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146959 91177308-0d34-0410-b5e6-96231b3b80d8
08d6e032a2a0a8656d12b3b7b93942987bb12eb7 16-Dec-2011 Richard Smith <richard-llvm@metafoo.co.uk> C++11 constexpr: Add note stacks containing backtraces if constant evaluation
fails within a call to a constexpr function. Add -fconstexpr-backtrace-limit
argument to driver and frontend, to control the maximum number of notes so
produced (default 10). Fix APValue printing to be able to pretty-print all
APValue types, and move the testing for this functionality from a unittest to
a -verify test now that it's visible in clang's output.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146749 91177308-0d34-0410-b5e6-96231b3b80d8
87429a05ff66fe6460eaa4855fd0da574e26bf7b 09-Nov-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> [PCH] Fix reading from PCH of diagnostic pragmas.

In certain cases ASTReader would call the normal DiagnosticsEngine API to initialize
the state of diagnostic pragmas but DiagnosticsEngine would try to compare source locations
leading to crash because the main FileID was not yet initialized.

Yet another case of the ASTReader trying to use the normal APIs and inadvertently breaking
invariants. Fix this by having the ASTReader set up the internal state directly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144153 91177308-0d34-0410-b5e6-96231b3b80d8
53201a86f775c064b62ec25742106c7b43ba8749 04-Oct-2011 Daniel Dunbar <daniel@zuster.org> Basic/Diagnostics: Apparently, #pragma ... diagnostic is intended to override
the command line options (at least according to GCC's documentation). GCC 4.2
didn't appear to actually do this, but it seems like that has been fixed in
later release, so we will follow the docs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141119 91177308-0d34-0410-b5e6-96231b3b80d8
aeacae523a1c6e5bb99d12754415bbbc3ccb86c9 29-Sep-2011 Daniel Dunbar <daniel@zuster.org> Basic/Diagnostic: Kill off a few unnecessary functions now that refactoring is done, and add a note that the new setDiagnosticGroup{...} methods only operate on the current diagnostic state.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140771 91177308-0d34-0410-b5e6-96231b3b80d8
be1aa410274b28fc143c47c814f07c989f4534d6 29-Sep-2011 Daniel Dunbar <daniel@zuster.org> Basic/Diagnostics: Rewrite DiagnosticIDs::getDiagnosticLevel completely to be straighter line code, use the new DiagnosticMappingInfo flags, and eliminate the odd MAP_WARNING_NO_WERROR and friend mappings.
- This fixes a host of obscure bugs with regards to how warning mapping options composed with one another, and I believe makes the code substantially easier to read and reason about.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140770 91177308-0d34-0410-b5e6-96231b3b80d8
a5e41333b06fdf036d58495490eb14d6a0a3fcf7 29-Sep-2011 Daniel Dunbar <daniel@zuster.org> Basic/Diagnostics: Add three explicit bits to DiagnosticMappingInfo to track "no-warning-as-error", "no-error-as-fatal", and "show-in-system-header", and update DiagnosticsEngine::setDiagnosticGroup{WarningAsError,ErrorAsFatal} and GetDefaultDiagMappingInfo to set them appropriately.
- No actual functionality change for now, we still also use the diag::Mapping::{MAP_WARNING_NO_ERROR,MAP_ERROR_NO_FATAL,MAP_WARNING_SHOW_IN_SYSTEM_HEADER} for a little while longer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140768 91177308-0d34-0410-b5e6-96231b3b80d8
3f8394669673451061f57ced81f0a2cae087f119 29-Sep-2011 Daniel Dunbar <daniel@zuster.org> Basic/Diagnostics: Add a DiagnosticIDs::getDiagnosticsInGroup method, and use
that in DiagnosticEngine instead of the convoluted calling into DiagnosticIDs
which then calls back into the DiagnosticsEngine.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140766 91177308-0d34-0410-b5e6-96231b3b80d8
09ea68d17bc0fc0b16d287ad4d3f61fe7def4f17 29-Sep-2011 Daniel Dunbar <daniel@zuster.org> Basic/Diagnostics: Move setDiagnosticMapping() to using DiagnosticMappingInfo
and eliminate setDiagnosticMappingInternal.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140763 91177308-0d34-0410-b5e6-96231b3b80d8
4aa8f2bce0f498152d624f748712a991adc23fdd 29-Sep-2011 Daniel Dunbar <daniel@zuster.org> Basic/Diagnostic: Factor out
DiagnosticsEngine::setDiagnosticGroup{ErrorAsFatal,WarningAsError} methods which
more accurately model the correct API -- no internal change to the diagnostics
engine yet though.
- Also, stop honoring -Werror=everything (etc.) as a valid (but oddly behaved) option.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140747 91177308-0d34-0410-b5e6-96231b3b80d8
40847cfb58acc3cac7d68727df9455ac45f2e118 26-Sep-2011 David Blaikie <dblaikie@gmail.com> Rename DiagnosticInfo to Diagnostic as per issue 5397

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140493 91177308-0d34-0410-b5e6-96231b3b80d8
78ad0b98848c17a0a11847fa1d456e2dfec8aa2f 26-Sep-2011 David Blaikie <dblaikie@gmail.com> Rename DiagnosticClient to DiagnosticConsumer as per issue 5397

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140479 91177308-0d34-0410-b5e6-96231b3b80d8
d6471f7c1921c7802804ce3ff6fe9768310f72b9 26-Sep-2011 David Blaikie <dblaikie@gmail.com> Rename Diagnostic to DiagnosticsEngine as per issue 5397

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140478 91177308-0d34-0410-b5e6-96231b3b80d8
1e473ccb0e0f6fd1954bef330f7193c1a3fb3ba1 18-Aug-2011 Ted Kremenek <kremenek@apple.com> Implement '-Weverything', which enables all warnings except those explicitly mapped to be ignored.

Currently this includes -pedantic warnings as well; we'll need to consider whether these should
be included.

This works as expected with -Werror.

Test cases were added to Sema/warn-unused-parameters.c, but they should probably be broken off into
their own test file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137910 91177308-0d34-0410-b5e6-96231b3b80d8
c0a575f9b791a25c94b1c3c832dd73ec564646bb 29-Jul-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> Make DiagnosticErrorTrap keep a count of the errors that occurred so multiple
DiagnosticErrorTraps can be composed (e.g. a trap inside another trap).

Fixes http://llvm.org/PR10462 & rdar://9852007.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136447 91177308-0d34-0410-b5e6-96231b3b80d8
2d3ba4f5a923a90c3fc290ddfba5e36c2d0a9b46 23-Jul-2011 Chris Lattner <sabre@nondot.org> Move ArrayRef to LLVM.h and eliminate now-redundant qualifiers, patch by Jon Mulder!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135855 91177308-0d34-0410-b5e6-96231b3b80d8
5f9e272e632e951b1efe824cd16acb4d96077930 23-Jul-2011 Chris Lattner <sabre@nondot.org> remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports
them into the clang namespace.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135852 91177308-0d34-0410-b5e6-96231b3b80d8
f62d43d2afe1960755a1b5813cae1e5983bcac1b 19-Jul-2011 Douglas Gregor <dgregor@apple.com> Revamp the SourceManager to separate the representation of parsed
source locations from source locations loaded from an AST/PCH file.

Previously, loading an AST/PCH file involved carefully pre-allocating
space at the beginning of the source manager for the source locations
and FileIDs that correspond to the prefix, and then appending the
source locations/FileIDs used for parsing the remaining translation
unit. This design forced us into loading PCH files early, as a prefix,
whic has become a rather significant limitation.

This patch splits the SourceManager space into two parts: for source
location "addresses", the lower values (growing upward) are used to
describe parsed code, while upper values (growing downward) are used
for source locations loaded from AST/PCH files. Similarly, positive
FileIDs are used to describe parsed code while negative FileIDs are
used to file/macro locations loaded from AST/PCH files. As a result,
we can load PCH/AST files even during parsing, making various
improvemnts in the future possible, e.g., teaching #include <foo.h> to
look for and load <foo.h.gch> if it happens to be already available.

This patch was originally written by Sebastian Redl, then brought
forward to the modern age by Jonathan Turner, and finally
polished/finished by me to be committed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135484 91177308-0d34-0410-b5e6-96231b3b80d8
0673cb30340aadaede7b795c763b00f6b64e611c 11-Jul-2011 Chandler Carruth <chandlerc@gmail.com> Apply patch from Richard Trieu to fix PR9548:

When two different types has the same text representation in the same
diagnostic message, print an a.k.a. after the type if the a.k.a. gives extra
information about the type.

class versa_string;

typedef versa_string string;

namespace std {template <typename T> class vector;}

using std::vector;

void f(vector<string> v);

namespace std {
class basic_string;
typedef basic_string string;
template <typename T> class vector {};
void g() {
vector<string> v;

Old message:
test.cc:15:3: error: no matching function for call to 'f'
test.cc:7:6: note: candidate function not viable: no known conversion from
'vector<string>' to 'vector<string>' for 1st argument
void f(vector<string> v);
1 error generated.

New message:
test.cc:15:3: error: no matching function for call to 'f'
test.cc:7:6: note: candidate function not viable: no known conversion from
'vector<string>' (aka 'std::vector<std::basic_string>') to
'vector<string>' (aka 'std::vector<versa_string>') for 1st argument
void f(vector<string> v);
1 error generated.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134904 91177308-0d34-0410-b5e6-96231b3b80d8
85bea9777d444ccbcc086d98f075fe666c2e865d 06-Jul-2011 Douglas Gregor <dgregor@apple.com> Keep track of when "unrecoverable" errors occur, then allow
clang_saveTranslationUnit() to save a PCH file if the only errors it
contains are recoverable errors. Fixes <rdar://problem/9727804>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134503 91177308-0d34-0410-b5e6-96231b3b80d8
477aab6782795e7472055a54108d2df270ce1a89 25-May-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> A StringRef-ication of the DiagnosticIDs API and internals.

Patch by Matthieu Monrocq with tweaks by me to avoid StringRefs in the static
diagnostic data structures, which resulted in a huge global-var-init function.

Depends on llvm commit r132046.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132047 91177308-0d34-0410-b5e6-96231b3b80d8
e59abb56ce0e1c206fb80bd945a0c358b0abe1ef 05-May-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> Introduce a Diagnostic::Report function that accepts and emits a StoredDiagnostic.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130919 91177308-0d34-0410-b5e6-96231b3b80d8
fc8f0e14ad142ed811e90fbd9a30e419e301c717 15-Apr-2011 Chris Lattner <sabre@nondot.org> fix a bunch of comment typos found by codespell. Patch by
Luis Felipe Strano Moraes!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129559 91177308-0d34-0410-b5e6-96231b3b80d8
dc0a2da1038cc725ad23d070e6a0d03078b7300d 26-Mar-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> For Diagnostic::Reset() also reset the state related to #pragma diagnostic. Fixes rdar://9170766.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128346 91177308-0d34-0410-b5e6-96231b3b80d8
cd1eecfe4f43a542c8f9a6e7d12fa69b28c23a67 21-Mar-2011 Ted Kremenek <kremenek@apple.com> Relax assertion to fail during crash recovery cleanup.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128010 91177308-0d34-0410-b5e6-96231b3b80d8
03201fbbdeb3eb7f465610b09c281ee6aa84e3ca 21-Mar-2011 Ted Kremenek <kremenek@apple.com> Use CrashRecoveryContextCleanup objects to reclaim resources from CompilerInstance objects.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128009 91177308-0d34-0410-b5e6-96231b3b80d8
4f5e21e24fb9e6ec473a13f83b5c9a2c41501a70 31-Jan-2011 Douglas Gregor <dgregor@apple.com> Teach Diagnostic::setClient() to free the existing, owned
client. Fixes a libclang leak.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124614 91177308-0d34-0410-b5e6-96231b3b80d8
3efd52cf8f4e57c5571bd8cc3168264c3bc46a1e 14-Jan-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> Properly propagate #pragma diagnostic mappings from PCH but not command-line warning flags.
Addresses rdar://8435969&8852495

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123462 91177308-0d34-0410-b5e6-96231b3b80d8
0827408865e32789e0ec4b8113a302ccdc531423 15-Dec-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Fix diagnostic pragmas.

Diagnostic pragmas are broken because we don't keep track of the diagnostic state changes and we only check the current/latest state.
Problems manifest if a diagnostic is emitted for a source line that has different diagnostic state than the current state; this can affect
a lot of places, like C++ inline methods, template instantiations, the lexer, etc.

Fix the issue by having the Diagnostic object keep track of the source location of the pragmas so that it is able to know what is the diagnostic state at any given source location.

Fixes rdar://8365684.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121873 91177308-0d34-0410-b5e6-96231b3b80d8
a6a32e295379570b489cc041053d2cd53bcafd1c 19-Nov-2010 Benjamin Kramer <benny.kra@googlemail.com> Initialize StoredDiagnostic's members in order.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119808 91177308-0d34-0410-b5e6-96231b3b80d8
aa5f135f8db82b5e5fb1640fd51f8078e0b2d82d 19-Nov-2010 Douglas Gregor <dgregor@apple.com> Extend the libclang diagnostic API to provide information about the
option name, category ID, and category name corresponding to a diagnostic.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119802 91177308-0d34-0410-b5e6-96231b3b80d8
f2224d89a6ae65a3839529e26d0f6d025d83d6bb 18-Nov-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Since multiple diagnostics can share one diagnostic client, have the client keeping track
of the total number of warnings/errors reported.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119731 91177308-0d34-0410-b5e6-96231b3b80d8
33e4e70c8c0a17e0ccb7465d96556b077a68ecb1 18-Nov-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Refactoring of Diagnostic class.

-Move the stuff of Diagnostic related to creating/querying diagnostic IDs into a new DiagnosticIDs class.
-DiagnosticIDs can be shared among multiple Diagnostics for multiple translation units.
-The rest of the state in Diagnostic object is considered related and tied to one translation unit.
-Have Diagnostic point to the SourceManager that is related with. Diagnostic can now accept just a
SourceLocation instead of a FullSourceLoc.
-Reflect the changes to various interfaces.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119730 91177308-0d34-0410-b5e6-96231b3b80d8
e53a44bcd342e964a3c69bc27734f01e23f5fec8 14-Oct-2010 John McCall <rjmccall@apple.com> Teach Diagnostic to recursively expand inside %plural formats.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116468 91177308-0d34-0410-b5e6-96231b3b80d8
b535041ee33c5eff255832bc5541c8d52aae8254 13-Oct-2010 Douglas Gregor <dgregor@apple.com> Fix a silly bug in the suppression of non-error diagnostics in a
SFINAE context, where we weren't getting the right diagnostic argument
count. I blame DiagnosticBuilder's weirdness. Fixes PR8372.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116411 91177308-0d34-0410-b5e6-96231b3b80d8
d3ab63e0f66429abf2a3e4cde889e420e41e8790 12-Oct-2010 Douglas Gregor <dgregor@apple.com> Eliminate -fdiagnostics-binary and all of the infrastructure for
emitting diagnostics in a binary form to be consumed by libclang,
since libclang no longer does any of its work out-of-process, making
this code dead. Besides, this stuff never worked at 100% anyway.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116250 91177308-0d34-0410-b5e6-96231b3b80d8
783c56f47745f719590b17afd7ed937bf2407b53 18-Aug-2010 Douglas Gregor <dgregor@apple.com> Simplify FixItHint by eliminated the unnecessary InsertionLoc
location. Patch by Eelis van der Weegen!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111362 91177308-0d34-0410-b5e6-96231b3b80d8
7a5bf5fb01c676809efcf63de322a88819115652 18-Aug-2010 Chandler Carruth <chandlerc@gmail.com> Check whether errors should be included in the diagnostic counts. Previously,
only warnings did this check.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111355 91177308-0d34-0410-b5e6-96231b3b80d8
ba6f816d633e3b88c38c6896c2d78d19489650f2 15-Aug-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> Remove dead code, caught by unused function warnings.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111091 91177308-0d34-0410-b5e6-96231b3b80d8
270c03550b311058d140d8c6a0257c553bc96241 02-Aug-2010 Eli Friedman <eli.friedman@gmail.com> PR7777: Set EnabledByDefault to something useful, instead of setting it
randomly. This makes us consistently show "-pedantic" as the warning option
for a warning where appropriate.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109987 91177308-0d34-0410-b5e6-96231b3b80d8
cc5888d833caf90ebda37f24da40d2cd06b4d820 31-Jul-2010 Douglas Gregor <dgregor@apple.com> Implement dependency analysis for the precompiled preamble. If any of
the files in the precompiled preamble have changed since it was build,
force the preamble to be rebuilt.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109937 91177308-0d34-0410-b5e6-96231b3b80d8
3c46e8db99196179b30e7ac5c20c4efd5f3926d7 26-Jul-2010 Dan Gohman <gohman@apple.com> Fix namespace polution.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109440 91177308-0d34-0410-b5e6-96231b3b80d8
3c2d3016adec79c81c4efff64e208fd3ecdd92ae 25-Jul-2010 Benjamin Kramer <benny.kra@googlemail.com> Wrap bit mangling logic for DiagMappings in its own class so it doesn't leak
into other code. Make it an array instead of a constant-length vector.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109384 91177308-0d34-0410-b5e6-96231b3b80d8
abc563f554951259bbe0315055cad92ee14d87e4 19-Jul-2010 Douglas Gregor <dgregor@apple.com> Introduce a new libclang API, clang_reparseTranslationUnit(), which
reparses an already-parsed translation unit. At the moment it's just a
convenience function, but we hope to use it for performance

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108756 91177308-0d34-0410-b5e6-96231b3b80d8
0a76aae8c03cb7dd7bdbe683485560afaf695959 19-Jun-2010 Chris Lattner <sabre@nondot.org> introduce a new CharSourceRange class, and enhance the diagnostics routines
to use them instead of SourceRange. CharSourceRange is just a SourceRange
plus a bool that indicates whether the range has the end character resolved
or whether the end location is the start of the end token. While most of
the compiler wants to think of ranges that have ends that are the start of
the end token, the printf diagnostic stuff wants to highlight ranges within

This is transparent to the diagnostic stuff. To start taking advantage of
the new capabilities, you can do something like this:
Diag(..) << CharSourceRange::getCharRange(Begin,End)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106338 91177308-0d34-0410-b5e6-96231b3b80d8
5edbdcc62098e305cd55654814dcf783a3f3c477 11-Jun-2010 Jeffrey Yasskin <jyasskin@google.com> Add an option -fshow-overloads=best|all to limit the number of overload
candidates printed. We default to 'all'. At the moment, 'best' prints only
the first 4 overloads, but we'll improve that over time.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105815 91177308-0d34-0410-b5e6-96231b3b80d8
5ef12b37f00f747f130664c655bb9b29dc10c816 13-May-2010 Chandler Carruth <chandlerc@gmail.com> Update the types for warning option subgroup arrays to 'short', we have more
than 127 groups so this was already failing given -fsigned-char. A subsequent
to commit to TableGen will generate shorts for the arrays themselves.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103703 91177308-0d34-0410-b5e6-96231b3b80d8
c9b889044c8e1e2d6ab194e34e8b74f6998094fa 04-May-2010 Chris Lattner <sabre@nondot.org> When -fdiagnostics-print-source-range-info is specified,
print the diagnostic category number in the [] at the end
of the line. For example:

$ cat t.c
#include <stdio.h>
void foo() {
printf("%s", 4);
$ clang t.c -fsyntax-only -fdiagnostics-print-source-range-info
t.c:3:11:{3:10-3:12}{3:15-3:16}: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat,1]
printf("%s", 4);
~^ ~
1 warning generated.

Clients that want category information can now pick the number
out of the output, rdar://7928231.

More coming.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103053 91177308-0d34-0410-b5e6-96231b3b80d8
27b0f510d1d4f9ed5668eec1195f04b4a74a4426 04-May-2010 Chris Lattner <sabre@nondot.org> add the ability to associate 'category' names with diagnostics
and diagnostic groups. This allows the compiler to group
diagnostics together (e.g. "Logic Warning",
"Format String Warning", etc) like the static analyzer does.
This is not exposed through anything in the compiler yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103051 91177308-0d34-0410-b5e6-96231b3b80d8
575cf3791216c33770ba950430493cdd43099f8f 20-Apr-2010 Douglas Gregor <dgregor@apple.com> Introduce a limit on the depth of the template instantiation backtrace
we will print with each error that occurs during template
instantiation. When the backtrace is longer than that, we will print
N/2 of the innermost backtrace entries and N/2 of the outermost
backtrace entries, then skip the middle entries with a note such as:

note: suppressed 2 template instantiation contexts; use
-ftemplate-backtrace-limit=N to change the number of template
instantiation entries shown

This should eliminate some excessively long backtraces that aren't
providing any value.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101882 91177308-0d34-0410-b5e6-96231b3b80d8
1864f2eb59471d07db51adfc3e5b1a229eed631a 15-Apr-2010 Douglas Gregor <dgregor@apple.com> Once we've emitted a fatal diagnostic, keep counting errors but with a
separate count of "suppressed" errors. This way, semantic analysis
bits that depend on the error count to determine whether problems
occured (e.g., some template argument deduction failures, jump-scope
checking) will not get confused.

The actual problem here is that a missing #include (which is a fatal
error) could cause the jump-scope checker to run on invalid code,
which it is not prepared to do. Trivial fix for both
<rdar://problem/7775941> and <rdar://problem/7775709>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101297 91177308-0d34-0410-b5e6-96231b3b80d8
04e442714c292d9381cad2ac14087991132bddca 12-Apr-2010 Chris Lattner <sabre@nondot.org> fix PR6814 - Only print [-pedantic] on a diagnostic if -pedantic
actually turned it on. If a diag is produced by a warning which
is an extension but defaults to on, and has no warning group, don't
print any option info.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101071 91177308-0d34-0410-b5e6-96231b3b80d8
ec55c941f2846db48bce4ed6dd2ce339e1a48962 12-Apr-2010 Ted Kremenek <kremenek@apple.com> Fix null dereference in 'WriteSourceLocation' when the FileEntry is null.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101060 91177308-0d34-0410-b5e6-96231b3b80d8
c100214fdc41a7ea215f75d433eb1cb829fd4330 07-Apr-2010 Chris Lattner <sabre@nondot.org> add clang -cc1 level support for "-ferror-limit 42"

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100687 91177308-0d34-0410-b5e6-96231b3b80d8
b205ac9fcd22b87b41697172d1983c5ae9dabaaf 07-Apr-2010 Chris Lattner <sabre@nondot.org> add capabilities to stop emitting errors after some limit.
Right now the limit is 0 (aka disabled)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100684 91177308-0d34-0410-b5e6-96231b3b80d8
53eee7ba970d21ff15bbd4334164037a3b4cc4b8 07-Apr-2010 Chris Lattner <sabre@nondot.org> Instead of counting totally diagnostics, split the count into a count
of errors and warnings. This allows us to emit something like this:

2 warnings and 1 error generated.

instead of:

3 diagnostics generated.

This also stops counting 'notes' because they are just follow-on information
about the previous diag, not a diagnostic in themselves.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100675 91177308-0d34-0410-b5e6-96231b3b80d8
849b243d4065f56742a4677d6dc8277609a151f8 31-Mar-2010 Douglas Gregor <dgregor@apple.com> Reinstate my CodeModificationHint -> FixItHint renaming patch, without
the C-only "optimization".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100022 91177308-0d34-0410-b5e6-96231b3b80d8
275313cbb0847f1f117f60d144d113804d4fa42d 31-Mar-2010 Douglas Gregor <dgregor@apple.com> Revert r100008, which inexplicably breaks the clang-i686-darwin10 builder

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100018 91177308-0d34-0410-b5e6-96231b3b80d8
d0ebe080eee7c37e73754068b47fd90cc506e128 31-Mar-2010 Douglas Gregor <dgregor@apple.com> 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100008 91177308-0d34-0410-b5e6-96231b3b80d8
fe6b2d481d91140923f4541f273b253291884214 30-Mar-2010 Douglas Gregor <dgregor@apple.com> Optimize PartialDiagnostic's memory-allocation behavior by placing a
cache of PartialDiagnostic::Storage objects into an allocator within
the ASTContext. This eliminates a significant amount of malloc
traffic, for a 10% performance improvement in -fsyntax-only wall-clock
time with 403.gcc's combine.c.

Also, eliminate the RequireNonAbstractType hack I put in earlier,
which was but a symptom of this larger problem.

Fixes <rdar://problem/7806091>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99849 91177308-0d34-0410-b5e6-96231b3b80d8
eab5d1eaaa662c849f1f9920dc8c6a31d7c32d47 25-Mar-2010 Douglas Gregor <dgregor@apple.com> Teach the diagnostic engine to provide more detailed information about
how to handle a diagnostic during template argument deduction, which
may be "substitution failure", "suppress", or "report". This keeps us
from, e.g., emitting warnings while performing template argument

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99560 91177308-0d34-0410-b5e6-96231b3b80d8
9e2dac9c9b6bc4384c816a447cca6516a03c89f2 22-Mar-2010 Douglas Gregor <dgregor@apple.com> Fix a thinko and a typo in the delayed-diagnostic code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99178 91177308-0d34-0410-b5e6-96231b3b80d8
93ea5cb0edf8e509c5113e70cb05ee247c9bdf6b 22-Mar-2010 Douglas Gregor <dgregor@apple.com> Introduce the notion of a single "delayed" diagnostic into the
Diagnostic subsystem, which is used in the rare case where we find a
serious problem (i.e., an inconsistency in the file system) while
we're busy formatting another diagnostic. In this case, the delayed
diagnostic will be emitted after we're done with the other
diagnostic. This is only to be used for fatal conditions detected at
very inconvenient times, where we can neither stop the current
diagnostic in flight nor can we suppress the second error.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99175 91177308-0d34-0410-b5e6-96231b3b80d8
b9c903bc7c11adf86b1f1e68ad35cd49703dc654 19-Feb-2010 Douglas Gregor <dgregor@apple.com> Use a little binary header in serialized diagnostics to help the deserializer skip over noise in the stream

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96641 91177308-0d34-0410-b5e6-96231b3b80d8
0a812cf707da15dadd19fdeb0178b9707f4e01a6 19-Feb-2010 Douglas Gregor <dgregor@apple.com> Re-apply my diagnostics-capture patch for CIndex, with some tweaks to
try to address the msvc failures.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96624 91177308-0d34-0410-b5e6-96231b3b80d8
a88084b78fd4ca5d3d858c14b02414f8cc399f02 18-Feb-2010 Douglas Gregor <dgregor@apple.com> Rework how CIndex handles diagnostics. Rather than using a callback,
we attach diagnostics to translation units and code-completion
results, so they can be queried at any time.

To facilitate this, the new StoredDiagnostic class stores a diagnostic
in a serializable/deserializable form, and ASTUnit knows how to
capture diagnostics in this stored form. CIndex's CXDiagnostic is a
thin wrapper around StoredDiagnostic, providing a C interface to
stored or de-serialized diagnostics.

I've XFAIL'd one test case temporarily, because currently we end up
storing diagnostics in an ASTUnit that's never returned to the user
(because it contains errors). I'll introduce a temporary fix for this
soon; the real fix will be to allow us to return and query invalid ASTs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96592 91177308-0d34-0410-b5e6-96231b3b80d8
779cf424a153ca92d501af87cb50c7a701514a61 11-Feb-2010 John McCall <rjmccall@apple.com> Suppress warnings if their instantiation location is in a system header, not
their spelling location. This prevents warnings from being swallowed just
because the caret is on the first parenthesis in, say, NULL.

This is an experiment; the risk is that there might be a substantial number
of system headers which #define symbols to expressions which inherently cause
warnings. My theory is that that's rare enough that it can be worked
around case-by-case, and that producing useful warnings around NULL is worth
it. But I'm willing to accept that I might be empirically wrong.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95870 91177308-0d34-0410-b5e6-96231b3b80d8
d93256e55673a17d18543397ec462416acb13792 28-Jan-2010 Douglas Gregor <dgregor@apple.com> Introduce serialization and deserialization of diagnostic information
so that CIndex can report diagnostics through the normal mechanisms
even when executing Clang in a separate process. This applies both
when performing code completion and when using ASTs as an intermediary
for clang_createTranslationUnitFromSourceFile().

The serialized format is not perfect at the moment, because it does
not encapsulate macro-instantiation information. Instead, it maps all
source locations back to the instantiation location. However, it does
maintain source-range and fix-it information. To get perfect fidelity
from the serialized format would require serializing a large chunk of
the source manager; at present, it isn't clear if this code will live
long enough for that to matter.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94740 91177308-0d34-0410-b5e6-96231b3b80d8
909c182f6a0e6169475eef6a71add14555b6162c 14-Jan-2010 John McCall <rjmccall@apple.com> Pre-emptive bugfixes in the diagnostics code: allow arbitrary punctuation
characters to be escaped and implement a scan-forward function which
properly respects brace nesting.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93447 91177308-0d34-0410-b5e6-96231b3b80d8
3be16b7d9d0ab075461ed3498b4c01b30b517c0e 14-Jan-2010 John McCall <rjmccall@apple.com> Add the %ordinal format modifier for turning '1' into '1st'. Hard-coded for
English right now; would not be impossible to grab a special format string
from the diagnostic pool and localize that way.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93390 91177308-0d34-0410-b5e6-96231b3b80d8
9f28614bf1a8387000d8df57a713fcf69e198145 14-Jan-2010 John McCall <rjmccall@apple.com> Perform format-expansion on %select results.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93377 91177308-0d34-0410-b5e6-96231b3b80d8
e663c720063fc9ff9f75bcbe38cd070c73c78b0e 23-Dec-2009 Chris Lattner <sabre@nondot.org> implement -W[no-]fatal-errors, patch by Christian Adåker!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91938 91177308-0d34-0410-b5e6-96231b3b80d8
0304c6cb7fd3b2137213858b1e5ae85ef3f4f8e2 05-Dec-2009 Steve Naroff <snaroff@apple.com> Remove 'LangOpts' from Diagnostic (added in http://llvm.org/viewvc/llvm-project?view=rev&revision=90642).

Simply use the 'LangOpts' member already present in TextDiagnosticPrinter.

Sorry for the confusion!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90664 91177308-0d34-0410-b5e6-96231b3b80d8
e0c4d895ffe4320aa4e29485711ad7d154f2cc2b 05-Dec-2009 Steve Naroff <snaroff@apple.com> Integrate the following from the 'objective-rewrite' branch:


Note - This commit only includes the fix for:

<rdar://problem/6309338> slightly different error message format for Visual Studio.

The fix for <rdar://problem/6845623> from protocol to template. is separate/forthcoming.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90642 91177308-0d34-0410-b5e6-96231b3b80d8
32d4d80c26e8c4c1922cff4661e0b9f44a3aabfc 01-Dec-2009 Daniel Dunbar <daniel@zuster.org> Convert Diagnostic::getCustomDiagID to take a StringRef.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90244 91177308-0d34-0410-b5e6-96231b3b80d8
ca2c3e2cfc630db614298e8d7f2aaca4507e01e1 23-Oct-2009 John Thompson <John.Thompson.JTSoftware@gmail.com> Fixed undefined behavior in pushMappings when the stack has to resize.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84924 91177308-0d34-0410-b5e6-96231b3b80d8
b54d8af9a66cc20a6a9a9219c7eaea8df7ee7fd4 20-Oct-2009 Chris Lattner <sabre@nondot.org> teach FormatDiagnostic to aggregate previously formatted arguments and
pass them down into the ArgToStringFn implementation. This allows
redundancy across operands to a diagnostic to be eliminated.

This isn't used yet, so no functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84602 91177308-0d34-0410-b5e6-96231b3b80d8
01eb9b9683535d8a65c704ad2c545903409e2d36 18-Oct-2009 Daniel Dunbar <daniel@zuster.org> PR5218: Replace IdentifierInfo::getName with StringRef version, now that clients
are updated.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84447 91177308-0d34-0410-b5e6-96231b3b80d8
23e47c6b6e8ccdd8daa378ab2a879644425c72d8 17-Oct-2009 Daniel Dunbar <daniel@zuster.org> Use raw_ostream for formatting integers, and use IdentifierInfo::getNameStr
instead of getName.
- -2 FIXMEs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84337 91177308-0d34-0410-b5e6-96231b3b80d8
5a3ce9b10c164d9bf75a70d429e55d4e171a9a9e 16-Oct-2009 Chris Lattner <sabre@nondot.org> increase helpfulness of assert message.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84240 91177308-0d34-0410-b5e6-96231b3b80d8
3f09327b26033d0a9676d52d80cf92c48f581aff 13-Oct-2009 Douglas Gregor <dgregor@apple.com> Unify our diagnostic printing for errors of the form, "we didn't like
what we found when we looked into <blah>", where <blah> is a
DeclContext*. We can now format DeclContext*'s in nice ways, e.g.,
"namespace N", "the global namespace", "'class Foo'".

This is part of PR3990, but we're not quite there yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84028 91177308-0d34-0410-b5e6-96231b3b80d8
81b747b7fcc91c2fba9a3183d8fac80adbfc1d3e 17-Sep-2009 Douglas Gregor <dgregor@apple.com> Initial implementation of a code-completion interface in Clang. In
essence, code completion is triggered by a magic "code completion"
token produced by the lexer [*], which the parser recognizes at
certain points in the grammar. The parser then calls into the Action
object with the appropriate CodeCompletionXXX action.

Sema implements the CodeCompletionXXX callbacks by performing minimal
translation, then forwarding them to a CodeCompletionConsumer
subclass, which uses the results of semantic analysis to provide
code-completion results. At present, only a single, "printing" code
completion consumer is available, for regression testing and
debugging. However, the design is meant to permit other
code-completion consumers.

This initial commit contains two code-completion actions: one for
member access, e.g., "x." or "p->", and one for
nested-name-specifiers, e.g., "std::". More code-completion actions
will follow, along with improved gathering of code-completion results
for the various contexts.

[*] In the current -code-completion-dump testing/debugging mode, the
file is truncated at the completion point and EOF is translated into
"code completion".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82166 91177308-0d34-0410-b5e6-96231b3b80d8
1eb4433ac451dc16f4133a88af2d002ac26c58ef 09-Sep-2009 Mike Stump <mrs@apple.com> Remove tabs, and whitespace cleanups.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81346 91177308-0d34-0410-b5e6-96231b3b80d8
dacd434c49658286c380c7b4c357d76d53cb4aa1 26-Aug-2009 Douglas Gregor <dgregor@apple.com> Improve diagnostics and recovery when the nested-name-specifier of a
qualified name does not actually refer into a class/class
template/class template partial specialization.

Improve printing of nested-name-specifiers to eliminate redudant
qualifiers. Also, make it possible to output a nested-name-specifier
through a DiagnosticBuilder, although there are relatively few places
that will use this leeway.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80056 91177308-0d34-0410-b5e6-96231b3b80d8
04ae2df026b275aae5dddfc0db5ca55ff4e62179 12-Jul-2009 Chris Lattner <sabre@nondot.org> add push/pop semantics for diagnostics. Patch by Louis Gerbarg!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75431 91177308-0d34-0410-b5e6-96231b3b80d8
8439fac3ce6c26db7982e34d119bf905b57eac91 15-Jun-2009 Douglas Gregor <dgregor@apple.com> Base SFINAE error suppression counting on the class of an error, not
its (possibly-remapped) diagnostics. Thanks, Chris!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73390 91177308-0d34-0410-b5e6-96231b3b80d8
5e9f35c7cb61aea46f56d46c77cbcf47c0cf28ba 14-Jun-2009 Douglas Gregor <dgregor@apple.com> Update LLVM.

Implement support for C++ Substitution Failure Is Not An Error
(SFINAE), which says that errors that occur during template argument
deduction do *not* produce diagnostics and do not necessarily make a
program ill-formed. Instead, template argument deduction silently
fails. This is currently implemented for template argument deduction
during matching of class template partial specializations, although
the mechanism will also apply to template argument deduction for
function templates. The scheme is simple:

- If we are in a template argument deduction context, any diagnostic
that is considered a SFINAE error (or warning) will be
suppressed. The error will be propagated up the call stack via the
normal means.
- By default, all warnings and errors are SFINAE errors. Add the
NoSFINAE class to a diagnostic in the .td file to make it a hard
error (e.g., for access-control violations).

Note that, to make this fully work, every place in Sema that emits an
error *and then immediately recovers* will need to check
Sema::isSFINAEContext() to determine whether it must immediately
return an error rather than recovering.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73332 91177308-0d34-0410-b5e6-96231b3b80d8
a7e1898e6b84ed7911d1f25c975b27b78a4950cb 02-May-2009 Chris Lattner <sabre@nondot.org> when creating custom warning diagnostics, do not attempt to map
them with -Werror. Custom diags cannot be mapped, and this makes
-Werror cause a determinstic crash for the checker and other
clients of the custom diagnostics machinery. rdar://6816191

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70639 91177308-0d34-0410-b5e6-96231b3b80d8
e46e354ecb9a04c8d3724ae2b0f95f4424e3f69c 20-Apr-2009 Daniel Dunbar <daniel@zuster.org> Don't crash in the diagnostic printer if we happen to get passed a
null string / identifier.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69575 91177308-0d34-0410-b5e6-96231b3b80d8
3bc172bc6a787842db6fea351cf6929539fca70d 20-Apr-2009 Chris Lattner <sabre@nondot.org> move group twiddling options into Diagnostic.cpp instead of
Warnings.cpp. Warnings.cpp now doesn't need to #include
tblgen produced output directly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69559 91177308-0d34-0410-b5e6-96231b3b80d8
87d854ebedb43a9ff0f55591821dc5600984e479 16-Apr-2009 Chris Lattner <sabre@nondot.org> optimize and comment GetDiagInfo.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69273 91177308-0d34-0410-b5e6-96231b3b80d8
121f60c2aa51eae81eac75a9bd8c076140896f3d 16-Apr-2009 Chris Lattner <sabre@nondot.org> merge several scattered tables into StaticDiagInfo.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69272 91177308-0d34-0410-b5e6-96231b3b80d8
33dd2822f3972afe99b61315a890f8bad8ee5d7f 16-Apr-2009 Chris Lattner <sabre@nondot.org> Implement Diagnostic::getWarningOptionForDiag with information from tblgen,
this implements -fdiagnostics-show-option in clang-cc.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69271 91177308-0d34-0410-b5e6-96231b3b80d8
19cbb44e3c4f2181dafa2ab92d3e3a26619b71d9 16-Apr-2009 Chris Lattner <sabre@nondot.org> tblgen is now passing diagnostic group information in the .inc file, ignore it everywhere.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69269 91177308-0d34-0410-b5e6-96231b3b80d8
d51d74a3e89c5e5fc9bfd2814996a5feab6dc932 16-Apr-2009 Chris Lattner <sabre@nondot.org> implement framework for -fdiagnostics-show-option, but tblgen isn't
passing down the right info yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69268 91177308-0d34-0410-b5e6-96231b3b80d8
b54b276a920246c595a0498da281821eb9d22996 16-Apr-2009 Chris Lattner <sabre@nondot.org> move handling of -pedantic and -pedantic-errors into Diagnostics,
out of Warnings.cpp. This simplifies warnings.cpp and makes it more

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69266 91177308-0d34-0410-b5e6-96231b3b80d8
2b07d8fe9e8a8ba12d64066632e17a9a5308a12e 16-Apr-2009 Chris Lattner <sabre@nondot.org> arrange for -Wno-error=foo warnings to be immune to -Werror as
they are supposed to be.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69265 91177308-0d34-0410-b5e6-96231b3b80d8
691f1ae7164ba78c3dd7ac20c487399935b9544b 16-Apr-2009 Chris Lattner <sabre@nondot.org> change mappings to distinguish between "unset", "set by the user" and
"set to the default value".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69264 91177308-0d34-0410-b5e6-96231b3b80d8
fe526d2be9faf52a40640ed610baba9bc6cb16d8 15-Apr-2009 Chris Lattner <sabre@nondot.org> fix some out of bounds array access problems, which manifest particularly
spectacularly when built for x86-64.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69197 91177308-0d34-0410-b5e6-96231b3b80d8
d2aa7c90e7646c509f3493fa8548635ccf4a2d0a 15-Apr-2009 Chris Lattner <sabre@nondot.org> move {'s

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69179 91177308-0d34-0410-b5e6-96231b3b80d8
8a941e0c71d318430648e24eeca91a464a46eba9 15-Apr-2009 Chris Lattner <sabre@nondot.org> Make diagnostic class explicit in the diag record instead of
implicit from its parenting. Now that diag mapping is
explicit, eliminate the fatal and extwarn classes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69177 91177308-0d34-0410-b5e6-96231b3b80d8
4ac072aceb9c68f7a023050e2ab9ccacb4fe6e5b 15-Apr-2009 Chris Lattner <sabre@nondot.org> Tblgen now passes the default mapping explicitly, instead of having it
be tied to the diag class. This requires an LLVM tree update.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69175 91177308-0d34-0410-b5e6-96231b3b80d8
27ceb9d77d929f02a8a811d189a96885629c7c0c 15-Apr-2009 Chris Lattner <sabre@nondot.org> Rejigger how -pedantic and -pedantic-errors work and their interaction
with other diagnostic mapping. In the new scheme, -Wfoo or -Wno-foo or
-Werror=foo all override the -pedantic options, and __extension__
robustly silences all extension diagnostics in their scope.

An added bonus of this change is that MAP_DEFAULT goes away, meaning that
per-diagnostic mapping information can now be stored in 2 bits, doubling
the density of the Diagnostic::DiagMapping array. This also
substantially simplifies Diagnostic::getDiagnosticLevel.

OTOH, this temporarily introduces some "macro intensive" code in
Diagnostic.cpp. This will be addressed in a later patch.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69154 91177308-0d34-0410-b5e6-96231b3b80d8
25a88bbf042317976f0d9cbfa87dfe89426e8393 20-Mar-2009 Douglas Gregor <dgregor@apple.com> Eliminate post-diagnostic hooks. Instead, implement a Sema-specific
variant of DiagnosticBuilder that emits the template instantiation
backtrace when needed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67413 91177308-0d34-0410-b5e6-96231b3b80d8
4d7a089144f336b11e5e8ce437b3b27bce2b310d 20-Mar-2009 Sebastian Redl <sebastian.redl@getdesigned.at> Bindir and Win32 builds work, so switch to .inc files. Leave the .def files in the tree for a day or so longer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67346 91177308-0d34-0410-b5e6-96231b3b80d8
525c4b0d1bd1a70bf269adecf91b192f3e6c1a89 19-Mar-2009 Douglas Gregor <dgregor@apple.com> Allow notes to be printed following a fatal error, then suppress any
diagnostics following those notes.

Make exceeding the template instantiation depth a fatal error.

Thanks to Daniel for pointing out the problem!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67320 91177308-0d34-0410-b5e6-96231b3b80d8
e89b6b272f9f3b15afa56a701a4d7a6b1001ed34 14-Mar-2009 Sebastian Redl <sebastian.redl@getdesigned.at> Revert the switch to the tablegen diags. It fails for seperate objdir builds and cmake builds, and I have no clue what to do about it. Revisit this after someone with a clue about the build systems has looked at it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67009 91177308-0d34-0410-b5e6-96231b3b80d8
3801d71fbeb6e74a22cdd6a858e10d887bc29c7a 14-Mar-2009 Sebastian Redl <sebastian.redl@getdesigned.at> Switch diagnostics from .def to tablegen files. Please validate the Windows build.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67007 91177308-0d34-0410-b5e6-96231b3b80d8
50f4f469024928670f2d634c445686d00eeb89b7 12-Mar-2009 Daniel Dunbar <daniel@zuster.org> Add Diagnostic files for Frontend and move a couple errors over.
- Notably, clang now exits with an error if it can't find a
file. This flushed out a bug in the CGColorSpace.c test case. :)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66789 91177308-0d34-0410-b5e6-96231b3b80d8
4ad4b3ebbe5769143389dccfcfadb666a4ba5940 12-Mar-2009 Daniel Dunbar <daniel@zuster.org> Driver: Use standard Diagnostic interface for diagnostics.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66786 91177308-0d34-0410-b5e6-96231b3b80d8
ee1828a6b5ae1bc4ea300e48f3840ac1ec5be295 10-Mar-2009 Douglas Gregor <dgregor@apple.com> Add a notion of "post-diagnostic hooks", which are callbacks attached
to a diagnostic that will be invoked after the diagnostic (if it is
not suppressed). The hooks are allowed to produce additional
diagnostics (typically notes) that provide more information. We should
be able to use this to help diagnostic clients link notes back to the
diagnostic they clarify. Comments welcome; I'll write up documentation
and convert other clients (e.g., overload resolution failures) if
there are no screams of protest.

As the first client of post-diagnostic hooks, we now produce a
template instantiation backtrace when a failure occurs during template
instantiation. There's still more work to do to make this output
pretty, if that's even possible.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66557 91177308-0d34-0410-b5e6-96231b3b80d8
d42ffbd22fc7eb61321f6a88173ee424991f01c6 07-Mar-2009 Ted Kremenek <kremenek@apple.com> Revert my last couple patches until I can get them to not make the tests fail.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66317 91177308-0d34-0410-b5e6-96231b3b80d8
b9eb3afc9eafbb1c6815c8b63633065f370be6a5 07-Mar-2009 Ted Kremenek <kremenek@apple.com> Teach Diagnostic about Selector.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66314 91177308-0d34-0410-b5e6-96231b3b80d8
92dd386e3f05d176b45a638199d51f536bd9d1c4 20-Feb-2009 Chris Lattner <sabre@nondot.org> replace a dirty hack with a clean solution. Too bad we can't
use Blocks for our callbacks ;-)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65083 91177308-0d34-0410-b5e6-96231b3b80d8
d0344a4a6182ad704881cbbaa21cca14913d2296 20-Feb-2009 Chris Lattner <sabre@nondot.org> Fix a long standard problem with clang retaining "too much" sugar
information about types. We often print diagnostics where we say
"foo_t" is bad, but the user doesn't know how foo_t is declared
(because it is a typedef). Fix this by expanding sugar when present
in a diagnostic (and not one of a few special cases, like vectors).

t.m:5:2: error: invalid operands to binary expression ('typeof(P)' and 'typeof(F)')
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; })

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; })

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65081 91177308-0d34-0410-b5e6-96231b3b80d8
336f26be05c30c0c65b8b518d68f04c29b43b3d2 17-Feb-2009 Chris Lattner <sabre@nondot.org> fix a minor bug with my previous patch

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64747 91177308-0d34-0410-b5e6-96231b3b80d8
f5d2328fc849288c3a62e43d065685f516d57091 17-Feb-2009 Chris Lattner <sabre@nondot.org> fix notes so that they are always filtered with the same logic
as the last non-note diagnostic that preceeded them. This ensures
that diagnostics in main files which have notes with locations in
system headers get all the bits and pieces emitted or not in a
unit. This fixes PR3215.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64746 91177308-0d34-0410-b5e6-96231b3b80d8
15221422eda7bac679e38b07512feda49715ef66 06-Feb-2009 Chris Lattner <sabre@nondot.org> don't emit any diagnostics after a fatal one.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63914 91177308-0d34-0410-b5e6-96231b3b80d8
da0cbc1ad4a553c4de111c1181ec7b42c5ddefce 05-Feb-2009 Chris Lattner <sabre@nondot.org> add support to the diagnostics machinery for mapping warnings and
errors to 'fatal' error severity.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63894 91177308-0d34-0410-b5e6-96231b3b80d8
47b9a1ca55e61e37f5a368740e29de190345acc6 04-Feb-2009 Douglas Gregor <dgregor@apple.com> Some name-lookup-related fixes, from Piotr Rak!

- Changes Lookup*Name functions to return NamedDecls, instead of
Decls. Unfortunately my recent statement that it will simplify lot of
code, was not quite right, but it simplifies some...
- Makes MergeLookupResult SmallPtrSet instead of vector, following
Douglas suggestions.
- Adds %qN format for printing qualified names to Diagnostic.
- Avoids searching for using-directives in Scopes, which are not
DeclScope, during unqualified name lookup.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63739 91177308-0d34-0410-b5e6-96231b3b80d8
19e8e2cffc19606d0f44e7c2897cd126ffd3f9b0 29-Jan-2009 Chris Lattner <sabre@nondot.org> next round of diagnostics cleanups, moving some
diags around, eliminating #defines, etc. Patch by
Anders Johnsen!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63318 91177308-0d34-0410-b5e6-96231b3b80d8
88eccaf06f9d88191723e71bdf5ca68409393be6 29-Jan-2009 Chris Lattner <sabre@nondot.org> Fix -Wimplicit-function-declaration, which required some refactoring and
changes in various diagnostics code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63282 91177308-0d34-0410-b5e6-96231b3b80d8
20c6b3b85e186cd52d5d99489132d71d498159eb 27-Jan-2009 Chris Lattner <sabre@nondot.org> Split the single monolithic DiagnosticKinds.def file into one
.def file for each library. This means that adding a diagnostic
to sema doesn't require all the other libraries to be rebuilt.

Patch by Anders Johnsen!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63111 91177308-0d34-0410-b5e6-96231b3b80d8
cabe66811fe43835b8c5a0854552768fc53261e3 23-Jan-2009 Ted Kremenek <kremenek@apple.com> Added virtual method DiagnosticClient::IncludeInDiagnosticCounts(). This is used by Diagnostics to determine if a diagnostic sent to a given DiagnosticClient should be included in the count of diagnostics. The default implementation of this method returns 'true'.

Implemented DiagCollector::IncludeInDiagnosticCounts() to return 'false' so that the batching of diagnostics for use with BugReporter doesn't mess up the count of real diagnostics.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62873 91177308-0d34-0410-b5e6-96231b3b80d8
df7c17a8d02fe09a3466786bae3e40fc3252687a 16-Jan-2009 Chris Lattner <sabre@nondot.org> Change some terminology in SourceLocation: instead of referring to
the "physical" location of tokens, refer to the "spelling" location.
This is more concrete and useful, tokens aren't really physical objects!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62309 91177308-0d34-0410-b5e6-96231b3b80d8
e20653219732b03294130999415fc3aa92d2336a 27-Nov-2008 Sebastian Redl <sebastian.redl@getdesigned.at> Fix order of evaluation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60160 91177308-0d34-0410-b5e6-96231b3b80d8
08631c5fa053867146b5ee8be658c229f6bf127c 23-Nov-2008 Chris Lattner <sabre@nondot.org> Convert IdentifierInfo's to be printed the same as DeclarationNames
with implicit quotes around them. This has a bunch of follow-on
effects and requires tweaking to a whole lot of code. This causes
a regression in two tests (xfailed) by causing it to emit things like:

Line 10: duplicate interface declaration for category 'MyClass1' ('Category1')

instead of:

Line 10: duplicate interface declaration for category 'MyClass1(Category1)'

I will fix this in a follow-up commit.

As part of this, I had to start switching stuff to use ->getDeclName() instead
of Decl::getName() for consistency. This is good, but I was planning to do this
as an independent patch. There will be several follow-on patches
to clean up some of the mess, but this patch is already too big.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59917 91177308-0d34-0410-b5e6-96231b3b80d8
011bb4edf731d529da1cbf71c7c2696aaf5a054f 23-Nov-2008 Chris Lattner <sabre@nondot.org> add support for inserting a DeclarationName into a diagnostic directly
without calling getAsString(). This implicitly puts quotes around the
name, so diagnostics need to be tweaked to accommodate this.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59916 91177308-0d34-0410-b5e6-96231b3b80d8
3fdf4b071dc79fae778fb5f376485480756c76a3 23-Nov-2008 Chris Lattner <sabre@nondot.org> Genericize the qualtype formating callback to support any diag argument.
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59908 91177308-0d34-0410-b5e6-96231b3b80d8
22caddc91d2f6186739c6b20ec58ed38cd68e595 23-Nov-2008 Chris Lattner <sabre@nondot.org> Add support for sending QualType's directly into diags and convert two
diags over to use this. QualTypes implicitly print single quotes around
them for uniformity and future extension.

Doing this requires a little function pointer dance to prevent libbasic
from depending on libast.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59907 91177308-0d34-0410-b5e6-96231b3b80d8
e4c452c4c7b9124fe94a96f559ff077d59cdf996 22-Nov-2008 Sebastian Redl <sebastian.redl@getdesigned.at> Implement a %plural modifier for complex plural forms in diagnostics. Use it in the overload diagnostics.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59871 91177308-0d34-0410-b5e6-96231b3b80d8
3cbfe2c4159e0a219ae660d50625c013aa4afbd0 22-Nov-2008 Chris Lattner <sabre@nondot.org> Split the DiagnosticInfo class into two disjoint classes:
one for building up the diagnostic that is in flight (DiagnosticBuilder)
and one for pulling structured information out of the diagnostic when
formatting and presenting it.

There is no functionality change with this patch.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59849 91177308-0d34-0410-b5e6-96231b3b80d8
af7ae4e8160fc5c23e471f2125b3fe5911e3532a 21-Nov-2008 Chris Lattner <sabre@nondot.org> Add the concept of "modifiers" to the clang diagnostic format
strings. This allows us to have considerable flexibility in how
these things are displayed and provides extra information that
allows us to merge away diagnostics that are very similar.

Diagnostic modifiers are a string of characters with the regex
[-a-z]+ that occur between the % and digit. They may
optionally have an argument that can parameterize them.

For now, I've added two example modifiers. One is a very useful
tool that allows you to factor commonality across diagnostics
that need single words or phrases combined. Basically you can
use %select{a|b|c}4 with with an integer argument that selects
either a/b/c based on an integer value in the range [0..3).

The second modifier is also an integer modifier, aimed to help
English diagnostics handle plurality. "%s3" prints to 's' if
integer argument #3 is not 1, otherwise it prints to nothing.
I'm fully aware that 's' is an English concept and doesn't
apply to all situations (mouse vs mice). However, this is very
useful and we can add other crazy modifiers once we add support
for polish! ;-)

I converted a couple C++ diagnostics over to use this as an
example, I'd appreciate it if others could merge the other
likely candiates. If you have other modifiers that you want,
lets talk on cfe-dev.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59803 91177308-0d34-0410-b5e6-96231b3b80d8
43b628cd47ecdc3caf640d79b3ad7ecef0f2c285 19-Nov-2008 Chris Lattner <sabre@nondot.org> Allow sending IdentifierInfo*'s into Diagnostics without turning them into strings
first. This should allow removal of a bunch of II->getName() calls.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59601 91177308-0d34-0410-b5e6-96231b3b80d8
30bc96544346bea42921cf6837e66cef80d664b4 19-Nov-2008 Chris Lattner <sabre@nondot.org> add direct support for signed and unsigned integer arguments to diagnostics.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59598 91177308-0d34-0410-b5e6-96231b3b80d8
f4c839657742b823cea1a95b18422f1ba74d3ddd 19-Nov-2008 Chris Lattner <sabre@nondot.org> rewrite FormatDiagnostic to be less gross and a lot more efficient.
This also makes it illegal to have bare '%'s in diagnostics. If you
want a % in a diagnostic, use %%.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59596 91177308-0d34-0410-b5e6-96231b3b80d8
73d2a1b05bb04ab0136af374ddaa5d4602d4c939 19-Nov-2008 Chris Lattner <sabre@nondot.org> implement a transparent optimization with the diagnostics stuff:
const char*'s are now not converted to std::strings when the diagnostic
is formed, we just hold onto their pointer and format as needed.

This commit makes DiagnosticClient::FormatDiagnostic even more of a
mess, I'll fix it in the next commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59593 91177308-0d34-0410-b5e6-96231b3b80d8
0a14eee528a901c16f0e288fbc10a3abc1660d87 18-Nov-2008 Chris Lattner <sabre@nondot.org> This reworks some of the Diagnostic interfaces a bit to change how diagnostics
are formed. In particular, a diagnostic with all its strings and ranges is now
packaged up and sent to DiagnosticClients as a DiagnosticInfo instead of as a
ton of random stuff. This has the benefit of simplifying the interface, making
it more extensible, and allowing us to do more checking for things like access
past the end of the various arrays passed in.

In addition to introducing DiagnosticInfo, this also substantially changes how
Diagnostic::Report works. Instead of being passed in all of the info required
to issue a diagnostic, Report now takes only the required info (a location and
ID) and returns a fresh DiagnosticInfo *by value*. The caller is then free to
stuff strings and ranges into the DiagnosticInfo with the << operator. When
the dtor runs on the DiagnosticInfo object (which should happen at the end of
the statement), the diagnostic is actually emitted with all of the accumulated
information. This is a somewhat tricky dance, but it means that the
accumulated DiagnosticInfo is allowed to keep pointers to other expression
temporaries without those pointers getting invalidated.

This is just the minimal change to get this stuff working, but this will allow
us to eliminate the zillions of variant "Diag" methods scattered throughout
(e.g.) sema. For example, instead of calling:

Diag(BuiltinLoc, diag::err_overload_no_match, typeNames,
SourceRange(BuiltinLoc, RParenLoc));

We will soon be able to just do:

Diag(BuiltinLoc, diag::err_overload_no_match)
<< typeNames << SourceRange(BuiltinLoc, RParenLoc));

This scales better to support arbitrary types being passed in (not just
strings) in a type-safe way. Go operator overloading?!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59502 91177308-0d34-0410-b5e6-96231b3b80d8
2383b7f6aea2cb2bf2b5bfc0ec730f9354fecbbf 18-Nov-2008 Chris Lattner <sabre@nondot.org> Change the diagnostics interface to take an array of pointers to
strings instead of array of strings. This reduces string copying
in some not-very-important cases, but paves the way for future

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59494 91177308-0d34-0410-b5e6-96231b3b80d8
e7f74fc1964527bcaeff1bdb979d67f8e9087097 16-Nov-2008 Chris Lattner <sabre@nondot.org> Fix PR3077: tokens that come from macro expansions whose macro was
defined in a system header should be treated as system header tokens
even if they are instantiated in a different place.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59418 91177308-0d34-0410-b5e6-96231b3b80d8
a1f23cc7f5dae8b71b8ee631994274609d35eb89 17-Oct-2008 Chris Lattner <sabre@nondot.org> fix rdar://6288301: custom warnings don't respect -Werror.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57731 91177308-0d34-0410-b5e6-96231b3b80d8
2fe0997427d92388e66e7573f4b043e7ba285ef0 12-Sep-2008 Daniel Dunbar <daniel@zuster.org> Add --suppress-system-warnings (on by default, use =0 to disable)
- For investigating warnings in system headers / builtins.
- Currently also enables the behavior that allows silent redefinition
of types in system headers. Conceptually these are separate but I
didn't feel it was worth two options (or changing LangOptions).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56163 91177308-0d34-0410-b5e6-96231b3b80d8
7bfaaaecb3113f955db31e8d8a51acffd1bc0c27 10-Aug-2008 Nico Weber <nicolasweber@gmx.de> * Remove isInSystemHeader() from DiagClient, move it to SourceManager
* Move FormatError() from TextDiagnostic up to DiagClient, remove now
empty class TextDiagnostic
* Make DiagClient optional for Diagnostic

This fixes the following problems:

* -html-diags (and probably others) does now output the same set of
warnings as console clang does
* nothing crashes if one forgets to call setHeaderSearch() on
* some code duplication is removed

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54620 91177308-0d34-0410-b5e6-96231b3b80d8
b4398aa27da4d6919c3ae448d1ae66ba6cafc048 07-Aug-2008 Ted Kremenek <kremenek@apple.com> Fix --html-diags in driver by delaying the construction of an HTMLDiagnosticClient until after we have created the Preprocessor object.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54472 91177308-0d34-0410-b5e6-96231b3b80d8
4489fe10fa073eb326e2c8906db170f009050911 05-Aug-2008 Daniel Dunbar <daniel@zuster.org> Add EXTWARN Diagnostic class.
- Like EXTENSION but always generates a warning (even without
- Updated ptr -> int, int -> ptr, and incompatible cast warnings to
- Other EXTENSION level diagnostics should be audited for upgrade.
- Updated several test cases to fix code which produced unanticipated

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54335 91177308-0d34-0410-b5e6-96231b3b80d8
5b4681c8ef65808ec4d72ab6081efd24d53d4969 29-May-2008 Chris Lattner <sabre@nondot.org> Implement support for -w, which silences all warnings. PR2384.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51683 91177308-0d34-0410-b5e6-96231b3b80d8
d0734e56d6794181e672d705ddb6e5e1f24af4ed 14-Apr-2008 Ted Kremenek <kremenek@apple.com> Fix regression in Diagnostic that caused it to not register the number
of errors.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49686 91177308-0d34-0410-b5e6-96231b3b80d8
06bdb3a4fa8e84721b57a86f73aa3224f5367d58 14-Apr-2008 Ted Kremenek <kremenek@apple.com> Only increment the number of diagnostics when the DiagnosticClient used
is the one attached to the Diagnostic object.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49677 91177308-0d34-0410-b5e6-96231b3b80d8
615f5177095e62b36bf88f1b1b7b644295e4097b 31-Mar-2008 Ted Kremenek <kremenek@apple.com> Added variation of the "Report" method in the class Diagnostic that takes
an optional DiagnosticClient argument that differs from the client stored
internally in the Diagnostic object.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48986 91177308-0d34-0410-b5e6-96231b3b80d8
bda0b626e74513950405c27525af87e214e605e2 16-Mar-2008 Chris Lattner <sabre@nondot.org> Make a major restructuring of the clang tree: introduce a top-level
lib dir and move all the libraries into it. This follows the main
llvm tree, and allows the libraries to be built in parallel. The
top level now enforces that all the libs are built before Driver,
but we don't care what order the libs are built in. This speeds
up parallel builds, particularly incremental ones.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48402 91177308-0d34-0410-b5e6-96231b3b80d8