enum-scoped.cpp:93:6: error: enumeration redeclared with different underlying type 'short' (was 'int')
enum Redeclare6 : short;
^
enum-scoped.cpp:92:6: note: previous declaration is here
enum Redeclare6 : int;
^ ~~~
The redeclaration source range is still missing but this is a step forward,
potentially edging towards a FixIt.
llvm-svn: 198601
In all three checks, the note indicates a previous declaration and never a 'use'.
Before:
enum-scoped.cpp:92:6: note: previous use is here
enum Redeclare6 : int;
^
After:
enum-scoped.cpp:92:6: note: previous declaration is here
enum Redeclare6 : int;
^
llvm-svn: 198600
Before:
enum ShortEnum {
A,
B,
C
};
After:
enum ShortEnum { A, B, C };
This seems to be the predominant choice in LLVM/Clang as well as in
Google style.
llvm-svn: 198558
It was previously enabled in both but should only have been part of the drop-in
quirks mode that is 'MicrosoftMode' given that it's only useful for
compatibility with the Microsoft headers/runtime.
llvm-svn: 198548
Cover a hypothetical case when we might not have reached the final argument
declaration for some reason during recovery, and split out for readability.
llvm-svn: 198542
void knrNoSemi(i) int i { }
Adherents of The C Programming Language unfortunate enough to miss a semicolon
as above would be met with a cascade of errors spanning the remainder of the
TU.
This patch introduces a beautiful parse error recovery, complete with helpful
FixIt to restore sanity.
Before (output redacted for brevity):
error: 'error' diagnostics seen but not expected:
File declarators.c Line 119: declaration does not declare a parameter
File declarators.c Line 123: declaration does not declare a parameter
File declarators.c Line 127: parameter named 'func_E12' is missing
File declarators.c Line 127: expected ';' at end of declaration
File declarators.c Line 133: parameter named 'func_E13' is missing
File declarators.c Line 133: expected ';' at end of declaration
File declarators.c Line 139: parameter named 'func_E14' is missing
File declarators.c Line 139: expected ';' at end of declaration
File declarators.c Line 145: parameter named 'func_E15' is missing
File declarators.c Line 145: expected ';' at end of declaration
File declarators.c Line 150: expected function body after function declarator
File declarators.c Line 119: declaration of 'enum E11' will not be visible outside of this function
File declarators.c Line 123: declaration of 'enum E12' will not be visible outside of this function
File declarators.c Line 133: ISO C forbids forward references to 'enum' types
File declarators.c Line 133: declaration of 'enum E13' will not be visible outside of this function
File declarators.c Line 139: ISO C forbids forward references to 'enum' types
File declarators.c Line 139: declaration of 'enum E14' will not be visible outside of this function
File declarators.c Line 145: ISO C forbids forward references to 'enum' types
File declarators.c Line 145: declaration of 'enum E15' will not be visible outside of this function
...
After:
declarators.c:103:24: error: expected ';' at end of declaration
void knrNoSemi(i) int i { }
^
;
Patch found in a sealed envelope dated 1978 with the message "Do not open until
January 2014"
llvm-svn: 198540
type_info has been made an implicitly predeclared type in r198497 and will no
longer appear as a user-declared type so we can remove this old hack.
This reverts commit r158595.
llvm-svn: 198502
Instead of keeping it in amongst the macros, build the declaration at Sema init
the same way we do with other predeclared and builtin types.
In practice this means the declaration is marked implicit and therefore won't
show up as an unwanted user-declared type in tooling which has been a
frequently reported issue (though I haven't been able to cook up a test).
llvm-svn: 198497
This has the dual effect of (1) enabling more dead-stripping in release builds
and (2) ensuring that debug helper functions aren't stripped away in debug
builds, as they're intended to be called from the debugger.
Note that the attribute is applied to definitions rather than declarations in
headers going forward because it's now conditional on NDEBUG:
/// \brief Mark debug helper function definitions like dump() that should not be
/// stripped from debug builds.
Requires corresponding macro added in LLVM r198456.
llvm-svn: 198489
This checker has not been updated to work with interprocedural analysis,
and actually contains both logical correctness issues but also
memory bugs. We can resuscitate it from version control once there
is focused interest in making it a real viable checker again.
llvm-svn: 198476
consideration the num-of-elements*width-of-element width.
Disallow casts when such width is not equal between the vector types otherwise
we may end up with an invalid LLVM bitcast.
rdar://15722308.
llvm-svn: 198474
Summary:
This makes us more compatible with MSVC 2012+ and fixes PR17748 where we
would give two tables the same name.
Rather than doing a fresh depth-first traversal of the inheritance graph
for every record's vbtables, now we memoize vbtable paths for each
record. By doing memoization, we end up considering virtual bases of
subobjects that come later in the depth-first traversal. Where
previously we would have ignored a virtual base that we'd already seen,
we now consider it for name mangling purposes without emitting a
duplicate vbtable for it.
Reviewers: majnemer
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D2509
llvm-svn: 198462
- Remove the additions to ObjCMethodDecl & ObjCIVarDecl that were getting de/serialized and consolidate
all functionality for the checking for this warning in Sema::DiagnoseUnusedBackingIvarInAccessor
- Don't check immediately after the method body is finished, check when the @implementation is finished.
This is so we can see if the ivar was referenced by any other method, even if the method was defined after the accessor.
- Don't silence the warning if any method is called from the accessor silence it if the accessor delegates to another method via self.
rdar://15727325
llvm-svn: 198432
Summary:
This allows for a better alternative to the FrontendAction hack used in
clang-tidy in order to get static analyzer's ASTConsumer.
Reviewers: jordan_rose, krememek
Reviewed By: jordan_rose
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D2505
llvm-svn: 198426
Summary:
No functionality change.
This code should live here long-term because we should be able to use it
to compute correct vftable names.
It turns out that the most natural way to implement the naming algorithm
is to use a caching layer similar to what we already have for virtual
table info in VTableContext. Subsequent changes will take advantage of
this to fix PR17748, where we have a vbtable name collision.
Reviewers: majnemer
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D2499
llvm-svn: 198380
In a standalone build, Clang binaries should end up in Clang's build folder,
not LLVM's.
Xcode still has a few issues finding auxiliary tools and libraries in the
build folders. I'll fix those next.
llvm-svn: 198328
The separate Xcode project generated for Clang is putting the clang
executables into the same location where the LLVM executables are
going. This is wrong, and breaks the Clang build because we try to
create clang++ and clang-cl symlinks in the wrong place and to the
wrong place.
As a stop-gap to get these builds working again, teach the symlink
generation to point into the LLVM executable directory instead.
llvm-svn: 198319
The backend string is only verified when available as it's possible to run
clang IRGen for targets that haven't been built or don't exist in LLVM.
llvm-svn: 198309
Remove UnaryTypeTraitExpr and switch all remaining type trait related handling
over to TypeTraitExpr.
The UTT/BTT/TT enum prefix and evaluation code is retained pending further
cleanup.
This is part of the ongoing work to unify type traits following the removal of
BinaryTypeTraitExpr in r197273.
llvm-svn: 198271
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