1) Teach ExpectAndConsume() to emit expected and expected-after diagnostics
using the generic diagnostic descriptions added in r197972, eliminating another
set of trivial err_expected_* variations while maintaining existing behaviour.
2) Lift SkipUntil() recovery out of ExpectAndConsume(). The Expect/Consume
family of functions are primitive parser operations that now have the
well-defined property of operating on single tokens. Factoring out recovery
exposes opportunities for more consistent and tailored error recover at the
call sites instead of just relying on a bottled SkipUntil formula.
llvm-svn: 198270
Previously any error in enum definition body stopped parsing it. With this
change parser tries to recover from errors.
The patch fixes PR10982.
Differential Revision: http://llvm-reviews.chandlerc.com/D2018
llvm-svn: 198259
lib/ASTMatchers/ASTMatchFinder.cpp:276:28: error: typedef 'traverse_can_only_be_instantiated_with_base_type' locally defined but not used [-Werror=unused-local-typedefs]
traverse_can_only_be_instantiated_with_base_type);
llvm-svn: 198256
important for thread safety attributes, which contain expressions that were
not being visited, and were thus invisible to various tools. There are now
Visit*Attr methods that can be overridden for every attribute.
llvm-svn: 198224
We have been seeing nasty directory layout with CMake multiconfig, such as,
bin/Release/clang.exe
lib/clang/3.x/...
lib/Release/clang/3.x/.. (duplicated)
Move the layout similar to autoconf's;
Release/bin/clang.exe
Release/lib/clang/3.x/...
Checked on Visual Studio 10. Could you guys please confirm my change on XCode(and other multiconfig builders)?
Note: Don't set variables CMAKE_*_OUTPUT_DIRECTORY any more, or a certain builder, for eaxample, msbuild.exe, would be confused.
llvm-svn: 198205
Also stop setting passing -dead_strip explicitly for libclang and instead
rely on this now happening by default. (And make it happen by default for
add_clang_library, which doesn't use the library cmake functions from llvm.)
llvm-svn: 198200
This is approaching consistency but the PP and Parse categories they still have
slightly different wording:
def err_pp_expected_after : Error<"missing %1 after %0">;
def err_expected_after : Error<"expected %1 after %0">;
llvm-svn: 198189
It may be a quick and dirty script but it's still useful to have some
indication as to its purpose.
Text taken straight from Jordan's r158682 commit message.
llvm-svn: 198128
'create' functions conventionally return a pointer, not a reference.
Also use an OwningPtr to get replace the delete of a reference member.
No functional change.
llvm-svn: 198126
This is a follow-up to r194907, which added a new -arch setting to make it
easier to specify AVX2 targets. The "-arch x86_64h" option needs to be passed
on to the linker, but it was getting canonicalized to x86_64 by the code
in getArchTypeForDarwinArchName.
llvm-svn: 198096
Most importantly, this makes our vtable layout match MSVC's. Previously
we would emit a return adjusting thunk whenever the return types
differed, even if the adjustment would have been trivial.
MSVC does emit some trivial return adjusting thunks, but only if there
was already an overridden method that required a return adjustment.
llvm-svn: 198080
Thisadds a new warning that warns on code like this:
if (memcmp(a, b, sizeof(a) != 0))
The warning looks like:
test4.cc:5:30: warning: size argument in 'memcmp' call is a comparison [-Wmemsize-comparison]
if (memcmp(a, b, sizeof(a) != 0))
~~~~~~~~~~^~~~
test4.cc:5:7: note: did you mean to compare the result of 'memcmp' instead?
if (memcmp(a, b, sizeof(a) != 0))
^ ~
)
test4.cc:5:20: note: explicitly cast the argument to size_t to silence this warning
if (memcmp(a, b, sizeof(a) != 0))
^
(size_t)( )
1 warning generated.
This found 2 bugs in chromium and has 0 false positives on both chromium and
llvm.
The idea of triggering this warning on a binop in the size argument is due to
rnk.
llvm-svn: 198063
With pragma pack, the layout engine would produce vfptrs that were
packed width rather than pointer width. This patch addresses the issue
and adds a test case.
llvm-svn: 198059
Since this warning was generalized, it was also given a sensible warning group flag and the corresponding test was updated to reflect this.
llvm-svn: 198053
Even g++ considers this a valid C++ identifier and it should only have been
visible in C mode.
Also drop the associated low-value diagnostic.
llvm-svn: 197995
Introduce proper facilities to render token spellings using the diagnostic
formatter.
Replaces most of the hard-coded diagnostic messages related to expected tokens,
which all shared the same semantics but had to be multiply defined due to
variations in token order or quote marks.
The associated parser changes are largely mechanical but they expose
commonality in whole chunks of the parser that can now be factored away.
This commit uses C++11 typed enums along with a speculative legacy fallback
until the transition is complete.
Requires corresponding changes in LLVM r197895.
llvm-svn: 197972
The TextDiagnosticBuffer is meant to scrub SourceLocations as the input/output
SourceManagers may be different.
To be safe this commit restores the original behaviour though in practice
all current users seem to share a single SM.
Would be nice to replace TextDiagnosticBuffer now that more capable interfaces
like CaptureDiagnosticConsumer / StoredDiagnosticConsumer exist.
llvm-svn: 197902
These names weren't referred to anywhere in the source so don't need a written
name.
Depends on the TableGen fix for anonymous records in LLVM r197869.
llvm-svn: 197896
DiagIDs are a cached resource generally only constructed from compile-time
constant or stable format strings.
Escaping arbitrary messages and constructing DiagIDs from them didn't make
sense.
llvm-svn: 197856
This new warning detects when a function will recursively call itself on every
code path though that function. This catches simple recursive cases such as:
void foo() {
foo();
}
As well as more complex functions like:
void bar() {
if (test()) {
bar();
return;
} else {
bar();
}
return;
}
This warning uses the CFG. As with other CFG-based warnings, this is off
by default. Due to false positives, this warning is also disabled for
templated functions.
llvm-svn: 197853
Without this patch, record decls with invalid out-of-line method delcs would
sometimes be marked invalid, but not always. With this patch, they are
consistently never marked invalid.
(The code to do this was added in
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20100809/033154.html
, but the test from that revision is still passing.)
As far as I can tell, this was the only place where a class was marked invalid
after its definition was complete.
llvm-svn: 197848
Now CodeGenVTables has only one VTableContext object, which is either
Itanium or Microsoft.
Fixes a FIXME with no functionality change intended.
Ideally we could avoid the downcasts by pushing the things that
reference the Itanium vtable context into ItaniumCXXABI.cpp, but we're
not there yet.
llvm-svn: 197845
These members will still be lazily added to the relevant DWARF DIEs in
LLVM but when enumerating the members they will not appear. This allows
DWARF type units to be more consistent - the type unit will never
contain these special members (so all instances of the type should have
the same DIEs without some having some special members and others having
others) and the special members will be added to the skeletal
declaration that appears in the relevant compile_unit.
llvm-svn: 197844
This matches llc's behavior.
Before this patch clang would create a TargetInfo base on -triple but a llvm
CodeGen based on the triple in the module.
llvm-svn: 197837
This was part of the cause for PR17655. We were generating thunks when
we shouldn't have. I suspect that if we tweak the test case for PR17655
to actually require thunks, we can reproduce the same crash.
llvm-svn: 197836
If a header file belonging to a certain module is not found on the
filesystem, that header gets marked as unavailable. Now, the layering
warning (-fmodules-decluse) should still warn about headers of this
module being wrongfully included. Currently, headers belonging to those
modules are just treated as not belonging to modules at all which means
they can be included freely from everywhere.
To implement this (somewhat) cleanly, I have moved most of the layering
checks into the ModuleMap. This will also help with showing FixIts
later.
llvm-svn: 197805
This caused some crazy crashes involving std::unordered_map being
deserialized from a PCH file and then template instantiation requiring
an explicit instantiation location; unfortunately I don't really know
how to come up with a minimal test case.
llvm-svn: 197764
files to tell if they were changed since the last time we have computed the
preamble
We used to check only the buffer size, so if the new remapped buffer has the
same size as the previous one, we would think that the buffer did not change,
and we did not rebuild the preambule, which sometimes caused us to crash.
llvm-svn: 197755
We have assertions for this, but a few edge cases had snuck through where
we were still unconditionally using 'int'.
<rdar://problem/15703011>
llvm-svn: 197733
A comment following the "{" of a braced list seems to almost always
refer to the first element of the list and thus should be aligned
to it.
Before (with Cpp11 braced list style):
SomeFunction({ // Comment 1
"first entry",
// Comment 2
"second entry"});
After:
SomeFunction({// Comment 1
"first entry",
// Comment 2
"second entry"});
llvm-svn: 197725
- If llvm-config fails, output an error to the user rather than allowing
errors to cascade.
- Always get llvm-tblgen from llvm-config's bindir.
Turns out my PATH points to a really old version of LLVM; both of these
fell out of trying to make this experience nicer.
llvm-svn: 197714
Unexpectedly, it seems that people commonly know what they were doing
when writing a comment.
Also, being more conservative about comment breaking has the advantage
of giving more flexibility. If a linebreak within the comment can
improve formatting, the author can add it (after which clang-format
won't undo it). There is no way to override clang-format's behavior if
it breaks a comment.
llvm-svn: 197698
Checked on VS10(multiconfig) and some singleconfig builders.
* Assumptions
- You should specify llvm-config as LLVM_CONFIG.
CMake could find one in $PATH by default.
- ENABLE_ASSERTIONS obeys LLVM's.
* Use cases
a) With LLVM build tree
Assume llvm-config is in your build tree.
Everything should work as ever.
b) With *installed* LLVM
Assume distributions. The source tree can be optional.
b1) The source tree is provided on the location `llvm-config --src-root`
- Test utils, FileCheck &c., are imported and built in the new tree.
- Gtest is built in the tree if gtest library is not found.
- Lit is used in $(SRCROOT)/utils/lit/lit.py.
b2) The source tree is not provided
- clang and utilities can be built.
- All tests, unittests and check-clang are invalidated and not built.
llvm-svn: 197697
We started by trying to deserialize decltype(func-param) in a trailing return
type, which causes the function parameter decl to be deserialized, which pulls
in the function decl, which pulls the function type, which pulls the same
decltype() in the return type, and then we crashed.
llvm-svn: 197644
The alignment impact of the virtual bases apperas to be applied in
order, rather than up front. This patch adds the new behavior and
provides a test case.
llvm-svn: 197639
Fixes <rdar://problem/15584219> and <rdar://problem/12241361>.
This change looks large, but all it does is reuse and consolidate
the delayed diagnostic logic for deprecation warnings with unavailability
warnings. By doing so, it showed various inconsistencies between the
diagnostics, which were close, but not consistent. It also revealed
some missing "note:"'s in the deprecated diagnostics that were showing
up in the unavailable diagnostics, etc.
This change also changes the wording of the core deprecation diagnostics.
Instead of saying "function has been explicitly marked deprecated"
we now saw "'X' has been been explicitly marked deprecated". It
turns out providing a bit more context is useful, and often we
got the actual term wrong or it was not very precise
(e.g., "function" instead of "destructor"). By just saying the name
of the thing that is deprecated/deleted/unavailable we define
this issue away. This diagnostic can likely be further wordsmithed
to be shorter.
llvm-svn: 197627
The problem here is more serious than the fix implies. Adding a field
to a class updates the triviality bits for the class (among other
things). Failing to require a complete type before adding the field
meant that these updates don't happen in the well-formed case where
the capture is an uninstantiated class template specialization,
leading the lambda itself to be treated as having a trivial copy
constructor when it shouldn't. Fixes <rdar://problem/15560464>.
llvm-svn: 197623
Move some of the verifier directives away from the end of the pragma line.
This ensures that the diagnostics relate to the trailing token being tested and
not the verifier comments which are themselves part of the token stream.
llvm-svn: 197616
While debating the finer points of file extension matching, we somehow missed
the bigger problem that the current code will match anything starting with the
default or user-specified pattern (e.g. lit.site.cfg.in).
Fix this by doing what find(1) does, implicitly wrapping the pattern with ^$.
llvm-svn: 197608
cstring, converted to NSString, produce the
matching AST for it. This also required some
refactoring of the previous code. // rdar://14106083
llvm-svn: 197605
The recovery was failing due to a missing case in SkipUntil().
Also add back tests from r197553 that were reverted in the previous commit.
llvm-svn: 197598
These parser changes were redundant. The same or better recovery can be
achieved with a one-line fix to SkipUntil() due to land in the next commit.
This reverts commit r197553.
llvm-svn: 197597
This commit kills off custom type specifier and keyword handling of OpenCL C
data types.
Although the OpenCL spec describes them as keywords, we can handle them more
elegantly as predefined types. This should provide better error correction and
code completion as well as simplifying the implementation.
The primary intention is however to simplify the C/C++ parser and save some
packed bits on AST structures that had been extended in r170432 just for
OpenCL.
llvm-svn: 197578
Before:
aaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
aaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();
After:
aaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
aaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();
Probably still not ideal, but should be a step into the right direction.
llvm-svn: 197557
Right now clang produces the same DataLayout for all of them, but it could, for
example, add 'n' specifications when the end architecture is given.
No functionality change, this should just make future changes easier to read.
llvm-svn: 197549
This has no functionality change as clang adds explicit alignment info for
byval arguments. The only difference is that now the clang produced
DataLayout string for AArch64 is identical to the LLVM produced one.
llvm-svn: 197538
Unlike Itanium's VTTs, the 'most derived' boolean or bitfield is the
last parameter for non-variadic constructors, rather than the second.
For variadic constructors, the 'most derived' parameter comes after the
'this' parameter. This affects constructor calls and constructor decls
in a variety of places.
Reviewers: timurrrr
Differential Revision: http://llvm-reviews.chandlerc.com/D2405
llvm-svn: 197518
Avoid the gratuitous repurposing of C++ keyword 'private' by using a keyword
alias.
Also attempt to document the OpenCL keywords based on scraps of information
found online.
The purpose of this commit is to reduce impact on the C++ parser.
llvm-svn: 197511
We would previously emit redundant diagnostics for the following code:
struct S {
virtual ~S() = delete;
void operator delete(void*, int);
void operator delete(void*, double);
} s;
First we would check on ~S() and error about the ambigous delete functions,
and then we would error about using the deleted destructor.
If the destructor is deleted, there's no need to check it.
Also, move the check from Sema::ActOnFields to CheckCompleteCXXClass. These
are run at almost the same time, called from ActOnFinishCXXMemberSpecification.
However, CHeckCompleteCXXClass may mark a defaulted destructor as deleted, and
if that's the case we don't want to check it.
Differential Revision: http://llvm-reviews.chandlerc.com/D2421
llvm-svn: 197509
1) Introduce TryConsumeToken() to handle the common test-and-consume pattern.
This brings about readability improvements in the parser and optimizes to avoid
redundant checks in the common case.
2) Eliminate the ConsumeCodeCompletionTok special case from ConsumeToken(). This
was used by only one caller which has been switched over to the more
appropriate ConsumeCodeCompletionToken() function.
llvm-svn: 197497
Now that we emit diagnostics for keyword-as-identifier hacks (-Wkeyword-compat)
we can go ahead and simplify some of the old revertible keyword support.
This commit adds a TryIdentKeywordUpgrade() function to mirror the recently
added TryKeywordIdentFallback() and uses it to replace the hard-coded list of
REVERTIBLE_TYPE_TRAITs.
llvm-svn: 197496
Formatting this:
void f() { // 1 space initial indent.
int i;
#define A \
int i; \
int j;
int k; // Format this line.
}
void f() {
#define A 1 // Format this line.
}
Before:
void f() { // 1 space initial indent.
int i;
#define A \
int i; \
int j;
int k; // Format this line.
}
void f() {
#define A 1 // Format this line.
}
After:
void f() { // 1 space initial indent.
int i;
#define A \
int i; \
int j;
int k; // Format this line.
}
void f() {
#define A 1 // Format this line.
}
llvm-svn: 197494
Instead, mark the module as unavailable so that clang errors as soon as
someone tries to build this module.
This works towards the long-term goal of not stat'ing the header files at all
while reading the module map and instead read them only when the module is
being built (there is a corresponding FIXME in parseHeaderDecl()). However, it
seems non-trivial to get there and this unblock us and moves us into the right
direction.
Also changed the implementation to reuse the same DiagnosticsEngine.
llvm-svn: 197485
to determine if a move function is the std::move function. This allows functions
like std::__1::move to also be treated a the move function.
llvm-svn: 197445
This completes the cleanup/refactoring of DataLayout on the clang side. Next
is figuring out the differences between the llvm and clang produced strings
llvm-svn: 197442
of objc_bridge_related attribute; eliminate
unnecessary diagnostics which is issued elsewhere,
fixit now produces a valid AST tree per convention.
This results in some simplification in handling of
this attribute as well. // rdar://15499111
llvm-svn: 197436
This reverts commit 2b43f500cfea10a8c59c986dcfc24fd08eecc77d.
This was accidentally committed because I failed to notice my client
wasn't clean prior to submitting a fix for a crasher.
llvm-svn: 197410
CXXScopeSpec when necessary while performing typo correction. This fixes
the crash reported in PR18213 (the problem existed since r185487, and
r193020 made it easier to hit).
llvm-svn: 197409
Instead, mark the module as unavailable so that clang errors as soon as
someone tries to build this module.
A better long-term strategy might be to not stat the header files at all
while reading the module map and instead read them only when the module
is being built (there is a corresponding FIXME in parseHeaderDecl()).
However, it seems non-trivial to get there and this would be a temporary
solution to unblock us.
Also changed the implementation to reuse the same DiagnosticsEngine as
otherwise warnings can't be enabled or disabled with command-line flags.
llvm-svn: 197388
BreakConstructorInitializersBeforeComma is true.
This option is used in WebKit style, so this also ensures initializer lists are
not put on a single line, as per the WebKit coding guidelines.
Patch by Florian Sowade!
llvm-svn: 197386
Summary:
-regex and -iregex both mimic options of the find utility.
Made the default list of extensions case-insensitive, so that it's not only C
and CPP extensions are accepted in upper case.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D2415
llvm-svn: 197378
Especially try to keep existing line breaks before raw string literals,
as the code author might have aligned content to it.
Thereby, clang-format now keeps things like:
parseStyle(R"(
BasedOnStyle: Google,
ColumnLimit: 100)");
parseStyle(
R"(BasedOnStyle: Google,
ColumnLimit: 100)");
llvm-svn: 197368
An empty string for an ASM input constraint is invalid, and will crash
during clang CodeGen. Change TargetInfo::validateInputConstraint to
reject an empty string.
<rdar://problem/15552191>
llvm-svn: 197362
These right now just test that the same string is present in two files, but will
become more useful as clang's handling of DataLayout is refactored.
llvm-svn: 197347
__builtin_va_list and friends have been showing up where they shouldn't for way
to long, making unwanted appearences in -ast-print, tooling and source level
visitors and even the hello world tutorial on the clang website.
This commit factors down the implicit typedef and record creation facilities to
ensure they're marked implicit.
Also fixes a unit test that was testing incorrect behaviour, and removes old
hacks in the DeclPrinter that tried to skip implicit declarations manually.
llvm-svn: 197336
The warning for backslash and newline separated by whitespace was missed in
this code path.
backslash<whitespace><newline> is handled differently from compiler to compiler
so it's important to warn consistently where there's ambiguity.
Matches similar handling of block comments and non-comment lines.
llvm-svn: 197331
is specialized by an explicit specialization, start from the first declaration
in case we've got a member of a class template (redeclarations might not number
the template parameters the same way).
Our recover here is still far from ideal.
llvm-svn: 197305
This patch was submitted to the list for review and didn't receive a LGTM.
(In fact one explicit objection and one query were raised.)
This reverts commit r197295.
llvm-svn: 197299
clang still doesn't emit the right llvm code when initializing multi-D arrays it seems.
For e.g. the following code would still crash for me on Windows 7, 64 bit:
auto f4 = new int[100][200][300]{{{1,2,3}, {4, 5, 6}}, {{10, 20, 30}}};
It seems that the final new loop that iterates through each outermost array and memsets it to zero gets confused with its final ptr arithmetic.
This patch ensures that it converts the pointer to the allocated type (int [200][300]) before incrementing it (instead of using the base type: 'int').
Richard somewhat squeamishly approved the patch (as a quick fix to potentially make it into 3.4) - while exhorting for a more optimized fix in the future. http://llvm-reviews.chandlerc.com/D2398
Thanks Richard!
llvm-svn: 197294