Commit Graph

1530 Commits

Author SHA1 Message Date
Kaelyn Uhrain 4dc695daea Move some bool flags out of function parameter lists.
llvm-svn: 141610
2011-10-11 00:28:45 +00:00
Douglas Gregor 728d00b8e7 Parse the initializer for a class member after handling its
declarator, so that the declarator is in scope for the
initializer. Fixes PR9989.

llvm-svn: 141539
2011-10-10 14:49:18 +00:00
NAKAMURA Takumi 93eafc6ce1 Fix "Uninitialized" warnings.
llvm-svn: 141487
2011-10-08 11:31:53 +00:00
NAKAMURA Takumi 82a351197f Whitespace
llvm-svn: 141486
2011-10-08 11:31:46 +00:00
Douglas Gregor 6f981006f6 Add braces around do-while body. The lack of them gives me the chills
llvm-svn: 141411
2011-10-07 20:35:25 +00:00
Argyrios Kyrtzidis 9321ad3f97 When using an unavailable/deprecated interface Foo inside Foo's interface/implementation
don't emit unavailable errors.

llvm-svn: 141334
2011-10-06 23:23:20 +00:00
Eli Friedman 0dfb889575 Support for C1x _Atomic specifier (see testcase). This is primarily being committed at the moment to help support C++0x <atomic>, but it should be a solid base for implementing the full specification of C1x _Atomic.
Thanks to Jeffrey Yasskin for the thorough review!

llvm-svn: 141330
2011-10-06 23:00:33 +00:00
Peter Collingbourne 485b80fecc OpenCL: add a non-standard extension, cl_clang_storage_class_specifiers,
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
2011-10-06 03:01:00 +00:00
Peter Collingbourne 6a0e48c746 OpenCL: disallow '#pragma OPENCL EXTENSION all : enable', per OpenCL 1.1 9.1
llvm-svn: 141270
2011-10-06 03:00:50 +00:00
Argyrios Kyrtzidis dfd6570643 Pass from the parser the locations of selector identifiers when creating
objc method decls.

They are not stored in the AST yet.

llvm-svn: 140984
2011-10-03 06:36:36 +00:00
Argyrios Kyrtzidis f934ec8b7b Pass all the locations of the selector identifiers for a message expression from the parser.
They are not kept in the AST yet.

llvm-svn: 140982
2011-10-03 06:36:17 +00:00
John McCall a55902bf98 Parse attributes written in an ObjC method parameter type as
attributes on the parameter declaration.

llvm-svn: 140944
2011-10-01 09:56:14 +00:00
Sebastian Redl 0d16401228 Fix a bug in the token caching for inline constructors in C++11, and improve error recovery in both dialects. This should fix the GCC test suite failures as well.
llvm-svn: 140847
2011-09-30 08:32:17 +00:00
Eli Friedman a4b02c30de Some fixes for MS-style asm parsing: specifically, add some error checking, and handle asm comments using semicolons correctly. (The comments are actually surprisingly tricky.)
llvm-svn: 140837
2011-09-30 01:13:51 +00:00
Richard Smith 1a526fd96c PR11000: Fix crash on invalid.
llvm-svn: 140802
2011-09-29 19:42:27 +00:00
Peter Collingbourne 2f3cf4b158 Add support for alignment-specifiers in C1X and C++11, remove
support for the C++0x draft [[align]] attribute and add the C1X
standard header file stdalign.h

llvm-svn: 140796
2011-09-29 18:04:28 +00:00
Peter Collingbourne 49eedecd70 Add support for parsing an attribute-specifier-seq containing multiple
attribute-specifiers

llvm-svn: 140794
2011-09-29 18:04:05 +00:00
Peter Collingbourne 70188b3fc2 Add support for parsing the optional attribute-specifier-seq at the
end of a decl-specifier-seq

