aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/Sema.cpp
AgeCommit message (Collapse)AuthorFilesLines
2014-11-22Delay checking overrides for exception specifications if the overriddenRichard Smith1-1/+1
specification has not yet been parsed. llvm-svn: 222603
2014-11-21Add an assertion for detecting missed/uncorrected TypoExprs.Kaelyn Takata1-0/+2
llvm-svn: 222552
2014-11-19Update for LLVM API change to make Small(Ptr)Set::insert return ↵David Blaikie1-1/+1
pair<iterator, bool> as per the C++ standard's associative container concept. llvm-svn: 222335
2014-10-28Objective-C. revert patch for rdar://17554063.Fariborz Jahanian1-4/+0
llvm-svn: 220812
2014-10-22Reland r219810 "Fix late template parsing leak with incremental processing"Reid Kleckner1-0/+4
Original message: Add a second late template parser callback meant to cleanup any resources allocated by late template parsing. Call it from the Sema::ActOnEndOfTranslationUnit method after all pending template instantiations have been completed. Teach Parser::ParseTopLevelDecl to install the cleanup callback when incremental processing is enabled so that Parser::TemplateIds can be freed. Patch by Brad King! llvm-svn: 220400
2014-10-15Revert "Fix late template parsing leak with incremental processing"Reid Kleckner1-3/+0
This reverts commit r219810. The test suite appears broken. llvm-svn: 219813
2014-10-15Fix late template parsing leak with incremental processingReid Kleckner1-0/+3
Add a second late template parser callback meant to cleanup any resources allocated by late template parsing. Call it from the Sema::ActOnEndOfTranslationUnit method after all pending template instantiations have been completed. Teach Parser::ParseTopLevelDecl to install the cleanup callback when incremental processing is enabled so that Parser::TemplateIds can be freed. Patch by Brad King! llvm-svn: 219810
2014-10-11clang-cl: Don't warn for unused private fields when encountering a late ↵Ehsan Akhgari1-1/+6
parsed template member Summary: This fixes PR21235. Test Plan: Includes an automated test. Reviewers: hansw Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5718 llvm-svn: 219551
2014-09-22ms-inline-asm: Scope inline asm labels to functionsEhsan Akhgari1-0/+1
Summary: This fixes PR20023. In order to implement this scoping rule, we piggy back on the existing LabelDecl machinery, by creating LabelDecl's that will carry the "internal" name of the inline assembly label, which we will rewrite the asm label to. Reviewers: rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4589 llvm-svn: 218230
2014-09-06Add -Wunused-local-typedef, a warning that finds unused local typedefs.Nico Weber1-0/+19
The warning warns on TypedefNameDecls -- typedefs and C++11 using aliases -- that are !isReferenced(). Since the isReferenced() bit on TypedefNameDecls wasn't used for anything before this warning it wasn't always set correctly, so this patch also adds a few missing MarkAnyDeclReferenced() calls in various places for TypedefNameDecls. This is made a bit complicated due to local typedefs possibly being used only after their local scope has closed. Consider: template <class T> void template_fun(T t) { typename T::Foo s3foo; // YYY (void)s3foo; } void template_fun_user() { struct Local { typedef int Foo; // XXX } p; template_fun(p); } Here the typedef in XXX is only used at end-of-translation unit, when YYY in template_fun() gets instantiated. To handle this, typedefs that are unused when their scope exits are added to a set of potentially unused typedefs, and that set gets checked at end-of-TU. Typedefs that are still unused at that point then get warned on. There's also serialization code for this set, so that the warning works with precompiled headers and modules. For modules, the warning is emitted when the module is built, for precompiled headers each time the header gets used. Finally, consider a function using C++14 auto return types to return a local type defined in a header: auto f() { struct S { typedef int a; }; return S(); } Here, the typedef escapes its local scope and could be used by only some translation units including the header. To not warn on this, add a RecursiveASTVisitor that marks all delcs on local types returned from auto functions as referenced. (Except if it's a function with internal linkage, or the decls are private and the local type has no friends -- in these cases, it _is_ safe to warn.) Several of the included testcases (most of the interesting ones) were provided by Richard Smith. (gcc's spelling -Wunused-local-typedefs is supported as an alias for this warning.) llvm-svn: 217298
2014-09-05Move the initialization of VAListTagName after InitializeSema()Ben Langmuir1-2/+4
This innocuous statement to get the identifier info for __va_list_tag was causing an assertion failure: NextIsPrevious() && "decl became non-canonical unexpectedly" if the __va_list_tag identifier was found in a PCH in some circumstances, because it was looked up before the ASTReader had a Sema object to use to find existing decls to merge with. We could possibly move getting the identifier info even later, or make it lazy if we wanted to, but this seemed like the minimal change. Now why a PCH would have this identifier in the first place is a bit mysterious. This seems to be related to the global module index in some way, because when the test case is built without the global module index it will not emit an identifier for __va_list_tag into the PCH, but with the global module index it does. llvm-svn: 217275
2014-08-08Objective-C ARC. Use of non-retain/autorelease APIFariborz Jahanian1-0/+1
for building Objective-C array literals in ARC mode. rdar://17554063 llvm-svn: 215232
2014-08-06Objective-C ARC. More code for Objective-C'sFariborz Jahanian1-1/+1
new APIs for literals. nfc. wip. rdar://17554063 llvm-svn: 215043
2014-08-06Objective-C ARC. Adding declarations for Objective-C'sFariborz Jahanian1-0/+3
new APIs for literals. nfc. wip. rdar://17554063 llvm-svn: 214993
2014-07-26Wrap to 80 columns. No behavior change.Nico Weber1-4/+5
llvm-svn: 214038
2014-07-22-fms-extensions: Implement half of #pragma init_segReid Kleckner1-1/+1
Summary: This pragma is very rare. We could *hypothetically* lower some uses of it down to @llvm.global_ctors, but given that GlobalOpt isn't able to optimize prioritized global ctors today, there's really no point. If we wanted to do this in the future, I would check if the section used in the pragma started with ".CRT$XC" and had up to two characters after it. Those two characters could form the 16-bit initialization priority that we support in @llvm.global_ctors. We would have to teach LLVM to lower prioritized global ctors on COFF as well. This should let us compile some silly uses of this pragma in WebKit / Blink. Reviewers: rsmith, majnemer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4549 llvm-svn: 213593
2014-06-18Replace some assert(0)'s with llvm_unreachable.Craig Topper1-1/+2
llvm-svn: 211143
2014-06-15Hide the concept of diagnostic levels from lex, parse and semaAlp Toker1-6/+2
The compilation pipeline doesn't actually need to know about the high-level concept of diagnostic mappings, and hiding the final computed level presents several simplifications and other potential benefits. The only exceptions are opportunistic checks to see whether expensive code paths can be avoided for diagnostics that are guaranteed to be ignored at a certain SourceLocation. This commit formalizes that invariant by introducing and using DiagnosticsEngine::isIgnored() in place of individual level checks throughout lex, parse and sema. llvm-svn: 211005
2014-05-29Refactoring. Remove Owned method from Sema.Nikola Smiljanic1-3/+3
llvm-svn: 209812
2014-05-29Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic1-1/+1
takeAs to getAs. llvm-svn: 209800
2014-05-26[C++11] Use 'nullptr'. Sema edition.Craig Topper1-36/+37
llvm-svn: 209613
2014-05-22Don't warn about undefined inline functions if they're dllexport/importHans Wennborg1-0/+7
llvm-svn: 209471
2014-05-15Refactoring another for loop to use a range-based for loop instead. Also ↵Aaron Ballman1-11/+4
cleaned up a bit of formatting. No functional changes intended. llvm-svn: 208918
2014-05-10Decouple ExprCXX.h and DeclCXX.h and clean up includes a bit.Benjamin Kramer1-0/+1
Required pulling LambdaExpr::Capture into its own header. No functionality change. llvm-svn: 208470
2014-05-03Wrap a few lines at 80 columns, change a confusing indent. No behavior change.Nico Weber1-1/+2
llvm-svn: 207921
2014-05-03Fix a bunch of mislayered clang/Lex includes from SemaAlp Toker1-1/+7
llvm-svn: 207896
2014-04-26[Sema] Adjust Sema::getCurBlock()/getCurLambda() to take into account that ↵Argyrios Kyrtzidis1-2/+18
we may have switch CurContext due to class template instantiation. Fixes crash of the included test case. rdar://16527205 llvm-svn: 207325
2014-04-08[MS-ABI] Add support for #pragma section and related pragmasWarren Hunt1-1/+2
This patch adds support for the msvc pragmas section, bss_seg, code_seg, const_seg and data_seg as well as support for __declspec(allocate()). Additionally it corrects semantics and adds diagnostics for __attribute__((section())) and the interaction between the attribute and the msvc pragmas and declspec. In general conflicts should now be well diganosed within and among these features. In supporting the pragmas new machinery for uniform lexing for msvc pragmas was introduced. The new machinery always lexes the entire pragma and stores it on an annotation token. The parser is responsible for parsing the pragma when the handling the annotation token. There is a known outstanding bug in this implementation in C mode. Because these attributes and pragmas apply _only_ to definitions, we process them at the time we detect a definition. Due to tentative definitions in C, we end up processing the definition late. This means that in C mode, everything that ends up in a BSS section will end up in the _last_ BSS section rather than the one that was live at the time of tentative definition, even if that turns out to be the point of actual definition. This issue is not known to impact anything as of yet because we are not aware of a clear use or use case for #pragma bss_seg but should be fixed at some point. Differential Revision=http://reviews.llvm.org/D3065#inline-16241 llvm-svn: 205810
2014-03-22Refactor: move loading pending instantiations from chained PCHs to a more ↵Richard Smith1-0/+8
appropriate place, so that we only ask the external source once. llvm-svn: 204535
2014-03-01[C++11] Replace verbose functors with succinct lambdasBenjamin Kramer1-20/+12
No functionality change. llvm-svn: 202590
2014-02-24Follow up to r201927: remove the Sema::InFunctionDeclarator field.Peter Collingbourne1-1/+1
llvm-svn: 202069
2014-02-19Use llvm::DeleteContainerSeconds when possibleReid Kleckner1-4/+1
llvm-svn: 201739
2014-02-12MS ABI: Implement #pragma vtordisp() and clang-cl /vdNReid Kleckner1-1/+2
These features are new in VS 2013 and are necessary in order to layout std::ostream correctly. Currently we have an ABI incompatibility when self-hosting with the 2013 stdlib in our convertible_fwd_ostream wrapper in gtest. This change adds another implicit attribute, MSVtorDispAttr, because implicit attributes are currently the best way to make sure the information stays on class templates through instantiation. Reviewers: majnemer Differential Revision: http://llvm-reviews.chandlerc.com/D2746 llvm-svn: 201274
2014-02-11MS ABI: Add support for the -vm{b,g,s,m,v} flagsDavid Majnemer1-1/+3
These flags control the inheritance model initially used by the translation unit. Differential Revision: http://llvm-reviews.chandlerc.com/D2741 llvm-svn: 201175
2014-02-10MS ABI: Add support for #pragma pointers_to_membersDavid Majnemer1-1/+2
Introduce a notion of a 'current representation method' for pointers-to-members. When starting out, this is set to 'best case' (representation method is chosen by examining the class, selecting the smallest representation that would work given the class definition or lack thereof). This pragma allows the translation unit to dictate exactly what representation to use, similar to how the inheritance model keywords operate. N.B. PCH support is forthcoming. Differential Revision: http://llvm-reviews.chandlerc.com/D2723 llvm-svn: 201105
2014-02-10Sema: Remove useless MSStructPragmaOn update in Sema::~SemaDavid Majnemer1-1/+0
No functional change, this code was just superfluous. llvm-svn: 201099
2014-01-25Rename getResultType() on function and method declarations to getReturnType()Alp Toker1-4/+4
A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. llvm-svn: 200082
2014-01-20Rename FunctionProtoType accessors from 'arguments' to 'parameters'Alp Toker1-1/+1
Fix a perennial source of confusion in the clang type system: Declarations and function prototypes have parameters to which arguments are supplied, so calling these 'arguments' was a stretch even in C mode, let alone C++ where default arguments, templates and overloading make the distinction important to get right. Readability win across the board, especially in the casting, ADL and overloading implementations which make a lot more sense at a glance now. Will keep an eye on the builders and update dependent projects shortly. No functional change. llvm-svn: 199686
2014-01-16Distinguish between attributes explicitly written at the request of the ↵Aaron Ballman1-1/+1
user, and attributes implicitly generated to assist in bookkeeping by the compiler. This is done so by table generating a CreateImplicit method for each attribute. Additionally, remove the optional nature of the spelling list index when creating attributes. This is supported by table generating a Spelling enumeration when the spellings for an attribute are distinct enough to warrant it. llvm-svn: 199378
2014-01-14Rename language option MicrosoftMode to MSVCCompatAlp Toker1-1/+1
There's been long-standing confusion over the role of these two options. This commit makes the necessary changes to differentiate them clearly, following up from r198936. MicrosoftExt (aka. fms-extensions): Enable largely unobjectionable Microsoft language extensions to ease portability. This mode, also supported by gcc, is used for building software like FreeBSD and Linux kernel extensions that share code with Windows drivers. MSVCCompat (aka. -fms-compatibility, formerly MicrosoftMode): Turn on a special mode supporting 'heinous' extensions for drop-in compatibility with the Microsoft Visual C++ product. Standards-compilant C and C++ code isn't guaranteed to work in this mode. Implies MicrosoftExt. Note that full -fms-compatibility mode is currently enabled by default on the Windows target, which may need tuning to serve as a reasonable default. See cfe-commits for the full discourse, thread 'r198497 - Move MS predefined type_info out of InitializePredefinedMacros' No change in behaviour. llvm-svn: 199209
2014-01-14Sema: Predefine size_t in MSVC Compatibility modeDavid Majnemer1-0/+2
MSVC defines size_t without any explicit declarations. This change allows us to be compatible with TUs that depend on this declaration appearing from nowhere. llvm-svn: 199190
2014-01-09Removing the notion of TargetAttributesSema and replacing it with one where ↵Aaron Ballman1-3/+1
the parsed attributes are responsible for knowing their target-specific nature, instead of letting Sema figure it out. This is necessary so that __has_attribute can eventually determine whether a parsed attribute applies to the given target or not. llvm-svn: 198896
2014-01-05Pre-declare '::type_info' in MicrosoftMode only, not MicrosoftExtAlp Toker1-1/+1
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
2014-01-04Move MS predefined type_info out of InitializePredefinedMacrosAlp Toker1-0/+7
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
2013-12-18Remove OpenCL-specific type keywords and specifiersAlp Toker1-0/+18
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
2013-11-12COSMETIC: Right justify an asterix in the previous refactoring.Faisal Vali1-1/+1
Hopefully Richard won't notice this terrible egregiocity - clearly the work of a malevolent poltergeist - fixed now ;) No functionality change. llvm-svn: 194439
2013-11-12REFACTOR: Have PushLambdaScope return the LambdaScopeInfo that it creates.Faisal Vali1-2/+4
No Functionality change. This refactoring avoids having to call getCurLambda right after PushLambdaScope, to obtain the LambdaScopeInfo that was created during the call to PushLambdaScope. llvm-svn: 194438
2013-10-18Fix missed exception spec checks and crashesAlp Toker1-0/+6
Delayed exception specification checking for defaulted members and virtual destructors are both susceptible to mutation during iteration so we need to swap and process the worklists. This resolves both accepts-invalid and rejects-valid issues and moreover fixes potential invalid memory access as the contents of the vectors change during iteration and recursive template instantiation. Checking can be further delayed where parent classes aren't yet fully defined. This patch adds two assertions at end of TU to ensure no specs are left unchecked as was happenning before the fix, plus a test case from Marshall Clow for the defaulted member crash extracted from the libcxx headers. Reviewed by Richard Smith. llvm-svn: 192947
2013-10-17Revert "Fix missed exception spec checks and crashes"Alp Toker1-5/+0
The changes caused the sanitizer bot to hang: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/2311 Needs investigation. This reverts commit r192914. llvm-svn: 192921
2013-10-17Fix missed exception spec checks and crashesAlp Toker1-0/+5
Delayed exception specification checking for defaulted members and virtual destructors are both susceptible to mutation during iteration so we need to process the worklists fully. This resolves both accepts-invalid and rejects-valid issues and moreover fixes potential invalid memory access as the contents of the vectors change during iteration and recursive template instantiation. This patch also adds two assertions at end of TU to ensure no specs are left unchecked as was happenning before the fix, plus a test case from Marshall Clow for the defaulted member crash extracted from the libcxx headers. Reviewed by Richard Smith. llvm-svn: 192914