summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
* Parse: Don't crash during parsing if we lack a simple-type-specifierDavid Majnemer2013-09-221-0/+1
| | | | | | | | | | | | | | | | | Summary: Parsing cast expressions during error recovery can put us in a bad state. Check to see if the token for a simple-type-specifier makes sense before further parsing. Fixes PR17255. Reviewers: rsmith, doug.gregor, CornedBee, eli.friedman CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1696 llvm-svn: 191159
* ObjectiveC: ObjC declarations, including forward classFariborz Jahanian2013-09-221-0/+12
| | | | | | and protocols can be at global scope only. llvm-svn: 191155
* PR17295: Do not allow explicit conversion functions to be used in cases whereRichard Smith2013-09-213-1/+49
| | | | | | | | | | an additional conversion (other than a qualification conversion) would be required after the explicit conversion. Conversely, do allow explicit conversion functions to be used when initializing a temporary for a reference binding in direct-list-initialization. llvm-svn: 191150
* Some comment updates and tweaks for clarity.Richard Smith2013-09-211-21/+28
| | | | llvm-svn: 191147
* Rearrange narrowing checks in initialization to be a different form of stepRichard Smith2013-09-211-35/+40
| | | | | | | | rather than a post-processing action, so we can support inserting these checks at stages other than the end of the initialization. No functionality change intended. llvm-svn: 191146
* Refactor: CheckExplicitInitList is only called to check an entire InitListExpr,Richard Smith2013-09-201-15/+20
| | | | | | | so the Index in/out parameters are pointless (always passed in as 0, always ignored by the caller). llvm-svn: 191103
* Use -fms-compatibility to trigger lookup into dep. basesReid Kleckner2013-09-201-2/+2
| | | | | | | Update the docs for -fms-extensions and -fms-compatibility to try to clarify the difference between the two. llvm-svn: 191095
* Modify the uninitialized field visitor to detect uninitialized use across theRichard Trieu2013-09-201-32/+180
| | | | | | | | | | | | | | | | | | fields in the class. This allows a better checking of member intiailizers and in class initializers in regards to initialization ordering. For instance, this code will now produce warnings: class A { int x; int y; A() : x(y) {} // y is initialized after x, warn here A(int): y(x) {} // default initialization of leaves x uninitialized, warn here }; Several test cases were updated with -Wno-uninitialized to silence this warning. llvm-svn: 191068
* Switch the semantic DeclContext for a block-scope declaration of a function orRichard Smith2013-09-207-71/+204
| | | | | | | | | | | | | | variable from being the function to being the enclosing namespace scope (in C++) or the TU (in C). This allows us to fix a selection of related issues where we would build incorrect redeclaration chains for such declarations, and fail to notice type mismatches. Such declarations are put into a new IdentifierNamespace, IDNS_LocalExtern, which is only found when searching scopes, and not found when searching DeclContexts. Such a declaration is only made visible in its DeclContext if there are no non-LocalExtern declarations. llvm-svn: 191064
* PR17290: Use 'false' macro in fix-it hint for initializing a variable of typeRichard Smith2013-09-204-19/+29
| | | | | | | | | _Bool in C, if the macro is defined. Also teach FixItUtils to look at whether the macro was defined at the source location for which it is creating a fixit, rather than looking at whether it's defined *now*. This is especially relevant for analysis-based warnings which are delayed until end of TU. llvm-svn: 191057
* Don't correct typos in Sema::BuildCXXNestedNameSpecifier with -fms-extensionsKaelyn Uhrain2013-09-191-1/+1
| | | | | | | | When -fms-extensions is enabled, the typo correction was being called here on non-error paths (as in test/SemaTemplate/lookup-dependent-bases.cpp) and correct compilation depended on Sema::CorrectTypo not finding a viable candidate. llvm-svn: 191046
* Fixes a buildbot failure (was using localFariborz Jahanian2013-09-191-4/+2
| | | | | | type in template instantiation). llvm-svn: 191022
* Refinement to my previous patch forFariborz Jahanian2013-09-191-1/+7
| | | | | | objc_returns_inner_pointer on properties. // rdar://14990439 llvm-svn: 191016
* ObjectiveC: Allow NS_RETURNS_INNER_POINTER annotation Fariborz Jahanian2013-09-192-12/+22
| | | | | | | | | | of ObjectiveC properties to mean annotation of NS_RETURNS_INNER_POINTER on its synthesized getter. This also facilitates more migration to properties when methods are annotated with NS_RETURNS_INNER_POINTER. // rdar://14990439 llvm-svn: 191009
* Fix crash with cast of value-dependent expr.Eli Friedman2013-09-191-2/+5
| | | | | | | | | We don't really need to perform semantic analysis on the dependent expression anyway, so just call the cast dependent. <rdar://problem/15012610> llvm-svn: 190981
* Remove a bogus diagnostic preventing static data member templates from beingRichard Smith2013-09-181-15/+0
| | | | | | defined with no initializer. llvm-svn: 190970
* Remove some dead code.Richard Smith2013-09-181-6/+3
| | | | llvm-svn: 190959
* Recommited:Stepan Dyatkovskiy2013-09-181-65/+12
| | | | | | | | | | | | | | | | | | | | | | | | | Fix for PR16752. Second commit. PR16752: 'mode' attribute for unusual targets doesn't work properly Description: Troubles could be happened due to some assumptions in handleModeAttr function (see SemaDeclAttr.cpp). For example, it assumes that 32 bit integer is 'int', while it could be 16 bit only. Instead of asking target: 'which type do you want to use for int32_t ?' it just hardcodes general opinion. That doesn't looks pretty correct. Please consider the next solution: 1. In Basic/TargetInfo add getIntTypeByWidth and getRealTypeByWidth methods. Methods asks target for proper type for given bit width. 2. Fix handleModeAttr according to new methods in TargetInfo. Fixes: 1st Commit (Done): Add new methods for TargetInfo: getRealTypeByWidth and getIntTypeByWidth for ASTContext names are almost same(invokes new methods from TargetInfo): getIntTypeForBitwidth and getRealTypeForBitwidth 2nd Commit (Current): Fix SemaDeclAttr, handleModeAttr function. Also test/Sema/attr-mode.c was fixed. 'XC' mode test was disabled for PPC64 machines. llvm-svn: 190926
* Add the intrinsic __builtin_convertvectorHal Finkel2013-09-184-0/+74
| | | | | | | | | | | | | | | | | | LLVM supports applying conversion instructions to vectors of the same number of elements (fptrunc, fptosi, etc.) but there had been no way for a Clang user to cause such instructions to be generated when using builtin vector types. C-style casting on vectors is already defined in terms of bitcasts, and so cannot be used for these conversions as well (without leading to a very confusing set of semantics). As a result, this adds a __builtin_convertvector intrinsic (patterned after the OpenCL __builtin_astype intrinsic). This is intended to aid the creation of vector intrinsic headers that create generic IR instead of target-dependent intrinsics (in other words, this is a generic _mm_cvtepi32_ps). As noted in the documentation, the action of __builtin_convertvector is defined in terms of the action of a C-style cast on each vector element. llvm-svn: 190915
* Fix accepts-invalid if a variable template explicit instantiation is missing anRichard Smith2013-09-181-9/+19
| | | | | | argument list, but could be instantiated with argument list of <>. llvm-svn: 190913
* If a variable template specialization with an incomplete array type isRichard Smith2013-09-181-18/+22
| | | | | | referenced, try to instantiate its definition in order to complete the type. llvm-svn: 190910
* Revert "Revert "[-cxx-abi microsoft] Mangle local TagDecls appropriately""David Majnemer2013-09-172-2/+23
| | | | | | This reverts commit r190895 which reverted r190892. llvm-svn: 190904
* Revert "[-cxx-abi microsoft] Mangle local TagDecls appropriately"David Majnemer2013-09-172-23/+2
| | | | | | This reverts commit r190892. llvm-svn: 190895
* [-cxx-abi microsoft] Mangle local TagDecls appropriatelyDavid Majnemer2013-09-172-2/+23
| | | | | | | | | | | | | | | | | | | | | | | Summary: When selecting a mangling for an anonymous tag type: - We should first try it's typedef'd name. - If that doesn't work, we should mangle in the name of the declarator that specified it as a declaration specifier. - If that doesn't work, fall back to a static mangling of <unnamed-type>. This should make our anonymous type mangling compatible. This partially fixes PR16994; we would need to have an implementation of scope numbering to get it right (a separate issue). Reviewers: rnk, rsmith, rjmccall, cdavis5x CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1540 llvm-svn: 190892
* Don't build extra init lists.Eli Friedman2013-09-171-1/+1
| | | | | | | | | | AssignConvertType::IncompatibleVectors means the two types are in fact compatible. :) No testcase; I don't think the extra init list has any actual visible effect other than making the resulting AST dump look a bit strange. llvm-svn: 190845
* [-cxx-abi microsoft] Correctly identify Win32 entry pointsDavid Majnemer2013-09-162-1/+32
| | | | | | | | | | | | | | | | | | | Summary: This fixes several issues with the original implementation: - Win32 entry points cannot be in namespaces - A Win32 entry point cannot be a function template, diagnose if we it. - Win32 entry points cannot be overloaded. - Win32 entry points implicitly return, similar to main. Reviewers: rnk, rsmith, whunt, timurrrr Reviewed By: rnk CC: cfe-commits, nrieck Differential Revision: http://llvm-reviews.chandlerc.com/D1683 llvm-svn: 190818
* Move the uninitialized field check to after all the field initializers are addedRichard Trieu2013-09-161-17/+39
| | | | | | to the CXXConstructorDecl so that information from the constructor can be used. llvm-svn: 190810
* Pass additional information around the uninitialized field visitor.Richard Trieu2013-09-161-7/+12
| | | | llvm-svn: 190805
* Updated the way the ownership attributes are semantically diagnosed. Added ↵Aaron Ballman2013-09-161-59/+43
| | | | | | test cases for the semantics checks. llvm-svn: 190802
* Add error checking to reject neon_vector_type attribute on targets without NEON.Amara Emerson2013-09-161-0/+6
| | | | | | Patch by Artyom Skrobov. llvm-svn: 190801
* Handle PredefinedExpr with templates and lambdasWei Pan2013-09-162-37/+24
| | | | | | | | | | | Summary: - lambdas, blocks or captured statements in templates were not handled which causes codegen crashes. Differential Revision: http://llvm-reviews.chandlerc.com/D1628 llvm-svn: 190784
* Avoid getting an argument of allocation function if it does not exist.Serge Pavlov2013-09-141-11/+12
| | | | | | | | This is a fix to PR12778: in erroneous code an allocation function can be declared with no arguments, quering the first argument in this case causes assertion violation. llvm-svn: 190751
* vector_size cannot be applied to Booleans. Updated the semantic checking ↵Aaron Ballman2013-09-131-2/+3
| | | | | | logic, as well as the comment and added a test case. Fixes PR12649 llvm-svn: 190721
* Switching the WeakRef attribute to using the new checkStringLiteralArgument ↵Aaron Ballman2013-09-131-50/+41
| | | | | | helper function. llvm-svn: 190719
* Updated the PCS calling convention to use the new checkStringLiteralArgument ↵Aaron Ballman2013-09-132-12/+11
| | | | | | helper function. llvm-svn: 190710
* As Aaron pointed out it's simpler to reject wide string availability attr ↵Benjamin Kramer2013-09-131-9/+2
| | | | | | messages in the parser. llvm-svn: 190706
* Guard availability and thread safety attributes against wide strings.Benjamin Kramer2013-09-131-4/+10
| | | | | | Found by inspection. llvm-svn: 190701
* Unify handling of string literal arguments for attributes and add fixits.Benjamin Kramer2013-09-131-71/+69
| | | | | | | | | | | | | | | | | | | | | | This fixes a couple of latent crashes for invalid attributes and also adds a fixit hint to turn identifiers into string literals if one was expected. It then proceeds recovery as if the identifier was a literal. Diagnostic locations are also changed to point at the literal instead of the attribute if the error concerns the argument. PR17175. For example: hidden.c:1:40: error: 'visibility' attribute requires a string extern int x __attribute__((visibility(hidden))); ^ " " hidden.c:2:29: error: visibility does not match previous declaration extern int x __attribute__((visibility("default"))); ^ hidden.c:1:29: note: previous attribute is here extern int x __attribute__((visibility(hidden))); ^ llvm-svn: 190699
* Refactor the uninitialized field visitor. Also moved the calls to the visitorRichard Trieu2013-09-131-54/+69
| | | | | | | later in the code so that the expressions will have addition processing first. This catches a few additional cases of uninitialized uses of class fields. llvm-svn: 190657
* PR13657 (and duplicates):Richard Smith2013-09-122-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a comma occurs in a default argument or default initializer within a class, disambiguate whether it is part of the initializer or whether it ends the initializer. The way this works (which I will be proposing for standardization) is to treat the comma as ending the default argument or default initializer if the following token sequence matches the syntactic constraints of a parameter-declaration-clause or init-declarator-list (respectively). This is both consistent with the disambiguation rules elsewhere (where entities are treated as declarations if they can be), and should have no regressions over our old behavior. I think it might also disambiguate all cases correctly, but I don't have a proof of that. There is an annoyance here: because we're performing a tentative parse in a situation where we may not have seen declarations of all relevant entities (if the comma is part of the initializer, lookup may find entites declared later in the class), we need to turn off typo-correction and diagnostics during the tentative parse, and in the rare case that we decide the comma is part of the initializer, we need to revert all token annotations we performed while disambiguating. Any diagnostics that occur outside of the immediate context of the tentative parse (for instance, if we trigger the implicit instantiation of a class template) are *not* suppressed, mirroring the usual rules for a SFINAE context. llvm-svn: 190639
* Fix regression from r190427.Eli Friedman2013-09-121-1/+1
| | | | | | <rdar://problem/14970968> llvm-svn: 190635
* PR16054: Slight strengthening for -Wsometimes-uninitialized: if we use aRichard Smith2013-09-121-10/+42
| | | | | | | | | | | variable uninitialized every time we reach its (reachable) declaration, or every time we call the surrounding function, promote the warning from -Wmaybe-uninitialized to -Wsometimes-uninitialized. This is still slightly weaker than desired: we should, in general, warn if a use is uninitialized the first time it is evaluated. llvm-svn: 190623
* Tablegen now generates a StringSwitch for attributes containing enumeration ↵Aaron Ballman2013-09-113-81/+36
| | | | | | arguments to map strings to the proper enumeration value. This makes error checking more consistent and reduces the amount of hand-written code required. llvm-svn: 190545
* Split -Wunused-variable warning.Daniel Jasper2013-09-111-0/+3
| | | | | | | | | | | With r190382, -Wunused-variable warns about unused const variables when appropriate. For codebases that use -Werror, this poses a problem as existing unused const variables need to be cleaned up first. To make the transistion easier, this patch splits -Wunused-variable by pulling out an additional -Wunused-const-variable (by default activated along with -Wunused-variable). llvm-svn: 190508
* SemaTemplateDeduction.cpp: Prune two stray \param(s), TPOC and ↵NAKAMURA Takumi2013-09-111-6/+0
| | | | | | NumCallArguments in Sema::getMostSpecialized(). They were removed since r190444. [-Wdocumentation] llvm-svn: 190501
* volatile types are not trivially copyable.Eli Friedman2013-09-111-1/+2
| | | | | | PR17123. llvm-svn: 190484
* Fix is_trivially_constructible preconditions.Eli Friedman2013-09-111-12/+12
| | | | | | | | | Fixes a crash in cases where the first argument was an incomplete type or an uninstantiated template type. <rdar://problem/14938471> llvm-svn: 190482
* The cleanup attribute no longer uses an unresolved, simple identifier as its ↵Aaron Ballman2013-09-111-28/+30
| | | | | | argument. Instead, it takes an expression that is fully resolved. llvm-svn: 190476
* PR17075: When performing partial ordering of a member function against aRichard Smith2013-09-112-41/+45
| | | | | | | | | | | non-member function, the number of arguments in the two candidate calls will be different (the non-member call will have one extra argument). We used to get confused by this, and fail to compare the last argument when testing whether the member is better, resulting in us always thinking it is, even if the non-member is more specialized in the last argument. llvm-svn: 190470
* Remove unused class.Eli Friedman2013-09-111-20/+0
| | | | llvm-svn: 190462
OpenPOWER on IntegriCloud