llvm-svn: 140793
2011-09-29 18:03:57 +00:00
Bill Wendling d9dcf18cb0 Revert r140589. It was causing failures during llvm compilation:
llvm[1]: Compiling CommandLine.cpp for Debug+Asserts build
if  /Users/void/llvm/llvm-opt.obj/Release+Asserts/bin/clang++ -I/Users/void/llvm/llvm.obj/include -I/Users/void/llvm/llvm.obj/lib/Support -I/Users/void/llvm/llvm.src/include -I/Users/void/llvm/llvm.src/lib/Support  -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -g -fno-exceptions -fno-common -Woverloaded-virtual -Wcast-qual   -m64 -Wall -W -Wno-unused-parameter -Wwrite-strings -c -MMD -MP -MF "/Users/void/llvm/llvm.obj/lib/Support/Debug+Asserts/CommandLine.d.tmp" -MT "/Users/void/llvm/llvm.obj/lib/Support/Debug+Asserts/CommandLine.o" -MT "/Users/void/llvm/llvm.obj/lib/Support/Debug+Asserts/CommandLine.d" /Users/void/llvm/llvm.src/lib/Support/CommandLine.cpp -o /Users/void/llvm/llvm.obj/lib/Support/Debug+Asserts/CommandLine.o ; \
            then /bin/mv -f "/Users/void/llvm/llvm.obj/lib/Support/Debug+Asserts/CommandLine.d.tmp" "/Users/void/llvm/llvm.obj/lib/Support/Debug+Asserts/CommandLine.d"; else /bin/rm "/Users/void/llvm/llvm.obj/lib/Support/Debug+Asserts/CommandLine.d.tmp"; exit 1; fi
In file included from /Users/void/llvm/llvm.src/lib/Support/CommandLine.cpp:25:
/Users/void/llvm/llvm.src/include/llvm/Support/system_error.h:690:14: error: unknown type name 'make_error_condition'; did you mean 'error_condition'?
    {*this = make_error_condition(_e);}
             ^~~~~~~~~~~~~~~~~~~~
             error_condition
...

llvm-svn: 140599
2011-09-27 10:09:33 +00:00
Kaelyn Uhrain d889d2461f Add typo correction for the type name in C++ "new" statements
llvm-svn: 140589
2011-09-27 00:33:13 +00:00
Douglas Gregor 882a61a640 Diagnose attempts to use 'using typename' with a non-identifier name,
from Stepan Dyatkovskiy. Fixes PR10925.

llvm-svn: 140528
2011-09-26 14:30:28 +00:00
David Blaikie 9c902b5502 Rename Diagnostic to DiagnosticsEngine as per issue 5397
llvm-svn: 140478
2011-09-25 23:23:43 +00:00
Sebastian Redl a74948d347 Correctly parse braced member initializers (even in delayed parsing) and correctly pass
the information on to Sema. There's still an incorrectness in the way template instantiation
works now, but that is due to a far larger underlying representational problem.
Also add a test case for various list initialization cases of scalars, which test this
commit as well as the previous one.

llvm-svn: 140460
2011-09-24 17:48:25 +00:00
Matt Beaumont-Gay d0457924e3 Fix a crash-on-invalid.
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
2011-09-23 22:39:23 +00:00
David Blaikie aa347f9392 Removing a bunch of dead returns/breaks after llvm_unreachables.
llvm-svn: 140407
2011-09-23 20:26:49 +00:00
Douglas Gregor 0c254a00c1 Clean up parsing the category names in interfaces slightly, using
MatchRHSPunctuation appropriately and giving a useful source location
for the complaint about attributes being added to a category.

llvm-svn: 140404
2011-09-23 19:19:41 +00:00
Douglas Gregor 0745ac8016 Fix up comment now that 'new' is no longer a virt-specifier, from Aaron Ballman
llvm-svn: 140389
2011-09-23 16:58:49 +00:00
Francois Pichet 44bb90d9d9 Fix wrong comment about reentering template scope for -fdelayed-template-parsing.
llvm-svn: 140382
2011-09-23 16:02:49 +00:00
David Blaikie 83d382b1ca Switch assert(0/false) llvm_unreachable.
llvm-svn: 140367
2011-09-23 05:06:16 +00:00
Francois Pichet 8134518331 [microsoft] Fix a bug in -fdelayed-template-parsing mode where we were not reentering the delayed function context correctly. The problem was that all template params were reintroduced inside the same scope. So if we had a situation where we had 2 template params with the same name at different scope then clang would generate an error about ambiguous name.
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
2011-09-22 22:14:56 +00:00
David Blaikie 751c558d8e ArrayRef-ifying the fields passed to Sema::ActOnFields
llvm-svn: 140293
2011-09-22 02:58:26 +00:00
Richard Trieu 02e25db543 Fix a problem in digraph handling where "[:" might be treated as "<::" and
erronously trigger the digraph correction fix-it.  Include a new test to catch
this in the future.

