instead of a semicolon (as sometimes happens during refactorings). When such a
comma is seen at the end of a line, and is followed by something which can't
possibly be a declarator (or even something which might be a plausible typo for
a declarator), suggest that a semicolon was intended.
llvm-svn: 142544
We'd also like for "C++11" or "c++11" to be used for the warning
groups, but without removing the old warning flags. Patches welcome;
I've run out of time to work on this today.
llvm-svn: 141801
which enables support for C99 storage-class specifiers.
This extension is intended to be used by implementations to implement
OpenCL C built-in functions.
llvm-svn: 141271
increasingly prevailing case to the point that new features
like ARC don't even support the fragile ABI anymore.
This required a little bit of reshuffling with exceptions
because a check was assuming that ObjCNonFragileABI was
only being set in ObjC mode, and that's actually a bit
obnoxious to do.
Most, though, it involved a perl script to translate a ton
of test cases.
Mostly no functionality change for driver users, although
there are corner cases with disabling language-specific
exceptions that we should handle more correctly now.
llvm-svn: 140957
The token stream was not getting properly reset when leaving
ParseLexedMethodDef in some error cases. In the testcase, that caused later
accesses to the token stream to touch memory which had been freed as we
finished parsing the class definition. Major hat-tip to AddressSanitizer for
helping pinpoint the use-after-free, including the allocation and deallocation
points:
==21510== ERROR: AddressSanitizer heap-use-after-free on address 0x7feb3de87848 at pc 0x249f4e2 bp 0x7fff15a89df0 sp 0x7fff15a89ce0
READ of size 1 at 0x7feb3de87848 thread T0
#0 0x249f4e2 clang::TokenLexer::Lex()
#1 0x1c834a0 clang::Parser::ConsumeToken()
#2 0x1c7dc0f clang::Parser::ParseDeclarationOrFunctionDefinition()
#3 0x1c7e16b clang::Parser::ParseDeclarationOrFunctionDefinition()
<snip>
0x7feb3de87848 is located 1992 bytes inside of 3816-byte region [0x7feb3de87080,0x7feb3de87f68)
freed by thread T0 here:
#0 0x3a22c19 free
#1 0x1d136a1 clang::Parser::LexedMethod::~LexedMethod()
#2 0x1cef528 clang::Parser::DeallocateParsedClasses()
#3 0x1cef676 clang::Parser::PopParsingClass()
#4 0x1cea094 clang::Parser::ParseCXXMemberSpecification()
#5 0x1ce7ae5 clang::Parser::ParseClassSpecifier()
#6 0x1cfe588 clang::Parser::ParseDeclarationSpecifiers()
#7 0x1c7dbe8 clang::Parser::ParseDeclarationOrFunctionDefinition()
#8 0x1c7e16b clang::Parser::ParseDeclarationOrFunctionDefinition()
<snip>
previously allocated by thread T0 here:
#0 0x3a2302d realloc
#1 0x39d7c97 llvm::SmallVectorBase::grow_pod()
#2 0x1ac588e llvm::SmallVectorImpl<>::push_back()
#3 0x1d12d8b clang::Parser::ConsumeAndStoreUntil()
#4 0x1c9c24d clang::Parser::ConsumeAndStoreUntil()
#5 0x1d12c1e clang::Parser::ConsumeAndStoreUntil()
#6 0x1c9c24d clang::Parser::ConsumeAndStoreUntil()
#7 0x1d10042 clang::Parser::ParseCXXInlineMethodDef()
#8 0x1cec51a clang::Parser::ParseCXXClassMemberDeclaration()
#9 0x1ce9de5 clang::Parser::ParseCXXMemberSpecification()
#10 0x1ce7ae5 clang::Parser::ParseClassSpecifier()
#11 0x1cfe588 clang::Parser::ParseDeclarationSpecifiers()
#12 0x1c7dbe8 clang::Parser::ParseDeclarationOrFunctionDefinition()
#13 0x1c7e16b clang::Parser::ParseDeclarationOrFunctionDefinition()
<snip>
llvm-svn: 140427
The solution is to create a new ParseScope(Scope::TemplateParamScope) for each template scope that we want to reenter. (from the outmost to the innermost scope)
This fixes some errors when parsing MFC code with clang.
llvm-svn: 140344
For instance:
template <class T> void E() {};
class F {};
void test() {
::E<::F>();
E<::F>();
}
Gives the following error messages:
error: found '<::' after a template name which forms the
digraph '<:' (aka '[') and a ':', did you mean '< ::'?
::E<::F>();
^~~
< ::
error: expected expression
E<::F>();
^
error: expected ']'
note: to match this '['
E<::F>();
This patch adds the digraph fix-it check right before the name lookup,
moves the shared checking code to a new function, and adds new
tests to catch future regressions.
llvm-svn: 140039
collision between C99 hexfloats and C++0x user-defined literals by
giving C99 hexfloats precedence. Also, warning about user-defined
literals that conflict with hexfloats and those that have names that
are reserved by the implementation. Fixes <rdar://problem/9940194>.
llvm-svn: 138839
When a macro instantiation occurs, reserve a SLocEntry chunk with length the
full length of the macro definition source. Set the spelling location of this chunk
to point to the start of the macro definition and any tokens that are lexed directly
from the macro definition will get a location from this chunk with the appropriate offset.
For any tokens that come from argument expansion, '##' paste operator, etc. have their
instantiation location point at the appropriate place in the instantiated macro definition
(the argument identifier and the '##' token respectively).
This improves macro instantiation diagnostics:
Before:
t.c:5:9: error: invalid operands to binary expression ('struct S' and 'int')
int y = M(/);
^~~~
t.c:5:11: note: instantiated from:
int y = M(/);
^
After:
t.c:5:9: error: invalid operands to binary expression ('struct S' and 'int')
int y = M(/);
^~~~
t.c:3:20: note: instantiated from:
\#define M(op) (foo op 3);
~~~ ^ ~
t.c:5:11: note: instantiated from:
int y = M(/);
^
The memory savings for a candidate boost library that abuses the preprocessor are:
- 32% less SLocEntries (37M -> 25M)
- 30% reduction in PCH file size (900M -> 635M)
- 50% reduction in memory usage for the SLocEntry table (1.6G -> 800M)
llvm-svn: 134587
int f(int x) {
if (int foo = f(bar)) {}
return 0;
}
Clang produces the following error messages:
paren_imbalance.cc:2:19: error: use of undeclared identifier 'bar'
if (int foo = f(bar)) {}
^
paren_imbalance.cc:2:26: error: expected ')'
if (int foo = f(bar)) {}
^
paren_imbalance.cc:2:6: note: to match this '('
if (int foo = f(bar)) {}
^
The second error is incorrect. This patch will stop Clang from producing an error on parenthesis imbalance during error recovery when there isn't one.
llvm-svn: 134258
- Move the diagnostic to the case statement instead of at the end of the switch
- Add a fix-it hint as to how to fix the compilation error
llvm-svn: 132903
__builtin_astype(): Used to reinterpreted as another data type of the same size using for both scalar and vector data types.
Added test case.
llvm-svn: 132612
that they are C++0x extensions, and put them in the appropriate
group. We already support most of the semantics. Addresses
<rdar://problem/9407525>.
llvm-svn: 131153