aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST
AgeCommit message (Collapse)AuthorFilesLines
2017-07-05[modules ts] Improve merging of module-private declarations.Richard Smith1-2/+4
These cases occur frequently for declarations in the global module (above the module-declaration) in a Modules TS module interface. When we merge a definition from another module into such a module-private definition, ensure that we transitively make everything lexically within that definition visible to that translation unit. llvm-svn: 307129
2017-07-05fix trivial typos in comments; NFCHiroshi Inoue1-2/+2
llvm-svn: 307123
2017-07-05[modules ts] Declarations from a module interface unit are only visible outsideRichard Smith1-1/+1
the module if declared in an export block. llvm-svn: 307115
2017-07-01[modules] Teach clang how to merge typedef over anonymous structs in C mode.Vassil Vassilev1-2/+1
In C mode clang fails to merge the textually included definition with the one imported from a module. The C lookup rules fail to find the imported definition because its linkage is internal in non C++ mode. This patch reinstates some of the ODR merging rules for typedefs of anonymous tags for languages other than C++. Patch by Raphael Isemann and me (D34510). llvm-svn: 306964
2017-07-01[ODRHash] Revert r305104 - Skip inline namespaces when hashing.Richard Trieu2-19/+13
Test inline namespaces and handle them in the ODR hash again. llvm-svn: 306926
2017-07-01[Modules] Implement ODR-like semantics for tag types in C/ObjCBruno Cardoso Lopes1-10/+48
Allow ODR for ObjC/C in the sense that we won't keep more that one definition around (merge them). However, ensure the decl pass the structural compatibility check in C11 6.2.7/1, for that, reuse the structural equivalence checks used by the ASTImporter. Few other considerations: - Create error diagnostics for tag types mismatches and thread them into the structural equivalence checks. - Note that by doing this we only support redefinition between types that are considered "compatible types" by C. This is mixed approach of the suggestions discussed in http://lists.llvm.org/pipermail/cfe-dev/2017-March/053257.html Differential Revision: https://reviews.llvm.org/D31778 rdar://problem/31909368 llvm-svn: 306918
2017-07-01Change enumerator default linkage type for CBruno Cardoso Lopes1-1/+3
Redeclaration lookup should never find hidden enumerators in C, because they do not have linkage (C11 6.2.2/6) The linkage of an enumerator should be VisibleNoLinkage, and isHiddenDeclarationVisible should be checking hasExternalFormalLinkage. This is was reviewed as part of D31778, but splitted into a different commit for clarity. rdar://problem/31909368 llvm-svn: 306917
2017-06-30Fix PR 33189: Clang assertion on template destructor declarationHubert Tong1-4/+1
Summary: This patch aims to fix the bug reported at https://bugs.llvm.org/show_bug.cgi?id=33189. Clang hits an assertion when a template destructor declaration is present. This is caused by later processing that does not expect to encounter a template when looking at a destructor. The resolution is to treat the destructor as being not declared when later processing is interested in the properties of the destructor of a class. Reviewers: rcraik, hubert.reinterpretcast, aaron.ballman, rsmith Reviewed By: rsmith Subscribers: rsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D33833 Patch by Kuang He! llvm-svn: 306905
2017-06-30[ODRHash] Support Type TemplateArgumentRichard Trieu1-0/+3
llvm-svn: 306904
2017-06-29[ODRHash] Improve typedef handling.Richard Trieu1-1/+14
Follow typedef chains to find the root type when processing types, and also keep track of qualifiers. llvm-svn: 306753
2017-06-29[Sema] Issue diagnostics if a new/delete expression generates a call toAkira Hatanaka1-2/+5
a c++17 aligned allocation/deallocation function that is unavailable in the standard library on Apple platforms. The aligned functions are implemented only in the following versions or later versions of the OSes, so clang issues diagnostics if the deployment target being targeted is older than these: macosx: 10.13 ios: 11.0 tvos: 11.0 watchos: 4.0 The diagnostics are issued whenever the aligned functions are selected except when the selected function has a definition in the same file. If there is a user-defined function available somewhere else, option -Wno-aligned-allocation-unavailable can be used to silence the diagnostics. rdar://problem/32664169 Differential Revision: https://reviews.llvm.org/D34574 llvm-svn: 306722
2017-06-27Make CastExpr::getSubExprAsWritten look through implicit temporary under ↵Stephan Bergmann1-11/+18
CK_ConstructorConversion With struct S1 {}; struct S2 { operator S1(); }; S1 f(S2 s) { return static_cast<S1>(s); } the static_cast expr is CXXStaticCastExpr 0x... 'struct S1' static_cast<struct S1> <ConstructorConversion> `-CXXConstructExpr 0x... 'struct S1' 'void (struct S1 &&) noexcept' elidable `-MaterializeTemporaryExpr 0x... 'struct S1' xvalue `-ImplicitCastExpr 0x... 'struct S1' <UserDefinedConversion> `-CXXMemberCallExpr 0x... 'struct S1' `-MemberExpr 0x... '<bound member function type>' .operator S1 0x... `-DeclRefExpr 0x... 'struct S2' lvalue ParmVar 0x... 's' 'struct S2' getSubExprAsWritten used to return the MaterializeTemporaryExpr (of type S1) under the CXXConstructExpr, instead of unwinding further to the DeclRefExpr (of type S2) at the bottom. Differential Revision: https://reviews.llvm.org/D22128 llvm-svn: 306377
2017-06-27[CodeGen][ObjC] Fix GNU's encoding of bit-field ivars.Akira Hatanaka2-3/+48
According to the documentation, when encoding a bit-field, GNU runtime needs its starting position in addition to its type and size. https://gcc.gnu.org/onlinedocs/gcc/Type-encoding.html Prior to r297702, the starting position information was not being encoded, which is incorrect, and after r297702, an assertion started to fail because an ObjCIvarDecl was being passed to a function expecting a FieldDecl. This commit moves LookupFieldBitOffset to ASTContext and uses the function to encode the starting position of bit-fields. llvm-svn: 306364
2017-06-26AST: enhance mangling for blocks with MS ABISaleem Abdulrasool1-10/+65
When generating the decorated name for a static variable inside a BlockDecl, construct a scope for the block invocation function that homes the parameter. This allows for arbitrary nesting of the blocks even if the variables are shadowed. Furthermore, using this for the name allows for undname to properly undecorated the name for us. It shows up as the synthetic __block_invocation function that the compiler emitted in the local scope. llvm-svn: 306347
2017-06-26Revert r301742, which caused us to try to evaluate all full-expressions.Richard Smith1-9/+4
Also add testcases for a bunch of expression forms that cause our evaluator to crash. See PR33140 and PR32864 for crashes that this was causing. This reverts r305287, which reverted r305239, which reverted r301742. The previous revert claimed that buildbots were broken, but did not add any testcases and the buildbots have lost all memory of what was wrong here. Changes to test/OpenMP are not reverted; another change has triggered those tests to change their output in the same way that r301742 did. llvm-svn: 306346
2017-06-23Revert "[MS] Don't statically initialize dllimport member function pointers"Reid Kleckner1-16/+0
This reverts commit r306137. It has problems on code like this: struct __declspec(dllimport) Foo { int a; int get_a() { return a; } }; template <int (Foo::*Getter)()> struct HasValue { int operator()(Foo *p) { return (p->*Getter)(); } }; int main() { Foo f; f.a = 3; int x = HasValue<&Foo::get_a>()(&f); } llvm-svn: 306175
2017-06-23[MS] Don't statically initialize dllimport member function pointersReid Kleckner1-0/+16
We were already applying the same rules to dllimport function pointers. David Majnemer added that logic back in r211677 to fix PR20130. We failed to extend that logic to non-virtual member function pointers, which are basically function pointers in a struct with some extra offsets. Fixes PR33570. llvm-svn: 306137
2017-06-23PR33552: Distinguish between declarations that are owned by no module andRichard Smith2-4/+4
declarations that are owned but unconditionally visible. This allows us to set declarations as visible even if they have a local owning module, without losing information. In turn, that means that our Objective-C support can keep on incorrectly assuming the "hidden" bit on the declaration is the whole story with regard to name visibility. This will also be useful once we support the C++ Modules TS export semantics. Objective-C name visibility is still incorrect in any case where the "hidden" bit is not the complete story: for instance, in Objective-C++ the set of visible categories will be wrong during template instantiation, and with local submodule visibility enabled it will be wrong when building modules. Fixing that will require a major overhaul of how visibility is handled for Objective-C (and particularly for categories). llvm-svn: 306075
2017-06-21Support MS builtins using 'long' on LP64 platformsBruno Cardoso Lopes1-1/+13
This allows for -fms-extensions to work the same on LP64. For example, _BitScanReverse is expected to be 32-bit, matching Windows/LLP64, even though long is 64-bit on x86_64 Darwin or Linux (LP64). Implement this by adding a new character code 'N', which is 'int' if the target is LP64 and the same 'L' otherwise Differential Revision: https://reviews.llvm.org/D34377 rdar://problem/32599746 llvm-svn: 305875
2017-06-20Special-case handling of destructors in override lists when dumping ASTs.Lang Hames1-3/+6
Fixes a bug in r305850: CXXDestructors don't have names, so we need to handle printing of them separately. llvm-svn: 305860
2017-06-20Preserve CXX method overrides in ASTImporterLang Hames2-0/+36
Summary: The ASTImporter should import CXX method overrides from the source context when it imports a method decl. Reviewers: spyffe, rsmith, doug.gregor Reviewed By: spyffe Differential Revision: https://reviews.llvm.org/D34371 llvm-svn: 305850
2017-06-20D31187: Fix removal of out-of-line definitions.Vassil Vassilev1-1/+1
Consider: struct MyClass { void f() {} } MyClass::f(){} // expected error redefinition of f. #1 Some clients (eg. cling) need to call removeDecl for the redefined (#1) decl. This patch enables us to remove the lookup entry is registered in the semantic decl context and not in the primary decl context of the lexical decl context where we currently are trying to remove it from. It is not trivial to test this piece and writing a full-blown unit test seems too much. llvm-svn: 305799
2017-06-17Call setMustBuildLookupTable on TagDecls in ExternalASTMergerLang Hames1-0/+1
Summary: setMustBuildLookupTable should be called on imported TagDecls otherwise we may fail to import their member decls (if they have any). Not calling the setMustBuildLookupTable method results in a failure in the attached test case when lookup for the 'x' member fails on struct S, which hasn't had its decls imported elsewhere. (By contrast the member-in-struct testcase hasn't run into this issue because the import of its decls is triggered when the struct instance is defined, and the member access follows this). Reviewers: spyffe, rsmith Reviewed By: spyffe, rsmith Differential Revision: https://reviews.llvm.org/D34253 llvm-svn: 305619
2017-06-16[ODRHash] Hash VarDecl members.Richard Trieu1-0/+12
These VarDecl's are static data members of classes. Since the initializers are also hashed, this also provides checking for default arguments to methods. llvm-svn: 305543
2017-06-15[coroutines] Allow co_await and co_yield expressions that return an lvalue ↵Eric Fiselier1-2/+2
to compile Summary: The title says it all. Reviewers: GorNishanov, rsmith Reviewed By: GorNishanov Subscribers: rjmccall, cfe-commits Differential Revision: https://reviews.llvm.org/D34194 llvm-svn: 305496
2017-06-15[ODRHash] Hash TemplateArgument::Pack and TemplateTypeParmTypeRichard Trieu1-0/+11
llvm-svn: 305440
2017-06-14AST: Add missing break at end of switchDuncan P. N. Exon Smith1-0/+1
llvm-svn: 305418
2017-06-14Fix for Itanium mangler issue with templatesDmitry Polukhin1-0/+2
Patch by Serge Preis Differential Revision: https://reviews.llvm.org/D32428 llvm-svn: 305377
2017-06-14[ODRHash] Remove debugging code from r305361Richard Trieu1-1/+0
llvm-svn: 305362
2017-06-14[ODRHash] Hash Template and TemplateExpansion in TemplateArgument.Richard Trieu1-0/+3
llvm-svn: 305361
2017-06-14[ODRHash] Hash Expr for TemplateArgument::ExpressionRichard Trieu1-0/+16
llvm-svn: 305360
2017-06-13[ODRHash] Add TemplateArgument kind to hash.Richard Trieu1-1/+5
llvm-svn: 305328
2017-06-13Revert "Revert r301742 which made ExprConstant checking apply to all ↵Diana Picus1-4/+9
full-exprs." This reverts commit r305239 because it broke the buildbots (the diag-flags.cpp test is failing). llvm-svn: 305287
2017-06-12Revert r301742 which made ExprConstant checking apply to all full-exprs.Nick Lewycky1-9/+4
This patch also exposed pre-existing bugs in clang, see PR32864 and PR33140#c3 . llvm-svn: 305239
2017-06-12Revert r303316, a change to ExprConstant to evaluate function arguments.Nick Lewycky1-28/+5
The patch was itself correct but it uncovered other bugs which are going to be difficult to fix, per PR33140. llvm-svn: 305233
2017-06-12[Sema] Use the right FoldingSet.George Burgess IV1-1/+1
We were doing FindNodeOrInsertPos on SubstTemplateTypeParmPackTypes, so we should presumably be inserting into SubstTemplateTypeParmPackTypes. Looks like the FoldingSet API can be tweaked a bit so that we can catch things like this at compile-time. I'll look into that shortly. I'm unsure of how to test this; suggestions welcome. Thanks to Vladimir Voskresensky for bringing this up! llvm-svn: 305207
2017-06-09Revert r305110 to fix buildbotRichard Trieu1-19/+1
llvm-svn: 305130
2017-06-09[ODRHash] Add support for TemplateArgument types.Richard Trieu1-1/+19
Recommit r304592 that was reverted in r304618. r305104 should have fixed the issue. llvm-svn: 305110
2017-06-09[ODRHash] Skip inline namespaces when hashing.Richard Trieu2-13/+19
Speculatively try to fix the underlying issue from r304592, of underlying types being confused when inline namespaces are used. llvm-svn: 305104
2017-06-09[DebugInfo] Add kind of ImplicitParamDecl for emission of FlagObjectPointer.Alexey Bataev3-18/+21
Summary: If the first parameter of the function is the ImplicitParamDecl, codegen automatically marks it as an implicit argument with `this` or `self` pointer. Added internal kind of the ImplicitParamDecl to separate 'this', 'self', 'vtt' and other implicit parameters from other kind of parameters. Reviewers: rjmccall, aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33735 llvm-svn: 305075
2017-06-07Update libdeps to add BinaryFormat, introduced in r304864.NAKAMURA Takumi1-0/+1
llvm-svn: 304869
2017-06-07Reorder and reformat.NAKAMURA Takumi1-1/+3
llvm-svn: 304868
2017-06-06[clang] Remove double semicolons. NFC.Mandeep Singh Grang1-1/+1
Reviewers: rsmith, craig.topper, efriedma Reviewed By: efriedma Subscribers: efriedma, cfe-commits Tags: #clang-c Differential Revision: https://reviews.llvm.org/D33926 llvm-svn: 304823
2017-06-05[OpenCL] Fix pipe size in TypeInfo.Anastasia Stulova1-3/+2
Pipes are now the size of pointers rather than the size of the type that they contain. Patch by Simon Perretta! Differential Revision: https://reviews.llvm.org/D33597 llvm-svn: 304708
2017-06-04Implement isDefined by call to isThisDeclarationADefinition.Serge Pavlov1-3/+2
Modifies FunctionDecl::isThisDeclarationADefinition so that it covers all the cases checked by FunctionDecl::isDefined. Implements the latter method by call to isThisDeclarationADefinition. This change is a part of the patch D30170. llvm-svn: 304684
2017-06-03Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.Galina Kistanova7-0/+11
llvm-svn: 304650
2017-06-03Revert r304592Richard Trieu1-19/+1
r304592 - [ODRHash] Add support for TemplateArgument types. Possibly causing one of the errors in modules build bot. llvm-svn: 304618
2017-06-02[ODRHash] Add support for TemplateArgument types.Richard Trieu1-1/+19
llvm-svn: 304592
2017-06-02ASTPrinter: Objective-C method declarations don't need a space afterAlex Lorenz1-2/+4
the return type rdar://32332039 llvm-svn: 304553
2017-06-02Mangle __unaligned in Itanium ABIRoger Ferrer Ibanez1-6/+16
__unaligned is not currently mangled in any way in the Itanium ABI. This causes failures when using -fms-extensions and C++ in targets using Itanium ABI. As suggested by @rsmith the simplest thing to do here is actually mangle the qualifier as a vendor extension. This patch also removes the change done in D31976 and updates its test to the new reality. This fixes https://bugs.llvm.org/show_bug.cgi?id=33080 https://bugs.llvm.org/show_bug.cgi?id=33178 Differential Revision: https://reviews.llvm.org/D33398 llvm-svn: 304523