llvm-svn: 140175
2011-09-20 20:03:50 +00:00
Argyrios Kyrtzidis e6e67deeed Rename SourceLocation::getFileLocWithOffset -> getLocWithOffset.
It already works (and is useful with) macro locs as well.

llvm-svn: 140057
2011-09-19 20:40:19 +00:00
Richard Trieu 01fc001062 Changes to the name lookup have caused a regression in the digraph fix-it hint.
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
2011-09-19 19:01:00 +00:00
Francois Pichet 0706d203cf Rename LangOptions::Microsoft to LangOptions::MicrosoftExt to make it clear that this flag must be used only for Microsoft extensions and not emulation; to avoid confusion with the new LangOptions::MicrosoftMode flag.
Many of the code now under LangOptions::MicrosoftExt will eventually be moved under the LangOptions::MicrosoftMode flag.

llvm-svn: 139987
2011-09-17 17:15:52 +00:00
Argyrios Kyrtzidis 635a9b4dcf Record the full source range of an attribute.
llvm-svn: 139599
2011-09-13 16:05:53 +00:00
Douglas Gregor 3c7cd6a0c4 Specializations cannot be module-hidden. Diagnose attempts to do so.
llvm-svn: 139406
2011-09-09 20:53:38 +00:00
Douglas Gregor 2820e6923a __module_private__ is inherited by redeclarations of an entity, and
must also be present of the first declaration of that entity.

llvm-svn: 139384
2011-09-09 19:05:14 +00:00
Richard Trieu 9becef691d Changed references of BaseTy, MemInitTy, CXXScopeTy, TemplateParamsTy to CXXBaseSpecifier, CXXCtorInitializer, NestedNameSpecifier, TemplateParameterList and removed their typedefs.
llvm-svn: 139350
2011-09-09 03:18:59 +00:00
Richard Trieu 3481fcd869 Change references to StmtTy to Stmt and removed typedefs of StmtTy. Also removed typedef of AttrTy since it is not used.
llvm-svn: 139349
2011-09-09 02:16:15 +00:00
Douglas Gregor 26701a4371 Modules: introduce the __module_private__ declaration specifier, which
indicates that a declaration is only visible within the module it is
declared in.

llvm-svn: 139348
2011-09-09 02:06:17 +00:00
Richard Trieu 2bd0401b04 Change all references of type ExprTy to Expr and get rid of the typedefs.
llvm-svn: 139347
2011-09-09 02:00:50 +00:00
Caitlin Sadowski 990d571226 Thread safety: added support for function scopes in attribute arguments.
This patch was written by DeLesley Hutchins.

llvm-svn: 139302
2011-09-08 17:42:31 +00:00
Caitlin Sadowski 9385dd7415 Thread Safety: Patch to implement delayed parsing of attributes within a
class scope.

This patch was also written by DeLesley Hutchins.

llvm-svn: 139301
2011-09-08 17:42:22 +00:00
Douglas Gregor 8b7d403684 Allow C++0x enumerations with a fixed underlying type in
Objective-C. The @encode'ing of such an enumeration type is the same
as its underlying type. <rdar://problem/5276348>.

llvm-svn: 139297
2011-09-08 17:18:35 +00:00
Douglas Gregor bab8a96f2f Implement the Objective-C 'instancetype' type, which is an alias of
'id' that can be used (only!) via a contextual keyword as the result
type of an Objective-C message send. 'instancetype' then gives the
method a related result type, which we have already been inferring for
a variety of methods (new, alloc, init, self, retain). Addresses
<rdar://problem/9267640>.

llvm-svn: 139275
2011-09-08 01:46:34 +00:00
Douglas Gregor 5ca153f112 When parsing a function-try-block that does not have a
ctor-initializer, remember to call the Sema action to generate default
ctor-initializers. What a delightful little miscompile. Fixes PR10578
/ <rdar://problem/9877267>.

