summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse
Commit message (Collapse)AuthorAgeFilesLines
* PR10359: Template declarations which define classes are not permitted to ↵Richard Smith2011-07-141-0/+5
| | | | | | | | | | | | 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
* Move the rest of the preprocessor terminology from 'instantiate' andChandler Carruth2011-07-141-1/+1
| | | | | | | | | | | | | 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
* Convert terminology in the Lexer from 'instantiate' and variants toChandler Carruth2011-07-141-1/+1
| | | | | | | | | '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
* Add 'mutable' to the function declarator chunk, to be used whenDouglas Gregor2011-07-132-0/+2
| | | | | | parsing lambda expressions, from John Freeman! llvm-svn: 135090
* Remove a no-op break after a return, and correct one of the mostChandler Carruth2011-07-081-2/+2
| | | | | | | | | confusing indentations I've seen recently... Just noticed these while making a change elsewhere. No functionality changed. llvm-svn: 134685
* Minor style cleanup.Chandler Carruth2011-07-081-6/+9
| | | | | | Original patch by John Freeman, some style tweaks by me. llvm-svn: 134683
* Move SourceManager::isAt[Start/End]OfMacroInstantiation functions to the ↵Argyrios Kyrtzidis2011-07-071-2/+1
| | | | | | Lexer, since they depend on it now. llvm-svn: 134644
* Make the Preprocessor more memory efficient and improve macro instantiation ↵Argyrios Kyrtzidis2011-07-071-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Properly implement the scope restriction on the NRVO forDouglas Gregor2011-07-062-5/+11
| | | | | | | | | | | | 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
* Build up statistics about the work done for analysis based warnings.Chandler Carruth2011-07-061-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Properly protect colons when parsing a nested-name-specifier as partJohn McCall2011-07-061-11/+16
| | | | | | | of an enum specifier in dialects which permit fixed underlying types. Fixes the rejects-valid part of PR10264. llvm-svn: 134468
* Some documentation fixes for the parser, from John FreemanDouglas Gregor2011-07-051-3/+2
| | | | llvm-svn: 134419
* Clean up and refactor ParseFunctionDeclarator to reduce codeDouglas Gregor2011-07-051-250/+188
| | | | | | repetition and better reflect the actual grammar, from John Freeman! llvm-svn: 134417
* Start switching the AST stats printing to use llvm::errs() instead ofChandler Carruth2011-07-041-1/+1
| | | | | | fprintf. There is more cleanup to be done to the AST stats printing... llvm-svn: 134373
* [ARC] When casting from a pointer to an objective-c object with known ↵Argyrios Kyrtzidis2011-07-012-37/+59
| | | | | | | | | | | | 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
* -Remove Sema::ActOnCastOfParenListExpr and move most of its functionality toArgyrios Kyrtzidis2011-07-011-1/+1
| | | | | | | | | 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
* [ARC] When casting from a pointer to an objective-c object with known ↵Argyrios Kyrtzidis2011-07-011-3/+10
| | | | | | | | | | | | | | 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
* Introduce Declarator::ObjCCatchContext, this will result in correct error ↵Argyrios Kyrtzidis2011-07-011-4/+1
| | | | | | for 'auto' in obj-c catch. llvm-svn: 134271
* For code such as:Richard Trieu2011-07-011-1/+0
| | | | | | | | | | | | | | | | | | | | | | | 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
* Fix AST representations of alias-declarations which define tag types. Inside ↵Richard Smith2011-07-012-11/+20
| | | | | | classes, the tag types need to have an associated access specifier, and inside function definitions, they need to be included in the declarations of the DeclStmt. These issues manifested as assertions during template instantiation, and also in a WIP constexpr patch. llvm-svn: 134250
* Introduce Declarator::CXXNewContext and remove 'AutoAllowedInTypeName' parameterArgyrios Kyrtzidis2011-06-281-1/+1
| | | | | | from Sema::GetTypeForDeclarator. No functionality change. llvm-svn: 133987
* When deciding how to parse "= something" as part of a memberDouglas Gregor2011-06-251-2/+2
| | | | | | | | | declaration, determine whether the declaration will end up declaring a function using semantic criteria (e.g., it will have function type) rather than purely syntactic criteria (e.g., it has the form of a function declarator). Fixes <rdar://problem/9670557>. llvm-svn: 133854
* Allow the fixit for missing ':' in the ?: ternary operator if it is pointingArgyrios Kyrtzidis2011-06-241-2/+3
| | | | | | at the start of a macro instantiation. llvm-svn: 133801
* Introduce DelayedCleanupPool useful for simplifying clean-up of certain ↵Argyrios Kyrtzidis2011-06-227-37/+27
| | | | | | | | | | resources that, while their lifetime is well-known and restricted, cleaning them up manually is easy to miss and cause a leak. Use it to plug the leaking of TemplateIdAnnotation objects. rdar://9634138. llvm-svn: 133610
* Handle decltype keyword in Parser::isDeclarationSpecifier.Francois Pichet2011-06-191-0/+4
| | | | | | Fixes PR10154. Found by parsing MFC 2010 code with clang. llvm-svn: 133380
* Remove dead variables.Benjamin Kramer2011-06-181-1/+0
| | | | llvm-svn: 133346
* Only accept __bridge_retain in system headers, as Doug suggested.John McCall2011-06-171-5/+17
| | | | llvm-svn: 133300
* As a hopefully temporary workaround for a header mistake, treatJohn McCall2011-06-171-1/+2
| | | | | | __bridge_retain as a synonym for __bridge_retained. llvm-svn: 133295
* Automatic Reference Counting.John McCall2011-06-153-5/+73
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Remove the Fix-it for missing statement in switchesDavid Majnemer2011-06-141-6/+4
| | | | llvm-svn: 132994
* Improve the diagnostics generated for switch statements missing expressionsDavid Majnemer2011-06-131-4/+7
| | | | | | | - 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
* Correct the spelling of instantiationDavid Majnemer2011-06-131-1/+1
| | | | llvm-svn: 132901
* Don't assert on initialized typedef declarations in classes:Richard Smith2011-06-121-1/+3
| | | | | | | | | | | | struct { typedef int A = 0; }; According to the C++11 standard, this is not ill-formed, but does not have any ascribed meaning. We can't reasonably accept it, so treat it as ill-formed. Also switch C++ from an incorrect 'fields can only be initialized in constructors' diagnostic for this case to C's 'illegal initializer (only variables can be initialized)' llvm-svn: 132890
* Implement support for C++11 in-class initialization of non-static data members.Richard Smith2011-06-113-42/+249
| | | | llvm-svn: 132878
* Implement Objective-C Related Result Type semantics.Douglas Gregor2011-06-111-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Related result types apply Cocoa conventions to the type of message sends and property accesses to Objective-C methods that are known to always return objects whose type is the same as the type of the receiving class (or a subclass thereof), such as +alloc and -init. This tightens up static type safety for Objective-C, so that we now diagnose mistakes like this: t.m:4:10: warning: incompatible pointer types initializing 'NSSet *' with an expression of type 'NSArray *' [-Wincompatible-pointer-types] NSSet *array = [[NSArray alloc] init]; ^ ~~~~~~~~~~~~~~~~~~~~~~ /System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:72:1: note: instance method 'init' is assumed to return an instance of its receiver type ('NSArray *') - (id)init; ^ It also means that we get decent type inference when writing code in Objective-C++0x: auto array = [[NSMutableArray alloc] initWithObjects:@"one", @"two",nil]; // ^ now infers NSMutableArray* rather than id llvm-svn: 132868
* Restore 'atomic' as an attribute of objcFariborz Jahanian2011-06-111-0/+2
| | | | | | properties. llvm-svn: 132866
* Remove 'atomic' as a property attribute keyword.Fariborz Jahanian2011-06-081-2/+0
| | | | | | | It is not a sanctioned keyword and is assumed as default. // rdar://8790791 llvm-svn: 132753
* Parse C++0x generalized initializers.Sebastian Redl2011-06-054-51/+123
| | | | llvm-svn: 132662
* Add support for builtin astype:Tanya Lattner2011-06-041-0/+30
| | | | | | | __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
* Silence sign compare warning.Benjamin Kramer2011-05-261-4/+4
| | | | llvm-svn: 132146
* Add a fix-it and better error recovery for improperly nested namespaces. ↵Richard Trieu2011-05-261-7/+86
| | | | | | This will give a better error message for cases such as "namespace foo::bar::baz {}" and a suggested fix-it of "namespace foo { namespace bar { namespace baz {} } }" llvm-svn: 132138
* Add support for Microsoft __if_exists, __if_not_exists extension at class scope.Francois Pichet2011-05-252-2/+69
| | | | | | | | | | | | | | | | Example: typedef int TYPE; class C { __if_exists(TYPE) { TYPE a; } __if_not_exists(TYPE) { this will never be parsed. } }; llvm-svn: 132052
* Implement a new type node, UnaryTransformType, designed to represent aAlexis Hunt2011-05-241-1/+1
| | | | | | | | type that turns one type into another. This is used as the basis to implement __underlying_type properly - with TypeSourceInfo and proper behavior in the face of templates. llvm-svn: 132017
* Implement explicit specialization of explicitly-defaulted constructors.Alexis Hunt2011-05-231-68/+39
| | | | | | | | The general out-of-line case (including explicit instantiation mostly works except that the definition is being lost somewhere between the AST and CodeGen, so the definition is never emitted. llvm-svn: 131933
* Implement __underlying_type for libc++.Alexis Hunt2011-05-194-0/+50
| | | | llvm-svn: 131633
* Implement the __is_trivially_copyable type traitAlexis Hunt2011-05-133-0/+6
| | | | llvm-svn: 131270
* Properly parse the 'default' and 'delete' keywords.Alexis Hunt2011-05-124-32/+156
| | | | | | | | | | | | | | | | | They are actually grammatically considered definitions and parsed accordingly. This fixes the outstanding bugs regarding defaulting functions after their declarations. We now really nicely diagnose the following construct (try it!) int foo() = delete, bar; Still todo: Defaulted functions other than default constructors Test cases (including for the above construct) llvm-svn: 131228
* In Microsoft mode, allow pure specifier (=0) on inline functions declared at ↵Francois Pichet2011-05-112-4/+16
| | | | | | | | | | | | | class scope. This removes 2 errors when parsing MFC code with clang Example: class A { virtual void f() = 0 { } } llvm-svn: 131175
* Rename "hasTrivialConstructor" to "hasTrivialDefaultConstructor" andAlexis Hunt2011-05-091-1/+2
| | | | | | | modify the semantics slightly to accomodate default constructors (I hope). llvm-svn: 131087
* Don't fail at parsing __declspec(property(get=get_func_name)). Just skip ↵Francois Pichet2011-05-071-0/+8
| | | | | | everything inside property() for now while we wait for the BoostPro people to provide a complete patch. llvm-svn: 131053
OpenPOWER on IntegriCloud