llvm-svn: 139253
2011-09-07 20:36:12 +00:00
Richard Smith 5065864151 PR10458: Last part of providing 'auto' type specifier as an extension in C++98: permit it within type-ids.
llvm-svn: 139103
2011-09-04 20:24:20 +00:00
Richard Smith 58c7433709 PR10458: Finesse behaviour of C++0x features when in pre-0x mode. Accept for-range and auto with an ExtWarn, and produce a -Wc++0x-compat warning in C++98 mode when auto is used as a storage class.
llvm-svn: 139102
2011-09-04 19:54:14 +00:00
Sebastian Redl e9c4e84f8e Add test case for defaulted copy and move structure validation.
Fix bug this uncovered.
Address minor comments from Doug.
Enable cxx_implicit_moves feature.

llvm-svn: 139101
2011-09-04 18:14:28 +00:00
Argyrios Kyrtzidis 5cec2aea3f Support code-completion for C++ inline methods and ObjC buffering methods.
Previously we would cut off the source file buffer at the code-completion
point; this impeded code-completion inside C++ inline methods and,
recently, with buffering ObjC methods.

Have the code-completion inserted into the source buffer so that it can
be buffered along with a method body. When we actually hit the code-completion
point the cut-off lexing or parsing.

Fixes rdar://10056932&8319466

llvm-svn: 139086
2011-09-04 03:32:15 +00:00
Argyrios Kyrtzidis 43ea78b48d Don't try keeping a 'LeadingEmptyMacroLoc' in NullStmt. This fails
in the face of buffering C++/ObjC method bodies.

llvm-svn: 138972
2011-09-01 21:53:45 +00:00
Fariborz Jahanian 97d744bea4 objective-c: this patch (re)introduces objective-c's default property
synthesis. This new feature is currently placed under 
-fobjc-default-synthesize-properties option
and is off by default pending further testing.
It will become the default feature soon. 
// rdar://8843851

llvm-svn: 138913
2011-08-31 22:24:06 +00:00
Douglas Gregor ca97589f7d Switch __import__ over to __import_module__, so we don't conflict with
existing practice with Python extension modules. Not that Python
extension modules should be using a double-underscored identifier
anyway, but...

llvm-svn: 138870
2011-08-31 18:19:09 +00:00
Fariborz Jahanian bd0642fede objective-c - This patch buffers method implementations
and does the Sema on their body after the entire 
class/category @implementation is seen. This change allows messaging 
of forward private methods, as well as, access to 
synthesized ivars of properties with foward synthesize
declarations; among others. In effect, this patch removes
several restrictions placed on objective-c due to in-place
semantics processing of methods.
This is part of // rdar://8843851.

llvm-svn: 138865
2011-08-31 17:37:55 +00:00
Fariborz Jahanian 59b75285f6 objc - fixes a regression in declaring c decls nested in
objective-c containers due to recent changes to objc decl 
contexts. // rdar://10041908

llvm-svn: 138803
2011-08-30 17:10:52 +00:00
Fariborz Jahanian 4327b32654 Minor clean up of objc's decl context stuff.
No change in functionality.

llvm-svn: 138742
2011-08-29 17:33:12 +00:00
Fariborz Jahanian 3a039e339f objective-c: Treat top-level objective-c declarations
, such as list of forward @class decls, in a DeclGroup
node. Deal with its consequence throught clang. This
is in preparation for more Sema work ahead. // rdar://8843851.
Feel free to reverse if it breaks something important
and I am unavailable.

llvm-svn: 138709
2011-08-27 20:50:59 +00:00
Douglas Gregor afeabec7e1 Improve caret location for the GNU old-style field designator warning, from David Blaikie
llvm-svn: 138684
2011-08-27 00:13:16 +00:00
Douglas Gregor 081425343b Introduce support for a simple module import declaration, which
loads the named module. The syntax itself is intentionally hideous and
will be replaced at some later point with something more
palatable. For now, we're focusing on the semantics:
  - Module imports are handled first by the preprocessor (to get macro
  definitions) and then the same tokens are also handled by the parser
  (to get declarations). If both happen (as in normal compilation),
  the second one is redundant, because we currently have no way to
  hide macros or declarations when loading a module. Chris gets credit
  for this mad-but-workable scheme.
  - The Preprocessor now holds on to a reference to a module loader,
  which is responsible for loading named modules. CompilerInstance is
  the only important module loader: it now knows how to create and
  wire up an AST reader on demand to actually perform the module load.
  - We search for modules in the include path, using the module name
  with the suffix ".pcm" (precompiled module) for the file name. This
  is a temporary hack; we hope to improve the situation in the
  future.

llvm-svn: 138679
2011-08-26 23:56:07 +00:00
Douglas Gregor 69f74f80db Introduce a -cc1 option "-emit-module", that creates a binary module
from the given source. -emit-module behaves similarly to -emit-pch,
except that Sema is somewhat more strict about the contents of
-emit-module. In the future, there are likely to be more interesting
differences.

llvm-svn: 138595
2011-08-25 22:30:56 +00:00
Fariborz Jahanian d8114f7560 Reverse r138567 until a buildbot failure is investigated.
llvm-svn: 138584
2011-08-25 21:09:22 +00:00
Fariborz Jahanian 73d5f67f5a objc -arse: Use DeclGroup for forward class declarations;
as in @class foo, bar. More cleanup to follow.

llvm-svn: 138567
2011-08-25 17:47:31 +00:00
Francois Pichet f2fb411d4a Add support for Microsoft __ptr32 keyword.
Patch by Chris Cudmore!

llvm-svn: 138533
2011-08-25 00:36:46 +00:00
Fariborz Jahanian b66de9f37b objc refactoring - minor clean up.
llvm-svn: 138276
2011-08-22 21:44:58 +00:00
Fariborz Jahanian 4bf8262a43 objc - Simplify switing objc decl context by using
a context switching object.

llvm-svn: 138248
2011-08-22 17:59:19 +00:00
Fariborz Jahanian 8d382dc781 Restore patch I reversed in r138040. Known buildbot
failures are resolved.

llvm-svn: 138234
2011-08-22 15:54:49 +00:00
Fariborz Jahanian 9a3b269ea1 Revers r138040. Need to look at a few buildbot failures.
llvm-svn: 138049
2011-08-19 18:02:47 +00:00
Fariborz Jahanian d6d866d6fa objective-c: Bring objective-c handling of decl context
to modernity. Instead of passing down individual
context objects from parser to sema, establish decl
context in parser and have sema access current context
as needed. I still need to take of Doug's comment for
minor cleanups.

llvm-svn: 138040
2011-08-19 16:06:57 +00:00
Francois Pichet 17ed020569 Add support for MSVC __unaligned attribute. Necessary to parse MSVC headers in 64-bit mode (ie: when _M_IA64 or _M_AMD64 is defined)
more info: http://msdn.microsoft.com/en-us/library/ms177389.aspx

llvm-svn: 137935
2011-08-18 09:59:55 +00:00
Richard Smith a77a0a6bf2 Track in the AST whether a function is constexpr.
llvm-svn: 137653
2011-08-15 21:04:07 +00:00
Caitlin Sadowski 4b1e8399c2 Thread Safety: Added basic argument parsing for all new attributes.
This patch special cases the parser for thread safety attributes so that all
attribute arguments are put in the argument list (instead of a special
parameter) since arguments may not otherwise resolve correctly without two-token
lookahead.

This patch also adds checks to make sure that attribute arguments are
lockable objects.

llvm-svn: 137130
2011-08-09 17:59:31 +00:00
Douglas Gregor db0b9f1264 Parsing of C++0x lambda expressions, from John Freeman with help from
David Blaikie!

llvm-svn: 136876
2011-08-04 15:30:47 +00:00
Douglas Gregor 4ecb7209bf Add code completion to produce "else" blocks after an "if"
statement. Fixes <rdar://problem/9229438>.

llvm-svn: 136564
2011-07-30 08:36:53 +00:00
Douglas Gregor df445f0ae1 Turn off __has_feature(is_empty) and __has_feature(is_pod) if the
libstdc++ hack has reverted these type traits to keywords. Icky, but
fixes <rdar://problem/9836262>.

llvm-svn: 136560
2011-07-30 07:01:49 +00:00
John McCall d9bb743e0d The lock operand to an @synchronized statement is also
supposed to be a full-expression;  make it so.  In ARC, make sure
we retain the lock for the entire protected block. 

llvm-svn: 136271
2011-07-27 21:50:02 +00:00
Douglas Gregor fb65e592e0 Add support for C++0x unicode string and character literals, from Craig Topper!
llvm-svn: 136210
2011-07-27 05:40:30 +00:00
John McCall 538482373b Clean up the analysis of the collection operand to ObjC
for-in statements;  specifically, make sure to close over any
temporaries or cleanups it might require.  In ARC, this has
implications for the lifetime of the collection, so emit it
with a retain and release it upon exit from the loop.

rdar://problem/9817306

llvm-svn: 136204
2011-07-27 01:07:15 +00:00
Chandler Carruth 0b5cf7c863 Fix a stray instantiation comment in Parse.
llvm-svn: 136059
2011-07-26 05:19:46 +00:00
Chandler Carruth d48db2115a Rename getInstantiationLineNumber to getExpansionLineNumber in both
SourceManager and FullSourceLoc.

llvm-svn: 135969
2011-07-25 21:09:52 +00:00
Chandler Carruth 35f5320d8e Mechanically rename SourceManager::getInstantiationLoc and
FullSourceLoc::getInstantiationLoc to ...::getExpansionLoc. This is part
of the API and documentation update from 'instantiation' as the term for
macros to 'expansion'.

llvm-svn: 135914
2011-07-25 16:49:02 +00:00
Chris Lattner 0e62c1cc0b remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports
them into the clang namespace.

llvm-svn: 135852
2011-07-23 10:55:15 +00:00
Joerg Sonnenberger 869f0b70d4 PR10392: "#pragma GCC visibility" must not expand macros in its
arguments.

llvm-svn: 135552
2011-07-20 01:03:50 +00:00
Richard Smith 7b8c3c91f4 PR10359: Template declarations which define classes are not permitted to also contain declarators. Previously we would accept code like this:
template<typename T> struct S { } f() { return 0; }

This case now produces a missing ';' diagnostic, since that seems like a much more likely error than an attempt to declare a function or variable in addition to the class template.

Treat this 

llvm-svn: 135195
2011-07-14 21:35:26 +00:00
Chandler Carruth a88a221855 Move the rest of the preprocessor terminology from 'instantiate' and
variants to 'expand'. This changed a couple of public APIs, including
one public type "MacroInstantiation" which is now "MacroExpansion". The
rest of the codebase was updated to reflect this, especially the
libclang code. Two of the C++ (and thus easily changed) libclang APIs
were updated as well because they pertained directly to the old
MacroInstantiation class.

No functionality changed.

llvm-svn: 135139
2011-07-14 08:20:46 +00:00
Chandler Carruth e2c09ebcaa Convert terminology in the Lexer from 'instantiate' and variants to
'expand'. Also update the public API it provides to the new term, and
propagate that update to the various clients.

No functionality changed.

llvm-svn: 135138
2011-07-14 08:20:40 +00:00
Douglas Gregor ad69e65a39 Add 'mutable' to the function declarator chunk, to be used when
parsing lambda expressions, from John Freeman!

llvm-svn: 135090
2011-07-13 21:47:47 +00:00
Chandler Carruth 904cb14225 Remove a no-op break after a return, and correct one of the most
confusing indentations I've seen recently... Just noticed these while
making a change elsewhere.

No functionality changed.

llvm-svn: 134685
2011-07-08 04:59:44 +00:00
Chandler Carruth c5c3b0a25b Minor style cleanup.
Original patch by John Freeman, some style tweaks by me.

llvm-svn: 134683
2011-07-08 04:28:55 +00:00
Argyrios Kyrtzidis 61c58f7f43 Move SourceManager::isAt[Start/End]OfMacroInstantiation functions to the Lexer, since they depend on it now.
llvm-svn: 134644
2011-07-07 21:54:45 +00:00
Argyrios Kyrtzidis 41fb2d95a3 Make the Preprocessor more memory efficient and improve macro instantiation diagnostics.
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
2011-07-07 03:40:34 +00:00
Douglas Gregor 53e191ed94 Properly implement the scope restriction on the NRVO for
throw-expressions, such that we don't consider the NRVO when the
non-volatile automatic object comes from outside the innermost try
scope (C++0x [class.copymove]p13). In C++98/03, our ASTs were
incorrect but it didn't matter because IR generation doesn't actually
apply the NRVO here. In C++0x, however, we were moving from an object
when in fact we should have copied from it. Fixes PR10142 /
<rdar://problem/9714312>.

llvm-svn: 134548
2011-07-06 22:04:06 +00:00
Chandler Carruth b4836ea7a8 Build up statistics about the work done for analysis based warnings.
Special detail is added for uninitialized variable analysis as this has
serious performance problems than need to be tracked.

Computing some of this data is expensive, for example walking the CFG to
determine its size. To avoid doing that unless the stats data is going
to be used, we thread a bit into the Sema object to track whether
detailed stats should be collected or not. This bit is used to avoid
computations whereever the computations are likely to be more expensive
than checking the state of the flag. Thus, counters are in some cases
unconditionally updated, but the more expensive (and less frequent)
aggregation steps are skipped.

With this patch, we're able to see that for 'gcc.c':
*** Analysis Based Warnings Stats:
232 functions analyzed (0 w/o CFGs).
  7151 CFG blocks built.
  30 average CFG blocks per function.
  1167 max CFG blocks per function.
163 functions analyzed for uninitialiazed variables
  640 variables analyzed.
  3 average variables per function.
  94 max variables per function.
  96409 block visits.
  591 average block visits per function.
  61546 max block visits per function.

And for the reduced testcase in PR10183:
*** Analysis Based Warnings Stats:
98 functions analyzed (0 w/o CFGs).
  8526 CFG blocks built.
  87 average CFG blocks per function.
  7277 max CFG blocks per function.
68 functions analyzed for uninitialiazed variables
  1359 variables analyzed.
  19 average variables per function.
  1196 max variables per function.
  2540494 block visits.
  37360 average block visits per function.
  2536495 max block visits per function.

That last number is the somewhat scary one that indicates the problem in
PR10183.

llvm-svn: 134494
2011-07-06 16:21:37 +00:00
John McCall cb432faf6d Properly protect colons when parsing a nested-name-specifier as part
of an enum specifier in dialects which permit fixed underlying types.
Fixes the rejects-valid part of PR10264.

llvm-svn: 134468
2011-07-06 05:58:41 +00:00
Douglas Gregor 6b9be0ffb3 Some documentation fixes for the parser, from John Freeman
llvm-svn: 134419
2011-07-05 17:13:11 +00:00
Douglas Gregor 9e66af44ad Clean up and refactor ParseFunctionDeclarator to reduce code
repetition and better reflect the actual grammar, from John Freeman!

llvm-svn: 134417
2011-07-05 16:44:18 +00:00
Chandler Carruth 3c147a7731 Start switching the AST stats printing to use llvm::errs() instead of
fprintf. There is more cleanup to be done to the AST stats printing...

llvm-svn: 134373
2011-07-04 05:32:14 +00:00
Argyrios Kyrtzidis 7192a3b841 [ARC] When casting from a pointer to an objective-c object with known ownership, if the
cast type has no ownership specified, implicitly "transfer" the ownership of the cast'ed type
to the cast type:

id x;
(NSString**)&x; // Casting as (__strong NSString**).

llvm-svn: 134275
2011-07-01 22:22:59 +00:00
Argyrios Kyrtzidis d8701b60f7 -Remove Sema::ActOnCastOfParenListExpr and move most of its functionality to
newly introduced Sema::BuildVectorLiteral.
-Make Sema::ActOnCastExpr handle a vector initializer both when the cast'ed expression
 is a ParenListExpr and when it is a ParenExpr.
-Ultimately make Sema::ActOnParenOrParenListExpr independent of what the cast type was.

llvm-svn: 134274
2011-07-01 22:22:54 +00:00
Argyrios Kyrtzidis 7451d1cd00 [ARC] When casting from a pointer to an objective-c object with known ownership, if the
cast type has no ownership specified, implicitly "transfer" the ownership of the cast'ed type
to the cast type:

id x;
static_cast<NSString**>(&x); // Casting as (__strong NSString**).

This currently only works for C++ named casts, C casts to follow.

llvm-svn: 134273
2011-07-01 22:22:50 +00:00