Re: [PATCH] D11742: Add -gcodeview and -gdwarf to control which type Clang emits
rnk marked 2 inline comments as done. Comment at: test/CodeGen/dwarf-version.c:11 @@ -7,3 +10,3 @@ // RUN: %clang -target powerpc-unknown-freebsd -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2 // RUN: %clang -target i386-pc-solaris -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2 int main (void) { hans wrote: > Maybe add %clang_cl invocations here? I'd rather keep the %clang_cl tests in test/Driver, though. http://reviews.llvm.org/D11742 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D11476: Marked call instruction in thunk function with tail attribute when applicable
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. The patch seems right, but I'm surprised there isn't more test fallout. Repository: rL LLVM http://reviews.llvm.org/D11476 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r244097 - Add -gcodeview and -gdwarf to control which type Clang emits
Author: rnk Date: Wed Aug 5 13:51:13 2015 New Revision: 244097 URL: http://llvm.org/viewvc/llvm-project?rev=244097&view=rev Log: Add -gcodeview and -gdwarf to control which type Clang emits Summary: By default, 'clang' emits dwarf and 'clang-cl' emits codeview. You can force emission of one or both by passing -gcodeview and -gdwarf to either driver. Reviewers: dblaikie, hans Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D11742 Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td cfe/trunk/include/clang/Driver/Options.td cfe/trunk/include/clang/Frontend/CodeGenOptions.def cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/CodeGen/dwarf-version.c cfe/trunk/test/Driver/cl-options.c Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=244097&r1=244096&r2=244097&view=diff == --- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original) +++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Wed Aug 5 13:51:13 2015 @@ -157,9 +157,10 @@ def _SLASH_Zc_trigraphs : CLFlag<"Zc:tri HelpText<"Enable trigraphs">, Alias; def _SLASH_Zc_trigraphs_off : CLFlag<"Zc:trigraphs-">, HelpText<"Disable trigraphs (default)">, Alias; -def _SLASH_Z7 : CLFlag<"Z7">, Alias; -def _SLASH_Zi : CLFlag<"Zi">, HelpText<"Enable debug information">, - Alias; +def _SLASH_Z7 : CLFlag<"Z7">, + HelpText<"Enable CodeView debug information in object files">; +def _SLASH_Zi : CLFlag<"Zi">, Alias<_SLASH_Z7>, + HelpText<"Alias for /Z7. Does not produce PDBs.">; def _SLASH_Zp : CLJoined<"Zp">, HelpText<"Specify the default maximum struct packing alignment">, Alias; Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=244097&r1=244096&r2=244097&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Wed Aug 5 13:51:13 2015 @@ -1096,6 +1096,13 @@ def gdwarf_3 : Flag<["-"], "gdwarf-3">, HelpText<"Generate source-level debug information with dwarf version 3">, Flags<[CC1Option,CC1AsOption]>; def gdwarf_4 : Flag<["-"], "gdwarf-4">, Group, HelpText<"Generate source-level debug information with dwarf version 4">, Flags<[CC1Option,CC1AsOption]>; +def gcodeview : Flag<["-"], "gcodeview">, + HelpText<"Generate CodeView debug information">, + Flags<[CC1Option, CC1AsOption, CoreOption]>; +// Equivalent to our default dwarf version. Forces usual dwarf emission when +// CodeView is enabled. +def gdwarf : Flag<["-"], "gdwarf">, Alias, Flags<[CoreOption]>; + def gfull : Flag<["-"], "gfull">, Group; def gused : Flag<["-"], "gused">, Group; def gstabs : Joined<["-"], "gstabs">, Group, Flags<[Unsupported]>; Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=244097&r1=244096&r2=244097&view=diff == --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original) +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed Aug 5 13:51:13 2015 @@ -173,9 +173,14 @@ VALUE_CODEGENOPT(SSPBufferSize, 32, 0) /// The kind of generated debug info. ENUM_CODEGENOPT(DebugInfo, DebugInfoKind, 3, NoDebugInfo) -/// Dwarf version. +/// Dwarf version. Version zero indicates to LLVM that no DWARF should be +/// emitted. VALUE_CODEGENOPT(DwarfVersion, 3, 0) +/// Whether we should emit CodeView debug information. It's possible to emit +/// CodeView and DWARF into the same object. +CODEGENOPT(EmitCodeView, 1, 0) + /// The kind of inlining to perform. ENUM_CODEGENOPT(Inlining, InliningMethod, 2, NoInlining) Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=244097&r1=244096&r2=244097&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Aug 5 13:51:13 2015 @@ -369,11 +369,16 @@ void CodeGenModule::Release() { (Context.getLangOpts().Modules || !LinkerOptionsMetadata.empty())) { EmitModuleLinkOptions(); } - if (CodeGenOpts.DwarfVersion) + if (CodeGenOpts.DwarfVersion) { // We actually want the latest version when there are conflicts. // We can change from Warning to Latest if such mode is supported. getModule().addModuleFlag(llvm::Module::Warning, "Dwarf Version", CodeGenOpts.DwarfVersion); + } + if (CodeGenOpts.EmitCodeView) { +// In
r339638 - Revert r339623 "Model type attributes as regular Attrs."
Author: rnk Date: Mon Aug 13 18:55:37 2018 New Revision: 339638 URL: http://llvm.org/viewvc/llvm-project?rev=339638&view=rev Log: Revert r339623 "Model type attributes as regular Attrs." This breaks compiling atlwin.h in Chromium. I'm sure the code is invalid in some way, but we put a lot of work into accepting it, and I'm sure rejecting it was not an intended consequence of this refactoring. :) Modified: cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/include/clang/AST/Attr.h cfe/trunk/include/clang/AST/Type.h cfe/trunk/include/clang/AST/TypeLoc.h cfe/trunk/include/clang/Basic/Attr.td cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/include/clang/Serialization/ASTReader.h cfe/trunk/include/clang/Serialization/ASTWriter.h cfe/trunk/lib/ARCMigrate/TransGCAttrs.cpp cfe/trunk/lib/ARCMigrate/Transforms.cpp cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/AST/TypeLoc.cpp cfe/trunk/lib/AST/TypePrinter.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaInit.cpp cfe/trunk/lib/Sema/SemaObjCProperty.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/lib/Serialization/ASTReaderDecl.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp cfe/trunk/lib/StaticAnalyzer/Core/CheckerHelpers.cpp cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=339638&r1=339637&r2=339638&view=diff == --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Mon Aug 13 18:55:37 2018 @@ -31,7 +31,6 @@ #include "clang/AST/TemplateName.h" #include "clang/AST/Type.h" #include "clang/Basic/AddressSpaces.h" -#include "clang/Basic/AttrKinds.h" #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/LangOptions.h" @@ -1423,7 +1422,7 @@ public: QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const; - QualType getAttributedType(attr::Kind attrKind, + QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType); Modified: cfe/trunk/include/clang/AST/Attr.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=339638&r1=339637&r2=339638&view=diff == --- cfe/trunk/include/clang/AST/Attr.h (original) +++ cfe/trunk/include/clang/AST/Attr.h Mon Aug 13 18:55:37 2018 @@ -113,19 +113,6 @@ public: void printPretty(raw_ostream &OS, const PrintingPolicy &Policy) const; }; -class TypeAttr : public Attr { -protected: - TypeAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex, - bool IsLateParsed) - : Attr(AK, R, SpellingListIndex, IsLateParsed) {} - -public: - static bool classof(const Attr *A) { -return A->getKind() >= attr::FirstTypeAttr && - A->getKind() <= attr::LastTypeAttr; - } -}; - class StmtAttr : public Attr { protected: StmtAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex, Modified: cfe/trunk/include/clang/AST/Type.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=339638&r1=339637&r2=339638&view=diff == --- cfe/trunk/include/clang/AST/Type.h (original) +++ cfe/trunk/include/clang/AST/Type.h Mon Aug 13 18:55:37 2018 @@ -21,7 +21,6 @@ #include "clang/AST/NestedNameSpecifier.h" #include "clang/AST/TemplateName.h" #include "clang/Basic/AddressSpaces.h" -#include "clang/Basic/AttrKinds.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/ExceptionSpecificationType.h" #include "clang/Basic/LLVM.h" @@ -1871,16 +1870,7 @@ public: bool isObjCQualifiedClassType() const;// Class bool isObjCObjectOrInterfaceType() const; bool isObjCIdType() const;// id - - /// Was this type written with the special inert-in-ARC __unsafe_unretained - /// qualifier? - /// - /// This approximates the answer to the following question: if this - /// translation unit were compiled in ARC, would this type be qualified - /// with __unsafe_unretained? - bool isObjCInertUnsafeUnretainedType() const { -return hasAttr(attr::ObjCInertUnsafeUnretained); - } + bool isObjCInertUnsafeUnretainedType() const; /// Whether the type is Objective-C 'id' or a __kindof type of an /// object type, e.g., __kindof NSView * or __kindof id @@ -2094,10 +2084,6 @@ public: /// qualifiers from the outermost type. const ArrayType *castAsArrayTypeUnsafe() const; - /// Determine whether this type had the specified
r339728 - Fix lit fatal errors about requiring a USE_Z3_SOLVER param
Author: rnk Date: Tue Aug 14 14:15:57 2018 New Revision: 339728 URL: http://llvm.org/viewvc/llvm-project?rev=339728&view=rev Log: Fix lit fatal errors about requiring a USE_Z3_SOLVER param Modified: cfe/trunk/test/lit.site.cfg.py.in Modified: cfe/trunk/test/lit.site.cfg.py.in URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.site.cfg.py.in?rev=339728&r1=339727&r2=339728&view=diff == --- cfe/trunk/test/lit.site.cfg.py.in (original) +++ cfe/trunk/test/lit.site.cfg.py.in Tue Aug 14 14:15:57 2018 @@ -26,7 +26,7 @@ config.enable_shared = @ENABLE_SHARED@ config.enable_backtrace = @ENABLE_BACKTRACES@ config.host_arch = "@HOST_ARCH@" config.python_executable = "@PYTHON_EXECUTABLE@" -config.use_z3_solver = "@USE_Z3_SOLVER@" +config.use_z3_solver = lit_config.params.get('USE_Z3_SOLVER', "@USE_Z3_SOLVER@") # Support substitution of the tools and libs dirs with user parameters. This is # used when we can't determine the tool dir at configuration time. @@ -35,7 +35,6 @@ try: config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params -config.use_z3_solver = lit_config.params['USE_Z3_SOLVER'] except KeyError: e = sys.exc_info()[1] key, = e.args ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r339629 - [analyzer] [NFC] Introduce separate targets for testing the analyzer: check-clang-analyzer and check-clang-analyzer-z3
After this, check-clang no longer worked, it emitted a fatal error because USE_Z3_SOLVER was not in lit_config.params. I worked around it in r339728, but you might want to double check it. On Mon, Aug 13, 2018 at 4:13 PM George Karpenkov via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: george.karpenkov > Date: Mon Aug 13 16:12:43 2018 > New Revision: 339629 > > URL: http://llvm.org/viewvc/llvm-project?rev=339629&view=rev > Log: > [analyzer] [NFC] Introduce separate targets for testing the analyzer: > check-clang-analyzer and check-clang-analyzer-z3 > > Current testing setup for analyzer tests with Z3 is rather inconvenient: > > There's no way to run the analyzer tests separately (I use > LIT_FILTER=Analysis ninja check-clang, but a direct target is nicer). > > When Clang is built with Z3 support, there's no way to *not* run tests > with Z3 solver, and this is often desired, as tests with Z3 solver take > a very long time. > > This patch introduces two extra targets: > > - check-clang-analyzer > - check-clang-analyzer-z3 > > which solve those problems. > > Differential Revision: https://reviews.llvm.org/D50594 > > Modified: > cfe/trunk/test/Analysis/analyzer_test.py > cfe/trunk/test/Analysis/lit.local.cfg > cfe/trunk/test/CMakeLists.txt > cfe/trunk/test/lit.site.cfg.py.in > > Modified: cfe/trunk/test/Analysis/analyzer_test.py > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/analyzer_test.py?rev=339629&r1=339628&r2=339629&view=diff > > == > --- cfe/trunk/test/Analysis/analyzer_test.py (original) > +++ cfe/trunk/test/Analysis/analyzer_test.py Mon Aug 13 16:12:43 2018 > @@ -4,6 +4,10 @@ import lit.TestRunner > # Custom format class for static analyzer tests > class AnalyzerTest(lit.formats.ShTest): > > +def __init__(self, execute_external, use_z3_solver=False): > +super(AnalyzerTest, self).__init__(execute_external) > +self.use_z3_solver = use_z3_solver > + > def execute(self, test, litConfig): > results = [] > > @@ -19,7 +23,8 @@ class AnalyzerTest(lit.formats.ShTest): > return results[-1] > > # If z3 backend available, add an additional run line for it > -if test.config.clang_staticanalyzer_z3 == '1': > +if self.use_z3_solver == '1': > +assert(test.config.clang_staticanalyzer_z3 == '1') > results.append(self.executeWithAnalyzeSubstitution( > saved_test, litConfig, '-analyzer-constraints=z3 > -DANALYZER_CM_Z3')) > > > Modified: cfe/trunk/test/Analysis/lit.local.cfg > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/lit.local.cfg?rev=339629&r1=339628&r2=339629&view=diff > > == > --- cfe/trunk/test/Analysis/lit.local.cfg (original) > +++ cfe/trunk/test/Analysis/lit.local.cfg Mon Aug 13 16:12:43 2018 > @@ -7,7 +7,7 @@ import site > site.addsitedir(os.path.dirname(__file__)) > import analyzer_test > config.test_format = analyzer_test.AnalyzerTest( > -config.test_format.execute_external) > +config.test_format.execute_external, config.use_z3_solver) > > if not config.root.clang_staticanalyzer: > config.unsupported = True > > Modified: cfe/trunk/test/CMakeLists.txt > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=339629&r1=339628&r2=339629&view=diff > > == > --- cfe/trunk/test/CMakeLists.txt (original) > +++ cfe/trunk/test/CMakeLists.txt Mon Aug 13 16:12:43 2018 > @@ -88,8 +88,15 @@ endif () > > set(CLANG_TEST_PARAMS >clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg > + USE_Z3_SOLVER=0 >) > > +set(ANALYZER_TEST_PARAMS > + USE_Z3_SOLVER=0) > + > +set(ANALYZER_TEST_PARAMS_Z3 > + USE_Z3_SOLVER=1) > + > if( NOT CLANG_BUILT_STANDALONE ) >list(APPEND CLANG_TEST_DEPS > llvm-config > @@ -126,6 +133,24 @@ add_lit_testsuite(check-clang "Running t >) > set_target_properties(check-clang PROPERTIES FOLDER "Clang tests") > > +if (CLANG_ENABLE_STATIC_ANALYZER) > + add_lit_testsuite(check-clang-analyzer "Running the Clang analyzer > tests" > +${CMAKE_CURRENT_BINARY_DIR}/Analysis > +PARAMS ${ANALYZER_TEST_PARAMS} > +DEPENDS ${CLANG_TEST_DEPS}) > + set_target_properties(check-clang-analyzer PROPERTIES FOLDER "Clang > tests") > + > + > + if (CLANG_ANALYZER_WITH_Z3) > +add_lit_testsuite(check-clang-analyzer-z3 "Running the Clang analyzer > tests, using Z3 as a solver" > + ${CMAKE_CURRENT_BINARY_DIR}/Analysis > + PARAMS ${ANALYZER_TEST_PARAMS_Z3} > + DEPENDS ${CLANG_TEST_DEPS}) > +set_target_properties(check-clang-analyzer-z3 PROPERTIES FOLDER > "Clang tests") > + endif() > + > +endif() > + > add_lit_testsuites(CLANG ${CMAKE_CURRENT_SOURCE_DIR} >PARAMS ${CLANG_TEST_PARAMS} >DEPENDS ${CLA
r340079 - [MS] Mangle a hash of the main file path into anonymous namespaces
Author: rnk Date: Fri Aug 17 13:59:27 2018 New Revision: 340079 URL: http://llvm.org/viewvc/llvm-project?rev=340079&view=rev Log: [MS] Mangle a hash of the main file path into anonymous namespaces Summary: This is needed to avoid conflicts in mangled names for codeview types in anonymous namespaces. In CodeView, types refer to each other typically through forward declarations, which contain mangled names. These names have to be unique, otherwise the debugger will look up the mangled name and find the wrong definition. Furthermore, ThinLTO will deduplicate the types, and debug info verification can fail when the types have the wrong sizes. This is PR38608. Fixes PR38609. Reviewers: majnemer, inglorion, hans Subscribers: mehdi_amini, aprantl, JDevlieghere, dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D50877 Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp cfe/trunk/test/CodeGenCXX/cfi-cross-dso.cpp cfe/trunk/test/CodeGenCXX/cfi-icall.cpp cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp cfe/trunk/test/CodeGenCXX/dllexport.cpp cfe/trunk/test/CodeGenCXX/mangle-ms.cpp cfe/trunk/test/CodeGenCXX/microsoft-abi-structors.cpp cfe/trunk/test/CodeGenCXX/microsoft-abi-throw.cpp cfe/trunk/test/CodeGenCXX/microsoft-abi-thunks.cpp cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-member-pointers.cpp cfe/trunk/test/CodeGenCXX/msabi-swiftcall-cc.cpp cfe/trunk/test/CodeGenCXX/pragma-init_seg.cpp cfe/trunk/test/CodeGenCXX/type-metadata.cpp Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=340079&r1=340078&r2=340079&view=diff == --- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original) +++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Fri Aug 17 13:59:27 2018 @@ -29,6 +29,7 @@ #include "clang/Basic/TargetInfo.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/JamCRC.h" +#include "llvm/Support/xxhash.h" #include "llvm/Support/MD5.h" #include "llvm/Support/MathExtras.h" @@ -127,10 +128,10 @@ class MicrosoftMangleContextImpl : publi llvm::DenseMap LambdaIds; llvm::DenseMap SEHFilterIds; llvm::DenseMap SEHFinallyIds; + SmallString<16> AnonymousNamespaceHash; public: - MicrosoftMangleContextImpl(ASTContext &Context, DiagnosticsEngine &Diags) - : MicrosoftMangleContext(Context, Diags) {} + MicrosoftMangleContextImpl(ASTContext &Context, DiagnosticsEngine &Diags); bool shouldMangleCXXName(const NamedDecl *D) override; bool shouldMangleStringLiteral(const StringLiteral *SL) override; void mangleCXXName(const NamedDecl *D, raw_ostream &Out) override; @@ -238,6 +239,12 @@ public: return Result.first->second; } + /// Return a character sequence that is (somewhat) unique to the TU suitable + /// for mangling anonymous namespaces. + StringRef getAnonymousNamespaceHash() const { +return AnonymousNamespaceHash; + } + private: void mangleInitFiniStub(const VarDecl *D, char CharCode, raw_ostream &Out); }; @@ -371,6 +378,34 @@ private: }; } +MicrosoftMangleContextImpl::MicrosoftMangleContextImpl(ASTContext &Context, + DiagnosticsEngine &Diags) +: MicrosoftMangleContext(Context, Diags) { + // To mangle anonymous namespaces, hash the path to the main source file. The + // path should be whatever (probably relative) path was passed on the command + // line. The goal is for the compiler to produce the same output regardless of + // working directory, so use the uncanonicalized relative path. + // + // It's important to make the mangled names unique because, when CodeView + // debug info is in use, the debugger uses mangled type names to distinguish + // between otherwise identically named types in anonymous namespaces. + // + // These symbols are always internal, so there is no need for the hash to + // match what MSVC produces. For the same reason, clang is free to change the + // hash at any time without breaking compatibility with old versions of clang. + // The generated names are intended to look similar to what MSVC generates, + // which are something like "?A0x01234567@". + SourceManager &SM = Context.getSourceManager(); + if (const FileEntry *FE = SM.getFileEntryForID(SM.getMainFileID())) { +// Truncate the hash so we get 8 characters of hexadecimal. +uint32_t TruncatedHash = uint32_t(xxHash64(FE->getName())); +AnonymousNamespaceHash = llvm::utohexstr(TruncatedHash); + } else { +// If we don't have a path to the main file, we'll just use 0. +AnonymousNamespaceHash = "0"; + } +} + bool MicrosoftMangleContextImpl::shouldMangleCXXName(const NamedDecl *D) { if (const FunctionDecl *FD = dyn_cast(D)) { LanguageLinkage L = FD->getLanguageLinkage(); @@ -785,7 +820,7 @@ void MicrosoftCXXNameMa
r340080 - Update comments in CGDebugInfo to reflect changes in the MS mangler, NFC
Author: rnk Date: Fri Aug 17 13:59:52 2018 New Revision: 340080 URL: http://llvm.org/viewvc/llvm-project?rev=340080&view=rev Log: Update comments in CGDebugInfo to reflect changes in the MS mangler, NFC I've tried to elaborate on the purpose of these type identifiers and why and when clang uses them. Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=340080&r1=340079&r2=340080&view=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Aug 17 13:59:52 2018 @@ -829,31 +829,45 @@ static bool hasCXXMangling(const TagDecl } } -// Determines if the tag declaration will require a type identifier. +// Determines if the debug info for this tag declaration needs a type +// identifier. The purpose of the unique identifier is to deduplicate type +// information for identical types across TUs. Because of the C++ one definition +// rule (ODR), it is valid to assume that the type is defined the same way in +// every TU and its debug info is equivalent. +// +// C does not have the ODR, and it is common for codebases to contain multiple +// different definitions of a struct with the same name in different TUs. +// Therefore, if the type doesn't have a C++ mangling, don't give it an +// identifer. Type information in C is smaller and simpler than C++ type +// information, so the increase in debug info size is negligible. +// +// If the type is not externally visible, it should be unique to the current TU, +// and should not need an identifier to participate in type deduplication. +// However, when emitting CodeView, the format internally uses these +// unique type name identifers for references between debug info. For example, +// the method of a class in an anonymous namespace uses the identifer to refer +// to its parent class. The Microsoft C++ ABI attempts to provide unique names +// for such types, so when emitting CodeView, always use identifiers for C++ +// types. This may create problems when attempting to emit CodeView when the MS +// C++ ABI is not in use. static bool needsTypeIdentifier(const TagDecl *TD, CodeGenModule &CGM, llvm::DICompileUnit *TheCU) { // We only add a type identifier for types with C++ name mangling. if (!hasCXXMangling(TD, TheCU)) return false; - // CodeView types with C++ mangling need a type identifier. - if (CGM.getCodeGenOpts().EmitCodeView) -return true; - // Externally visible types with C++ mangling need a type identifier. if (TD->isExternallyVisible()) return true; + // CodeView types with C++ mangling need a type identifier. + if (CGM.getCodeGenOpts().EmitCodeView) +return true; + return false; } -// When emitting CodeView debug information we need to produce a type -// identifier for all types which have a C++ mangling. Until a GUID is added -// to the identifier (not currently implemented) the result will not be unique -// across compilation units. -// When emitting DWARF debug information, we need to produce a type identifier -// for all externally visible types with C++ name mangling. This identifier -// should be unique across ODR-compliant compilation units. +// Returns a unique type identifier string if one exists, or an empty string. static SmallString<256> getTypeIdentifier(const TagType *Ty, CodeGenModule &CGM, llvm::DICompileUnit *TheCU) { SmallString<256> Identifier; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r340101 - Don't warn on returning the address of a label from a statement expression
Author: rnk Date: Fri Aug 17 15:11:31 2018 New Revision: 340101 URL: http://llvm.org/viewvc/llvm-project?rev=340101&view=rev Log: Don't warn on returning the address of a label from a statement expression Summary: There isn't anything inherently wrong with returning a label from a statement expression. In practice, the Linux kernel uses this pattern to materialize PCs. Fixes PR38569 Reviewers: niravd, rsmith, nickdesaulniers Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50805 Modified: cfe/trunk/lib/Sema/SemaInit.cpp cfe/trunk/test/Sema/statements.c Modified: cfe/trunk/lib/Sema/SemaInit.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=340101&r1=340100&r2=340101&view=diff == --- cfe/trunk/lib/Sema/SemaInit.cpp (original) +++ cfe/trunk/lib/Sema/SemaInit.cpp Fri Aug 17 15:11:31 2018 @@ -6924,6 +6924,10 @@ void Sema::checkInitializerLifetime(cons } else if (isa(L)) { Diag(DiagLoc, diag::err_ret_local_block) << DiagRange; } else if (isa(L)) { +// Don't warn when returning a label from a statement expression. +// Leaving the scope doesn't end its lifetime. +if (LK == LK_StmtExprResult) + return false; Diag(DiagLoc, diag::warn_ret_addr_label) << DiagRange; } else { Diag(DiagLoc, diag::warn_ret_local_temp_addr_ref) Modified: cfe/trunk/test/Sema/statements.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/statements.c?rev=340101&r1=340100&r2=340101&view=diff == --- cfe/trunk/test/Sema/statements.c (original) +++ cfe/trunk/test/Sema/statements.c Fri Aug 17 15:11:31 2018 @@ -34,6 +34,15 @@ bar: return &&bar; // expected-warning {{returning address of label, which is local}} } +// PR38569: Don't warn when returning a label from a statement expression. +void test10_logpc(void*); +void test10a() { + test10_logpc(({ +my_pc: + &&my_pc; + })); +} + // PR6034 void test11(int bit) { switch (bit) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r340427 - Disable the aligned allocation test on old mac versions instead of XFAILing it
Author: rnk Date: Wed Aug 22 10:47:41 2018 New Revision: 340427 URL: http://llvm.org/viewvc/llvm-project?rev=340427&view=rev Log: Disable the aligned allocation test on old mac versions instead of XFAILing it It looks like this test XPASSes when the deployment target is older than the OS of the system the test is running on. It looks like we run the tests with -mmacosx-version-min=10.12, and that makes the test expect to fail, but it passes. Modified: libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp Modified: libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp?rev=340427&r1=340426&r2=340427&view=diff == --- libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp (original) +++ libcxx/trunk/test/libcxx/memory/aligned_allocation_macro.pass.cpp Wed Aug 22 10:47:41 2018 @@ -10,12 +10,12 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 // aligned allocation functions are not provided prior to macosx10.13 -// XFAIL: macosx10.12 -// XFAIL: macosx10.11 -// XFAIL: macosx10.10 -// XFAIL: macosx10.9 -// XFAIL: macosx10.8 -// XFAIL: macosx10.7 +// UNSUPPORTED: macosx10.12 +// UNSUPPORTED: macosx10.11 +// UNSUPPORTED: macosx10.10 +// UNSUPPORTED: macosx10.9 +// UNSUPPORTED: macosx10.8 +// UNSUPPORTED: macosx10.7 #include ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r332018 - Allow dllimport non-type template arguments in C++17
Author: rnk Date: Thu May 10 11:57:35 2018 New Revision: 332018 URL: http://llvm.org/viewvc/llvm-project?rev=332018&view=rev Log: Allow dllimport non-type template arguments in C++17 Summary: Fixes PR35772. Reviewers: rsmith Differential Revision: https://reviews.llvm.org/D43320 Added: cfe/trunk/test/SemaCXX/dllimport-constexpr.cpp Modified: cfe/trunk/include/clang/AST/Expr.h cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/test/SemaCXX/dllimport-memptr.cpp Modified: cfe/trunk/include/clang/AST/Expr.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=332018&r1=332017&r2=332018&view=diff == --- cfe/trunk/include/clang/AST/Expr.h (original) +++ cfe/trunk/include/clang/AST/Expr.h Thu May 10 11:57:35 2018 @@ -658,6 +658,13 @@ public: ArrayRef Args, const Expr *This = nullptr) const; + /// Indicates how the constant expression will be used. + enum ConstExprUsage { EvaluateForCodeGen, EvaluateForMangling }; + + /// Evaluate an expression that is required to be a constant expression. + bool EvaluateAsConstantExpr(EvalResult &Result, ConstExprUsage Usage, + const ASTContext &Ctx) const; + /// If the current Expr is a pointer, this will try to statically /// determine the number of bytes available where the pointer is pointing. /// Returns true if all of the above holds and we were able to figure out the Modified: cfe/trunk/lib/AST/ExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=332018&r1=332017&r2=332018&view=diff == --- cfe/trunk/lib/AST/ExprConstant.cpp (original) +++ cfe/trunk/lib/AST/ExprConstant.cpp Thu May 10 11:57:35 2018 @@ -1720,7 +1720,8 @@ static void NoteLValueLocation(EvalInfo /// value for an address or reference constant expression. Return true if we /// can fold this expression, whether or not it's a constant expression. static bool CheckLValueConstantExpression(EvalInfo &Info, SourceLocation Loc, - QualType Type, const LValue &LVal) { + QualType Type, const LValue &LVal, + Expr::ConstExprUsage Usage) { bool IsReferenceType = Type->isReferenceType(); APValue::LValueBase Base = LVal.getLValueBase(); @@ -1753,7 +1754,7 @@ static bool CheckLValueConstantExpressio return false; // A dllimport variable never acts like a constant. - if (Var->hasAttr()) + if (Usage == Expr::EvaluateForCodeGen && Var->hasAttr()) return false; } if (const auto *FD = dyn_cast(VD)) { @@ -1767,7 +1768,8 @@ static bool CheckLValueConstantExpressio // The C language has no notion of ODR; furthermore, it has no notion of // dynamic initialization. This means that we are permitted to // perform initialization with the address of the thunk. - if (Info.getLangOpts().CPlusPlus && FD->hasAttr()) + if (Info.getLangOpts().CPlusPlus && Usage == Expr::EvaluateForCodeGen && + FD->hasAttr()) return false; } } @@ -1800,12 +1802,14 @@ static bool CheckLValueConstantExpressio static bool CheckMemberPointerConstantExpression(EvalInfo &Info, SourceLocation Loc, QualType Type, - const APValue &Value) { + const APValue &Value, + Expr::ConstExprUsage Usage) { const ValueDecl *Member = Value.getMemberPointerDecl(); const auto *FD = dyn_cast_or_null(Member); if (!FD) return true; - return FD->isVirtual() || !FD->hasAttr(); + return Usage == Expr::EvaluateForMangling || FD->isVirtual() || + !FD->hasAttr(); } /// Check that this core constant expression is of literal type, and if not, @@ -1843,8 +1847,10 @@ static bool CheckLiteralType(EvalInfo &I /// Check that this core constant expression value is a valid value for a /// constant expression. If not, report an appropriate diagnostic. Does not /// check that the expression is of literal type. -static bool CheckConstantExpression(EvalInfo &Info, SourceLocation DiagLoc, -QualType Type, const APValue &Value) { +static bool +CheckConstantExpression(EvalInfo &Info, SourceLocation DiagLoc, QualType Type, +const APValue &Value, +Expr::ConstExprUsage Usage = Expr::EvaluateForCodeGen) { if (Value.isUninit()) { Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized) << true << Type; @@ -1863,28 +1869,28 @@ static
r332053 - [clang-cl] Make -f[no-]coverage-mapping available
Author: rnk Date: Thu May 10 15:24:00 2018 New Revision: 332053 URL: http://llvm.org/viewvc/llvm-project?rev=332053&view=rev Log: [clang-cl] Make -f[no-]coverage-mapping available Modified: cfe/trunk/include/clang/Driver/Options.td Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=332053&r1=332052&r2=332053&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Thu May 10 15:24:00 2018 @@ -718,10 +718,10 @@ def fprofile_instr_use_EQ : Joined<["-"] Group, Flags<[CoreOption]>, HelpText<"Use instrumentation data for profile-guided optimization">; def fcoverage_mapping : Flag<["-"], "fcoverage-mapping">, -Group, Flags<[CC1Option]>, +Group, Flags<[CC1Option, CoreOption]>, HelpText<"Generate coverage mapping to enable code coverage analysis">; def fno_coverage_mapping : Flag<["-"], "fno-coverage-mapping">, -Group, Flags<[DriverOption]>, +Group, Flags<[DriverOption, CoreOption]>, HelpText<"Disable code coverage analysis">; def fprofile_generate : Flag<["-"], "fprofile-generate">, Group, Flags<[DriverOption]>, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r332074 - Don't propagate dllimport to base class template static data members
Author: rnk Date: Thu May 10 18:26:11 2018 New Revision: 332074 URL: http://llvm.org/viewvc/llvm-project?rev=332074&view=rev Log: Don't propagate dllimport to base class template static data members MSVC doesn't, so we shouldn't. Fixes PR37232. Added: cfe/trunk/test/CodeGenCXX/dllimport-template-sdm.cpp Modified: cfe/trunk/include/clang/Basic/Attr.td cfe/trunk/lib/Sema/SemaDeclCXX.cpp Modified: cfe/trunk/include/clang/Basic/Attr.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=332074&r1=332073&r2=332074&view=diff == --- cfe/trunk/include/clang/Basic/Attr.td (original) +++ cfe/trunk/include/clang/Basic/Attr.td Thu May 10 18:26:11 2018 @@ -2566,6 +2566,16 @@ def DLLImport : InheritableAttr, TargetS let Spellings = [Declspec<"dllimport">, GCC<"dllimport">]; let Subjects = SubjectList<[Function, Var, CXXRecord, ObjCInterface]>; let Documentation = [DLLImportDocs]; + + + let AdditionalMembers = [{ +private: + bool PropagatedToBaseTemplate = false; + +public: + void setPropagatedToBaseTemplate() { PropagatedToBaseTemplate = true; } + bool wasPropagatedToBaseTemplate() { return PropagatedToBaseTemplate; } + }]; } def SelectAny : InheritableAttr { Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=332074&r1=332073&r2=332074&view=diff == --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu May 10 18:26:11 2018 @@ -5626,6 +5626,13 @@ void Sema::checkClassLevelDLLAttribute(C // The class is either imported or exported. const bool ClassExported = ClassAttr->getKind() == attr::DLLExport; + // Check if this was a dllimport attribute propagated from a derived class to + // a base class template specialization. We don't apply these attributes to + // static data members. + const bool PropagatedImport = + !ClassExported && + cast(ClassAttr)->wasPropagatedToBaseTemplate(); + TemplateSpecializationKind TSK = Class->getTemplateSpecializationKind(); // Ignore explicit dllexport on explicit class template instantiation declarations. @@ -5677,6 +5684,11 @@ void Sema::checkClassLevelDLLAttribute(C } } +// Don't apply dllimport attributes to static data members of class template +// instantiations when the attribute is propagated from a derived class. +if (VD && PropagatedImport) + continue; + if (!cast(Member)->isExternallyVisible()) continue; @@ -5729,6 +5741,11 @@ void Sema::propagateDLLAttrToBaseClassTe NewAttr->setInherited(true); BaseTemplateSpec->addAttr(NewAttr); +// If this was an import, mark that we propagated it from a derived class to +// a base class template specialization. +if (auto *ImportAttr = dyn_cast(NewAttr)) + ImportAttr->setPropagatedToBaseTemplate(); + // If the template is already instantiated, checkDLLAttributeRedeclaration() // needs to be run again to work see the new attribute. Otherwise this will // get run whenever the template is instantiated. Added: cfe/trunk/test/CodeGenCXX/dllimport-template-sdm.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllimport-template-sdm.cpp?rev=332074&view=auto == --- cfe/trunk/test/CodeGenCXX/dllimport-template-sdm.cpp (added) +++ cfe/trunk/test/CodeGenCXX/dllimport-template-sdm.cpp Thu May 10 18:26:11 2018 @@ -0,0 +1,53 @@ +// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++14 -fms-extensions -o - %s | FileCheck %s --check-prefix=IMPORT +// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++14 -fms-extensions -o - %s -DTEST_EXPORT | FileCheck %s --check-prefix=EXPORT + +#ifndef TEST_EXPORT +#define DLLATTR __declspec(dllimport) +#else +#define DLLATTR __declspec(dllexport) +#endif + +// PR37232: When a dllimport attribute is propagated from a derived class to a +// base class that happens to be a template specialization, it is only applied +// to template *methods*, and not static data members. If a dllexport attribute +// is propagated, it still applies to static data members. + +// IMPORT-DAG: @"?sdm@Exporter@@2HB" = available_externally dllimport constant i32 2, align 4 +// IMPORT-DAG: @"?csdm@?$A@H@@2HB" = linkonce_odr dso_local constant i32 2, comdat, align 4 +// IMPORT-DAG: @"?sdm@?$A@H@@2HA" = linkonce_odr dso_local global i32 1, comdat, align 4 +// IMPORT-DAG: @"?sdm@?$B@H@@2HB" = available_externally dllimport constant i32 2, align 4 +// IMPORT-DAG: @"?sdm@?$C@H@@2HB" = available_externally dllimport constant i32 2, align 4 + +// EXPORT-DAG: @"?sdm@Exporter@@2HB" = weak_odr dso_local dllexport constant i32 2, comdat, align 4 +// EXPORT-DAG: @"?csdm@?$A@H@@2HB" = weak_
r332639 - Fix a mangling failure on clang-cl C++17
Author: rnk Date: Thu May 17 11:12:18 2018 New Revision: 332639 URL: http://llvm.org/viewvc/llvm-project?rev=332639&view=rev Log: Fix a mangling failure on clang-cl C++17 MethodVFTableLocations in MigrosoftVTableContext contains canonicalized decl. But, it's sometimes asked to lookup for non-canonicalized decl, and that causes assertion failure, and compilation failure. Fixes PR37481. Patch by Taiju Tsuiki! Differential Revision: https://reviews.llvm.org/D46929 Modified: cfe/trunk/lib/AST/VTableBuilder.cpp cfe/trunk/lib/CodeGen/CGCXX.cpp cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Modified: cfe/trunk/lib/AST/VTableBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=332639&r1=332638&r2=332639&view=diff == --- cfe/trunk/lib/AST/VTableBuilder.cpp (original) +++ cfe/trunk/lib/AST/VTableBuilder.cpp Thu May 17 11:12:18 2018 @@ -2223,6 +2223,7 @@ ItaniumVTableContext::ItaniumVTableConte ItaniumVTableContext::~ItaniumVTableContext() {} uint64_t ItaniumVTableContext::getMethodVTableIndex(GlobalDecl GD) { + GD = GD.getCanonicalDecl(); MethodVTableIndicesTy::iterator I = MethodVTableIndices.find(GD); if (I != MethodVTableIndices.end()) return I->second; @@ -2503,6 +2504,8 @@ private: for (const auto &I : MethodInfoMap) { const CXXMethodDecl *MD = I.first; const MethodInfo &MI = I.second; + assert(MD == MD->getCanonicalDecl()); + // Skip the methods that the MostDerivedClass didn't override // and the entries shadowed by return adjusting thunks. if (MD->getParent() != MostDerivedClass || MI.Shadowed) @@ -3737,6 +3740,8 @@ MicrosoftVTableContext::getMethodVFTable if (isa(GD.getDecl())) assert(GD.getDtorType() == Dtor_Deleting); + GD = GD.getCanonicalDecl(); + MethodVFTableLocationsTy::iterator I = MethodVFTableLocations.find(GD); if (I != MethodVFTableLocations.end()) return I->second; Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=332639&r1=332638&r2=332639&view=diff == --- cfe/trunk/lib/CodeGen/CGCXX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCXX.cpp Thu May 17 11:12:18 2018 @@ -267,7 +267,6 @@ static CGCallee BuildAppleKextVirtualCal const CXXRecordDecl *RD) { assert(!CGF.CGM.getTarget().getCXXABI().isMicrosoft() && "No kext in Microsoft ABI"); - GD = GD.getCanonicalDecl(); CodeGenModule &CGM = CGF.CGM; llvm::Value *VTable = CGM.getCXXABI().getAddrOfVTable(RD, CharUnits()); Ty = Ty->getPointerTo()->getPointerTo(); @@ -283,7 +282,7 @@ static CGCallee BuildAppleKextVirtualCal CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfnkxt"); llvm::Value *VFunc = CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.PointerAlignInBytes); - CGCallee Callee(GD.getDecl(), VFunc); + CGCallee Callee(GD.getDecl()->getCanonicalDecl(), VFunc); return Callee; } Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=332639&r1=332638&r2=332639&view=diff == --- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original) +++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Thu May 17 11:12:18 2018 @@ -825,7 +825,6 @@ ItaniumCXXABI::EmitMemberFunctionPointer llvm::Constant *ItaniumCXXABI::BuildMemberPointer(const CXXMethodDecl *MD, CharUnits ThisAdjustment) { assert(MD->isInstance() && "Member function must not be static!"); - MD = MD->getCanonicalDecl(); CodeGenTypes &Types = CGM.getTypes(); @@ -1640,7 +1639,6 @@ CGCallee ItaniumCXXABI::getVirtualFuncti Address This, llvm::Type *Ty, SourceLocation Loc) { - GD = GD.getCanonicalDecl(); Ty = Ty->getPointerTo()->getPointerTo(); auto *MethodDecl = cast(GD.getDecl()); llvm::Value *VTable = CGF.GetVTablePtr(This, Ty, MethodDecl->getParent()); @@ -1674,7 +1672,7 @@ CGCallee ItaniumCXXABI::getVirtualFuncti VFunc = VFuncLoad; } - CGCallee Callee(MethodDecl, VFunc); + CGCallee Callee(MethodDecl->getCanonicalDecl(), VFunc); return Callee; } Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=332639&r1=332638&r2=332639&view=diff == --- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original) +++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Thu May 17 11:12:18 2018 @@ -228,7 +228,
r332646 - Add missing test case for r332639
Author: rnk Date: Thu May 17 11:34:05 2018 New Revision: 332646 URL: http://llvm.org/viewvc/llvm-project?rev=332646&view=rev Log: Add missing test case for r332639 Added: cfe/trunk/test/CodeGenCXX/PR37481.cpp Added: cfe/trunk/test/CodeGenCXX/PR37481.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/PR37481.cpp?rev=332646&view=auto == --- cfe/trunk/test/CodeGenCXX/PR37481.cpp (added) +++ cfe/trunk/test/CodeGenCXX/PR37481.cpp Thu May 17 11:34:05 2018 @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -o /dev/null -emit-llvm -std=c++17 -triple x86_64-pc-windows-msvc %s + +struct Foo { + virtual void f(); + virtual void g(); +}; + +void Foo::f() {} +void Foo::g() {} + +template +void h() {} + +void x() { + h<&Foo::f>(); + h<&Foo::g>(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r332639 - Fix a mangling failure on clang-cl C++17
Thanks! Added in 332646 On Thu, May 17, 2018 at 11:30 AM Nico Weber wrote: > You might've forgotten to svn add the test :-) > > On Thu, May 17, 2018, 2:16 PM Reid Kleckner via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: rnk >> Date: Thu May 17 11:12:18 2018 >> New Revision: 332639 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=332639&view=rev >> Log: >> Fix a mangling failure on clang-cl C++17 >> >> MethodVFTableLocations in MigrosoftVTableContext contains canonicalized >> decl. But, it's sometimes asked to lookup for non-canonicalized decl, >> and that causes assertion failure, and compilation failure. >> >> Fixes PR37481. >> >> Patch by Taiju Tsuiki! >> >> Differential Revision: https://reviews.llvm.org/D46929 >> >> Modified: >> cfe/trunk/lib/AST/VTableBuilder.cpp >> cfe/trunk/lib/CodeGen/CGCXX.cpp >> cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp >> cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp >> >> Modified: cfe/trunk/lib/AST/VTableBuilder.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=332639&r1=332638&r2=332639&view=diff >> >> == >> --- cfe/trunk/lib/AST/VTableBuilder.cpp (original) >> +++ cfe/trunk/lib/AST/VTableBuilder.cpp Thu May 17 11:12:18 2018 >> @@ -2223,6 +2223,7 @@ ItaniumVTableContext::ItaniumVTableConte >> ItaniumVTableContext::~ItaniumVTableContext() {} >> >> uint64_t ItaniumVTableContext::getMethodVTableIndex(GlobalDecl GD) { >> + GD = GD.getCanonicalDecl(); >>MethodVTableIndicesTy::iterator I = MethodVTableIndices.find(GD); >>if (I != MethodVTableIndices.end()) >> return I->second; >> @@ -2503,6 +2504,8 @@ private: >> for (const auto &I : MethodInfoMap) { >>const CXXMethodDecl *MD = I.first; >>const MethodInfo &MI = I.second; >> + assert(MD == MD->getCanonicalDecl()); >> + >>// Skip the methods that the MostDerivedClass didn't override >>// and the entries shadowed by return adjusting thunks. >>if (MD->getParent() != MostDerivedClass || MI.Shadowed) >> @@ -3737,6 +3740,8 @@ MicrosoftVTableContext::getMethodVFTable >>if (isa(GD.getDecl())) >> assert(GD.getDtorType() == Dtor_Deleting); >> >> + GD = GD.getCanonicalDecl(); >> + >>MethodVFTableLocationsTy::iterator I = MethodVFTableLocations.find(GD); >>if (I != MethodVFTableLocations.end()) >> return I->second; >> >> Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=332639&r1=332638&r2=332639&view=diff >> >> == >> --- cfe/trunk/lib/CodeGen/CGCXX.cpp (original) >> +++ cfe/trunk/lib/CodeGen/CGCXX.cpp Thu May 17 11:12:18 2018 >> @@ -267,7 +267,6 @@ static CGCallee BuildAppleKextVirtualCal >>const CXXRecordDecl *RD) { >>assert(!CGF.CGM.getTarget().getCXXABI().isMicrosoft() && >> "No kext in Microsoft ABI"); >> - GD = GD.getCanonicalDecl(); >>CodeGenModule &CGM = CGF.CGM; >>llvm::Value *VTable = CGM.getCXXABI().getAddrOfVTable(RD, CharUnits()); >>Ty = Ty->getPointerTo()->getPointerTo(); >> @@ -283,7 +282,7 @@ static CGCallee BuildAppleKextVirtualCal >> CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, >> "vfnkxt"); >>llvm::Value *VFunc = >> CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.PointerAlignInBytes); >> - CGCallee Callee(GD.getDecl(), VFunc); >> + CGCallee Callee(GD.getDecl()->getCanonicalDecl(), VFunc); >>return Callee; >> } >> >> >> Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=332639&r1=332638&r2=332639&view=diff >> >> == >> --- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original) >> +++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Thu May 17 11:12:18 2018 >> @@ -825,7 +825,6 @@ ItaniumCXXABI::EmitMemberFunctionPointer >> llvm::Constant *ItaniumCXXABI::BuildMemberPointer(const CXXMethodDecl >> *MD, >>CharUnits >> ThisAdjustment) {
r314689 - Revert "[Sema] Warn on attribute nothrow conflicting with language specifiers"
Author: rnk Date: Mon Oct 2 10:16:14 2017 New Revision: 314689 URL: http://llvm.org/viewvc/llvm-project?rev=314689&view=rev Log: Revert "[Sema] Warn on attribute nothrow conflicting with language specifiers" This reverts r314461. It is warning on user code that uses END_COM_MAP(), which expands to declare QueryInterface with conflicting exception specifers. I've spent a while trying to understand why, but haven't been able to extract a reduced test case. Let's revert and I'll keep trying. Removed: cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaDeclAttr.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=314689&r1=314688&r2=314689&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Oct 2 10:16:14 2017 @@ -1419,10 +1419,6 @@ def err_noexcept_needs_constant_expressi "argument to noexcept specifier must be a constant expression">; def err_exception_spec_not_parsed : Error< "exception specification is not available until end of class definition">; -def warn_nothrow_attr_disagrees_with_exception_specification -: ExtWarn<"attribute 'nothrow' ignored due to conflicting exception " - "specification">, - InGroup; // C++ access checking def err_class_redeclared_with_different_access : Error< Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=314689&r1=314688&r2=314689&view=diff == --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Oct 2 10:16:14 2017 @@ -1985,25 +1985,6 @@ static void handleNoReturnAttr(Sema &S, Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex())); } -static void handleNoThrowAttr(Sema &S, Decl *D, const AttributeList &Attrs) { - assert(isa(D) && "attribute nothrow only valid on functions"); - - auto *FD = cast(D); - const auto *FPT = FD->getType()->getAs(); - - if (FPT && FPT->hasExceptionSpec() && - FPT->getExceptionSpecType() != EST_BasicNoexcept) { -S.Diag(Attrs.getLoc(), - diag::warn_nothrow_attr_disagrees_with_exception_specification); -S.Diag(FD->getExceptionSpecSourceRange().getBegin(), - diag::note_previous_decl) -<< "exception specification"; - } - - D->addAttr(::new (S.Context) NoThrowAttr( - Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex())); -} - static void handleNoCallerSavedRegsAttr(Sema &S, Decl *D, const AttributeList &Attr) { if (S.CheckNoCallerSavedRegsAttr(Attr)) @@ -6230,7 +6211,7 @@ static void ProcessDeclAttribute(Sema &S handleNoReturnAttr(S, D, Attr); break; case AttributeList::AT_NoThrow: -handleNoThrowAttr(S, D, Attr); +handleSimpleAttribute(S, D, Attr); break; case AttributeList::AT_CUDAShared: handleSharedAttr(S, D, Attr); Removed: cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp?rev=314688&view=auto == --- cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp (original) +++ cfe/trunk/test/SemaCXX/warn-conflicting-nothrow-attr-exception-spec.cpp (removed) @@ -1,24 +0,0 @@ -// RUN: %clang_cc1 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify -std=c++14 - -struct S { - //expected-warning@+2 {{attribute 'nothrow' ignored due to conflicting exception specification}} - //expected-note@+1 {{exception specification declared here}} - __attribute__((nothrow)) S() noexcept(true); - //expected-warning@+2 {{attribute 'nothrow' ignored due to conflicting exception specification}} - //expected-note@+1 {{exception specification declared here}} - __attribute__((nothrow)) void Func1() noexcept(false); - __attribute__((nothrow)) void Func3() noexcept; -}; - -void throwing() noexcept(false); -void non_throwing(bool b = true) noexcept; - -template -struct T { -__attribute__((nothrow)) void f(Fn) noexcept(Fn()); -}; - -//expected-warning@-3 {{attribute 'nothrow' ignored due to conflicting exception specification}} -//expected-note@-4 {{exception specification declared here}} -template struct T; -template struct T; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r314743 - [clang-cl] Claim ignored /O[12xd] arguments
Author: rnk Date: Mon Oct 2 17:14:03 2017 New Revision: 314743 URL: http://llvm.org/viewvc/llvm-project?rev=314743&view=rev Log: [clang-cl] Claim ignored /O[12xd] arguments Fixes PR34809 Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp cfe/trunk/test/Driver/cl-options.c Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.cpp?rev=314743&r1=314742&r2=314743&view=diff == --- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Mon Oct 2 17:14:03 2017 @@ -1317,24 +1317,26 @@ static void TranslateOptArg(Arg *A, llvm case '2': case 'x': case 'd': - if (&OptChar == ExpandChar) { -if (OptChar == 'd') { - DAL.AddFlagArg(A, Opts.getOption(options::OPT_O0)); -} else { - if (OptChar == '1') { -DAL.AddJoinedArg(A, Opts.getOption(options::OPT_O), "s"); - } else if (OptChar == '2' || OptChar == 'x') { -DAL.AddFlagArg(A, Opts.getOption(options::OPT_fbuiltin)); -DAL.AddJoinedArg(A, Opts.getOption(options::OPT_O), "2"); - } - if (SupportsForcingFramePointer && - !DAL.hasArgNoClaim(options::OPT_fno_omit_frame_pointer)) -DAL.AddFlagArg(A, - Opts.getOption(options::OPT_fomit_frame_pointer)); - if (OptChar == '1' || OptChar == '2') -DAL.AddFlagArg(A, - Opts.getOption(options::OPT_ffunction_sections)); + // Ignore /O[12xd] flags that aren't the last one on the command line. + // Only the last one gets expanded. + if (&OptChar != ExpandChar) { +A->claim(); +break; + } + if (OptChar == 'd') { +DAL.AddFlagArg(A, Opts.getOption(options::OPT_O0)); + } else { +if (OptChar == '1') { + DAL.AddJoinedArg(A, Opts.getOption(options::OPT_O), "s"); +} else if (OptChar == '2' || OptChar == 'x') { + DAL.AddFlagArg(A, Opts.getOption(options::OPT_fbuiltin)); + DAL.AddJoinedArg(A, Opts.getOption(options::OPT_O), "2"); } +if (SupportsForcingFramePointer && +!DAL.hasArgNoClaim(options::OPT_fno_omit_frame_pointer)) + DAL.AddFlagArg(A, Opts.getOption(options::OPT_fomit_frame_pointer)); +if (OptChar == '1' || OptChar == '2') + DAL.AddFlagArg(A, Opts.getOption(options::OPT_ffunction_sections)); } break; case 'b': @@ -1430,9 +1432,7 @@ MSVCToolChain::TranslateArgs(const llvm: // First step is to search for the character we'd like to expand. const char *ExpandChar = nullptr; - for (Arg *A : Args) { -if (!A->getOption().matches(options::OPT__SLASH_O)) - continue; + for (Arg *A : Args.filtered(options::OPT__SLASH_O)) { StringRef OptStr = A->getValue(); for (size_t I = 0, E = OptStr.size(); I != E; ++I) { char OptChar = OptStr[I]; Modified: cfe/trunk/test/Driver/cl-options.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=314743&r1=314742&r2=314743&view=diff == --- cfe/trunk/test/Driver/cl-options.c (original) +++ cfe/trunk/test/Driver/cl-options.c Mon Oct 2 17:14:03 2017 @@ -178,6 +178,9 @@ // Oy_2: -momit-leaf-frame-pointer // Oy_2: -O2 +// RUN: %clang_cl --target=i686-pc-win32 -Werror /O2 /O2 -### -- %s 2>&1 | FileCheck -check-prefix=O2O2 %s +// O2O2: "-O2" + // RUN: %clang_cl /Zs -Werror /Oy -- %s 2>&1 // RUN: %clang_cl --target=i686-pc-win32 -Werror /Oy- -### -- %s 2>&1 | FileCheck -check-prefix=Oy_ %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r314840 - Fix hicpp-signed-bitwise.cpp test on Windows, where the MSVC ABI changes enum underlying types
Author: rnk Date: Tue Oct 3 13:37:06 2017 New Revision: 314840 URL: http://llvm.org/viewvc/llvm-project?rev=314840&view=rev Log: Fix hicpp-signed-bitwise.cpp test on Windows, where the MSVC ABI changes enum underlying types Modified: clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise.cpp Modified: clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise.cpp?rev=314840&r1=314839&r2=314840&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise.cpp Tue Oct 3 13:37:06 2017 @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s hicpp-signed-bitwise %t -- -- -std=c++11 +// RUN: %check_clang_tidy %s hicpp-signed-bitwise %t -- -- -std=c++11 --target=x86_64-linux // These could cause false positives and should not be considered. struct StreamClass { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r315107 - [MS] Raise the default value of _MSC_VER to 1911, which is VS 2017
Author: rnk Date: Fri Oct 6 14:02:28 2017 New Revision: 315107 URL: http://llvm.org/viewvc/llvm-project?rev=315107&view=rev Log: [MS] Raise the default value of _MSC_VER to 1911, which is VS 2017 Summary: This raises our default past 1900, which controls whether char16_t is a builtin type or not. Implements PR34243 Reviewers: hans Subscribers: STL_MSFT, rsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D38646 Modified: cfe/trunk/docs/ReleaseNotes.rst cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Modified: cfe/trunk/docs/ReleaseNotes.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=315107&r1=315106&r2=315107&view=diff == --- cfe/trunk/docs/ReleaseNotes.rst (original) +++ cfe/trunk/docs/ReleaseNotes.rst Fri Oct 6 14:02:28 2017 @@ -89,6 +89,11 @@ Non-comprehensive list of changes in thi - Bitrig OS was merged back into OpenBSD, so Bitrig support has been removed from Clang/LLVM. +- The default value of _MSC_VER was raised from 1800 to 1911, making it + compatible with the Visual Studio 2015 and 2017 C++ standard library headers. + Users should generally expect this to be regularly raised to match the most + recently released version of the Visual C++ compiler. + New Compiler Flags -- Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.cpp?rev=315107&r1=315106&r2=315107&view=diff == --- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Fri Oct 6 14:02:28 2017 @@ -1266,9 +1266,8 @@ VersionTuple MSVCToolChain::computeMSVCV if (MSVT.empty() && Args.hasFlag(options::OPT_fms_extensions, options::OPT_fno_ms_extensions, IsWindowsMSVC)) { -// -fms-compatibility-version=18.00 is default. -// FIXME: Consider bumping this to 19 (MSVC2015) soon. -MSVT = VersionTuple(18); +// -fms-compatibility-version=19.11 is default, aka 2017 +MSVT = VersionTuple(19, 11); } return MSVT; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r315111 - Revert "For dllexport class templates, export specializations of member functions (PR34849)"
Author: rnk Date: Fri Oct 6 14:28:21 2017 New Revision: 315111 URL: http://llvm.org/viewvc/llvm-project?rev=315111&view=rev Log: Revert "For dllexport class templates, export specializations of member functions (PR34849)" This reverts r315025, it caused http://crbug.com/772461 Modified: cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/test/CodeGenCXX/dllexport.cpp Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=315111&r1=315110&r2=315111&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Oct 6 14:28:21 2017 @@ -6041,21 +6041,6 @@ static void checkDLLAttributeRedeclarati diag::warn_dllimport_dropped_from_inline_function) << NewDecl << OldImportAttr; } - - // A specialization of a class template member function is processed here - // since it's a redeclaration. If the parent class is dllexport, the - // specialization inherits that attribute. This doesn't happen automatically - // since the parent class isn't instantiated until later. - if (IsSpecialization && isa(NewDecl) && !NewImportAttr && - !NewExportAttr) { -if (const DLLExportAttr *ParentExportAttr = cast(NewDecl) - ->getParent() - ->getAttr()) { - DLLExportAttr *NewAttr = ParentExportAttr->clone(S.Context); - NewAttr->setInherited(true); - NewDecl->addAttr(NewAttr); -} - } } /// Given that we are within the definition of the given function, Modified: cfe/trunk/test/CodeGenCXX/dllexport.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport.cpp?rev=315111&r1=315110&r2=315111&view=diff == --- cfe/trunk/test/CodeGenCXX/dllexport.cpp (original) +++ cfe/trunk/test/CodeGenCXX/dllexport.cpp Fri Oct 6 14:28:21 2017 @@ -831,14 +831,6 @@ template struct ExplicitIns template struct __declspec(dllexport) __declspec(dllimport) ExplicitInstantiationTwoAttributes; // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?f@?$ExplicitInstantiationTwoAttributes@H@@QAEXXZ" -// Specializations of exported class template functions get exported. -namespace pr34849 { -template struct __declspec(dllexport) ExportedClass { void foo(); }; -template<> void ExportedClass::foo() {} -template struct ExportedClass; -// M32-DAG: define dllexport x86_thiscallcc void @"\01?foo@?$ExportedClass@H@pr34849@@QAEXXZ" -} - //===--===// // Classes with template base classes ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r315656 - [MS] Don't bail on replacing dllimport vbase dtors with base dtors
Author: rnk Date: Thu Oct 12 17:53:02 2017 New Revision: 315656 URL: http://llvm.org/viewvc/llvm-project?rev=315656&view=rev Log: [MS] Don't bail on replacing dllimport vbase dtors with base dtors Fix PR32990 by effectively reverting r283063 and solving it a different way. We want to limit the hack to not replace equivalent available_externally dtors specifically to libc++, which uses always_inline. It seems certain versions of libc++ do not provide all the symbols that an explicit template instantiation is expected to provide. If we get to the code that forms a real alias, only *then* check if this is available_externally, and do that by asking a better question, which is "is this a declaration for the linker?", because *that's* what means we can't form an alias to it. As a follow-on simplification, remove the InEveryTU parameter. Its last use guarded this code for forming aliases, but we should never form aliases to declarations, regardless of what we know about every TU. Added: cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=315656&r1=315655&r2=315656&view=diff == --- cfe/trunk/lib/CodeGen/CGCXX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCXX.cpp Thu Oct 12 17:53:02 2017 @@ -110,16 +110,14 @@ bool CodeGenModule::TryEmitBaseDestructo return true; return TryEmitDefinitionAsAlias(GlobalDecl(D, Dtor_Base), - GlobalDecl(BaseD, Dtor_Base), - false); + GlobalDecl(BaseD, Dtor_Base)); } /// Try to emit a definition as a global alias for another definition. /// If \p InEveryTU is true, we know that an equivalent alias can be produced /// in every translation unit. bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl, - GlobalDecl TargetDecl, - bool InEveryTU) { + GlobalDecl TargetDecl) { if (!getCodeGenOpts().CXXCtorDtorAliases) return true; @@ -134,11 +132,6 @@ bool CodeGenModule::TryEmitDefinitionAsA llvm::GlobalValue::LinkageTypes TargetLinkage = getFunctionLinkage(TargetDecl); - // available_externally definitions aren't real definitions, so we cannot - // create an alias to one. - if (TargetLinkage == llvm::GlobalValue::AvailableExternallyLinkage) -return true; - // Check if we have it already. StringRef MangledName = getMangledName(AliasDecl); llvm::GlobalValue *Entry = GetGlobalValue(MangledName); @@ -161,7 +154,14 @@ bool CodeGenModule::TryEmitDefinitionAsA // Instead of creating as alias to a linkonce_odr, replace all of the uses // of the aliasee. - if (llvm::GlobalValue::isDiscardableIfUnused(Linkage)) { + if (llvm::GlobalValue::isDiscardableIfUnused(Linkage) && + !(TargetLinkage == llvm::GlobalValue::AvailableExternallyLinkage && +TargetDecl.getDecl()->hasAttr())) { +// FIXME: An extern template instantiation will create functions with +// linkage "AvailableExternally". In libc++, some classes also define +// members with attribute "AlwaysInline" and expect no reference to +// be generated. It is desirable to reenable this optimisation after +// corresponding LLVM changes. addReplacement(MangledName, Aliasee); return false; } @@ -176,13 +176,11 @@ bool CodeGenModule::TryEmitDefinitionAsA return true; } - if (!InEveryTU) { -// If we don't have a definition for the destructor yet, don't -// emit. We can't emit aliases to declarations; that's just not -// how aliases work. -if (Ref->isDeclaration()) - return true; - } + // If we don't have a definition for the destructor yet or the definition is + // avaialable_externally, don't emit an alias. We can't emit aliases to + // declarations; that's just not how aliases work. + if (Ref->isDeclarationForLinker()) +return true; // Don't create an alias to a linker weak symbol. This avoids producing // different COMDATs in different TUs. Another option would be to Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=315656&r1=315655&r2=315656&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.h (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.h Thu Oct 12 17:53:02 2017 @@ -1145,8 +1145,7 @@ public: /// are emitted lazily. void EmitGlobal(GlobalDecl D); - bool TryEmitDefinitionAsAlias(GlobalDecl Alias, GlobalDecl Target, -bool InEv
r315699 - Hide "#pragma optimize("", off)" from clang when it pretends to be MSVC 2017
Author: rnk Date: Fri Oct 13 09:18:32 2017 New Revision: 315699 URL: http://llvm.org/viewvc/llvm-project?rev=315699&view=rev Log: Hide "#pragma optimize("", off)" from clang when it pretends to be MSVC 2017 These pragmas work around a bug in VC 1911 that isn't present in clang, and clang warns about them. Modified: cfe/trunk/lib/AST/StmtProfile.cpp Modified: cfe/trunk/lib/AST/StmtProfile.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=315699&r1=315698&r2=315699&view=diff == --- cfe/trunk/lib/AST/StmtProfile.cpp (original) +++ cfe/trunk/lib/AST/StmtProfile.cpp Fri Oct 13 09:18:32 2017 @@ -1418,7 +1418,7 @@ static Stmt::StmtClass DecodeOperatorCal llvm_unreachable("Invalid overloaded operator expression"); } -#if defined(_MSC_VER) +#if defined(_MSC_VER) && !defined(__clang__) #if _MSC_VER == 1911 // Work around https://developercommunity.visualstudio.com/content/problem/84002/clang-cl-when-built-with-vc-2017-crashes-cause-vc.html // MSVC 2017 update 3 miscompiles this function, and a clang built with it @@ -1459,7 +1459,7 @@ void StmtProfiler::VisitCXXOperatorCallE ID.AddInteger(S->getOperator()); } -#if defined(_MSC_VER) +#if defined(_MSC_VER) && !defined(__clang__) #if _MSC_VER == 1911 #pragma optimize("", on) #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r315707 - [SEH] Use the SEH personality on frontend-outlined funclets
Author: rnk Date: Fri Oct 13 09:55:14 2017 New Revision: 315707 URL: http://llvm.org/viewvc/llvm-project?rev=315707&view=rev Log: [SEH] Use the SEH personality on frontend-outlined funclets This allows __try inside __finally to work. Fixes PR34939 Modified: cfe/trunk/lib/CodeGen/CGException.cpp cfe/trunk/test/CodeGenCXX/exceptions-seh.cpp Modified: cfe/trunk/lib/CodeGen/CGException.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=315707&r1=315706&r2=315707&view=diff == --- cfe/trunk/lib/CodeGen/CGException.cpp (original) +++ cfe/trunk/lib/CodeGen/CGException.cpp Fri Oct 13 09:55:14 2017 @@ -225,7 +225,12 @@ const EHPersonality &EHPersonality::get( } const EHPersonality &EHPersonality::get(CodeGenFunction &CGF) { - return get(CGF.CGM, dyn_cast_or_null(CGF.CurCodeDecl)); + const auto *FD = CGF.CurCodeDecl; + // For outlined finallys and filters, use the SEH personality in case they + // contain more SEH. This mostly only affects finallys. Filters could + // hypothetically use gnu statement expressions to sneak in nested SEH. + FD = FD ? FD : CGF.CurSEHParent; + return get(CGF.CGM, dyn_cast_or_null(FD)); } static llvm::Constant *getPersonalityFn(CodeGenModule &CGM, Modified: cfe/trunk/test/CodeGenCXX/exceptions-seh.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/exceptions-seh.cpp?rev=315707&r1=315706&r2=315707&view=diff == --- cfe/trunk/test/CodeGenCXX/exceptions-seh.cpp (original) +++ cfe/trunk/test/CodeGenCXX/exceptions-seh.cpp Fri Oct 13 09:55:14 2017 @@ -76,6 +76,27 @@ extern "C" void use_seh() { // CHECK: [[cont]] // CHECK: br label %[[ret]] +extern "C" void nested_finally() { + __try { +might_throw(); + } __finally { +__try { + might_throw(); +} __finally { +} + } +} + +// CHECK-LABEL: define void @nested_finally() #{{[0-9]+}} +// CHECK-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) +// CHECK: invoke void @might_throw() +// CHECK: call void @"\01?fin$0@0@nested_finally@@"(i8 1, i8* {{.*}}) + +// CHECK-LABEL: define internal void @"\01?fin$0@0@nested_finally@@" +// CHECK-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) +// CHECK: invoke void @might_throw() +// CHECK: call void @"\01?fin$1@0@nested_finally@@"(i8 1, i8* {{.*}}) + void use_seh_in_lambda() { ([]() { __try { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r315953 - Don't print end-of-directive tokens in -E output
Author: rnk Date: Mon Oct 16 16:07:15 2017 New Revision: 315953 URL: http://llvm.org/viewvc/llvm-project?rev=315953&view=rev Log: Don't print end-of-directive tokens in -E output This comes up when pre-processing standalone .s files containing hash-prefixed comments. The pre-processor should skip the unknown directive and not emit an extra newline as we were doing. Fixes PR34950 Added: cfe/trunk/test/Preprocessor/print-assembler.s Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=315953&r1=315952&r2=315953&view=diff == --- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original) +++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Mon Oct 16 16:07:15 2017 @@ -720,6 +720,12 @@ static void PrintPreprocessedTokens(Prep // -traditional-cpp the lexer keeps /all/ whitespace, including comments. SourceLocation StartLoc = Tok.getLocation(); Callbacks->MoveToLine(StartLoc.getLocWithOffset(Tok.getLength())); +} else if (Tok.is(tok::eod)) { + // Don't print end of directive tokens, since they are typically newlines + // that mess up our line tracking. These come from unknown pre-processor + // directives or hash-prefixed comments in standalone assembly files. + PP.Lex(Tok); + continue; } else if (Tok.is(tok::annot_module_include)) { // PrintPPOutputPPCallbacks::InclusionDirective handles producing // appropriate output here. Ignore this token entirely. Added: cfe/trunk/test/Preprocessor/print-assembler.s URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/print-assembler.s?rev=315953&view=auto == --- cfe/trunk/test/Preprocessor/print-assembler.s (added) +++ cfe/trunk/test/Preprocessor/print-assembler.s Mon Oct 16 16:07:15 2017 @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -E -x assembler-with-cpp %s -o - | FileCheck %s --strict-whitespace + +.intel_syntax noprefix +.text + .global _main +_main: +# asdf +# asdf + mov bogus_name, 20 + mov rax, 5 + ret + +// CHECK-LABEL: _main: +// CHECK-NEXT: {{^}} # asdf +// CHECK-NEXT: {{^}} # asdf +// CHECK-NEXT: mov bogus_name, 20 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r341572 - Re-land r334417 "[MS] Use mangled names and comdats for string merging with ASan"
Author: rnk Date: Thu Sep 6 11:25:39 2018 New Revision: 341572 URL: http://llvm.org/viewvc/llvm-project?rev=341572&view=rev Log: Re-land r334417 "[MS] Use mangled names and comdats for string merging with ASan" The issue with -fprofile-generate was fixed and the dependent CL relanded in r340232. Added: cfe/trunk/test/CodeGen/asan-strings.c Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=341572&r1=341571&r2=341572&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Sep 6 11:25:39 2018 @@ -4305,15 +4305,13 @@ CodeGenModule::GetAddrOfConstantStringFr StringRef GlobalVariableName; llvm::GlobalValue::LinkageTypes LT; - // Mangle the string literal if the ABI allows for it. However, we cannot - // do this if we are compiling with ASan or -fwritable-strings because they - // rely on strings having normal linkage. - if (!LangOpts.WritableStrings && - !LangOpts.Sanitize.has(SanitizerKind::Address) && - getCXXABI().getMangleContext().shouldMangleStringLiteral(S)) { + // Mangle the string literal if that's how the ABI merges duplicate strings. + // Don't do it if they are writable, since we don't want writes in one TU to + // affect strings in another. + if (getCXXABI().getMangleContext().shouldMangleStringLiteral(S) && + !LangOpts.WritableStrings) { llvm::raw_svector_ostream Out(MangledNameBuffer); getCXXABI().getMangleContext().mangleStringLiteral(S, Out); - LT = llvm::GlobalValue::LinkOnceODRLinkage; GlobalVariableName = MangledNameBuffer; } else { Added: cfe/trunk/test/CodeGen/asan-strings.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/asan-strings.c?rev=341572&view=auto == --- cfe/trunk/test/CodeGen/asan-strings.c (added) +++ cfe/trunk/test/CodeGen/asan-strings.c Thu Sep 6 11:25:39 2018 @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=address -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefix=LINUX +// RUN: %clang_cc1 -triple x86_64-windows-msvc -fsanitize=address -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefix=WINDOWS +// RUN: %clang_cc1 -triple x86_64-windows-msvc -fsanitize=address -fwritable-strings -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefix=WINWRITE + +// On Linux (and basically every non-MS target) string literals are emitted with +// private linkage, which means ASan can freely instrument them. On Windows, +// they are emitted with comdats. ASan's global instrumentation code for COFF +// knows how to make the metadata comdat associative, so the string literal +// global is only registered if the instrumented global prevails during linking. + +const char *foo() { return "asdf"; } + +// LINUX: @.str = private unnamed_addr constant [5 x i8] c"asdf\00", align 1 + +// WINDOWS: @"??_C@_04JIHMPGLA@asdf?$AA@" = linkonce_odr dso_local unnamed_addr constant [5 x i8] c"asdf\00", comdat, align 1 + +// WINWRITE: @.str = private unnamed_addr global [5 x i8] c"asdf\00", align 1 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r342281 - Relax assumption about default method calling convention in new test
Author: rnk Date: Fri Sep 14 13:50:39 2018 New Revision: 342281 URL: http://llvm.org/viewvc/llvm-project?rev=342281&view=rev Log: Relax assumption about default method calling convention in new test Modified: cfe/trunk/test/CodeGenCXX/debug-info-lambda.cpp Modified: cfe/trunk/test/CodeGenCXX/debug-info-lambda.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-lambda.cpp?rev=342281&r1=342280&r2=342281&view=diff == --- cfe/trunk/test/CodeGenCXX/debug-info-lambda.cpp (original) +++ cfe/trunk/test/CodeGenCXX/debug-info-lambda.cpp Fri Sep 14 13:50:39 2018 @@ -6,7 +6,7 @@ void lambda_in_func(int &ref) { // CHECK: [[ref_slot:%.*]] = getelementptr inbounds %class.anon, %class.anon* {{.*}}, i32 0, i32 0, !dbg [[lambda_decl_loc:![0-9]+]] // CHECK-NEXT: %1 = load i32*, i32** %ref.addr, align {{.*}}, !dbg [[capture_init_loc:![0-9]+]] // CHECK-NEXT: store i32* %1, i32** %0, align {{.*}}, !dbg [[lambda_decl_loc]] - // CHECK-NEXT: call void {{.*}}, !dbg [[lambda_call_loc:![0-9]+]] + // CHECK-NEXT: call {{.*}}void {{.*}}, !dbg [[lambda_call_loc:![0-9]+]] auto helper = [ // CHECK: [[lambda_decl_loc]] = !DILocation(line: [[@LINE]], column: 17 &]() { // CHECK: [[capture_init_loc]] = !DILocation(line: [[@LINE]], column: 18 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r342282 - Mark index-tools.test as REQUIRES: shell so that it does not run with the internal lit shell which does not support "if"
Author: rnk Date: Fri Sep 14 13:51:07 2018 New Revision: 342282 URL: http://llvm.org/viewvc/llvm-project?rev=342282&view=rev Log: Mark index-tools.test as REQUIRES: shell so that it does not run with the internal lit shell which does not support "if" Modified: clang-tools-extra/trunk/test/clangd/index-tools.test Modified: clang-tools-extra/trunk/test/clangd/index-tools.test URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/index-tools.test?rev=342282&r1=342281&r2=342282&view=diff == --- clang-tools-extra/trunk/test/clangd/index-tools.test (original) +++ clang-tools-extra/trunk/test/clangd/index-tools.test Fri Sep 14 13:51:07 2018 @@ -1,5 +1,6 @@ # RUN: clangd-indexer %p/Inputs/BenchmarkSource.cpp -- -I%p/Inputs > %t.index # FIXME: By default, benchmarks are excluded from the list of default targets hence not built. Find a way to depend on benchmarks to run the next command. +# REQUIRES: shell # RUN: if [ -f %clangd-benchmark-dir/IndexBenchmark ]; then %clangd-benchmark-dir/IndexBenchmark %t.index %p/Inputs/requests.json --benchmark_min_time=0.01 ; fi # Pass invalid JSON file and check that IndexBenchmark fails to parse it. # RUN: if [ -f %clangd-benchmark-dir/IndexBenchmark ]; then not %clangd-benchmark-dir/IndexBenchmark %t.index %t --benchmark_min_time=0.01 ; fi ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang-tools-extra] r342036 - Fix buildbots after r342027
That construct does not work on Windows, where we don't use bash. We use the lit internal shell, which doesn't support 'if [ ...]'. I marked it REQUIRES: shell in r342282. On Wed, Sep 12, 2018 at 2:29 AM Kirill Bobyrev via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: omtcyfz > Date: Wed Sep 12 02:27:55 2018 > New Revision: 342036 > > URL: http://llvm.org/viewvc/llvm-project?rev=342036&view=rev > Log: > Fix buildbots after r342027 > > Modified: > clang-tools-extra/trunk/test/clangd/index-tools.test > > Modified: clang-tools-extra/trunk/test/clangd/index-tools.test > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/index-tools.test?rev=342036&r1=342035&r2=342036&view=diff > > == > --- clang-tools-extra/trunk/test/clangd/index-tools.test (original) > +++ clang-tools-extra/trunk/test/clangd/index-tools.test Wed Sep 12 > 02:27:55 2018 > @@ -1,2 +1,3 @@ > # RUN: global-symbol-builder %p/Inputs/BenchmarkSource.cpp -- -I%p/Inputs > > %t.index > -# RUN: %clangd-benchmark-dir/IndexBenchmark %t.index > %p/Inputs/requests.log --benchmark_min_time=0.01 > +# FIXME: By default, benchmarks are excluded from the list of default > targets hence not built. Find a way to depend on benchmarks to run the next > command. > +# RUN: if [ -f %clangd-benchmark-dir/IndexBenchmark ]; then > %clangd-benchmark-dir/IndexBenchmark %t.index %p/Inputs/requests.log > --benchmark_min_time=0.01 ; fi > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r337616 - [codeview] Don't emit variable templates as class members
Author: rnk Date: Fri Jul 20 13:55:00 2018 New Revision: 337616 URL: http://llvm.org/viewvc/llvm-project?rev=337616&view=rev Log: [codeview] Don't emit variable templates as class members MSVC doesn't, so neither should we. Fixes PR38004, which is a crash that happens when we try to emit debug info for a still-dependent partial variable template specialization. As a follow-up, we should review what we're doing for function and class member templates. It looks like we don't filter those out, but I can't seem to get clang to emit any. Added: cfe/trunk/test/CodeGenCXX/debug-info-codeview-var-templates.cpp Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=337616&r1=337615&r2=337616&view=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Jul 20 13:55:00 2018 @@ -1298,10 +1298,6 @@ void CGDebugInfo::CollectRecordFields( else { const ASTRecordLayout &layout = CGM.getContext().getASTRecordLayout(record); -// Debug info for nested types is included in the member list only for -// CodeView. -bool IncludeNestedTypes = CGM.getCodeGenOpts().EmitCodeView; - // Field number for non-static fields. unsigned fieldNo = 0; @@ -1311,6 +1307,13 @@ void CGDebugInfo::CollectRecordFields( if (const auto *V = dyn_cast(I)) { if (V->hasAttr()) continue; + +// Skip variable template specializations when emitting CodeView. MSVC +// doesn't emit them. +if (CGM.getCodeGenOpts().EmitCodeView && +isa(V)) + continue; + // Reuse the existing static member declaration if one exists auto MI = StaticDataMemberCache.find(V->getCanonicalDecl()); if (MI != StaticDataMemberCache.end()) { @@ -1327,7 +1330,9 @@ void CGDebugInfo::CollectRecordFields( // Bump field number for next field. ++fieldNo; - } else if (IncludeNestedTypes) { + } else if (CGM.getCodeGenOpts().EmitCodeView) { +// Debug info for nested types is included in the member list only for +// CodeView. if (const auto *nestedType = dyn_cast(I)) if (!nestedType->isImplicit() && nestedType->getDeclContext() == record) Added: cfe/trunk/test/CodeGenCXX/debug-info-codeview-var-templates.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-codeview-var-templates.cpp?rev=337616&view=auto == --- cfe/trunk/test/CodeGenCXX/debug-info-codeview-var-templates.cpp (added) +++ cfe/trunk/test/CodeGenCXX/debug-info-codeview-var-templates.cpp Fri Jul 20 13:55:00 2018 @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 %s -std=c++14 -triple=i686-pc-windows-msvc -debug-info-kind=limited -gcodeview -emit-llvm -o - | FileCheck %s + +// Don't emit static data member debug info for variable templates. +// PR38004 + +struct TestImplicit { + template + static const __SIZE_TYPE__ size_var = sizeof(T); +}; +int instantiate_test1() { return TestImplicit::size_var + TestImplicit::size_var; } +TestImplicit gv1; + +// CHECK: ![[empty:[0-9]+]] = !{} + +// CHECK: ![[A:[^ ]*]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "TestImplicit", +// CHECK-SAME: elements: ![[empty]] + +template bool vtpl; +struct TestSpecialization { + template static const auto sdm = vtpl; + template <> static const auto sdm = false; +} gv2; + +// CHECK: ![[A:[^ ]*]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "TestSpecialization", +// CHECK-SAME: elements: ![[empty]] + +template bool a; +template struct b; +struct TestPartial { + template static auto d = a; + template static auto d> = d; +} c; + +// CHECK: ![[A:[^ ]*]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "TestPartial", +// CHECK-SAME: elements: ![[empty]] ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r337629 - Disable clang crash-report-modules.m test on Windows again
Author: rnk Date: Fri Jul 20 15:36:33 2018 New Revision: 337629 URL: http://llvm.org/viewvc/llvm-project?rev=337629&view=rev Log: Disable clang crash-report-modules.m test on Windows again It still appears to be failing: http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/12825 $ "rm" "-rf" "C:\b\slave\clang-x86-windows-msvc2015\clang-x86-windows-msvc2015\stage1\tools\clang\test\Driver\Output/crmdir" Error: 'rm' command failed, [Error 3] The system cannot find the path specified: 'C:\\b\\slave\\clang-x86-windows-msvc2015\\clang-x86-windows-msvc2015\\stage1\\tools\\clang\\test\\Driver\\Output/crmdir\\crash-report-modules-300567.cache\\vfs\\b\\slave\\clang-x86-windows-msvc2015\\clang-x86-windows-msvc2015\\llvm\\tools\\clang\\test\\Driver\\Inputs\\module\\module.modulemap' error: command failed with exit status: 1 Modified: cfe/trunk/test/Driver/crash-report-modules.m Modified: cfe/trunk/test/Driver/crash-report-modules.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/crash-report-modules.m?rev=337629&r1=337628&r2=337629&view=diff == --- cfe/trunk/test/Driver/crash-report-modules.m (original) +++ cfe/trunk/test/Driver/crash-report-modules.m Fri Jul 20 15:36:33 2018 @@ -12,6 +12,10 @@ // RUN: FileCheck --check-prefix=CHECKSH %s -input-file %T/crmdir/crash-report-*.sh // REQUIRES: crash-recovery +// FIXME: This test creates excessively deep directory hierarchies that cause +// problems on Windows. +// UNSUPPORTED: system-windows + @import simple; const int x = MODULE_MACRO; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r337715 - [MS] Update _MSVC_LANG values for C++17 and C++2a
Author: rnk Date: Mon Jul 23 10:44:00 2018 New Revision: 337715 URL: http://llvm.org/viewvc/llvm-project?rev=337715&view=rev Log: [MS] Update _MSVC_LANG values for C++17 and C++2a Fixes PR38262 Added: cfe/trunk/test/Preprocessor/predefined-win-macros.c Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h cfe/trunk/test/Preprocessor/predefined-macros.c Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=337715&r1=337714&r2=337715&view=diff == --- cfe/trunk/lib/Basic/Targets/OSTargets.h (original) +++ cfe/trunk/lib/Basic/Targets/OSTargets.h Mon Jul 23 10:44:00 2018 @@ -617,8 +617,10 @@ protected: Builder.defineMacro("_HAS_CHAR16_T_LANGUAGE_SUPPORT", Twine(1)); if (Opts.isCompatibleWithMSVC(LangOptions::MSVC2015)) { -if (Opts.CPlusPlus17) - Builder.defineMacro("_MSVC_LANG", "201403L"); +if (Opts.CPlusPlus2a) + Builder.defineMacro("_MSVC_LANG", "201704L"); +else if (Opts.CPlusPlus17) + Builder.defineMacro("_MSVC_LANG", "201703L"); else if (Opts.CPlusPlus14) Builder.defineMacro("_MSVC_LANG", "201402L"); } Modified: cfe/trunk/test/Preprocessor/predefined-macros.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-macros.c?rev=337715&r1=337714&r2=337715&view=diff == --- cfe/trunk/test/Preprocessor/predefined-macros.c (original) +++ cfe/trunk/test/Preprocessor/predefined-macros.c Mon Jul 23 10:44:00 2018 @@ -1,33 +1,5 @@ // This test verifies that the correct macros are predefined. // -// RUN: %clang_cc1 %s -x c++ -E -dM -triple i686-pc-win32 -fms-extensions -fms-compatibility \ -// RUN: -fms-compatibility-version=19.00 -std=c++1z -o - | FileCheck -match-full-lines %s --check-prefix=CHECK-MS -// CHECK-MS: #define _INTEGRAL_MAX_BITS 64 -// CHECK-MS: #define _MSC_EXTENSIONS 1 -// CHECK-MS: #define _MSC_VER 1900 -// CHECK-MS: #define _MSVC_LANG 201403L -// CHECK-MS: #define _M_IX86 600 -// CHECK-MS: #define _M_IX86_FP 0 -// CHECK-MS: #define _WIN32 1 -// CHECK-MS-NOT: #define __STRICT_ANSI__ -// CHECK-MS-NOT: GCC -// CHECK-MS-NOT: GNU -// CHECK-MS-NOT: GXX -// -// RUN: %clang_cc1 %s -x c++ -E -dM -triple x86_64-pc-win32 -fms-extensions -fms-compatibility \ -// RUN: -fms-compatibility-version=19.00 -std=c++14 -o - | FileCheck -match-full-lines %s --check-prefix=CHECK-MS64 -// CHECK-MS64: #define _INTEGRAL_MAX_BITS 64 -// CHECK-MS64: #define _MSC_EXTENSIONS 1 -// CHECK-MS64: #define _MSC_VER 1900 -// CHECK-MS64: #define _MSVC_LANG 201402L -// CHECK-MS64: #define _M_AMD64 100 -// CHECK-MS64: #define _M_X64 100 -// CHECK-MS64: #define _WIN64 1 -// CHECK-MS64-NOT: #define __STRICT_ANSI__ -// CHECK-MS64-NOT: GCC -// CHECK-MS64-NOT: GNU -// CHECK-MS64-NOT: GXX -// // RUN: %clang_cc1 %s -E -dM -triple i686-pc-win32 -fms-compatibility \ // RUN: -o - | FileCheck -match-full-lines %s --check-prefix=CHECK-MS-STDINT // CHECK-MS-STDINT:#define __INT16_MAX__ 32767 @@ -199,81 +171,6 @@ // MSCOPE:#define __OPENCL_MEMORY_SCOPE_WORK_GROUP 1 // MSCOPE:#define __OPENCL_MEMORY_SCOPE_WORK_ITEM 0 -// RUN: %clang_cc1 -triple i386-windows %s -E -dM -o - \ -// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-X86-WIN - -// CHECK-X86-WIN-NOT: #define WIN32 1 -// CHECK-X86-WIN-NOT: #define WIN64 1 -// CHECK-X86-WIN-NOT: #define WINNT 1 -// CHECK-X86-WIN: #define _WIN32 1 -// CHECK-X86-WIN-NOT: #define _WIN64 1 - -// RUN: %clang_cc1 -triple thumbv7-windows %s -E -dM -o - \ -// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM-WIN - -// CHECK-ARM-WIN-NOT: #define WIN32 1 -// CHECK-ARM-WIN-NOT: #define WIN64 1 -// CHECK-ARM-WIN-NOT: #define WINNT 1 -// CHECK-ARM-WIN: #define _WIN32 1 -// CHECK-ARM-WIN-NOT: #define _WIN64 1 - -// RUN: %clang_cc1 -triple x86_64-windows %s -E -dM -o - \ -// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-AMD64-WIN - -// CHECK-AMD64-WIN-NOT: #define WIN32 1 -// CHECK-AMD64-WIN-NOT: #define WIN64 1 -// CHECK-AMD64-WIN-NOT: #define WINNT 1 -// CHECK-AMD64-WIN: #define _WIN32 1 -// CHECK-AMD64-WIN: #define _WIN64 1 - -// RUN: %clang_cc1 -triple aarch64-windows %s -E -dM -o - \ -// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM64-WIN - -// CHECK-ARM64-WIN-NOT: #define WIN32 1 -// CHECK-ARM64-WIN-NOT: #define WIN64 1 -// CHECK-ARM64-WIN-NOT: #define WINNT 1 -// CHECK-ARM64-WIN: #define _M_ARM64 1 -// CHECK-ARM64-WIN: #define _WIN32 1 -// CHECK-ARM64-WIN: #define _WIN64 1 - -// RUN: %clang_cc1 -triple i686-windows-gnu %s -E -dM -o - \ -// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-X86-MINGW - -// CHECK-X86-MINGW: #define WIN32 1 -// CHECK-X86-MINGW-NOT: #define WIN64 1 -// CHECK-X86-MINGW: #define WINNT 1 -// CHECK-X86-MINGW: #define _WIN32 1 -// CHECK-X86-
r337746 - [clang-cl] Expose -fblocks and -fno-builtin as driver flags
Author: rnk Date: Mon Jul 23 14:29:43 2018 New Revision: 337746 URL: http://llvm.org/viewvc/llvm-project?rev=337746&view=rev Log: [clang-cl] Expose -fblocks and -fno-builtin as driver flags Users have requested them. Helps with PR36427. Modified: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/test/Driver/cl-options.c Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=337746&r1=337745&r2=337746&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Mon Jul 23 14:29:43 2018 @@ -762,12 +762,12 @@ def faddrsig : Flag<["-"], "faddrsig">, HelpText<"Emit an address-significance table">; def fno_addrsig : Flag<["-"], "fno-addrsig">, Group, Flags<[CoreOption]>, HelpText<"Don't emit an address-significance table">; -def fblocks : Flag<["-"], "fblocks">, Group, Flags<[CC1Option]>, +def fblocks : Flag<["-"], "fblocks">, Group, Flags<[CoreOption, CC1Option]>, HelpText<"Enable the 'blocks' language feature">; def fbootclasspath_EQ : Joined<["-"], "fbootclasspath=">, Group; def fborland_extensions : Flag<["-"], "fborland-extensions">, Group, Flags<[CC1Option]>, HelpText<"Accept non-standard constructs supported by the Borland compiler">; -def fbuiltin : Flag<["-"], "fbuiltin">, Group; +def fbuiltin : Flag<["-"], "fbuiltin">, Group, Flags<[CoreOption]>; def fbuiltin_module_map : Flag <["-"], "fbuiltin-module-map">, Group, Flags<[DriverOption]>, HelpText<"Load the clang builtins module map file.">; def fcaret_diagnostics : Flag<["-"], "fcaret-diagnostics">, Group; @@ -1320,11 +1320,11 @@ def fno_asynchronous_unwind_tables : Fla def fno_assume_sane_operator_new : Flag<["-"], "fno-assume-sane-operator-new">, Group, HelpText<"Don't assume that C++'s global operator new can't alias any pointer">, Flags<[CC1Option]>; -def fno_blocks : Flag<["-"], "fno-blocks">, Group; +def fno_blocks : Flag<["-"], "fno-blocks">, Group, Flags<[CoreOption]>; def fno_borland_extensions : Flag<["-"], "fno-borland-extensions">, Group; -def fno_builtin : Flag<["-"], "fno-builtin">, Group, Flags<[CC1Option]>, +def fno_builtin : Flag<["-"], "fno-builtin">, Group, Flags<[CC1Option, CoreOption]>, HelpText<"Disable implicit builtin knowledge of functions">; -def fno_builtin_ : Joined<["-"], "fno-builtin-">, Group, Flags<[CC1Option]>, +def fno_builtin_ : Joined<["-"], "fno-builtin-">, Group, Flags<[CC1Option, CoreOption]>, HelpText<"Disable implicit builtin knowledge of a specific function">; def fno_caret_diagnostics : Flag<["-"], "fno-caret-diagnostics">, Group, Flags<[CC1Option]>; Modified: cfe/trunk/test/Driver/cl-options.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=337746&r1=337745&r2=337746&view=diff == --- cfe/trunk/test/Driver/cl-options.c (original) +++ cfe/trunk/test/Driver/cl-options.c Mon Jul 23 14:29:43 2018 @@ -565,6 +565,11 @@ // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options) // RUN: %clang_cl \ // RUN: --driver-mode=cl \ +// RUN: -fblocks \ +// RUN: -fno-blocks \ +// RUN: -fbuiltin \ +// RUN: -fno-builtin \ +// RUN: -fno-builtin-strcpy \ // RUN: -fcolor-diagnostics \ // RUN: -fno-color-diagnostics \ // RUN: -fcoverage-mapping \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338083 - [MS] Add L__FUNCSIG__ for compatibility
Author: rnk Date: Thu Jul 26 16:18:44 2018 New Revision: 338083 URL: http://llvm.org/viewvc/llvm-project?rev=338083&view=rev Log: [MS] Add L__FUNCSIG__ for compatibility Clang already has L__FUNCTION__ as a workaround for dealing with pre-processor code that expects to be able to do L##__FUNCTION__ in a macro. This patch implements the same logic for __FUNCSIG__. Fixes PR38295. Modified: cfe/trunk/include/clang/AST/Expr.h cfe/trunk/include/clang/Basic/TokenKinds.def cfe/trunk/lib/AST/Expr.cpp cfe/trunk/lib/Parse/ParseExpr.cpp cfe/trunk/lib/Parse/ParseTentative.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/Sema/ms_wide_predefined_expr.cpp Modified: cfe/trunk/include/clang/AST/Expr.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=338083&r1=338082&r2=338083&view=diff == --- cfe/trunk/include/clang/AST/Expr.h (original) +++ cfe/trunk/include/clang/AST/Expr.h Thu Jul 26 16:18:44 2018 @@ -1206,9 +1206,10 @@ public: enum IdentType { Func, Function, -LFunction, // Same as Function, but as wide string. +LFunction, // Same as Function, but as wide string. FuncDName, FuncSig, +LFuncSig, // Same as FuncSig, but as as wide string PrettyFunction, /// The same as PrettyFunction, except that the /// 'virtual' keyword is omitted for virtual member functions. Modified: cfe/trunk/include/clang/Basic/TokenKinds.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=338083&r1=338082&r2=338083&view=diff == --- cfe/trunk/include/clang/Basic/TokenKinds.def (original) +++ cfe/trunk/include/clang/Basic/TokenKinds.def Thu Jul 26 16:18:44 2018 @@ -425,6 +425,7 @@ KEYWORD(typeof , KE KEYWORD(__FUNCDNAME__ , KEYMS) KEYWORD(__FUNCSIG__ , KEYMS) KEYWORD(L__FUNCTION__ , KEYMS) +KEYWORD(L__FUNCSIG__, KEYMS) TYPE_TRAIT_1(__is_interface_class, IsInterfaceClass, KEYMS) TYPE_TRAIT_1(__is_sealed, IsSealed, KEYMS) Modified: cfe/trunk/lib/AST/Expr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=338083&r1=338082&r2=338083&view=diff == --- cfe/trunk/lib/AST/Expr.cpp (original) +++ cfe/trunk/lib/AST/Expr.cpp Thu Jul 26 16:18:44 2018 @@ -484,6 +484,8 @@ StringRef PredefinedExpr::getIdentTypeNa return "__PRETTY_FUNCTION__"; case FuncSig: return "__FUNCSIG__"; + case LFuncSig: +return "L__FUNCSIG__"; case PrettyFunctionNoVirtual: break; } @@ -536,7 +538,8 @@ std::string PredefinedExpr::ComputeName( return Out.str(); } if (const FunctionDecl *FD = dyn_cast(CurrentDecl)) { -if (IT != PrettyFunction && IT != PrettyFunctionNoVirtual && IT != FuncSig) +if (IT != PrettyFunction && IT != PrettyFunctionNoVirtual && +IT != FuncSig && IT != LFuncSig) return FD->getNameAsString(); SmallString<256> Name; @@ -561,7 +564,7 @@ std::string PredefinedExpr::ComputeName( if (FD->hasWrittenPrototype()) FT = dyn_cast(AFT); -if (IT == FuncSig) { +if (IT == FuncSig || IT == LFuncSig) { switch (AFT->getCallConv()) { case CC_C: POut << "__cdecl "; break; case CC_X86StdCall: POut << "__stdcall "; break; @@ -586,7 +589,8 @@ std::string PredefinedExpr::ComputeName( if (FT->isVariadic()) { if (FD->getNumParams()) POut << ", "; POut << "..."; - } else if ((IT == FuncSig || !Context.getLangOpts().CPlusPlus) && + } else if ((IT == FuncSig || IT == LFuncSig || + !Context.getLangOpts().CPlusPlus) && !Decl->getNumParams()) { POut << "void"; } Modified: cfe/trunk/lib/Parse/ParseExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=338083&r1=338082&r2=338083&view=diff == --- cfe/trunk/lib/Parse/ParseExpr.cpp (original) +++ cfe/trunk/lib/Parse/ParseExpr.cpp Thu Jul 26 16:18:44 2018 @@ -617,6 +617,8 @@ class CastExpressionIdValidator : public /// [GNU] '__FUNCTION__' /// [MS]'__FUNCDNAME__' /// [MS]'L__FUNCTION__' +/// [MS]'__FUNCSIG__' +/// [MS]'L__FUNCSIG__' /// [GNU] '__PRETTY_FUNCTION__' /// [GNU] '(' compound-statement ')' /// [GNU] '__builtin_va_arg' '(' assignment-expression ',' type-name ')' @@ -1061,6 +1063,7 @@ ExprResult Parser::ParseCastExpression(b case tok::kw___FUNCDNAME__: // primary-expression: __FUNCDNAME__ [MS] case tok::kw___FUNCSIG__: // primary-expression: __FUNCSIG__ [MS] case tok::kw_L__FUNCTION__: // primary-expression: L__FUNCTION__ [MS] + case tok::kw_L__FUNCSIG__:// primary-expression: L__FUNCSIG__ [MS]
r338084 - Revert r338057 "[VirtualFileSystem] InMemoryFileSystem::status: Return a Status with the requested name"
Author: rnk Date: Thu Jul 26 16:21:51 2018 New Revision: 338084 URL: http://llvm.org/viewvc/llvm-project?rev=338084&view=rev Log: Revert r338057 "[VirtualFileSystem] InMemoryFileSystem::status: Return a Status with the requested name" This broke clang/test/PCH/case-insensitive-include.c on Windows. Modified: cfe/trunk/lib/Basic/FileManager.cpp cfe/trunk/lib/Basic/VirtualFileSystem.cpp cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp cfe/trunk/unittests/Driver/ToolChainTest.cpp Modified: cfe/trunk/lib/Basic/FileManager.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=338084&r1=338083&r2=338084&view=diff == --- cfe/trunk/lib/Basic/FileManager.cpp (original) +++ cfe/trunk/lib/Basic/FileManager.cpp Thu Jul 26 16:21:51 2018 @@ -315,11 +315,9 @@ const FileEntry *FileManager::getFile(St UFE.InPCH = Data.InPCH; UFE.File = std::move(F); UFE.IsValid = true; - - SmallString<128> RealPathName; - if (!FS->getRealPath(InterndFileName, RealPathName)) -UFE.RealPathName = RealPathName.str(); - + if (UFE.File) +if (auto RealPathName = UFE.File->getName()) + UFE.RealPathName = *RealPathName; return &UFE; } Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=338084&r1=338083&r2=338084&view=diff == --- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original) +++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Thu Jul 26 16:21:51 2018 @@ -474,28 +474,12 @@ class InMemoryNode { Status Stat; InMemoryNodeKind Kind; -protected: - /// Return Stat. This should only be used for internal/debugging use. When - /// clients wants the Status of this node, they should use - /// \p getStatus(StringRef). - const Status &getStatus() const { return Stat; } - public: InMemoryNode(Status Stat, InMemoryNodeKind Kind) : Stat(std::move(Stat)), Kind(Kind) {} virtual ~InMemoryNode() = default; - /// Return the \p Status for this node. \p RequestedName should be the name - /// through which the caller referred to this node. It will override - /// \p Status::Name in the return value, to mimic the behavior of \p RealFile. - Status getStatus(StringRef RequestedName) const { -return Status::copyWithNewName(Stat, RequestedName); - } - - /// Get the filename of this node (the name without the directory part). - StringRef getFileName() const { -return llvm::sys::path::filename(Stat.getName()); - } + const Status &getStatus() const { return Stat; } InMemoryNodeKind getKind() const { return Kind; } virtual std::string toString(unsigned Indent) const = 0; }; @@ -520,21 +504,14 @@ public: } }; -/// Adapt a InMemoryFile for VFS' File interface. The goal is to make -/// \p InMemoryFileAdaptor mimic as much as possible the behavior of -/// \p RealFile. +/// Adapt a InMemoryFile for VFS' File interface. class InMemoryFileAdaptor : public File { InMemoryFile &Node; - /// The name to use when returning a Status for this file. - std::string RequestedName; public: - explicit InMemoryFileAdaptor(InMemoryFile &Node, std::string RequestedName) - : Node(Node), RequestedName(std::move(RequestedName)) {} + explicit InMemoryFileAdaptor(InMemoryFile &Node) : Node(Node) {} - llvm::ErrorOr status() override { -return Node.getStatus(RequestedName); - } + llvm::ErrorOr status() override { return Node.getStatus(); } llvm::ErrorOr> getBuffer(const Twine &Name, int64_t FileSize, bool RequiresNullTerminator, @@ -734,7 +711,7 @@ lookupInMemoryNode(const InMemoryFileSys llvm::ErrorOr InMemoryFileSystem::status(const Twine &Path) { auto Node = lookupInMemoryNode(*this, Root.get(), Path); if (Node) -return (*Node)->getStatus(Path.str()); +return (*Node)->getStatus(); return Node.getError(); } @@ -747,8 +724,7 @@ InMemoryFileSystem::openFileForRead(cons // When we have a file provide a heap-allocated wrapper for the memory buffer // to match the ownership semantics for File. if (auto *F = dyn_cast(*Node)) -return std::unique_ptr( -new detail::InMemoryFileAdaptor(*F, Path.str())); +return std::unique_ptr(new detail::InMemoryFileAdaptor(*F)); // FIXME: errc::not_a_file? return make_error_code(llvm::errc::invalid_argument); @@ -760,33 +736,21 @@ namespace { class InMemoryDirIterator : public clang::vfs::detail::DirIterImpl { detail::InMemoryDirectory::const_iterator I; detail::InMemoryDirectory::const_iterator E; - std::string RequestedDirName; - - void setCurrentEntry() { -if (I != E) { - SmallString<256> Path(RequestedDirName); - llvm::sys::path::append(Path, I->second->getFileName()); - CurrentEntry = I->second->getStatus(Path); -} else { - // When we're at the end, make CurrentEntry invalid
Re: r338057 - [VirtualFileSystem] InMemoryFileSystem::status: Return a Status with the requested name
I reverted this in r338084 because it broke clang tests on Windows: http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/12916 On Thu, Jul 26, 2018 at 11:55 AM Simon Marchi via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: simark > Date: Thu Jul 26 11:55:02 2018 > New Revision: 338057 > > URL: http://llvm.org/viewvc/llvm-project?rev=338057&view=rev > Log: > [VirtualFileSystem] InMemoryFileSystem::status: Return a Status with the > requested name > > Summary: > > InMemoryFileSystem::status behaves differently than > RealFileSystem::status. The Name contained in the Status returned by > RealFileSystem::status will be the path as requested by the caller, > whereas InMemoryFileSystem::status returns the normalized path. > > For example, when requested the status for "../src/first.h", > RealFileSystem returns a Status with "../src/first.h" as the Name. > InMemoryFileSystem returns "/absolute/path/to/src/first.h". > > The reason for this change is that I want to make a unit test in the > clangd testsuite (where we use an InMemoryFileSystem) to reproduce a > bug I get with the clangd program (where a RealFileSystem is used). > This difference in behavior "hides" the bug in the unit test version. > > Reviewers: malaperle, ilya-biryukov, bkramer > > Subscribers: cfe-commits, ioeric, ilya-biryukov, bkramer, hokein, omtcyfz > > Differential Revision: https://reviews.llvm.org/D48903 > > Modified: > cfe/trunk/lib/Basic/FileManager.cpp > cfe/trunk/lib/Basic/VirtualFileSystem.cpp > cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp > cfe/trunk/unittests/Driver/ToolChainTest.cpp > > Modified: cfe/trunk/lib/Basic/FileManager.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=338057&r1=338056&r2=338057&view=diff > > == > --- cfe/trunk/lib/Basic/FileManager.cpp (original) > +++ cfe/trunk/lib/Basic/FileManager.cpp Thu Jul 26 11:55:02 2018 > @@ -315,9 +315,11 @@ const FileEntry *FileManager::getFile(St >UFE.InPCH = Data.InPCH; >UFE.File = std::move(F); >UFE.IsValid = true; > - if (UFE.File) > -if (auto RealPathName = UFE.File->getName()) > - UFE.RealPathName = *RealPathName; > + > + SmallString<128> RealPathName; > + if (!FS->getRealPath(InterndFileName, RealPathName)) > +UFE.RealPathName = RealPathName.str(); > + >return &UFE; > } > > > Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=338057&r1=338056&r2=338057&view=diff > > == > --- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original) > +++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Thu Jul 26 11:55:02 2018 > @@ -474,12 +474,28 @@ class InMemoryNode { >Status Stat; >InMemoryNodeKind Kind; > > +protected: > + /// Return Stat. This should only be used for internal/debugging use. > When > + /// clients wants the Status of this node, they should use > + /// \p getStatus(StringRef). > + const Status &getStatus() const { return Stat; } > + > public: >InMemoryNode(Status Stat, InMemoryNodeKind Kind) >: Stat(std::move(Stat)), Kind(Kind) {} >virtual ~InMemoryNode() = default; > > - const Status &getStatus() const { return Stat; } > + /// Return the \p Status for this node. \p RequestedName should be the > name > + /// through which the caller referred to this node. It will override > + /// \p Status::Name in the return value, to mimic the behavior of \p > RealFile. > + Status getStatus(StringRef RequestedName) const { > +return Status::copyWithNewName(Stat, RequestedName); > + } > + > + /// Get the filename of this node (the name without the directory part). > + StringRef getFileName() const { > +return llvm::sys::path::filename(Stat.getName()); > + } >InMemoryNodeKind getKind() const { return Kind; } >virtual std::string toString(unsigned Indent) const = 0; > }; > @@ -504,14 +520,21 @@ public: >} > }; > > -/// Adapt a InMemoryFile for VFS' File interface. > +/// Adapt a InMemoryFile for VFS' File interface. The goal is to make > +/// \p InMemoryFileAdaptor mimic as much as possible the behavior of > +/// \p RealFile. > class InMemoryFileAdaptor : public File { >InMemoryFile &Node; > + /// The name to use when returning a Status for this file. > + std::string RequestedName; > > public: > - explicit InMemoryFileAdaptor(InMemoryFile &Node) : Node(Node) {} > + explicit InMemoryFileAdaptor(InMemoryFile &Node, std::string > RequestedName) > + : Node(Node), RequestedName(std::move(RequestedName)) {} > > - llvm::ErrorOr status() override { return Node.getStatus(); } > + llvm::ErrorOr status() override { > +return Node.getStatus(RequestedName); > + } > >llvm::ErrorOr> >getBuffer(const Twine &Name, int64_t FileSize, bool > RequiresNullTerminator
Re: r337746 - [clang-cl] Expose -fblocks and -fno-builtin as driver flags
On Wed, Jul 25, 2018 at 4:39 AM Nico Weber wrote: > I thought about adding -fblocks when that thread happened, but since > there's no runtime for them that just works exposing it doesn't seem very > helpful. Maybe we should instead change the warning text to not suggest > -fblocks when building on a non-mac target? > Someone linked to a github repo that has a Windows implementation of the runtime. It may not be officially supported, but I don't see any reason to throw up extra roadblocks. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338444 - Revert r337635 "[Driver] Sanitizer support based on runtime library presence"
Author: rnk Date: Tue Jul 31 14:57:35 2018 New Revision: 338444 URL: http://llvm.org/viewvc/llvm-project?rev=338444&view=rev Log: Revert r337635 "[Driver] Sanitizer support based on runtime library presence" This change causes issues with distributed build systems, which may only have compiler binaries without any runtime libraries. See discussion about this on https://reviews.llvm.org/D15225. Removed: cfe/trunk/test/Driver/Inputs/resource_dir/lib/darwin/ Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp cfe/trunk/lib/Driver/ToolChains/Darwin.h cfe/trunk/test/Driver/darwin-asan-nofortify.c cfe/trunk/test/Driver/darwin-sanitizer-ld.c cfe/trunk/test/Driver/fsanitize.c cfe/trunk/test/Driver/fuzzer.c cfe/trunk/test/Driver/sanitizer-ld.c Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=338444&r1=338443&r2=338444&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Tue Jul 31 14:57:35 2018 @@ -916,26 +916,13 @@ unsigned DarwinClang::GetDefaultDwarfVer return 4; } -SmallString<128> MachO::runtimeLibDir(bool IsEmbedded) const { - SmallString<128> Dir(getDriver().ResourceDir); - llvm::sys::path::append( - Dir, "lib", IsEmbedded ? "macho_embedded" : "darwin"); - return Dir; -} - -std::string Darwin::getFileNameForSanitizerLib(StringRef SanitizerName, - bool Shared) const { - return (Twine("libclang_rt.") + SanitizerName + "_" + - getOSLibraryNameSuffix() + - (Shared ? "_dynamic.dylib" : ".a")).str(); - -} - void MachO::AddLinkRuntimeLib(const ArgList &Args, ArgStringList &CmdArgs, StringRef DarwinLibName, RuntimeLinkOptions Opts) const { + SmallString<128> Dir(getDriver().ResourceDir); + llvm::sys::path::append( + Dir, "lib", (Opts & RLO_IsEmbedded) ? "macho_embedded" : "darwin"); - SmallString<128> Dir = runtimeLibDir(Opts & RLO_IsEmbedded); SmallString<128> P(Dir); llvm::sys::path::append(P, DarwinLibName); @@ -1055,9 +1042,12 @@ void DarwinClang::AddLinkSanitizerLibArg StringRef Sanitizer, bool Shared) const { auto RLO = RuntimeLinkOptions(RLO_AlwaysLink | (Shared ? RLO_AddRPath : 0U)); - std::string SanitizerRelFilename = - getFileNameForSanitizerLib(Sanitizer, Shared); - AddLinkRuntimeLib(Args, CmdArgs, SanitizerRelFilename, RLO); + AddLinkRuntimeLib(Args, CmdArgs, +(Twine("libclang_rt.") + Sanitizer + "_" + + getOSLibraryNameSuffix() + + (Shared ? "_dynamic.dylib" : ".a")) +.str(), +RLO); } ToolChain::RuntimeLibType DarwinClang::GetRuntimeLibType( @@ -2295,43 +2285,24 @@ void Darwin::CheckObjCARC() const { SanitizerMask Darwin::getSupportedSanitizers() const { const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64; SanitizerMask Res = ToolChain::getSupportedSanitizers(); - - { -using namespace SanitizerKind; -assert(!(Res & (Address | Leak | Fuzzer | FuzzerNoLink | Thread)) && - "Sanitizer is already registered as supported"); - } - - if (sanitizerRuntimeExists("asan")) -Res |= SanitizerKind::Address; - if (sanitizerRuntimeExists("lsan")) -Res |= SanitizerKind::Leak; - if (sanitizerRuntimeExists("fuzzer", /*Shared=*/false)) { -Res |= SanitizerKind::Fuzzer; -Res |= SanitizerKind::FuzzerNoLink; - } + Res |= SanitizerKind::Address; + Res |= SanitizerKind::Leak; + Res |= SanitizerKind::Fuzzer; + Res |= SanitizerKind::FuzzerNoLink; Res |= SanitizerKind::Function; - if (isTargetMacOS() && !isMacosxVersionLT(10, 9)) -Res |= SanitizerKind::Vptr; - if (isTargetMacOS()) + if (isTargetMacOS()) { +if (!isMacosxVersionLT(10, 9)) + Res |= SanitizerKind::Vptr; Res |= SanitizerKind::SafeStack; - - if (sanitizerRuntimeExists("tsan") && IsX86_64 && - (isTargetMacOS() || isTargetIOSSimulator() || isTargetTvOSSimulator())) -Res |= SanitizerKind::Thread; - +if (IsX86_64) + Res |= SanitizerKind::Thread; + } else if (isTargetIOSSimulator() || isTargetTvOSSimulator()) { +if (IsX86_64) + Res |= SanitizerKind::Thread; + } return Res; } void Darwin::printVerboseInfo(raw_ostream &OS) const { CudaInstallation.print(OS); } - -bool Darwin::sanitizerRuntimeExists(StringRef SanitizerName, -bool Shared) const { -std::string RelName = getFileNameForSanitizerLib(SanitizerName, Shared); -SmallString<128> Dir = runtimeLibDir(); -SmallString<128> AbsName(Dir); -llvm::sys::path::append(AbsName, RelName); -return getVFS(
r338643 - Fix -Wcovered-switch-default uncovered after r338630
Author: rnk Date: Wed Aug 1 15:10:03 2018 New Revision: 338643 URL: http://llvm.org/viewvc/llvm-project?rev=338643&view=rev Log: Fix -Wcovered-switch-default uncovered after r338630 Modified: cfe/trunk/lib/AST/DeclBase.cpp Modified: cfe/trunk/lib/AST/DeclBase.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=338643&r1=338642&r2=338643&view=diff == --- cfe/trunk/lib/AST/DeclBase.cpp (original) +++ cfe/trunk/lib/AST/DeclBase.cpp Wed Aug 1 15:10:03 2018 @@ -154,11 +154,11 @@ void Decl::setInvalidDecl(bool Invalid) const char *DeclContext::getDeclKindName() const { switch (getDeclKind()) { - default: llvm_unreachable("Declaration context not in DeclNodes.inc!"); #define DECL(DERIVED, BASE) case Decl::DERIVED: return #DERIVED; #define ABSTRACT_DECL(DECL) #include "clang/AST/DeclNodes.inc" } + llvm_unreachable("Declaration context not in DeclNodes.inc!"); } bool Decl::StatisticsEnabled = false; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r324689 - [WinEH] Put funclet bundles on inline asm calls
Author: rnk Date: Thu Feb 8 16:16:41 2018 New Revision: 324689 URL: http://llvm.org/viewvc/llvm-project?rev=324689&view=rev Log: [WinEH] Put funclet bundles on inline asm calls Summary: Fixes PR36247, which is where WinEHPrepare replaces inline asm in funclets with unreachable. Make getBundlesForFunclet return by value to simplify some call sites. Reviewers: smeenai, majnemer Subscribers: eraman, cfe-commits Differential Revision: https://reviews.llvm.org/D43033 Added: cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-inlineasm.cpp Modified: cfe/trunk/lib/CodeGen/CGCall.cpp cfe/trunk/lib/CodeGen/CGStmt.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h Modified: cfe/trunk/lib/CodeGen/CGCall.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=324689&r1=324688&r2=324689&view=diff == --- cfe/trunk/lib/CodeGen/CGCall.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Feb 8 16:16:41 2018 @@ -3608,20 +3608,21 @@ CodeGenFunction::EmitRuntimeCall(llvm::V // Calls which may throw must have operand bundles indicating which funclet // they are nested within. -static void -getBundlesForFunclet(llvm::Value *Callee, llvm::Instruction *CurrentFuncletPad, - SmallVectorImpl &BundleList) { +SmallVector +CodeGenFunction::getBundlesForFunclet(llvm::Value *Callee) { + SmallVector BundleList; // There is no need for a funclet operand bundle if we aren't inside a // funclet. if (!CurrentFuncletPad) -return; +return BundleList; // Skip intrinsics which cannot throw. auto *CalleeFn = dyn_cast(Callee->stripPointerCasts()); if (CalleeFn && CalleeFn->isIntrinsic() && CalleeFn->doesNotThrow()) -return; +return BundleList; BundleList.emplace_back("funclet", CurrentFuncletPad); + return BundleList; } /// Emits a simple call (never an invoke) to the given runtime function. @@ -3629,10 +3630,8 @@ llvm::CallInst * CodeGenFunction::EmitRuntimeCall(llvm::Value *callee, ArrayRef args, const llvm::Twine &name) { - SmallVector BundleList; - getBundlesForFunclet(callee, CurrentFuncletPad, BundleList); - - llvm::CallInst *call = Builder.CreateCall(callee, args, BundleList, name); + llvm::CallInst *call = + Builder.CreateCall(callee, args, getBundlesForFunclet(callee), name); call->setCallingConv(getRuntimeCC()); return call; } @@ -3640,8 +3639,8 @@ CodeGenFunction::EmitRuntimeCall(llvm::V /// Emits a call or invoke to the given noreturn runtime function. void CodeGenFunction::EmitNoreturnRuntimeCallOrInvoke(llvm::Value *callee, ArrayRef args) { - SmallVector BundleList; - getBundlesForFunclet(callee, CurrentFuncletPad, BundleList); + SmallVector BundleList = + getBundlesForFunclet(callee); if (getInvokeDest()) { llvm::InvokeInst *invoke = @@ -3684,8 +3683,8 @@ CodeGenFunction::EmitCallOrInvoke(llvm:: ArrayRef Args, const Twine &Name) { llvm::BasicBlock *InvokeDest = getInvokeDest(); - SmallVector BundleList; - getBundlesForFunclet(Callee, CurrentFuncletPad, BundleList); + SmallVector BundleList = + getBundlesForFunclet(Callee); llvm::Instruction *Inst; if (!InvokeDest) @@ -4196,8 +4195,8 @@ RValue CodeGenFunction::EmitCall(const C } llvm::BasicBlock *InvokeDest = CannotThrow ? nullptr : getInvokeDest(); - SmallVector BundleList; - getBundlesForFunclet(CalleePtr, CurrentFuncletPad, BundleList); + SmallVector BundleList = + getBundlesForFunclet(CalleePtr); // Emit the actual call/invoke instruction. llvm::CallSite CS; Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=324689&r1=324688&r2=324689&view=diff == --- cfe/trunk/lib/CodeGen/CGStmt.cpp (original) +++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Feb 8 16:16:41 2018 @@ -2133,7 +2133,8 @@ void CodeGenFunction::EmitAsmStmt(const llvm::InlineAsm *IA = llvm::InlineAsm::get(FTy, AsmString, Constraints, HasSideEffect, /* IsAlignStack */ false, AsmDialect); - llvm::CallInst *Result = Builder.CreateCall(IA, Args); + llvm::CallInst *Result = + Builder.CreateCall(IA, Args, getBundlesForFunclet(IA)); Result->addAttribute(llvm::AttributeList::FunctionIndex, llvm::Attribute::NoUnwind); Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=324689&r1=324688&r2=324689&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Thu Feb 8 16:
r324913 - [Sema] Don't mark plain MS enums as fixed
Author: rnk Date: Mon Feb 12 09:37:06 2018 New Revision: 324913 URL: http://llvm.org/viewvc/llvm-project?rev=324913&view=rev Log: [Sema] Don't mark plain MS enums as fixed Summary: This fixes a flaw in our AST: PR27098 MSVC always gives plain enums the underlying type 'int'. Clang does this as well, but we claim the enum is "fixed", as if the user actually wrote ': int'. It means we end up emitting spurious -Wsign-compare warnings on code like this: enum Vals { E1, E2, E3 }; bool f(unsigned v1, Vals v2) { return v1 == v2; } We think 'v2' can take on negative values because we think 'Vals' is fixed. This fixes that. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43110 Modified: cfe/trunk/include/clang/AST/Decl.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp cfe/trunk/test/Sema/sign-compare-enum.c Modified: cfe/trunk/include/clang/AST/Decl.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=324913&r1=324912&r2=324913&view=diff == --- cfe/trunk/include/clang/AST/Decl.h (original) +++ cfe/trunk/include/clang/AST/Decl.h Mon Feb 12 09:37:06 2018 @@ -3449,7 +3449,9 @@ public: /// \brief Returns true if this can be considered a complete type. bool isComplete() const { -return isCompleteDefinition() || isFixed(); +// IntegerType is set for fixed type enums and non-fixed but implicitly +// int-sized Microsoft enums. +return isCompleteDefinition() || IntegerType; } /// Returns true if this enum is either annotated with Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=324913&r1=324912&r2=324913&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Mon Feb 12 09:37:06 2018 @@ -2315,8 +2315,7 @@ public: Expr *val); bool CheckEnumUnderlyingType(TypeSourceInfo *TI); bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, - QualType EnumUnderlyingTy, - bool EnumUnderlyingIsImplicit, + QualType EnumUnderlyingTy, bool IsFixed, const EnumDecl *Prev); /// Determine whether the body of an anonymous enumeration should be skipped. Modified: cfe/trunk/lib/AST/Type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=324913&r1=324912&r2=324913&view=diff == --- cfe/trunk/lib/AST/Type.cpp (original) +++ cfe/trunk/lib/AST/Type.cpp Mon Feb 12 09:37:06 2018 @@ -1997,12 +1997,7 @@ bool Type::isIncompleteType(NamedDecl ** EnumDecl *EnumD = cast(CanonicalType)->getDecl(); if (Def) *Def = EnumD; - -// An enumeration with fixed underlying type is complete (C++0x 7.2p3). -if (EnumD->isFixed()) - return false; - -return !EnumD->isCompleteDefinition(); +return !EnumD->isComplete(); } case Record: { // A tagged type (struct/union/enum/class) is incomplete if the decl is a Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=324913&r1=324912&r2=324913&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Feb 12 09:37:06 2018 @@ -13236,11 +13236,9 @@ bool Sema::CheckEnumUnderlyingType(TypeS /// Check whether this is a valid redeclaration of a previous enumeration. /// \return true if the redeclaration was invalid. -bool Sema::CheckEnumRedeclaration( -SourceLocation EnumLoc, bool IsScoped, QualType EnumUnderlyingTy, -bool EnumUnderlyingIsImplicit, const EnumDecl *Prev) { - bool IsFixed = !EnumUnderlyingTy.isNull(); - +bool Sema::CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, + QualType EnumUnderlyingTy, bool IsFixed, + const EnumDecl *Prev) { if (IsScoped != Prev->isScoped()) { Diag(EnumLoc, diag::err_enum_redeclare_scoped_mismatch) << Prev->isScoped(); @@ -13260,10 +13258,6 @@ bool Sema::CheckEnumRedeclaration( << Prev->getIntegerTypeRange(); return true; } - } else if (IsFixed && !Prev->isFixed() && EnumUnderlyingIsImplicit) { -; - } else if (!IsFixed && Prev->isFixed() && !Prev->getIntegerTypeSourceInfo()) { -; } else if (IsFixed != Prev->isFixed()) { Diag(EnumLoc, diag::err_enum_redeclare_fixed_mismatch) << Prev->isFixed(); @@ -13559,14 +13553,14 @@
r325375 - [MS] Make constexpr static data members implicitly inline
Author: rnk Date: Fri Feb 16 11:44:47 2018 New Revision: 325375 URL: http://llvm.org/viewvc/llvm-project?rev=325375&view=rev Log: [MS] Make constexpr static data members implicitly inline This handles them exactly the same way that we handle const integral static data members with inline definitions, which is what MSVC does. As a follow-up, now that we have a way to mark variables inline in the AST, we should consider marking them implicitly inline there instead of only treating them as inline in CodeGen. Unfortunately, this breaks a lot of dllimport test cases, so that is future work for now. Fixes PR36125. Modified: cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/test/CodeGenCXX/static-data-member.cpp Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=325375&r1=325374&r2=325375&view=diff == --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Fri Feb 16 11:44:47 2018 @@ -5857,7 +5857,7 @@ CharUnits ASTContext::getObjCEncodingTyp bool ASTContext::isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const { return getTargetInfo().getCXXABI().isMicrosoft() && VD->isStaticDataMember() && - VD->getType()->isIntegralOrEnumerationType() && + (VD->getType()->isIntegralOrEnumerationType() || VD->isConstexpr()) && !VD->getFirstDecl()->isOutOfLine() && VD->getFirstDecl()->hasInit(); } Modified: cfe/trunk/test/CodeGenCXX/static-data-member.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/static-data-member.cpp?rev=325375&r1=325374&r2=325375&view=diff == --- cfe/trunk/test/CodeGenCXX/static-data-member.cpp (original) +++ cfe/trunk/test/CodeGenCXX/static-data-member.cpp Fri Feb 16 11:44:47 2018 @@ -1,6 +1,10 @@ -// RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | \ -// RUN: FileCheck --check-prefix=MACHO %s +// RUN: %clang_cc1 -triple x86_64-pc-linux -std=c++14 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++14 -emit-llvm -o - %s \ +// RUN: | FileCheck %s --check-prefix=MACHO +// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -std=c++14 -emit-llvm -o - %s \ +// RUN: | FileCheck %s --check-prefix=MSVC +// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -std=c++17 -emit-llvm -o - %s \ +// RUN: | FileCheck %s --check-prefix=MSVC // CHECK: @_ZN5test11A1aE = constant i32 10, align 4 // CHECK: @_ZN5test212_GLOBAL__N_11AIiE1xE = internal global i32 0, align 4 @@ -9,12 +13,25 @@ // MACHO: @_ZGVN5test31AIiE1xE = weak_odr global i64 0 // MACHO-NOT: comdat +// MSVC: @"\01?a@A@test1@@2HB" = linkonce_odr constant i32 10, comdat, align 4 +// MSVC: @"\01?i@S@test1@@2HA" = external global i32 +// MSVC: @"\01?x@?$A@H@?A@test2@@2HA" = internal global i32 0, align 4 + // CHECK: _ZN5test51U2k0E = global i32 0 // CHECK: _ZN5test51U2k1E = global i32 0 // CHECK: _ZN5test51U2k2E = constant i32 76 // CHECK-NOT: test51U2k3E // CHECK-NOT: test51U2k4E +// On Linux in C++14, neither of these are inline. +// CHECK: @_ZN16inline_constexpr1A10just_constE = available_externally constant i32 42 +// CHECK: @_ZN16inline_constexpr1A10const_exprE = available_externally constant i32 43 +// +// In MSVC, these are both implicitly inline regardless of the C++ standard +// version. +// MSVC: @"\01?just_const@A@inline_constexpr@@2HB" = linkonce_odr constant i32 42, comdat, align 4 +// MSVC: @"\01?const_expr@A@inline_constexpr@@2HB" = linkonce_odr constant i32 43, comdat, align 4 + // PR5564. namespace test1 { struct A { @@ -28,7 +45,7 @@ namespace test1 { }; void f() { -int a = S::i; +int a = *&A::a + S::i; } } @@ -50,6 +67,11 @@ namespace test2 { // CHECK: [[TMP:%.*]] = call i32 @_ZN5test23fooEv() // CHECK-NEXT: store i32 [[TMP]], i32* @_ZN5test212_GLOBAL__N_11AIiE1xE, align 4 // CHECK-NEXT: ret void + + // MSVC-LABEL: define internal void @"\01??__Ex@?$A@H@?A@test2@@2HA@YAXXZ"() + // MSVC: [[TMP:%.*]] = call i32 @"\01?foo@test2@@YAHXZ"() + // MSVC-NEXT: store i32 [[TMP]], i32* @"\01?x@?$A@H@?A@test2@@2HA", align 4 + // MSVC-NEXT: ret void } // Test that we don't use threadsafe statics when initializing @@ -108,3 +130,13 @@ namespace test5 { // CHECK: store i32 {{.*}}, i32* @_ZN5test51U2k1E // CHECK-NOT: store {{.*}} i32* @_ZN5test51U2k2E } + +// Test that MSVC mode static constexpr data members are always inline, even pre +// C++17. +namespace inline_constexpr { +struct A { + static const int just_const = 42; + static constexpr int const_expr = 43; +}; +int useit() { return *&A::just_const + *&A::const_expr; } +} ___ cfe-commits mailing list cfe-commits@l
r326141 - Re-land "Emit proper CodeView when -gcodeview is passed without the cl driver."
Author: rnk Date: Mon Feb 26 14:55:33 2018 New Revision: 326141 URL: http://llvm.org/viewvc/llvm-project?rev=326141&view=rev Log: Re-land "Emit proper CodeView when -gcodeview is passed without the cl driver." Reverts r326116 and re-lands r326113 with a fix to ASan so that it enables column info in its test suite. Added: cfe/trunk/test/Driver/codeview-column-info.c Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=326141&r1=326140&r2=326141&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Feb 26 14:55:33 2018 @@ -2968,7 +2968,7 @@ static void RenderDebugOptions(const Too // Forward -gcodeview. EmitCodeView might have been set by CL-compatibility // argument parsing. - if (Args.hasArg(options::OPT_gcodeview) || EmitCodeView) { + if (EmitCodeView) { // DWARFVersion remains at 0 if no explicit choice was made. CmdArgs.push_back("-gcodeview"); } else if (DWARFVersion == 0 && @@ -3567,6 +3567,8 @@ void Clang::ConstructJob(Compilation &C, types::ID InputType = Input.getType(); if (D.IsCLMode()) AddClangCLArgs(Args, InputType, CmdArgs, &DebugInfoKind, &EmitCodeView); + else +EmitCodeView = Args.hasArg(options::OPT_gcodeview); const Arg *SplitDWARFArg = nullptr; RenderDebugOptions(getToolChain(), D, RawTriple, Args, EmitCodeView, Added: cfe/trunk/test/Driver/codeview-column-info.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/codeview-column-info.c?rev=326141&view=auto == --- cfe/trunk/test/Driver/codeview-column-info.c (added) +++ cfe/trunk/test/Driver/codeview-column-info.c Mon Feb 26 14:55:33 2018 @@ -0,0 +1,13 @@ +// Check that -dwarf-column-info does not get added to the cc1 line: +// 1) When -gcodeview is present via the clang or clang++ driver +// 2) When /Z7 is present via the cl driver. + +// RUN: %clang -### -c -g -gcodeview %s 2> %t1 +// RUN: FileCheck < %t1 %s +// RUN: %clangxx -### -c -g -gcodeview %s 2> %t2 +// RUN: FileCheck < %t2 %s +// RUN: %clang_cl -### /c /Z7 %s 2> %t2 +// RUN: FileCheck < %t2 %s + +// CHECK: "-cc1" +// CHECK-NOT: "-dwarf-column-info" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r326144 - Fix codeview-column-info.c test with a triple
Author: rnk Date: Mon Feb 26 15:06:40 2018 New Revision: 326144 URL: http://llvm.org/viewvc/llvm-project?rev=326144&view=rev Log: Fix codeview-column-info.c test with a triple Modified: cfe/trunk/test/Driver/codeview-column-info.c Modified: cfe/trunk/test/Driver/codeview-column-info.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/codeview-column-info.c?rev=326144&r1=326143&r2=326144&view=diff == --- cfe/trunk/test/Driver/codeview-column-info.c (original) +++ cfe/trunk/test/Driver/codeview-column-info.c Mon Feb 26 15:06:40 2018 @@ -2,11 +2,11 @@ // 1) When -gcodeview is present via the clang or clang++ driver // 2) When /Z7 is present via the cl driver. -// RUN: %clang -### -c -g -gcodeview %s 2> %t1 +// RUN: %clang -### --target=x86_64-windows-msvc -c -g -gcodeview %s 2> %t1 // RUN: FileCheck < %t1 %s -// RUN: %clangxx -### -c -g -gcodeview %s 2> %t2 +// RUN: %clangxx -### --target=x86_64-windows-msvc -c -g -gcodeview %s 2> %t2 // RUN: FileCheck < %t2 %s -// RUN: %clang_cl -### /c /Z7 %s 2> %t2 +// RUN: %clang_cl -### --target=x86_64-windows-msvc /c /Z7 %s 2> %t2 // RUN: FileCheck < %t2 %s // CHECK: "-cc1" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r303798 - For Microsoft compatibility, set fno_operator_names
I agree with Nico in retrospect. Setting -fno-operator-names is too big a hammer. Instead we should add some MSVCCompat hacks to pretend we saw an identifier token instead of a keyword token when these keywords are used as declarators. On Thu, May 25, 2017 at 10:14 AM, Nico Weber wrote: > Among the goals of the clang-cl project are a) being able to parse MS > system headers b) helper users to write standards-compliant C++ (in > particular, if your code builds with clang-cl without warnings, it'd be > good if it also built with regular clang then). > > The regular change plus header change plus warning would be one way to > achieve this, yes. > > On Thu, May 25, 2017 at 1:01 PM, Keane, Erich > wrote: > >> No problem, I definitely think it was the right choice. >> >> >> >> A change that contains all of what Melanie’s original patch did, plus the >> Header changes (plus the clang-tidy fixes that came out of this) would be >> acceptable? >> >> >> >> Also, I believe she’s working on the warning as well. We were discussing >> it, and I was thinking that if we track down where the >> operator-identification is done (hints as to where that is is appreciated), >> that we could simply warn if the user is using one of the Operators with >> operators off. The warning itself could then be suppressed if necessary. >> >> >> >> Thoughts? >> >> >> >> >> >> *From:* Nico Weber [mailto:tha...@google.com] >> *Sent:* Thursday, May 25, 2017 9:56 AM >> *To:* Keane, Erich >> *Cc:* Blower, Melanie ; rnk ; >> cfe-commits ; Hans Wennborg < >> h...@chromium.org> >> >> *Subject:* Re: r303798 - For Microsoft compatibility, set >> fno_operator_names >> >> >> >> On Thu, May 25, 2017 at 12:18 PM, Keane, Erich >> wrote: >> >> How does chromium compiler in CL? It seems that it would have a similar >> problem here… >> >> >> >> That's a good question! It looks like iso646.h is included, and in MSVC >> that contains something like `#define and &&`. But clang's >> lib/Headers/iso646.h assumes that the compiler provides this and doesn't >> define `and`. So for the reland, that header would have to check if the >> operator name is disabled, and if so, define it. (Or, better, maybe we can >> come up with something more targeted for the system header, similar to e.g. >> http://llvm.org/viewvc/llvm-project?view=revision&revision=212238) >> >> >> >> Thanks for the revert! >> >> >> >> >> >> *From:* tha...@google.com [mailto:tha...@google.com] *On Behalf Of *Nico >> Weber >> *Sent:* Thursday, May 25, 2017 9:16 AM >> *To:* Blower, Melanie >> *Cc:* rnk ; Keane, Erich ; >> cfe-commits ; Hans Wennborg < >> h...@chromium.org> >> >> >> *Subject:* RE: r303798 - For Microsoft compatibility, set >> fno_operator_names >> >> >> >> In addition to this making clang-cl silently accept invalid code, it also >> breaks existing valid code, building chromium now fails. Let's revert and >> come up with something better asynchronously. >> >> >> >> FAILED: obj/third_party/WebKit/Source/core/dom/dom/CustomElementRegistry.obj >> >> >> E:\b\c\goma_client/gomacc.exe ../../third_party/llvm-build/R >> elease+Asserts/bin/clang-cl.exe /nologo /showIncludes /FC >> @obj/third_party/WebKit/Source/core/dom/dom/CustomElementRegistry.obj.rsp >> /c ../../third_party/WebKit/Source/core/dom/custom/CustomElementRegistry.cpp >> /Foobj/third_party/WebKit/Source/core/dom/dom/CustomElementRegistry.obj >> /Fd"obj/third_party/WebKit/Source/core/dom/dom_cc.pdb" >> >> E:\b\c\b\win_clang\src\third_party\WebKit\Source\core\dom\cu >> stom\CustomElementRegistry.cpp(229,7): error: unknown type name >> 'definition' >> >> if (definition and definition->Descriptor().LocalName() == >> desc.LocalName()) { >> >> ^ >> >> E:\b\c\b\win_clang\src\third_party\WebKit\Source\core\dom\cu >> stom\CustomElementRegistry.cpp(229,18): error: variable declaration in >> condition must have an initializer >> >> if (definition and definition->Descriptor().LocalName() == >> desc.LocalName()) { >> >> ^ >> >> 2 errors generated. >> >> >> >> >> >> On May 24, 2017 4:01 PM, "Blower, Melanie" >> wrote: >> >> Thanks for the feedback, working on it… >> >> >> >> *From:* Keane, Erich >> *Sent:* Wednesday, May 24, 2017 3:47 PM >> *To:* Nico Weber ; Blower, Melanie < >> melanie.blo...@intel.com> >> >> >> *Cc:* cfe-commits ; rnk >> >> *Subject:* RE: r303798 - For Microsoft compatibility, set >> fno_operator_names >> >> >> >> Adding Melanie, the author of the patch. >> >> >> >> *From:* tha...@google.com [mailto:tha...@google.com ] *On >> Behalf Of *Nico Weber >> *Sent:* Wednesday, May 24, 2017 12:43 PM >> *To:* Keane, Erich >> *Cc:* cfe-commits ; rnk >> *Subject:* Re: r303798 - For Microsoft compatibility, set >> fno_operator_names >> >> >> >> Reviewed here: https://reviews.llvm.org/D33505 >> >> >> Still, please make this warn. >> >> >> >> On Wed, May 24, 2017 at 3:42 PM, Nico Weber wrote: >> >> Was this reviewed somewhere? >> >> >> >> Please make it so that this emits a warning. We want clang-cl t
r303908 - Revert "[AMDGPU] add __builtin_amdgcn_s_getpc"
Author: rnk Date: Thu May 25 15:28:26 2017 New Revision: 303908 URL: http://llvm.org/viewvc/llvm-project?rev=303908&view=rev Log: Revert "[AMDGPU] add __builtin_amdgcn_s_getpc" This reverts commit r303861, the LLVM intrinsic was reverted. Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=303908&r1=303907&r2=303908&view=diff == --- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Thu May 25 15:28:26 2017 @@ -36,7 +36,6 @@ BUILTIN(__builtin_amdgcn_workitem_id_z, // Instruction builtins. //===--===// BUILTIN(__builtin_amdgcn_s_getreg, "UiIi", "n") -BUILTIN(__builtin_amdgcn_s_getpc, "LUi", "n") BUILTIN(__builtin_amdgcn_s_waitcnt, "vIi", "n") BUILTIN(__builtin_amdgcn_s_sendmsg, "vIiUi", "n") BUILTIN(__builtin_amdgcn_s_sendmsghalt, "vIiUi", "n") Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=303908&r1=303907&r2=303908&view=diff == --- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Thu May 25 15:28:26 2017 @@ -481,13 +481,6 @@ void test_fmed3_f32(global float* out, f *out = __builtin_amdgcn_fmed3f(a, b, c); } -// CHECK-LABEL: @test_s_getpc -// CHECK: call i64 @llvm.amdgcn.s.getpc() -void test_s_getpc(global ulong* out) -{ - *out = __builtin_amdgcn_s_getpc(); -} - // CHECK-DAG: [[WI_RANGE]] = !{i32 0, i32 1024} // CHECK-DAG: attributes #[[NOUNWIND_READONLY:[0-9]+]] = { nounwind readonly } // CHECK-DAG: attributes #[[READ_EXEC_ATTRS]] = { convergent } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r304006 - Update MS mangling EBNF, NFC
Author: rnk Date: Fri May 26 12:11:10 2017 New Revision: 304006 URL: http://llvm.org/viewvc/llvm-project?rev=304006&view=rev Log: Update MS mangling EBNF, NFC Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=304006&r1=304005&r2=304006&view=diff == --- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original) +++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Fri May 26 12:11:10 2017 @@ -1689,6 +1689,8 @@ void MicrosoftCXXNameMangler::mangleType // ::= _N # bool // _O # // ::= _T # __float80 (Intel) + // ::= _S # char16_t + // ::= _U # char32_t // ::= _W # wchar_t // ::= _Z # __float80 (Digital Mars) switch (T->getKind()) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r304012 - Enable __float128 for mingw for GCC compatibility and define __SIZEOF_FLOAT128__ on x86
Author: rnk Date: Fri May 26 12:38:15 2017 New Revision: 304012 URL: http://llvm.org/viewvc/llvm-project?rev=304012&view=rev Log: Enable __float128 for mingw for GCC compatibility and define __SIZEOF_FLOAT128__ on x86 GCC defines __FLOAT128__ on Power and __SIZEOF_FLOAT128__ on x86. We're just following the inconsistency for now so users have some way to test. Effectively merges this patch as requested by Martell Malone: https://github.com/Alexpux/MINGW-packages/blob/master/mingw-w64-clang/0107-enable-__float128-for-X86-MinGW.patch Modified: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/lib/Frontend/InitPreprocessor.cpp cfe/trunk/test/Sema/128bitfloat.cpp Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=304012&r1=304011&r2=304012&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Fri May 26 12:38:15 2017 @@ -4644,7 +4644,9 @@ static void addMinGWDefines(const LangOp class MinGWX86_32TargetInfo : public WindowsX86_32TargetInfo { public: MinGWX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) - : WindowsX86_32TargetInfo(Triple, Opts) {} + : WindowsX86_32TargetInfo(Triple, Opts) { +HasFloat128 = true; + } void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override { WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder); @@ -4936,6 +4938,7 @@ public: // with x86 FP ops. Weird. LongDoubleWidth = LongDoubleAlign = 128; LongDoubleFormat = &llvm::APFloat::x87DoubleExtended(); +HasFloat128 = true; } void getTargetDefines(const LangOptions &Opts, Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=304012&r1=304011&r2=304012&view=diff == --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original) +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Fri May 26 12:38:15 2017 @@ -750,6 +750,8 @@ static void InitializePredefinedMacros(c TI.getTypeWidth(TI.getWIntType()), TI, Builder); if (TI.hasInt128Type()) DefineTypeSizeof("__SIZEOF_INT128__", 128, TI, Builder); + if (TI.hasFloat128Type()) +DefineTypeSizeof("__SIZEOF_FLOAT128__", 128, TI, Builder); DefineType("__INTMAX_TYPE__", TI.getIntMaxType(), Builder); DefineFmt("__INTMAX", TI.getIntMaxType(), TI, Builder); Modified: cfe/trunk/test/Sema/128bitfloat.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/128bitfloat.cpp?rev=304012&r1=304011&r2=304012&view=diff == --- cfe/trunk/test/Sema/128bitfloat.cpp (original) +++ cfe/trunk/test/Sema/128bitfloat.cpp Fri May 26 12:38:15 2017 @@ -1,7 +1,11 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=gnu++11 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -verify -std=gnu++11 %s +// RUN: %clang_cc1 -verify -std=c++11 %s +// RUN: %clang_cc1 -triple powerpc64-linux -verify -std=c++11 %s +// RUN: %clang_cc1 -triple i686-windows-gnu -verify -std=c++11 %s +// RUN: %clang_cc1 -triple x86_64-windows-gnu -verify -std=c++11 %s +// RUN: %clang_cc1 -triple x86_64-windows-msvc -verify -std=c++11 %s -#ifdef __FLOAT128__ +#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__) __float128 f; template struct __is_floating_point_helper {}; template<> struct __is_floating_point_helper<__float128> {}; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r304013 - Only define __SIZEOF_FLOAT128__ on x86 as intended in r304012
Author: rnk Date: Fri May 26 12:48:01 2017 New Revision: 304013 URL: http://llvm.org/viewvc/llvm-project?rev=304013&view=rev Log: Only define __SIZEOF_FLOAT128__ on x86 as intended in r304012 GCC only defines it on x86. Modified: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/lib/Frontend/InitPreprocessor.cpp Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=304013&r1=304012&r2=304013&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Fri May 26 12:48:01 2017 @@ -4165,6 +4165,9 @@ void X86TargetInfo::getTargetDefines(con } if (CPU >= CK_i586) Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8"); + + if (HasFloat128) +Builder.defineMacro("__SIZEOF_FLOAT128__", "16"); } bool X86TargetInfo::hasFeature(StringRef Feature) const { Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=304013&r1=304012&r2=304013&view=diff == --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original) +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Fri May 26 12:48:01 2017 @@ -750,8 +750,6 @@ static void InitializePredefinedMacros(c TI.getTypeWidth(TI.getWIntType()), TI, Builder); if (TI.hasInt128Type()) DefineTypeSizeof("__SIZEOF_INT128__", 128, TI, Builder); - if (TI.hasFloat128Type()) -DefineTypeSizeof("__SIZEOF_FLOAT128__", 128, TI, Builder); DefineType("__INTMAX_TYPE__", TI.getIntMaxType(), Builder); DefineFmt("__INTMAX", TI.getIntMaxType(), TI, Builder); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r304303 - [clang-cl] Ignore /Zc:ternary, clang behaves this way already
Author: rnk Date: Wed May 31 09:50:28 2017 New Revision: 304303 URL: http://llvm.org/viewvc/llvm-project?rev=304303&view=rev Log: [clang-cl] Ignore /Zc:ternary, clang behaves this way already Addresses part of PR33237 Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td cfe/trunk/test/Driver/cl-zc.cpp Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=304303&r1=304302&r2=304303&view=diff == --- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original) +++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Wed May 31 09:50:28 2017 @@ -324,6 +324,7 @@ def _SLASH_Zc_forScope : CLIgnoredFlag<" def _SLASH_Zc_inline : CLIgnoredFlag<"Zc:inline">; def _SLASH_Zc_rvalueCast : CLIgnoredFlag<"Zc:rvalueCast">; def _SLASH_Zc_wchar_t : CLIgnoredFlag<"Zc:wchar_t">; +def _SLASH_Zc_ternary : CLIgnoredFlag<"Zc:ternary">; def _SLASH_Zm : CLIgnoredJoined<"Zm">; def _SLASH_Zo : CLIgnoredFlag<"Zo">; def _SLASH_Zo_ : CLIgnoredFlag<"Zo-">; Modified: cfe/trunk/test/Driver/cl-zc.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-zc.cpp?rev=304303&r1=304302&r2=304303&view=diff == --- cfe/trunk/test/Driver/cl-zc.cpp (original) +++ cfe/trunk/test/Driver/cl-zc.cpp Wed May 31 09:50:28 2017 @@ -53,6 +53,11 @@ // RUN: %clang_cl /c -### /Zc:inline- -- %s 2>&1 | FileCheck -check-prefix=INLINE-OFF %s // INLINE-OFF: argument unused during compilation +// RUN: %clang_cl /c -### /Zc:ternary -- %s 2>&1 | FileCheck -check-prefix=TERNARY-ON %s +// TERNARY-ON-NOT: argument unused during compilation +// RUN: %clang_cl /c -### /Zc:ternary- -- %s 2>&1 | FileCheck -check-prefix=TERNARY-OFF %s +// TERNARY-OFF: argument unused during compilation + // These never warn, but don't have an effect yet. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r304305 - [clang-cl] Improve default calling convention flag handling
Author: rnk Date: Wed May 31 10:39:28 2017 New Revision: 304305 URL: http://llvm.org/viewvc/llvm-project?rev=304305&view=rev Log: [clang-cl] Improve default calling convention flag handling Ignore default CC flags that don't make sense for the target arch. This is consistent with MSVC. Addresses part of PR33237 Added: cfe/trunk/test/Driver/cl-cc-flags.c Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=304305&r1=304304&r2=304305&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed May 31 10:39:28 2017 @@ -4781,14 +4781,36 @@ void Clang::AddClangCLArgs(const ArgList CmdArgs.push_back("-fms-memptr-rep=virtual"); } - if (Args.getLastArg(options::OPT__SLASH_Gd)) - CmdArgs.push_back("-fdefault-calling-conv=cdecl"); - else if (Args.getLastArg(options::OPT__SLASH_Gr)) - CmdArgs.push_back("-fdefault-calling-conv=fastcall"); - else if (Args.getLastArg(options::OPT__SLASH_Gz)) - CmdArgs.push_back("-fdefault-calling-conv=stdcall"); - else if (Args.getLastArg(options::OPT__SLASH_Gv)) - CmdArgs.push_back("-fdefault-calling-conv=vectorcall"); + // Parse the default calling convention options. + if (Arg *CCArg = + Args.getLastArg(options::OPT__SLASH_Gd, options::OPT__SLASH_Gr, + options::OPT__SLASH_Gz, options::OPT__SLASH_Gv)) { +unsigned DCCOptId = CCArg->getOption().getID(); +const char *DCCFlag = nullptr; +bool ArchSupported = true; +llvm::Triple::ArchType Arch = getToolChain().getArch(); +switch (DCCOptId) { +case options::OPT__SLASH_Gd: + DCCFlag = "-fdefault-calling-convention=cdecl"; + break; +case options::OPT__SLASH_Gr: + ArchSupported = Arch == llvm::Triple::x86; + DCCFlag = "-fdefault-calling-convention=fastcall"; + break; +case options::OPT__SLASH_Gz: + ArchSupported = Arch == llvm::Triple::x86; + DCCFlag = "-fdefault-calling-convention=stdcall"; + break; +case options::OPT__SLASH_Gv: + ArchSupported = Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64; + DCCFlag = "-fdefault-calling-convention=vectorcall"; + break; +} + +// MSVC doesn't warn if /Gr or /Gz is used on x64, so we don't either. +if (ArchSupported && DCCFlag) + CmdArgs.push_back(DCCFlag); + } if (Arg *A = Args.getLastArg(options::OPT_vtordisp_mode_EQ)) A->render(Args, CmdArgs); Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=304305&r1=304304&r2=304305&view=diff == --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed May 31 10:39:28 2017 @@ -2214,8 +2214,8 @@ static void ParseLangArgs(LangOptions &O llvm::Triple T(TargetOpts.Triple); llvm::Triple::ArchType Arch = T.getArch(); bool emitError = (DefaultCC == LangOptions::DCC_FastCall || - DefaultCC == LangOptions::DCC_StdCall) && - Arch != llvm::Triple::x86; + DefaultCC == LangOptions::DCC_StdCall) && + Arch != llvm::Triple::x86; emitError |= DefaultCC == LangOptions::DCC_VectorCall && !(Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64); if (emitError) Added: cfe/trunk/test/Driver/cl-cc-flags.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-cc-flags.c?rev=304305&view=auto == --- cfe/trunk/test/Driver/cl-cc-flags.c (added) +++ cfe/trunk/test/Driver/cl-cc-flags.c Wed May 31 10:39:28 2017 @@ -0,0 +1,33 @@ +// Note: %s must be preceded by --, otherwise it may be interpreted as a +// command-line option, e.g. on Mac where %s is commonly under /Users. + +// RUN: %clang_cl --target=i686-windows-msvc /Gd -### -- %s 2>&1 | FileCheck --check-prefix=CDECL %s +// CDECL: -fdefault-calling-convention=cdecl + +// RUN: %clang_cl --target=i686-windows-msvc /Gr -### -- %s 2>&1 | FileCheck --check-prefix=FASTCALL %s +// FASTCALL: -fdefault-calling-convention=fastcall + +// RUN: %clang_cl --target=i686-windows-msvc /Gz -### -- %s 2>&1 | FileCheck --check-prefix=STDCALL %s +// STDCALL: -fdefault-calling-convention=stdcall + +// RUN: %clang_cl --target=i686-windows-msvc /Gv -### -- %s 2>&1 | FileCheck --check-prefix=VECTORCALL %s +// VECTORCALL: -fdefault-calling-convention=vectorcall + +// Last one should win: + +// RUN: %clang_cl --target=i686-windows-msvc /Gd /Gv -### -- %s 2>&1 | FileCheck --check-prefix=LASTWINS_VECTOR %s +//
r304308 - Fix incorrect spelling of calling conv flag and add -Wno-msvc-not-found to test
Author: rnk Date: Wed May 31 10:50:35 2017 New Revision: 304308 URL: http://llvm.org/viewvc/llvm-project?rev=304308&view=rev Log: Fix incorrect spelling of calling conv flag and add -Wno-msvc-not-found to test Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/test/Driver/cl-cc-flags.c Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=304308&r1=304307&r2=304308&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed May 31 10:50:35 2017 @@ -4791,19 +4791,19 @@ void Clang::AddClangCLArgs(const ArgList llvm::Triple::ArchType Arch = getToolChain().getArch(); switch (DCCOptId) { case options::OPT__SLASH_Gd: - DCCFlag = "-fdefault-calling-convention=cdecl"; + DCCFlag = "-fdefault-calling-conv=cdecl"; break; case options::OPT__SLASH_Gr: ArchSupported = Arch == llvm::Triple::x86; - DCCFlag = "-fdefault-calling-convention=fastcall"; + DCCFlag = "-fdefault-calling-conv=fastcall"; break; case options::OPT__SLASH_Gz: ArchSupported = Arch == llvm::Triple::x86; - DCCFlag = "-fdefault-calling-convention=stdcall"; + DCCFlag = "-fdefault-calling-conv=stdcall"; break; case options::OPT__SLASH_Gv: ArchSupported = Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64; - DCCFlag = "-fdefault-calling-convention=vectorcall"; + DCCFlag = "-fdefault-calling-conv=vectorcall"; break; } Modified: cfe/trunk/test/Driver/cl-cc-flags.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-cc-flags.c?rev=304308&r1=304307&r2=304308&view=diff == --- cfe/trunk/test/Driver/cl-cc-flags.c (original) +++ cfe/trunk/test/Driver/cl-cc-flags.c Wed May 31 10:50:35 2017 @@ -2,32 +2,32 @@ // command-line option, e.g. on Mac where %s is commonly under /Users. // RUN: %clang_cl --target=i686-windows-msvc /Gd -### -- %s 2>&1 | FileCheck --check-prefix=CDECL %s -// CDECL: -fdefault-calling-convention=cdecl +// CDECL: -fdefault-calling-conv=cdecl // RUN: %clang_cl --target=i686-windows-msvc /Gr -### -- %s 2>&1 | FileCheck --check-prefix=FASTCALL %s -// FASTCALL: -fdefault-calling-convention=fastcall +// FASTCALL: -fdefault-calling-conv=fastcall // RUN: %clang_cl --target=i686-windows-msvc /Gz -### -- %s 2>&1 | FileCheck --check-prefix=STDCALL %s -// STDCALL: -fdefault-calling-convention=stdcall +// STDCALL: -fdefault-calling-conv=stdcall // RUN: %clang_cl --target=i686-windows-msvc /Gv -### -- %s 2>&1 | FileCheck --check-prefix=VECTORCALL %s -// VECTORCALL: -fdefault-calling-convention=vectorcall +// VECTORCALL: -fdefault-calling-conv=vectorcall // Last one should win: // RUN: %clang_cl --target=i686-windows-msvc /Gd /Gv -### -- %s 2>&1 | FileCheck --check-prefix=LASTWINS_VECTOR %s -// LASTWINS_VECTOR: -fdefault-calling-convention=vectorcall +// LASTWINS_VECTOR: -fdefault-calling-conv=vectorcall // RUN: %clang_cl --target=i686-windows-msvc /Gv /Gd -### -- %s 2>&1 | FileCheck --check-prefix=LASTWINS_CDECL %s -// LASTWINS_CDECL: -fdefault-calling-convention=cdecl +// LASTWINS_CDECL: -fdefault-calling-conv=cdecl // No fastcall or stdcall on x86_64: -// RUN: %clang_cl --target=x86_64-windows-msvc /Gr -### -- %s 2>&1 | FileCheck --check-prefix=UNSUPPORTED %s -// RUN: %clang_cl --target=x86_64-windows-msvc /Gz -### -- %s 2>&1 | FileCheck --check-prefix=UNSUPPORTED %s -// RUN: %clang_cl --target=thumbv7-windows-msvc /Gv -### -- %s 2>&1 | FileCheck --check-prefix=UNSUPPORTED %s +// RUN: %clang_cl -Wno-msvc-not-found --target=x86_64-windows-msvc /Gr -### -- %s 2>&1 | FileCheck --check-prefix=UNSUPPORTED %s +// RUN: %clang_cl -Wno-msvc-not-found --target=x86_64-windows-msvc /Gz -### -- %s 2>&1 | FileCheck --check-prefix=UNSUPPORTED %s +// RUN: %clang_cl -Wno-msvc-not-found --target=thumbv7-windows-msvc /Gv -### -- %s 2>&1 | FileCheck --check-prefix=UNSUPPORTED %s // UNSUPPORTED-NOT: error: // UNSUPPORTED-NOT: warning: -// UNSUPPORTED-NOT: -fdefault-calling-convention= +// UNSUPPORTED-NOT: -fdefault-calling-conv= ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r304316 - [clang-cl] Implement /diagnostic: flag
Author: rnk Date: Wed May 31 12:37:49 2017 New Revision: 304316 URL: http://llvm.org/viewvc/llvm-project?rev=304316&view=rev Log: [clang-cl] Implement /diagnostic: flag This flag has three possible values: caret, column, and classic. "caret" corresponds to clang's default mode, "column" removes the caret and code snippet, and "classic" emits nothing. Documentation is here: https://docs.microsoft.com/en-us/cpp/build/reference/diagnostics-compiler-diagnostic-options Implements the last part of PR33237 Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td cfe/trunk/lib/Driver/ToolChains/Clang.cpp Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=304316&r1=304315&r2=304316&view=diff == --- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original) +++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Wed May 31 12:37:49 2017 @@ -63,6 +63,12 @@ def _SLASH_C : CLFlag<"C">, def _SLASH_c : CLFlag<"c">, HelpText<"Compile only">, Alias; def _SLASH_d1reportAllClassLayout : CLFlag<"d1reportAllClassLayout">, HelpText<"Dump record layout information">, Alias; +def _SLASH_diagnostics_caret : CLFlag<"diagnostics:caret">, + HelpText<"Enable caret and column diagnostics (on by default)">; +def _SLASH_diagnostics_column : CLFlag<"diagnostics:column">, + HelpText<"Disable caret diagnostics but keep column info">; +def _SLASH_diagnostics_classic : CLFlag<"diagnostics:classic">, + HelpText<"Disable column and caret diagnostics">; def _SLASH_D : CLJoinedOrSeparate<"D">, HelpText<"Define macro">, MetaVarName<"">, Alias; def _SLASH_E : CLFlag<"E">, HelpText<"Preprocess to stdout">, Alias; Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=304316&r1=304315&r2=304316&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed May 31 12:37:49 2017 @@ -3985,9 +3985,30 @@ void Clang::ConstructJob(Compilation &C, << value; } + bool CaretDefault = true; + bool ColumnDefault = true; + if (Arg *DiagArg = Args.getLastArg(options::OPT__SLASH_diagnostics_classic, + options::OPT__SLASH_diagnostics_column, + options::OPT__SLASH_diagnostics_caret)) { +switch (DiagArg->getOption().getID()) { +case options::OPT__SLASH_diagnostics_caret: + CaretDefault = true; + ColumnDefault = true; + break; +case options::OPT__SLASH_diagnostics_column: + CaretDefault = false; + ColumnDefault = true; + break; +case options::OPT__SLASH_diagnostics_classic: + CaretDefault = false; + ColumnDefault = false; + break; +} + } + // -fcaret-diagnostics is default. if (!Args.hasFlag(options::OPT_fcaret_diagnostics, -options::OPT_fno_caret_diagnostics, true)) +options::OPT_fno_caret_diagnostics, CaretDefault)) CmdArgs.push_back("-fno-caret-diagnostics"); // -fdiagnostics-fixit-info is default, only pass non-default. @@ -4059,7 +4080,7 @@ void Clang::ConstructJob(Compilation &C, CmdArgs.push_back("-fdiagnostics-absolute-paths"); if (!Args.hasFlag(options::OPT_fshow_column, options::OPT_fno_show_column, -true)) +ColumnDefault)) CmdArgs.push_back("-fno-show-column"); if (!Args.hasFlag(options::OPT_fspell_checking, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r304335 - Don't try to spill static allocas when emitting expr cleanups with branches
Author: rnk Date: Wed May 31 14:59:41 2017 New Revision: 304335 URL: http://llvm.org/viewvc/llvm-project?rev=304335&view=rev Log: Don't try to spill static allocas when emitting expr cleanups with branches Credit goes to Gor Nishanov for putting together the fix in https://reviews.llvm.org/D33733! This patch is essentially me patching it locally and writing some test cases to convince myself that it was necessary for GNU statement expressions with branches as well as coroutines. I'll ask Gor to land his patch with just the coroutines test. During LValue expression evaluation, references can be bound to anything, really: call results, aggregate temporaries, local variables, global variables, or indirect arguments. We really only want to spill instructions that were emitted as part of expression evaluation, and static allocas are not that. Modified: cfe/trunk/lib/CodeGen/CGCleanup.cpp cfe/trunk/test/CodeGenCXX/stmtexpr.cpp Modified: cfe/trunk/lib/CodeGen/CGCleanup.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.cpp?rev=304335&r1=304334&r2=304335&view=diff == --- cfe/trunk/lib/CodeGen/CGCleanup.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCleanup.cpp Wed May 31 14:59:41 2017 @@ -448,6 +448,13 @@ void CodeGenFunction::PopCleanupBlocks( auto *Inst = dyn_cast_or_null(*ReloadedValue); if (!Inst) continue; + +// Don't spill static allocas, they dominate all cleanups. These are created +// by binding a reference to a local variable or temporary. +auto *AI = dyn_cast(Inst); +if (AI && AI->isStaticAlloca()) + continue; + Address Tmp = CreateDefaultAlignTempAlloca(Inst->getType(), "tmp.exprcleanup"); Modified: cfe/trunk/test/CodeGenCXX/stmtexpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/stmtexpr.cpp?rev=304335&r1=304334&r2=304335&view=diff == --- cfe/trunk/test/CodeGenCXX/stmtexpr.cpp (original) +++ cfe/trunk/test/CodeGenCXX/stmtexpr.cpp Wed May 31 14:59:41 2017 @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Wno-unused-value -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -Wno-unused-value -triple i686-linux-gnu -emit-llvm -o - %s | FileCheck %s // rdar: //8540501 extern "C" int printf(...); extern "C" void abort(); @@ -139,6 +139,34 @@ extern "C" int cleanup_exit_lvalue(bool // CHECK: %[[v:[^ ]*]] = load i32*, i32** %[[tmp]] // CHECK-NEXT: store i32* %[[v]], i32** %r +// Bind the reference to a byval argument. It is not an instruction or Constant, +// so it's a bit of a corner case. +struct ByVal { int x[3]; }; +extern "C" int cleanup_exit_lvalue_byval(bool cond, ByVal arg) { + ByVal &r = (A(1), ({ if (cond) return 0; (void)ByVal(); }), arg); + return r.x[0]; +} +// CHECK-LABEL: define{{.*}} i32 @cleanup_exit_lvalue_byval({{.*}}, %struct.ByVal* byval align 4 %arg) +// CHECK: call {{.*}} @_ZN1AC1Ei +// CHECK: call {{.*}} @_ZN1AD1Ev +// CHECK: switch +// CHECK: store %struct.ByVal* %arg, %struct.ByVal** %r + +// Bind the reference to a local variable. We don't need to spill it. Binding a +// reference to it doesn't generate any instructions. +extern "C" int cleanup_exit_lvalue_local(bool cond) { + int local = 42; + int &r = (A(1), ({ if (cond) return 0; (void)0; }), local); + return r; +} +// CHECK-LABEL: define{{.*}} i32 @cleanup_exit_lvalue_local({{.*}}) +// CHECK: %local = alloca i32 +// CHECK: store i32 42, i32* %local +// CHECK: call {{.*}} @_ZN1AC1Ei +// CHECK-NOT: store i32* %local +// CHECK: call {{.*}} @_ZN1AD1Ev +// CHECK: switch +// CHECK: store i32* %local, i32** %r, align 4 // We handle ExprWithCleanups for complex evaluation type separately, and it had // the same bug. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r304336 - Add test case for r304316 which implemented clang-cl /diagnostics:*
Author: rnk Date: Wed May 31 15:02:27 2017 New Revision: 304336 URL: http://llvm.org/viewvc/llvm-project?rev=304336&view=rev Log: Add test case for r304316 which implemented clang-cl /diagnostics:* Added: cfe/trunk/test/Driver/cl-diagnostics.c Added: cfe/trunk/test/Driver/cl-diagnostics.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-diagnostics.c?rev=304336&view=auto == --- cfe/trunk/test/Driver/cl-diagnostics.c (added) +++ cfe/trunk/test/Driver/cl-diagnostics.c Wed May 31 15:02:27 2017 @@ -0,0 +1,28 @@ +// Note: %s must be preceded by --, otherwise it may be interpreted as a +// command-line option, e.g. on Mac where %s is commonly under /Users. + +// RUN: %clang_cl /diagnostics:classic -### -- %s 2>&1 | FileCheck %s --check-prefix=CLASSIC +// CLASSIC: -fno-caret-diagnostics +// CLASSIC: -fno-show-column + +// RUN: %clang_cl /diagnostics:column -### -- %s 2>&1 | FileCheck %s --check-prefix=COLUMN +// COLUMN: -fno-caret-diagnostics +// COLUMN-NOT: -fno-show-column + +// RUN: %clang_cl /diagnostics:caret -### -- %s 2>&1 | FileCheck %s --check-prefix=CARET +// CARET-NOT: -fno-caret-diagnostics +// CARET-NOT: -fno-show-column + +// RUN: not %clang_cl /diagnostics:classic /Zs -c -- %s 2>&1 | FileCheck %s --check-prefix=OUTPUT_CLASSIC + +// OUTPUT_CLASSIC: cl-diagnostics.c({{[0-9]+}}): error: "asdf" +// OUTPUT_CLASSIC-NOT: #error + +// RUN: not %clang_cl /diagnostics:caret /Zs -c -- %s 2>&1 | FileCheck %s --check-prefix=OUTPUT_CARET + +// OUTPUT_CARET: cl-diagnostics.c({{[0-9]+,[0-9]+}}): error: "asdf" +// OUTPUT_CARET-NEXT: #error "asdf" +// OUTPUT_CARET-NEXT: ^ + + +#error "asdf" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r304337 - Fix cl-diagnostics.c test by hardcoding the version of MSVC to mimic
Author: rnk Date: Wed May 31 15:07:36 2017 New Revision: 304337 URL: http://llvm.org/viewvc/llvm-project?rev=304337&view=rev Log: Fix cl-diagnostics.c test by hardcoding the version of MSVC to mimic Modified: cfe/trunk/test/Driver/cl-diagnostics.c Modified: cfe/trunk/test/Driver/cl-diagnostics.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-diagnostics.c?rev=304337&r1=304336&r2=304337&view=diff == --- cfe/trunk/test/Driver/cl-diagnostics.c (original) +++ cfe/trunk/test/Driver/cl-diagnostics.c Wed May 31 15:07:36 2017 @@ -13,12 +13,12 @@ // CARET-NOT: -fno-caret-diagnostics // CARET-NOT: -fno-show-column -// RUN: not %clang_cl /diagnostics:classic /Zs -c -- %s 2>&1 | FileCheck %s --check-prefix=OUTPUT_CLASSIC +// RUN: not %clang_cl -fms-compatibility-version=19 /diagnostics:classic /Zs -c -- %s 2>&1 | FileCheck %s --check-prefix=OUTPUT_CLASSIC // OUTPUT_CLASSIC: cl-diagnostics.c({{[0-9]+}}): error: "asdf" // OUTPUT_CLASSIC-NOT: #error -// RUN: not %clang_cl /diagnostics:caret /Zs -c -- %s 2>&1 | FileCheck %s --check-prefix=OUTPUT_CARET +// RUN: not %clang_cl -fms-compatibility-version=19 /diagnostics:caret /Zs -c -- %s 2>&1 | FileCheck %s --check-prefix=OUTPUT_CARET // OUTPUT_CARET: cl-diagnostics.c({{[0-9]+,[0-9]+}}): error: "asdf" // OUTPUT_CARET-NEXT: #error "asdf" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r304345 - [clang-cl] Expose -nostdinc and -nobuiltininc
Author: rnk Date: Wed May 31 15:42:43 2017 New Revision: 304345 URL: http://llvm.org/viewvc/llvm-project?rev=304345&view=rev Log: [clang-cl] Expose -nostdinc and -nobuiltininc These are already wired up to work in the MSVC toolchain header search code. However, they were unreachable from clang-cl. A user attempted to use them in https://bugs.llvm.org/show_bug.cgi?id=33205, so let's expose them. Added: cfe/trunk/test/Driver/cl-include.c Modified: cfe/trunk/include/clang/Driver/Options.td Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=304345&r1=304344&r2=304345&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Wed May 31 15:42:43 2017 @@ -2084,7 +2084,7 @@ def no_cpp_precomp : Flag<["-"], "no-cpp def no_integrated_cpp : Flag<["-", "--"], "no-integrated-cpp">, Flags<[DriverOption]>; def no_pedantic : Flag<["-", "--"], "no-pedantic">, Group; def no__dead__strip__inits__and__terms : Flag<["-"], "no_dead_strip_inits_and_terms">; -def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option]>, +def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option, CoreOption]>, HelpText<"Disable builtin #include directories">; def nocudainc : Flag<["-"], "nocudainc">; def nocudalib : Flag<["-"], "nocudalib">; @@ -2096,7 +2096,7 @@ def nopie : Flag<["-"], "nopie">; def noprebind : Flag<["-"], "noprebind">; def noseglinkedit : Flag<["-"], "noseglinkedit">; def nostartfiles : Flag<["-"], "nostartfiles">; -def nostdinc : Flag<["-"], "nostdinc">; +def nostdinc : Flag<["-"], "nostdinc">, Flags<[CoreOption]>; def nostdlibinc : Flag<["-"], "nostdlibinc">; def nostdincxx : Flag<["-"], "nostdinc++">, Flags<[CC1Option]>, HelpText<"Disable standard #include directories for the C++ standard library">; Added: cfe/trunk/test/Driver/cl-include.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-include.c?rev=304345&view=auto == --- cfe/trunk/test/Driver/cl-include.c (added) +++ cfe/trunk/test/Driver/cl-include.c Wed May 31 15:42:43 2017 @@ -0,0 +1,14 @@ +// Note: %s must be preceded by --, otherwise it may be interpreted as a +// command-line option, e.g. on Mac where %s is commonly under /Users. + +// RUN: %clang_cl -### -- %s 2>&1 | FileCheck %s --check-prefix=BUILTIN +// BUILTIN: "-internal-isystem" "{{.*lib.*clang.*[0-9]\.[0-9].*include}}" + +// RUN: %clang_cl -nobuiltininc -### -- %s 2>&1 | FileCheck %s --check-prefix=NOBUILTIN +// NOBUILTIN-NOT: "-internal-isystem" "{{.*lib.*clang.*[0-9]\.[0-9].*include}}" + +// RUN: env INCLUDE=/my/system/inc %clang_cl -### -- %s 2>&1 | FileCheck %s --check-prefix=STDINC +// STDINC: "-internal-isystem" "/my/system/inc" + +// RUN: env INCLUDE=/my/system/inc %clang_cl -nostdinc -### -- %s 2>&1 | FileCheck %s --check-prefix=NOSTDINC +// NOSTDINC-NOT: "-internal-isystem" "/my/system/inc" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r284060 - Implement MS _BitScan intrinsics
On Wed, Jun 7, 2017 at 7:31 PM, Saleem Abdulrasool wrote: > I'm worried about changing this signature all the time. I suspect that it > will cause the following to be emitted for valid code: > > warning: incompatible pointer types passing 'unsigned long *' to parameter > of type 'unsigned int *' [-Wincompatible-pointer-types] > > Switching the signature on LP64 sounds much better to me. > Right, we have to do this. It needs to be `long` on Windows. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r305224 - Correct debug info bit offset calculation for big-endian targets
Author: rnk Date: Mon Jun 12 14:57:56 2017 New Revision: 305224 URL: http://llvm.org/viewvc/llvm-project?rev=305224&view=rev Log: Correct debug info bit offset calculation for big-endian targets Summary: The change "[CodeView] Implement support for bit fields in Clang" (r274201, https://reviews.llvm.org/rL274201) broke the calculation of bit offsets for the debug info describing bitfields on big-endian targets. Prior to commit r274201 the debug info for bitfields got their offsets from the ASTRecordLayout in CGDebugInfo::CollectRecordFields(), the current field offset was then passed on to CGDebugInfo::CollectRecordNormalField() and used directly in the DIDerivedType. Since commit r274201, the bit offset ending up in the DIDerivedType no longer comes directly from the ASTRecordLayout. Instead CGDebugInfo::CollectRecordNormalField() calls the new method CGDebugInfo::createBitFieldType(), which in turn calls CodeGenTypes::getCGRecordLayout().getBitFieldInfo() to fetch a CGBitFieldInfo describing the field. The 'Offset' member of CGBitFieldInfo is then used to calculate the bit offset of the DIDerivedType. Unfortunately the previous and current method of calculating the bit offset are only equivalent for little endian targets, as CGRecordLowering::setBitFieldInfo() reverses the bit offsets for big endian targets as the last thing it does. A simple reproducer for this error is the following module: struct fields { unsigned a : 4; unsigned b : 4; } flags = {0x0f, 0x1}; Compiled for Mips, with commit r274200 both the DIDerivedType bit offsets on the IR-level and the DWARF information on the ELF-level will have the expected values: the offsets of 'a' and 'b' are 0 and 4 respectively. With r274201 the offsets are switched to 4 and 0. By noting that the static initialization of 'flags' in both cases is the same, we can eliminate a change in record layout as the cause of the change in the debug info. Also compiling this example with gcc, produces the same record layout and debug info as commit r274200. In order to restore the previous function we extend CGDebugInfo::createBitFieldType() to compensate for the reversal done in CGRecordLowering::setBitFieldInfo(). Patch by Frej Drejhammar! Reviewers: cfe-commits, majnemer, rnk, aaboud, echristo, aprantl Reviewed By: rnk, aprantl Subscribers: aprantl, arichardson, frej Differential Revision: https://reviews.llvm.org/D32745 Added: cfe/trunk/test/CodeGen/mips-debug-info-bitfield.c Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=305224&r1=305223&r2=305224&view=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jun 12 14:57:56 2017 @@ -1041,7 +1041,13 @@ llvm::DIType *CGDebugInfo::createBitFiel assert(SizeInBits > 0 && "found named 0-width bitfield"); uint64_t StorageOffsetInBits = CGM.getContext().toBits(BitFieldInfo.StorageOffset); - uint64_t OffsetInBits = StorageOffsetInBits + BitFieldInfo.Offset; + uint64_t Offset = BitFieldInfo.Offset; + // The bit offsets for big endian machines are reversed for big + // endian target, compensate for that as the DIDerivedType requires + // un-reversed offsets. + if (CGM.getDataLayout().isBigEndian()) +Offset = BitFieldInfo.StorageSize - BitFieldInfo.Size - Offset; + uint64_t OffsetInBits = StorageOffsetInBits + Offset; llvm::DINode::DIFlags Flags = getAccessFlag(BitFieldDecl->getAccess(), RD); return DBuilder.createBitFieldMemberType( RecordTy, Name, File, Line, SizeInBits, OffsetInBits, StorageOffsetInBits, Added: cfe/trunk/test/CodeGen/mips-debug-info-bitfield.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips-debug-info-bitfield.c?rev=305224&view=auto == --- cfe/trunk/test/CodeGen/mips-debug-info-bitfield.c (added) +++ cfe/trunk/test/CodeGen/mips-debug-info-bitfield.c Mon Jun 12 14:57:56 2017 @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -x c -debug-info-kind=limited -triple mips-none-linux-gnu -emit-llvm -o - %s | FileCheck %s + +struct fields +{ + unsigned a : 4; + unsigned b : 4; +} flags; + +// CHECK: !DIDerivedType(tag: DW_TAG_member, +// CHECK-SAME: {{.*}}name: "a" +// CHECK-NOT: {{.*}}offset: +// CHECK-SAME: {{.*}}flags: DIFlagBitField + +// CHECK: !DIDerivedType(tag: DW_TAG_member, +// CHECK-SAME: {{.*}}name: "b" +// CHECK-SAME: {{.*}}offset: 4 +// CHECK-SAME: {{.*}}flags: DIFlagBitField ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r284060 - Implement MS _BitScan intrinsics
We should fix it. We just need a new character code in the builtin function prototype encoding. Currently there is no encoding for a portable int32_t that magically becomes "long" on 32-bit Windows. The closest thing we have is 'W', which is used by Neon intrinsics to select between "long" and "long long". It was added in r202004. On Fri, Jun 16, 2017 at 10:28 AM, Erik Schwiebert wrote: > We (Office developers for Apple platforms at Microsoft) would prefer to > have the intrinsics work properly for LP64, as that will generate the most > optimal and efficient code. That said, we understand that this may be odd > to implement from the compiler's perspective and can work around it if the > intrinsics are not supported for ms-extensions+LP64. At the end of the day > we need the compiler to clearly adopt one of those two options, and not sit > somewhere in the middle as it currently does. We don't turn on any flags > other than -fms-extensions; we don’t attempt to define MSC_VER and we do > conditionalize code based on __clang__ so the code is aware it is being > compiled by clang vs MSVC. > > So I think we'd prefer what Duncan and Apple are offering to do, but if > the larger clang community thinks that is a bad idea and wants to > explicitly disable the intrinsics, we could live with that. > > Thanks, > Schwieb > > -Original Message- > From: Erik Schwiebert > Sent: Friday, June 16, 2017 8:49 AM > To: 'Bruno Cardoso Lopes' ; Brian Kelley < > bkel...@microsoft.com>; Tomasz Kukielka > Cc: dexonsm...@apple.com; Reid Kleckner ; cfe-commits < > cfe-commits@lists.llvm.org> > Subject: RE: r284060 - Implement MS _BitScan intrinsics > > Adding Brian and Tomasz. I'm pretty sure we have the Windows SDK > intrinsics headers. I'm not sure which method we'd prefer, so I'll walk > down the hall and ask them. Tomasz is our header maestro (because we play > crazy #include_next games so we can use both Windows and macOS SDKs!) > > We'll get back to you ASAP. > > Schwieb > > -Original Message- > From: Bruno Cardoso Lopes [mailto:bruno.card...@gmail.com] > Sent: Thursday, June 15, 2017 4:41 PM > To: Erik Schwiebert > Cc: dexonsm...@apple.com; Reid Kleckner ; cfe-commits < > cfe-commits@lists.llvm.org> > Subject: Re: r284060 - Implement MS _BitScan intrinsics > > On Tue, Jun 13, 2017 at 8:13 PM, Bruno Cardoso Lopes > wrote: > > On Mon, Jun 12, 2017 at 2:01 PM, Erik Schwiebert via cfe-commits > > wrote: > >> SGTM too. Regarding Duncan's last question -- I can't think of any such > customer. :) If you all think the right thing for clang to do is to infer > LLP64 behavior on LP64 (Darwin) + ms_extensions, then that is fine with me! > > Thinking more about this; what if we mark such builtins as unsupported > for "LP64 (Darwin) + ms_extensions" and then you provide the > definitions via intrin.h (we can generate a compiler macro for this > scenario and conditionalize the include_next as we do for _MSC_VER)? > Do you use this header at all? Are there any other MS related flags > that get passed to the compiler? > > > SGTM as well! > > > >> > >> Thanks all! > >> Schwieb > >> > >> -Original Message- > >> From: dexonsm...@apple.com [mailto:dexonsm...@apple.com] > >> Sent: Monday, June 12, 2017 1:55 PM > >> To: Reid Kleckner > >> Cc: Saleem Abdulrasool ; Albert Gutowski < > agutow...@google.com>; David Majnemer ; > cfe-commits ; Erik Schwiebert < > eri...@microsoft.com> > >> Subject: Re: r284060 - Implement MS _BitScan intrinsics > >> > >> > >>> On Jun 12, 2017, at 12:44, Reid Kleckner wrote: > >>> > >>>> On Wed, Jun 7, 2017 at 7:31 PM, Saleem Abdulrasool < > compn...@compnerd.org> wrote: > >>>> I'm worried about changing this signature all the time. I suspect > that it will cause the following to be emitted for valid code: > >>>> > >>>> warning: incompatible pointer types passing 'unsigned long *' to > parameter of type 'unsigned int *' [-Wincompatible-pointer-types] > >>>> > >>>> Switching the signature on LP64 sounds much better to me. > >>> > >>> Right, we have to do this. It needs to be `long` on Windows. > >> > >> SGTM. We'll go that way. > > > > +1 here! > > > >>> On Jun 8, 2017, at 12:21, Erik Schwiebert > wrote: > >>> > >>> It’s probably also better to not try to infer our weird desired &g
[libcxx] r305841 - Fix discovery of cxxabi.h in the monorepo layout
Author: rnk Date: Tue Jun 20 15:34:13 2017 New Revision: 305841 URL: http://llvm.org/viewvc/llvm-project?rev=305841&view=rev Log: Fix discovery of cxxabi.h in the monorepo layout Modified: libcxx/trunk/CMakeLists.txt Modified: libcxx/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=305841&r1=305840&r2=305841&view=diff == --- libcxx/trunk/CMakeLists.txt (original) +++ libcxx/trunk/CMakeLists.txt Tue Jun 20 15:34:13 2017 @@ -118,6 +118,7 @@ if (LIBCXX_CXX_ABI STREQUAL "default") cxxabi.h PATHS ${LLVM_MAIN_SRC_DIR}/projects/libcxxabi/include ${LLVM_MAIN_SRC_DIR}/runtimes/libcxxabi/include + ${LLVM_MAIN_SRC_DIR}/../libcxxabi/include NO_DEFAULT_PATH ) if (LIBCXX_TARGETING_MSVC) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r306137 - [MS] Don't statically initialize dllimport member function pointers
Author: rnk Date: Fri Jun 23 13:29:13 2017 New Revision: 306137 URL: http://llvm.org/viewvc/llvm-project?rev=306137&view=rev Log: [MS] Don't statically initialize dllimport member function pointers 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. Added: cfe/trunk/test/CodeGenCXX/dllimport-memptr-global.cpp Modified: cfe/trunk/lib/AST/ExprConstant.cpp Modified: cfe/trunk/lib/AST/ExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=306137&r1=306136&r2=306137&view=diff == --- cfe/trunk/lib/AST/ExprConstant.cpp (original) +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Jun 23 13:29:13 2017 @@ -1665,6 +1665,19 @@ static bool CheckLValueConstantExpressio return true; } +/// Member pointers are constant expressions unless they point to a +/// non-virtual dllimport member function. +static bool CheckMemberPointerConstantExpression(EvalInfo &Info, + SourceLocation Loc, + QualType Type, + const APValue &Value) { + const ValueDecl *Member = Value.getMemberPointerDecl(); + const auto *FD = dyn_cast_or_null(Member); + if (!FD) +return true; + return FD->isVirtual() || !FD->hasAttr(); +} + /// Check that this core constant expression is of literal type, and if not, /// produce an appropriate diagnostic. static bool CheckLiteralType(EvalInfo &Info, const Expr *E, @@ -1757,6 +1770,9 @@ static bool CheckConstantExpression(Eval return CheckLValueConstantExpression(Info, DiagLoc, Type, LVal); } + if (Value.isMemberPointer()) +return CheckMemberPointerConstantExpression(Info, DiagLoc, Type, Value); + // Everything else is fine. return true; } Added: cfe/trunk/test/CodeGenCXX/dllimport-memptr-global.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllimport-memptr-global.cpp?rev=306137&view=auto == --- cfe/trunk/test/CodeGenCXX/dllimport-memptr-global.cpp (added) +++ cfe/trunk/test/CodeGenCXX/dllimport-memptr-global.cpp Fri Jun 23 13:29:13 2017 @@ -0,0 +1,58 @@ +// Also check that -Wglobal-constructors does the right thing. Strictly +// speaking, this is a Sema test, but this avoids test case duplication. +// RUN: %clang_cc1 -Wglobal-constructors %s -verify -triple i686-windows-msvc -fms-extensions -std=c++11 +// +// RUN: %clang_cc1 %s -emit-llvm -o - -triple i686-windows-msvc -fms-extensions -std=c++11 | FileCheck %s + +struct __declspec(dllimport) Single { + void nonvirt(); + virtual void virt(); +}; + +struct A { int a; }; +struct B { int b; }; +struct __declspec(dllimport) Multi : A, B { + void nonvirt(); + virtual void virt(); +}; + +struct __declspec(dllimport) Virtual : virtual A { + void nonvirt(); + virtual void virt(); +}; + +struct General; +static_assert(sizeof(void (General::*)()) == 16, "force general memptr model"); +struct __declspec(dllimport) General { + void nonvirt(); + virtual void virt(); +}; + +auto mp_single_nv = &Single::nonvirt; // expected-warning {{global constructor}} +auto mp_multi_nv = &Multi::nonvirt; // expected-warning {{global constructor}} +auto mp_virtual_nv = &Virtual::nonvirt; // expected-warning {{global constructor}} +auto mp_general_nv = &General::nonvirt; // expected-warning {{global constructor}} + +auto mp_single_v = &Single::virt; +auto mp_multi_v = &Multi::virt; +auto mp_virtual_v = &Virtual::virt; +auto mp_general_v = &General::virt; + +// All of the non-virtual globals need dynamic initializers. + +// CHECK: @"\01?mp_single_nv@@3P8Single@@AEXXZQ1@" = global i8* null, align 4 +// CHECK: @"\01?mp_multi_nv@@3P8Multi@@AEXXZQ1@" = global { i8*, i32 } zeroinitializer, align 4 +// CHECK: @"\01?mp_virtual_nv@@3P8Virtual@@AEXXZQ1@" = global { i8*, i32, i32 } zeroinitializer, align 4 +// CHECK: @"\01?mp_general_nv@@3P8General@@AEXXZQ1@" = global { i8*, i32, i32, i32 } zeroinitializer, align 4 + +// CHECK: @"\01?mp_single_v@@3P8Single@@AEXXZQ1@" = global i8* bitcast (void (%struct.Single*, ...)* @"\01??_9Single@@$BA@AE" to i8*), align 4 +// CHECK: @"\01?mp_multi_v@@3P8Multi@@AEXXZQ1@" = global { i8*, i32 } { i8* bitcast (void (%struct.Multi*, ...)* @"\01??_9Multi@@$BA@AE" to i8*), i32 0 }, align 4 +// CHECK: @"\01?mp_virtual_v@@3P8Virtual@@AEXXZQ1@" = global { i8*, i32, i32 } { i8* bitcast (void (%struct.Virtual*, ...)* @"\01??_9Virtual@@$BA@AE" to i8*), i32 0, i32 0 }, align 4 +// CHECK: @"\01?mp_general_v@@3P8General@@AEXXZQ1@" = global { i8*, i32, i32, i32 } { i8* bitcast (void (%struct.General*, ...)* @"\01??_9Gen
r306175 - Revert "[MS] Don't statically initialize dllimport member function pointers"
Author: rnk Date: Fri Jun 23 17:39:01 2017 New Revision: 306175 URL: http://llvm.org/viewvc/llvm-project?rev=306175&view=rev Log: Revert "[MS] Don't statically initialize dllimport member function pointers" This reverts commit r306137. It has problems on code like this: struct __declspec(dllimport) Foo { int a; int get_a() { return a; } }; template struct HasValue { int operator()(Foo *p) { return (p->*Getter)(); } }; int main() { Foo f; f.a = 3; int x = HasValue<&Foo::get_a>()(&f); } Removed: cfe/trunk/test/CodeGenCXX/dllimport-memptr-global.cpp Modified: cfe/trunk/lib/AST/ExprConstant.cpp Modified: cfe/trunk/lib/AST/ExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=306175&r1=306174&r2=306175&view=diff == --- cfe/trunk/lib/AST/ExprConstant.cpp (original) +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Jun 23 17:39:01 2017 @@ -1665,19 +1665,6 @@ static bool CheckLValueConstantExpressio return true; } -/// Member pointers are constant expressions unless they point to a -/// non-virtual dllimport member function. -static bool CheckMemberPointerConstantExpression(EvalInfo &Info, - SourceLocation Loc, - QualType Type, - const APValue &Value) { - const ValueDecl *Member = Value.getMemberPointerDecl(); - const auto *FD = dyn_cast_or_null(Member); - if (!FD) -return true; - return FD->isVirtual() || !FD->hasAttr(); -} - /// Check that this core constant expression is of literal type, and if not, /// produce an appropriate diagnostic. static bool CheckLiteralType(EvalInfo &Info, const Expr *E, @@ -1770,9 +1757,6 @@ static bool CheckConstantExpression(Eval return CheckLValueConstantExpression(Info, DiagLoc, Type, LVal); } - if (Value.isMemberPointer()) -return CheckMemberPointerConstantExpression(Info, DiagLoc, Type, Value); - // Everything else is fine. return true; } Removed: cfe/trunk/test/CodeGenCXX/dllimport-memptr-global.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllimport-memptr-global.cpp?rev=306174&view=auto == --- cfe/trunk/test/CodeGenCXX/dllimport-memptr-global.cpp (original) +++ cfe/trunk/test/CodeGenCXX/dllimport-memptr-global.cpp (removed) @@ -1,58 +0,0 @@ -// Also check that -Wglobal-constructors does the right thing. Strictly -// speaking, this is a Sema test, but this avoids test case duplication. -// RUN: %clang_cc1 -Wglobal-constructors %s -verify -triple i686-windows-msvc -fms-extensions -std=c++11 -// -// RUN: %clang_cc1 %s -emit-llvm -o - -triple i686-windows-msvc -fms-extensions -std=c++11 | FileCheck %s - -struct __declspec(dllimport) Single { - void nonvirt(); - virtual void virt(); -}; - -struct A { int a; }; -struct B { int b; }; -struct __declspec(dllimport) Multi : A, B { - void nonvirt(); - virtual void virt(); -}; - -struct __declspec(dllimport) Virtual : virtual A { - void nonvirt(); - virtual void virt(); -}; - -struct General; -static_assert(sizeof(void (General::*)()) == 16, "force general memptr model"); -struct __declspec(dllimport) General { - void nonvirt(); - virtual void virt(); -}; - -auto mp_single_nv = &Single::nonvirt; // expected-warning {{global constructor}} -auto mp_multi_nv = &Multi::nonvirt; // expected-warning {{global constructor}} -auto mp_virtual_nv = &Virtual::nonvirt; // expected-warning {{global constructor}} -auto mp_general_nv = &General::nonvirt; // expected-warning {{global constructor}} - -auto mp_single_v = &Single::virt; -auto mp_multi_v = &Multi::virt; -auto mp_virtual_v = &Virtual::virt; -auto mp_general_v = &General::virt; - -// All of the non-virtual globals need dynamic initializers. - -// CHECK: @"\01?mp_single_nv@@3P8Single@@AEXXZQ1@" = global i8* null, align 4 -// CHECK: @"\01?mp_multi_nv@@3P8Multi@@AEXXZQ1@" = global { i8*, i32 } zeroinitializer, align 4 -// CHECK: @"\01?mp_virtual_nv@@3P8Virtual@@AEXXZQ1@" = global { i8*, i32, i32 } zeroinitializer, align 4 -// CHECK: @"\01?mp_general_nv@@3P8General@@AEXXZQ1@" = global { i8*, i32, i32, i32 } zeroinitializer, align 4 - -// CHECK: @"\01?mp_single_v@@3P8Single@@AEXXZQ1@" = global i8* bitcast (void (%struct.Single*, ...)* @"\01??_9Single@@$BA@AE" to i8*), align 4 -// CHECK: @"\01?mp_multi_v@@3P8Multi@@AEXXZQ1@" = global { i8*, i32 } { i8* bitcast (void (%struct.Multi*, ...)* @"\01??_9Multi@@$BA@AE" to i8*), i32 0 }, align 4 -// CHECK: @"\01?mp_virtual_v@@3P8Virtual@@AEXXZQ1@" = global { i8*, i32, i32 } { i8* bitcast (void (%struct.Virtual*, ...)* @"\01??_9Virtual@@$BA@AE" to i8*), i32 0, i32 0 }, align 4 -// CHECK: @"\01?mp_general_v@@3P8General@@AEXXZQ1@" = global { i8*, i32, i32, i32 } { i8* bitcast (void (%struct.General
r320730 - [CodeGen][X86] Implement _InterlockedCompareExchange128 intrinsic
Author: rnk Date: Thu Dec 14 11:00:21 2017 New Revision: 320730 URL: http://llvm.org/viewvc/llvm-project?rev=320730&view=rev Log: [CodeGen][X86] Implement _InterlockedCompareExchange128 intrinsic Summary: InterlockedCompareExchange128 is a bit more complicated than the other InterlockedCompareExchange functions, so it requires a bit more work. It doesn't directly refer to 128bit ints, instead it takes pointers to 64bit ints for Destination and ComparandResult, and exchange is taken as two 64bit ints (high & low). The previous value is written to ComparandResult, and success is returned. This implementation does the following in order to produce a cmpxchg instruction: 1. Cast everything to 128bit ints or int pointers, and glues together the Exchange values 2. Reads from CompareandResult to get the comparand 3. Calls cmpxchg volatile (on X86 this will produce a lock cmpxchg16b instruction) 1. Result 0 (previous value) is written back to ComparandResult 2. Result 1 (success bool) is zext'ed to a uchar and returned Resolves bug https://llvm.org/PR35251 Patch by Colden Cullen! Reviewers: rnk, agutowski Reviewed By: rnk Subscribers: majnemer, cfe-commits Differential Revision: https://reviews.llvm.org/D41032 Modified: cfe/trunk/include/clang/Basic/BuiltinsX86_64.def cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGen/ms-intrinsics.c Modified: cfe/trunk/include/clang/Basic/BuiltinsX86_64.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86_64.def?rev=320730&r1=320729&r2=320730&view=diff == --- cfe/trunk/include/clang/Basic/BuiltinsX86_64.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsX86_64.def Thu Dec 14 11:00:21 2017 @@ -40,6 +40,7 @@ TARGET_HEADER_BUILTIN(_InterlockedExchan TARGET_HEADER_BUILTIN(_InterlockedIncrement64, "LLiLLiD*","nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(_InterlockedOr64, "LLiLLiD*LLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(_InterlockedXor64, "LLiLLiD*LLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "") +TARGET_HEADER_BUILTIN(_InterlockedCompareExchange128, "UcLLiD*LLiLLiLLi*", "nh", "intrin.h", ALL_MS_LANGUAGES, "cx16") TARGET_BUILTIN(__builtin_ia32_readeflags_u64, "ULLi", "n", "") TARGET_BUILTIN(__builtin_ia32_writeeflags_u64, "vULLi", "n", "") Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=320730&r1=320729&r2=320730&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Dec 14 11:00:21 2017 @@ -8432,6 +8432,45 @@ Value *CodeGenFunction::EmitX86BuiltinEx return EmitMSVCBuiltinExpr(MSVCIntrin::_InterlockedDecrement, E); case X86::BI_InterlockedIncrement64: return EmitMSVCBuiltinExpr(MSVCIntrin::_InterlockedIncrement, E); + case X86::BI_InterlockedCompareExchange128: { +// InterlockedCompareExchange128 doesn't directly refer to 128bit ints, +// instead it takes pointers to 64bit ints for Destination and +// ComparandResult, and exchange is taken as two 64bit ints (high & low). +// The previous value is written to ComparandResult, and success is +// returned. + +llvm::Type *Int128Ty = Builder.getInt128Ty(); +llvm::Type *Int128PtrTy = Int128Ty->getPointerTo(); + +Value *Destination = +Builder.CreateBitCast(EmitScalarExpr(E->getArg(0)), Int128PtrTy); +Value *ExchangeHigh128 = +Builder.CreateZExt(EmitScalarExpr(E->getArg(1)), Int128Ty); +Value *ExchangeLow128 = +Builder.CreateZExt(EmitScalarExpr(E->getArg(2)), Int128Ty); +Address ComparandResult( +Builder.CreateBitCast(EmitScalarExpr(E->getArg(3)), Int128PtrTy), +getContext().toCharUnitsFromBits(128)); + +Value *Exchange = Builder.CreateOr( +Builder.CreateShl(ExchangeHigh128, 64, "", false, false), +ExchangeLow128); + +Value *Comparand = Builder.CreateLoad(ComparandResult); + +AtomicCmpXchgInst *CXI = +Builder.CreateAtomicCmpXchg(Destination, Comparand, Exchange, +AtomicOrdering::SequentiallyConsistent, +AtomicOrdering::SequentiallyConsistent); +CXI->setVolatile(true); + +// Write the result back to the inout pointer. +Builder.CreateStore(Builder.CreateExtractValue(CXI, 0), ComparandResult); + +// Get the success boolean and zero extend it to i8. +Value *Success = Builder.CreateExtractValue(CXI, 1); +return Builder.CreateZExt(Success, ConvertType(E->getType())); + } case X86::BI_AddressOfReturnAddress: { Value *F = CGM.getIntrinsic(Intrinsic::addressofreturnaddress); Modified: cfe/trunk/test/CodeGen/ms-intrinsics.c URL: http://llvm.org/viewvc/llvm-project/cfe/
r321298 - Revert "Fix for PR32990"
Author: rnk Date: Thu Dec 21 11:44:23 2017 New Revision: 321298 URL: http://llvm.org/viewvc/llvm-project?rev=321298&view=rev Log: Revert "Fix for PR32990" This reverts commit r321239. It broke the Chromium DLL build: [8834/50217] LINK(DLL) icui18n.dll icui18n.dll.lib icui18n.dll.pdb FAILED: icui18n.dll icui18n.dll.lib icui18n.dll.pdb zrule.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __cdecl icu_60::UnicodeString::`vbase destructor'(void)" (__imp_??_DUnicodeString@icu_60@@QEAAXXZ) Removed: cfe/trunk/test/CodeGenCXX/dllimport-virtual-base.cpp cfe/trunk/test/CodeGenCXX/external-linkage.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp cfe/trunk/test/CodeGenCXX/dllimport-members.cpp cfe/trunk/test/CodeGenCXX/dllimport.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=321298&r1=321297&r2=321298&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Dec 21 11:44:23 2017 @@ -856,25 +856,14 @@ CodeGenModule::getFunctionLinkage(Global GVALinkage Linkage = getContext().GetGVALinkageForFunction(D); if (isa(D) && - Context.getTargetInfo().getCXXABI().isMicrosoft()) { -switch (GD.getDtorType()) { -case CXXDtorType::Dtor_Base: - break; -case CXXDtorType::Dtor_Comdat: -case CXXDtorType::Dtor_Complete: - if (D->hasAttr() && - (cast(D)->getParent()->getNumVBases() || - (Linkage == GVA_AvailableExternally || - Linkage == GVA_StrongExternal))) - return llvm::Function::AvailableExternallyLinkage; - else -return Linkage == GVA_Internal ? llvm::GlobalValue::InternalLinkage - : llvm::GlobalValue::LinkOnceODRLinkage; -case CXXDtorType::Dtor_Deleting: - return Linkage == GVA_Internal ? llvm::GlobalValue::InternalLinkage - : llvm::GlobalValue::LinkOnceODRLinkage; -} + getCXXABI().useThunkForDtorVariant(cast(D), + GD.getDtorType())) { +// Destructor variants in the Microsoft C++ ABI are always internal or +// linkonce_odr thunks emitted on an as-needed basis. +return Linkage == GVA_Internal ? llvm::GlobalValue::InternalLinkage + : llvm::GlobalValue::LinkOnceODRLinkage; } + if (isa(D) && cast(D)->isInheritingConstructor() && Context.getTargetInfo().getCXXABI().isMicrosoft()) { @@ -890,25 +879,12 @@ CodeGenModule::getFunctionLinkage(Global void CodeGenModule::setFunctionDLLStorageClass(GlobalDecl GD, llvm::Function *F) { const auto *FD = cast(GD.getDecl()); - if (dyn_cast_or_null(FD)) { -switch (GD.getDtorType()) { -case CXXDtorType::Dtor_Comdat: -case CXXDtorType::Dtor_Deleting: { + if (const auto *Dtor = dyn_cast_or_null(FD)) { +if (getCXXABI().useThunkForDtorVariant(Dtor, GD.getDtorType())) { // Don't dllexport/import destructor thunks. F->setDLLStorageClass(llvm::GlobalValue::DefaultStorageClass); return; } -case CXXDtorType::Dtor_Complete: - if (FD->hasAttr()) -F->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass); - else if (FD->hasAttr()) -F->setDLLStorageClass(llvm::GlobalVariable::DLLExportStorageClass); - else -F->setDLLStorageClass(llvm::GlobalVariable::DefaultStorageClass); - return; -case CXXDtorType::Dtor_Base: - break; -} } if (FD->hasAttr()) Modified: cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp?rev=321298&r1=321297&r2=321298&view=diff == --- cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp (original) +++ cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp Thu Dec 21 11:44:23 2017 @@ -1,5 +1,4 @@ // RUN: %clang_cc1 -mconstructor-aliases %s -triple x86_64-windows-msvc -fms-extensions -emit-llvm -o - | FileCheck %s -// RUN: %clang_cc1 -mconstructor-aliases %s -triple x86_64-windows-msvc -fms-extensions -emit-llvm -O1 -disable-llvm-passes -o - | FileCheck --check-prefix=MO1 %s // FIXME: We should really consider removing -mconstructor-aliases for MS C++ // ABI. The risk of bugs introducing ABI incompatibility under @@ -24,7 +23,9 @@ struct __declspec(dllimport) ImportOverr virtual ~ImportOverrideVDtor() {} }; -// Virtually inherits from a non-dllimport base class. Emit the vbase destructor. +// Virtually inherits from a non-dllimport base class. This time we need to call +// the complete destructor and emit it inline. It's not exported from the DLL, +// and it must be emitte
r321676 - [WinEH] Allow for multiple terminatepads
Author: rnk Date: Tue Jan 2 13:34:16 2018 New Revision: 321676 URL: http://llvm.org/viewvc/llvm-project?rev=321676&view=rev Log: [WinEH] Allow for multiple terminatepads Fixes verifier errors with Windows EH and OpenMP, which injects a terminate scope around parallel blocks. Fixes PR35778 Modified: cfe/trunk/lib/CodeGen/CGException.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/test/OpenMP/openmp_win_codegen.cpp Modified: cfe/trunk/lib/CodeGen/CGException.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=321676&r1=321675&r2=321676&view=diff == --- cfe/trunk/lib/CodeGen/CGException.cpp (original) +++ cfe/trunk/lib/CodeGen/CGException.cpp Tue Jan 2 13:34:16 2018 @@ -646,7 +646,7 @@ CodeGenFunction::getMSVCDispatchBlock(EH return DispatchBlock; if (EHS.getKind() == EHScope::Terminate) -DispatchBlock = getTerminateHandler(); +DispatchBlock = getTerminateFunclet(); else DispatchBlock = createBasicBlock(); CGBuilderTy Builder(*this, DispatchBlock); @@ -1334,24 +1334,15 @@ llvm::BasicBlock *CodeGenFunction::getTe if (TerminateHandler) return TerminateHandler; - CGBuilderTy::InsertPoint SavedIP = Builder.saveAndClearIP(); - // Set up the terminate handler. This block is inserted at the very // end of the function by FinishFunction. TerminateHandler = createBasicBlock("terminate.handler"); + CGBuilderTy::InsertPoint SavedIP = Builder.saveAndClearIP(); Builder.SetInsertPoint(TerminateHandler); + llvm::Value *Exn = nullptr; - SaveAndRestore RestoreCurrentFuncletPad( - CurrentFuncletPad); - if (EHPersonality::get(*this).usesFuncletPads()) { -llvm::Value *ParentPad = CurrentFuncletPad; -if (!ParentPad) - ParentPad = llvm::ConstantTokenNone::get(CGM.getLLVMContext()); -CurrentFuncletPad = Builder.CreateCleanupPad(ParentPad); - } else { -if (getLangOpts().CPlusPlus) - Exn = getExceptionFromSlot(); - } + if (getLangOpts().CPlusPlus) +Exn = getExceptionFromSlot(); llvm::CallInst *terminateCall = CGM.getCXXABI().emitTerminateForUnexpectedException(*this, Exn); terminateCall->setDoesNotReturn(); @@ -1363,6 +1354,42 @@ llvm::BasicBlock *CodeGenFunction::getTe return TerminateHandler; } +llvm::BasicBlock *CodeGenFunction::getTerminateFunclet() { + assert(EHPersonality::get(*this).usesFuncletPads() && + "use getTerminateLandingPad for non-funclet EH"); + + llvm::BasicBlock *&TerminateFunclet = TerminateFunclets[CurrentFuncletPad]; + if (TerminateFunclet) +return TerminateFunclet; + + CGBuilderTy::InsertPoint SavedIP = Builder.saveAndClearIP(); + + // Set up the terminate handler. This block is inserted at the very + // end of the function by FinishFunction. + TerminateFunclet = createBasicBlock("terminate.handler"); + Builder.SetInsertPoint(TerminateFunclet); + + // Create the cleanuppad using the current parent pad as its token. Use 'none' + // if this is a top-level terminate scope, which is the common case. + SaveAndRestore RestoreCurrentFuncletPad( + CurrentFuncletPad); + llvm::Value *ParentPad = CurrentFuncletPad; + if (!ParentPad) +ParentPad = llvm::ConstantTokenNone::get(CGM.getLLVMContext()); + CurrentFuncletPad = Builder.CreateCleanupPad(ParentPad); + + // Emit the __std_terminate call. + llvm::CallInst *terminateCall = + CGM.getCXXABI().emitTerminateForUnexpectedException(*this, nullptr); + terminateCall->setDoesNotReturn(); + Builder.CreateUnreachable(); + + // Restore the saved insertion state. + Builder.restoreIP(SavedIP); + + return TerminateFunclet; +} + llvm::BasicBlock *CodeGenFunction::getEHResumeBlock(bool isCleanup) { if (EHResumeBlock) return EHResumeBlock; Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=321676&r1=321675&r2=321676&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Tue Jan 2 13:34:16 2018 @@ -419,6 +419,9 @@ void CodeGenFunction::FinishFunction(Sou EmitIfUsed(*this, TerminateHandler); EmitIfUsed(*this, UnreachableBlock); + for (const auto &FuncletAndParent : TerminateFunclets) +EmitIfUsed(*this, FuncletAndParent.second); + if (CGM.getCodeGenOpts().EmitDeclMetadata) EmitDeclMetadata(); Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=321676&r1=321675&r2=321676&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Jan 2 13:34:16 2018 @@ -34,6 +34,7 @@ #include "clang
Re: r326168 - Attempt to fix greendragon bot after r326141
Thanks, this is the correct fix, and the pattern used in all the rest of the clang-cl driver tests. On Mon, Feb 26, 2018 at 10:06 PM Shoaib Meenai wrote: > r326171 works locally. I'll keep an eye on the bots. > > > > *From: * on behalf of Adam Nemet > *Date: *Monday, February 26, 2018 at 9:51 PM > *To: *Shoaib Meenai > *Cc: *Zachary Turner , "cfe-commits@lists.llvm.org" < > cfe-commits@lists.llvm.org>, Reid Kleckner > *Subject: *Re: r326168 - Attempt to fix greendragon bot after r326141 > > > > Yep. > > > > On Feb 26, 2018, at 9:50 PM, Shoaib Meenai wrote: > > > > Reid re-committed r326141 this morning (and followed up with r326144), and > I don't think either of those have been reverted? > > > > *From: *Zachary Turner > *Date: *Monday, February 26, 2018 at 9:47 PM > *To: *Adam Nemet > *Cc: *Shoaib Meenai , "cfe-commits@lists.llvm.org" < > cfe-commits@lists.llvm.org>, Reid Kleckner > *Subject: *Re: r326168 - Attempt to fix greendragon bot after r326141 > > > > I already reverted this a long time ago, but if Shoaib has a proper fix > that would be great > > On Mon, Feb 26, 2018 at 9:45 PM Adam Nemet wrote: > > Ah, that should be sufficient. > > > > > > > On Feb 26, 2018, at 9:44 PM, Shoaib Meenai wrote: > > > > Thanks. I'm building on macOS locally to confirm the original problem and > my fix. > > > > *From: * on behalf of Adam Nemet > *Date: *Monday, February 26, 2018 at 9:42 PM > *To: *Shoaib Meenai > *Cc: *"cfe-commits@lists.llvm.org" , Reid > Kleckner , Zachary Turner > *Subject: *Re: r326168 - Attempt to fix greendragon bot after r326141 > > > > This is the bot with the failure: > > > > > http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental/46794/#showFailuresLink > <https://urldefense.proofpoint.com/v2/url?u=http-3A__lab.llvm.org-3A8080_green_job_clang-2Dstage1-2Dcmake-2DRA-2Dincremental_46794_-23showFailuresLink&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=OIgCAeO_dFHAJFlsBo7l_qhVKV7niFfyQ0fpICifvN4&s=OEMtPu3dUHXK8327qnfWOSUP62v1F-s_a13X0lqbdJ0&e=> > > > > But to make matters worse, greendragon is experience some difficulty > fetching from SVN so you might want to wait until things recover. I am not > sure if I will be able to get in touch with Mike Edwards until the morning > PST. > > > > There may also be llvm bots that exhibit the same problem. You may have > better luck with those in the short term. > > > > Adam > > > > On Feb 26, 2018, at 9:35 PM, Shoaib Meenai wrote: > > > > Could you point me to the specific bot that was failing? I've dealt with > that problem before, and it shouldn't be hard to fix, but I wanna monitor > the bot after the fix to make sure it stays green. > > > > *From: * on behalf of Adam Nemet > *Date: *Monday, February 26, 2018 at 9:30 PM > *To: *Shoaib Meenai > *Cc: *"cfe-commits@lists.llvm.org" , Reid > Kleckner , Zachary Turner > *Subject: *Re: r326168 - Attempt to fix greendragon bot after r326141 > > > > I don’t think we can deal with the slash options: > > > > clang-7.0: warning: > '/Users/buildslave/jenkins/workspace/apple-clang-master-RA-stage1-cmake-incremental/clang/src/tools/clang/test/Driver/codeview-column-info.c' > treated as the '/U' option [-Wslash-u-filename] > > clang-7.0: note: Use '--' to treat subsequent arguments as filenames > > clang-7.0: warning: argument unused during compilation: '/Z7' > [-Wunused-command-line-argument] > > clang-7.0: warning: argument unused during compilation: ‘-U > sers/buildslave/jenkins/workspace/apple-clang-master-RA-stage1-cmake-incremental/clang/src/tools/clang/test/Driver/codeview-column-info.c' > [-Wunused-command-line-argument] > > > > Anyhow as I said to Reid, feel free to improve the patch, I am just > bringing back a bot that has been red for hours. > > > > Adam > > > > > On Feb 26, 2018, at 9:22 PM, Shoaib Meenai wrote: > > > > This seems bogus to me. CodeView can be generated on any build platform; > it just needs the correct triple, which Reid added in r326144. > > > > *From: *cfe-commits on behalf of > Adam Nemet via cfe-commits > *Reply-To: *Adam Nemet > *Date: *Monday, February 26, 2018 at 8:51 PM > *To: *"cfe-commits@lists.llvm.org" > *Subject: *r326168 - Attempt to fix greendragon bot after r326141 > > > > Author: anemet > > Date: Mon Feb 26 20:49:26 2018 > > New Revision: 326168 > > > > URL: > http
Re: r326141 - Re-land "Emit proper CodeView when -gcodeview is passed without the cl driver."
I want to do that, but it will surely break the LLDB test suite, which assumes `clang -g` makes dwarf. It's just a matter of fixing up the flags their test makefiles use. On Thu, Mar 1, 2018 at 3:22 PM Nico Weber wrote: > Should we key the default off the triple? (I thought that what was the > patch did, but I misread.) I.e. with an MSVC triple, default to emitting > codeview? > > On Mon, Feb 26, 2018 at 5:55 PM, Reid Kleckner via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: rnk >> Date: Mon Feb 26 14:55:33 2018 >> New Revision: 326141 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=326141&view=rev >> Log: >> Re-land "Emit proper CodeView when -gcodeview is passed without the cl >> driver." >> >> Reverts r326116 and re-lands r326113 with a fix to ASan so that it >> enables column info in its test suite. >> >> Added: >> cfe/trunk/test/Driver/codeview-column-info.c >> Modified: >> cfe/trunk/lib/Driver/ToolChains/Clang.cpp >> >> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=326141&r1=326140&r2=326141&view=diff >> >> == >> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) >> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Feb 26 14:55:33 2018 >> @@ -2968,7 +2968,7 @@ static void RenderDebugOptions(const Too >> >>// Forward -gcodeview. EmitCodeView might have been set by >> CL-compatibility >>// argument parsing. >> - if (Args.hasArg(options::OPT_gcodeview) || EmitCodeView) { >> + if (EmitCodeView) { >> // DWARFVersion remains at 0 if no explicit choice was made. >> CmdArgs.push_back("-gcodeview"); >>} else if (DWARFVersion == 0 && >> @@ -3567,6 +3567,8 @@ void Clang::ConstructJob(Compilation &C, >>types::ID InputType = Input.getType(); >>if (D.IsCLMode()) >> AddClangCLArgs(Args, InputType, CmdArgs, &DebugInfoKind, >> &EmitCodeView); >> + else >> +EmitCodeView = Args.hasArg(options::OPT_gcodeview); >> >>const Arg *SplitDWARFArg = nullptr; >>RenderDebugOptions(getToolChain(), D, RawTriple, Args, EmitCodeView, >> >> Added: cfe/trunk/test/Driver/codeview-column-info.c >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/codeview-column-info.c?rev=326141&view=auto >> >> == >> --- cfe/trunk/test/Driver/codeview-column-info.c (added) >> +++ cfe/trunk/test/Driver/codeview-column-info.c Mon Feb 26 14:55:33 2018 >> @@ -0,0 +1,13 @@ >> +// Check that -dwarf-column-info does not get added to the cc1 line: >> +// 1) When -gcodeview is present via the clang or clang++ driver >> +// 2) When /Z7 is present via the cl driver. >> + >> +// RUN: %clang -### -c -g -gcodeview %s 2> %t1 >> +// RUN: FileCheck < %t1 %s >> +// RUN: %clangxx -### -c -g -gcodeview %s 2> %t2 >> +// RUN: FileCheck < %t2 %s >> +// RUN: %clang_cl -### /c /Z7 %s 2> %t2 >> +// RUN: FileCheck < %t2 %s >> + >> +// CHECK: "-cc1" >> +// CHECK-NOT: "-dwarf-column-info" >> >> >> ___ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >> > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r326622 - Don't claim that va_start has special semantic checks
Author: rnk Date: Fri Mar 2 13:41:08 2018 New Revision: 326622 URL: http://llvm.org/viewvc/llvm-project?rev=326622&view=rev Log: Don't claim that va_start has special semantic checks We don't have special checks for BI_va_start in Sema::CheckBuiltinFunctionCall, so setting the 't' flag for va_start in Builtins.def disables semantic checking for it. That's not desired, and IRGen crashes when it tries to generate a call to va_start that doesn't have at least one argument. Follow-up to r322573 Fixes PR36565 Modified: cfe/trunk/include/clang/Basic/Builtins.def cfe/trunk/test/Sema/varargs.c Modified: cfe/trunk/include/clang/Basic/Builtins.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=326622&r1=326621&r2=326622&view=diff == --- cfe/trunk/include/clang/Basic/Builtins.def (original) +++ cfe/trunk/include/clang/Basic/Builtins.def Fri Mar 2 13:41:08 2018 @@ -803,7 +803,7 @@ LIBBUILTIN(_setjmpex, "iJ", "fj", "set // C99 library functions // C99 stdarg.h -LIBBUILTIN(va_start, "vA.", "fnt", "stdarg.h", ALL_LANGUAGES) +LIBBUILTIN(va_start, "vA.", "fn","stdarg.h", ALL_LANGUAGES) LIBBUILTIN(va_end, "vA", "fn","stdarg.h", ALL_LANGUAGES) LIBBUILTIN(va_copy, "vAA","fn","stdarg.h", ALL_LANGUAGES) // C99 stdlib.h Modified: cfe/trunk/test/Sema/varargs.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/varargs.c?rev=326622&r1=326621&r2=326622&view=diff == --- cfe/trunk/test/Sema/varargs.c (original) +++ cfe/trunk/test/Sema/varargs.c Fri Mar 2 13:41:08 2018 @@ -112,3 +112,12 @@ void f13(enum E1 e, ...) { #endif __builtin_va_end(va); } + +void f14(int e, ...) { + // expected-warning@+3 {{implicitly declaring library function 'va_start'}} + // expected-note@+2 {{include the header }} + // expected-error@+1 {{too few arguments to function call}} + va_start(); + __builtin_va_list va; + va_start(va, e); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r326744 - [msvc] Allow MSVC toolchain driver to find the aarch64 / arm64 cross-compiler.
Author: rnk Date: Mon Mar 5 13:36:23 2018 New Revision: 326744 URL: http://llvm.org/viewvc/llvm-project?rev=326744&view=rev Log: [msvc] Allow MSVC toolchain driver to find the aarch64 / arm64 cross-compiler. Starting with the Fall Creators Update, Windows 10 Desktop can run on machines that are powered by aarch64 processors. Microsoft call the aarch64 architecture "arm64". This patch maps ArchType::aarch64 to "arm64" to allow the MSVC toolchain driver to find the aarch64 / arm64 cross-compiler. Patch by Chris January Differential Revision: https://reviews.llvm.org/D44087 Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.cpp?rev=326744&r1=326743&r2=326744&view=diff == --- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Mon Mar 5 13:36:23 2018 @@ -752,6 +752,8 @@ static const char *llvmArchToWindowsSDKA return "x64"; case ArchType::arm: return "arm"; + case ArchType::aarch64: +return "arm64"; default: return ""; } @@ -769,6 +771,8 @@ static const char *llvmArchToLegacyVCArc return "amd64"; case ArchType::arm: return "arm"; + case ArchType::aarch64: +return "arm64"; default: return ""; } @@ -784,6 +788,8 @@ static const char *llvmArchToDevDivInter return "amd64"; case ArchType::arm: return "arm"; + case ArchType::aarch64: +return "arm64"; default: return ""; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r326926 - Push a function scope when parsing function bodies without a declaration
Author: rnk Date: Wed Mar 7 10:55:10 2018 New Revision: 326926 URL: http://llvm.org/viewvc/llvm-project?rev=326926&view=rev Log: Push a function scope when parsing function bodies without a declaration Summary: This is PR36536. There are a few ways to reach Sema::ActOnStartOfFunctionDef with a null Decl. Currently, the parser continues on to attempt to parse the statements in the function body without pushing a function scope or declaration context. However, lots of statement parsing logic relies on getCurFunction() returning something reasonable. It turns out that getCurFunction() will never return null today because of an optimization where Sema pre-allocates one FunctionScopeInfo and reuses it when possible. This goes wrong when something inside the function body causes us to push another function scope, such as requiring an implicit definition of a special member function. Reusing the state clears it out, which will lead to bugs. In PR36536, we found that the SwitchStack gets unbalanced, because we push a switch, clear out the stack, and then try to pop a switch that isn't there. As a follow-up, I plan to move the pre-allocated FunctionScopeInfo out of the FunctionScopes stack. This means the FunctionScopes stack will often be empty, and callers of getCurFunction() will need to check for null. Reviewers: thakis Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43980 Added: cfe/trunk/test/SemaCXX/pr36536.cpp Modified: cfe/trunk/lib/Sema/SemaDecl.cpp Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=326926&r1=326925&r2=326926&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Mar 7 10:55:10 2018 @@ -12406,8 +12406,13 @@ static void RebuildLambdaScopeInfo(CXXMe Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D, SkipBodyInfo *SkipBody) { - if (!D) + if (!D) { +// Parsing the function declaration failed in some way. Push on a fake scope +// anyway so we can try to parse the function body. +PushFunctionScope(); return D; + } + FunctionDecl *FD = nullptr; if (FunctionTemplateDecl *FunTmpl = dyn_cast(D)) @@ -12816,6 +12821,9 @@ Decl *Sema::ActOnFinishFunctionBody(Decl getCurFunction()->ObjCWarnForNoInitDelegation = false; } } else { +// Parsing the function declaration failed in some way. Pop the fake scope +// we pushed on. +PopFunctionScopeInfo(ActivePolicy, dcl); return nullptr; } Added: cfe/trunk/test/SemaCXX/pr36536.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/pr36536.cpp?rev=326926&view=auto == --- cfe/trunk/test/SemaCXX/pr36536.cpp (added) +++ cfe/trunk/test/SemaCXX/pr36536.cpp Wed Mar 7 10:55:10 2018 @@ -0,0 +1,44 @@ +// RUN: %clang_cc1 -std=c++11 %s -verify -fno-spell-checking + +// These test cases are constructed to make clang call ActOnStartOfFunctionDef +// with nullptr. + +struct ImplicitDefaultCtor1 {}; +struct Foo { + typedef int NameInClass; + void f(); +}; +namespace bar { +// FIXME: Improved our recovery to make this a redeclaration of Foo::f, +// even though this is in the wrong namespace. That will allow name lookup to +// find NameInClass below. Users are likely to hit this when they forget to +// close namespaces. +// expected-error@+1 {{cannot define or redeclare 'f' here}} +void Foo::f() { + switch (0) { case 0: ImplicitDefaultCtor1 o; } + // expected-error@+1 {{unknown type name 'NameInClass'}} + NameInClass var; +} +} // namespace bar + +struct ImplicitDefaultCtor2 {}; +template class TFoo { void f(); }; +// expected-error@+1 {{nested name specifier 'decltype(TFoo())::'}} +template void decltype(TFoo())::f() { + switch (0) { case 0: ImplicitDefaultCtor1 o; } +} + +namespace tpl2 { +struct ImplicitDefaultCtor3 {}; +template class A { + template class B { +void mf2(); + }; +}; +template +template <> +// expected-error@+1 {{nested name specifier 'A::B::'}} +void A::B::mf2() { + switch (0) { case 0: ImplicitDefaultCtor3 o; } +} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r326957 - Avoid including ScopeInfo.h from Sema.h
Author: rnk Date: Wed Mar 7 14:48:35 2018 New Revision: 326957 URL: http://llvm.org/viewvc/llvm-project?rev=326957&view=rev Log: Avoid including ScopeInfo.h from Sema.h Summary: This provides no measurable build speedup, but it reinstates an optimization from r112038 that was lost in r179618. It requires moving CapturedScopeInfo::Capture out to clang::sema, which might be too general since we have plenty of other Capture records in BlockDecl and other AST nodes. Reviewers: rjmccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D44221 Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/include/clang/Sema/SemaLambda.h cfe/trunk/lib/Sema/Sema.cpp cfe/trunk/lib/Sema/SemaCoroutine.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaExprMember.cpp cfe/trunk/lib/Sema/SemaLambda.cpp cfe/trunk/lib/Sema/SemaPseudoObject.cpp cfe/trunk/lib/Sema/SemaStmt.cpp Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=326957&r1=326956&r2=326957&view=diff == --- cfe/trunk/include/clang/Sema/ScopeInfo.h (original) +++ cfe/trunk/include/clang/Sema/ScopeInfo.h Wed Mar 7 14:48:35 2018 @@ -469,6 +469,132 @@ public: void Clear(); }; +class Capture { + // There are three categories of capture: capturing 'this', capturing + // local variables, and C++1y initialized captures (which can have an + // arbitrary initializer, and don't really capture in the traditional + // sense at all). + // + // There are three ways to capture a local variable: + // - capture by copy in the C++11 sense, + // - capture by reference in the C++11 sense, and + // - __block capture. + // Lambdas explicitly specify capture by copy or capture by reference. + // For blocks, __block capture applies to variables with that annotation, + // variables of reference type are captured by reference, and other + // variables are captured by copy. + enum CaptureKind { +Cap_ByCopy, Cap_ByRef, Cap_Block, Cap_VLA + }; + enum { +IsNestedCapture = 0x1, +IsThisCaptured = 0x2 + }; + + /// The variable being captured (if we are not capturing 'this') and whether + /// this is a nested capture, and whether we are capturing 'this' + llvm::PointerIntPair VarAndNestedAndThis; + + /// Expression to initialize a field of the given type, and the kind of + /// capture (if this is a capture and not an init-capture). The expression + /// is only required if we are capturing ByVal and the variable's type has + /// a non-trivial copy constructor. + llvm::PointerIntPair InitExprAndCaptureKind; + + /// \brief The source location at which the first capture occurred. + SourceLocation Loc; + + /// \brief The location of the ellipsis that expands a parameter pack. + SourceLocation EllipsisLoc; + + /// \brief The type as it was captured, which is in effect the type of the + /// non-static data member that would hold the capture. + QualType CaptureType; + + /// \brief Whether an explicit capture has been odr-used in the body of the + /// lambda. + bool ODRUsed = false; + + /// \brief Whether an explicit capture has been non-odr-used in the body of + /// the lambda. + bool NonODRUsed = false; + +public: + Capture(VarDecl *Var, bool Block, bool ByRef, bool IsNested, + SourceLocation Loc, SourceLocation EllipsisLoc, + QualType CaptureType, Expr *Cpy) + : VarAndNestedAndThis(Var, IsNested ? IsNestedCapture : 0), +InitExprAndCaptureKind( +Cpy, !Var ? Cap_VLA : Block ? Cap_Block : ByRef ? Cap_ByRef +: Cap_ByCopy), +Loc(Loc), EllipsisLoc(EllipsisLoc), CaptureType(CaptureType) {} + + enum IsThisCapture { ThisCapture }; + Capture(IsThisCapture, bool IsNested, SourceLocation Loc, + QualType CaptureType, Expr *Cpy, const bool ByCopy) + : VarAndNestedAndThis( +nullptr, (IsThisCaptured | (IsNested ? IsNestedCapture : 0))), +InitExprAndCaptureKind(Cpy, ByCopy ? Cap_ByCopy : Cap_ByRef), +Loc(Loc), CaptureType(CaptureType) {} + + bool isThisCapture() const { +return VarAndNestedAndThis.getInt() & IsThisCaptured; + } + + bool isVariableCapture() const { +return !isThisCapture() && !isVLATypeCapture(); + } + + bool isCopyCapture() const { +return InitExprAndCaptureKind.getInt() == Cap_ByCopy; + } + + bool isReferenceCapture() const { +return InitExprAndCaptureKind.getInt() == Cap_ByRef; + } + + bool isBlockCapture() const { +return InitExprAndCaptureKind.getInt() == Cap_Block; + } + + bool isVLATypeCapture() const { +return InitExprAndCaptureKind.getInt() == Cap_VLA; + } + + bool isNested() const { +return Var
r326962 - [MS] Accept __unaligned as a qualifier on member function pointers
Author: rnk Date: Wed Mar 7 15:26:02 2018 New Revision: 326962 URL: http://llvm.org/viewvc/llvm-project?rev=326962&view=rev Log: [MS] Accept __unaligned as a qualifier on member function pointers We need to treat __unaligned like the other 'cvr' qualifiers when it appears at the end of a function prototype. We weren't doing that in some tentative parsing. Fixes PR36638. Modified: cfe/trunk/lib/Parse/ParseTentative.cpp cfe/trunk/test/Parser/MicrosoftExtensions.cpp Modified: cfe/trunk/lib/Parse/ParseTentative.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=326962&r1=326961&r2=326962&view=diff == --- cfe/trunk/lib/Parse/ParseTentative.cpp (original) +++ cfe/trunk/lib/Parse/ParseTentative.cpp Wed Mar 7 15:26:02 2018 @@ -1894,7 +1894,8 @@ Parser::TPResult Parser::TryParseFunctio return TPResult::Error; // cv-qualifier-seq - while (Tok.isOneOf(tok::kw_const, tok::kw_volatile, tok::kw_restrict)) + while (Tok.isOneOf(tok::kw_const, tok::kw_volatile, tok::kw___unaligned, + tok::kw_restrict)) ConsumeToken(); // ref-qualifier[opt] Modified: cfe/trunk/test/Parser/MicrosoftExtensions.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/MicrosoftExtensions.cpp?rev=326962&r1=326961&r2=326962&view=diff == --- cfe/trunk/test/Parser/MicrosoftExtensions.cpp (original) +++ cfe/trunk/test/Parser/MicrosoftExtensions.cpp Wed Mar 7 15:26:02 2018 @@ -424,3 +424,10 @@ struct S { S(T); } f([] {}); } + +namespace pr36638 { +// Make sure we accept __unaligned method qualifiers on member function +// pointers. +struct A; +void (A::*mp1)(int) __unaligned; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r326965 - [Sema] Make getCurFunction() return null outside function parsing
Author: rnk Date: Wed Mar 7 16:14:34 2018 New Revision: 326965 URL: http://llvm.org/viewvc/llvm-project?rev=326965&view=rev Log: [Sema] Make getCurFunction() return null outside function parsing Summary: Before this patch, Sema pre-allocated a FunctionScopeInfo and kept it in the first, always present element of the FunctionScopes stack. This meant that Sema::getCurFunction would return a pointer to this pre-allocated object when parsing code outside a function body. This is pretty much always a bug, so this patch moves the pre-allocated object into a separate unique_ptr. This should make bugs like PR36536 a lot more obvious. As you can see from this patch, there were a number of places that unconditionally assumed they were always called inside a function. However, there are also many places that null checked the result of getCurFunction(), so I think this is a reasonable direction. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D44039 Modified: cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp cfe/trunk/lib/Sema/Sema.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/lib/Sema/SemaStmt.cpp cfe/trunk/lib/Sema/SemaStmtAsm.cpp Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=326965&r1=326964&r2=326965&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Wed Mar 7 16:14:34 2018 @@ -528,12 +528,10 @@ public: /// full expression. llvm::SmallPtrSet MaybeODRUseExprs; + std::unique_ptr PreallocatedFunctionScope; + /// \brief Stack containing information about each of the nested /// function, block, and method scopes that are currently active. - /// - /// This array is never empty. Clients should ignore the first - /// element, which is used to cache a single FunctionScopeInfo - /// that's used to parse every top-level function. SmallVector FunctionScopes; typedef LazyVectorhttp://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=326965&r1=326964&r2=326965&view=diff == --- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original) +++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Wed Mar 7 16:14:34 2018 @@ -632,18 +632,19 @@ struct CheckFallThroughDiagnostics { } // anonymous namespace -/// CheckFallThroughForFunctionDef - Check that we don't fall off the end of a +/// CheckFallThroughForBody - Check that we don't fall off the end of a /// function that should return a value. Check that we don't fall off the end /// of a noreturn function. We assume that functions and blocks not marked /// noreturn will return. static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body, const BlockExpr *blkExpr, -const CheckFallThroughDiagnostics& CD, -AnalysisDeclContext &AC) { +const CheckFallThroughDiagnostics &CD, +AnalysisDeclContext &AC, +sema::FunctionScopeInfo *FSI) { bool ReturnsVoid = false; bool HasNoReturn = false; - bool IsCoroutine = S.getCurFunction() && S.getCurFunction()->isCoroutine(); + bool IsCoroutine = FSI->isCoroutine(); if (const auto *FD = dyn_cast(D)) { if (const auto *CBody = dyn_cast(Body)) @@ -675,7 +676,7 @@ static void CheckFallThroughForBody(Sema SourceLocation LBrace = Body->getLocStart(), RBrace = Body->getLocEnd(); auto EmitDiag = [&](SourceLocation Loc, unsigned DiagID) { if (IsCoroutine) - S.Diag(Loc, DiagID) << S.getCurFunction()->CoroutinePromise->getType(); + S.Diag(Loc, DiagID) << FSI->CoroutinePromise->getType(); else S.Diag(Loc, DiagID); }; @@ -2143,7 +2144,7 @@ AnalysisBasedWarnings::IssueWarnings(sem : (fscope->isCoroutine() ? CheckFallThroughDiagnostics::MakeForCoroutine(D) : CheckFallThroughDiagnostics::MakeForFunction(D))); -CheckFallThroughForBody(S, D, Body, blkExpr, CD, AC); +CheckFallThroughForBody(S, D, Body, blkExpr, CD, AC, fscope); } // Warning: check for unreachable code Modified: cfe/trunk/lib/Sema/Sema.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=326965&r1=326964&r2=326965&view=diff == --- cfe/trunk/lib/Sema/Sema.cpp (original) +++ cfe/trunk/lib/Sema/Sema.cpp Wed Mar 7 16:14:34 2018 @@ -162,7 +162,7 @@ Sema::Sema(Preprocessor &pp, ASTCont
r326971 - [MS] Pass CVRU qualifiers properly in Itanium mangler
Author: rnk Date: Wed Mar 7 16:55:09 2018 New Revision: 326971 URL: http://llvm.org/viewvc/llvm-project?rev=326971&view=rev Log: [MS] Pass CVRU qualifiers properly in Itanium mangler We already have a mangling for the __unaligned qualifier, we just have to call Qualifiers::getFromCVRUMask instead of getFromCVRMask. PR36638 Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp cfe/trunk/test/CodeGenCXX/pr33080.cpp Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=326971&r1=326970&r2=326971&view=diff == --- cfe/trunk/lib/AST/ItaniumMangle.cpp (original) +++ cfe/trunk/lib/AST/ItaniumMangle.cpp Wed Mar 7 16:55:09 2018 @@ -2688,7 +2688,7 @@ void CXXNameMangler::mangleType(const Fu // Mangle CV-qualifiers, if present. These are 'this' qualifiers, // e.g. "const" in "int (A::*)() const". - mangleQualifiers(Qualifiers::fromCVRMask(T->getTypeQuals())); + mangleQualifiers(Qualifiers::fromCVRUMask(T->getTypeQuals())); // Mangle instantiation-dependent exception-specification, if present, // per cxx-abi-dev proposal on 2016-10-11. Modified: cfe/trunk/test/CodeGenCXX/pr33080.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/pr33080.cpp?rev=326971&r1=326970&r2=326971&view=diff == --- cfe/trunk/test/CodeGenCXX/pr33080.cpp (original) +++ cfe/trunk/test/CodeGenCXX/pr33080.cpp Wed Mar 7 16:55:09 2018 @@ -21,6 +21,10 @@ void hb(__unaligned struct A *, __unalig void ja(__unaligned struct A *, __unaligned struct A *__unaligned *, __unaligned struct A *__unaligned *__unaligned *) {} // CHECK: define {{(dso_local )?}}void @_Z2jaPU11__unaligned1APU11__unalignedS1_PU11__unalignedS3_( +struct A; +void memptr(void (A::*a)(int) __unaligned) {} +// CHECK: define {{.*}} @_Z6memptrM1AU11__unalignedFviE( + void jb(__unaligned struct A *, __unaligned struct A **, __unaligned struct A *__unaligned *__unaligned *) {} // CHECK: @_Z2jbPU11__unaligned1APS1_PU11__unalignedPU11__unalignedS1_( ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r326974 - Revert "[Sema] Make getCurFunction() return null outside function parsing"
Author: rnk Date: Wed Mar 7 17:12:22 2018 New Revision: 326974 URL: http://llvm.org/viewvc/llvm-project?rev=326974&view=rev Log: Revert "[Sema] Make getCurFunction() return null outside function parsing" This reverts r326965. It seems to have caused repeating test failures in clang/test/Sema/diagnose_if.c on some buildbots. I cannot reproduce the problem, and it's not immediately obvious what the problem is, so let's revert to green. Modified: cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp cfe/trunk/lib/Sema/Sema.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/lib/Sema/SemaStmt.cpp cfe/trunk/lib/Sema/SemaStmtAsm.cpp Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=326974&r1=326973&r2=326974&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Wed Mar 7 17:12:22 2018 @@ -528,10 +528,12 @@ public: /// full expression. llvm::SmallPtrSet MaybeODRUseExprs; - std::unique_ptr PreallocatedFunctionScope; - /// \brief Stack containing information about each of the nested /// function, block, and method scopes that are currently active. + /// + /// This array is never empty. Clients should ignore the first + /// element, which is used to cache a single FunctionScopeInfo + /// that's used to parse every top-level function. SmallVector FunctionScopes; typedef LazyVectorhttp://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=326974&r1=326973&r2=326974&view=diff == --- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original) +++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Wed Mar 7 17:12:22 2018 @@ -632,19 +632,18 @@ struct CheckFallThroughDiagnostics { } // anonymous namespace -/// CheckFallThroughForBody - Check that we don't fall off the end of a +/// CheckFallThroughForFunctionDef - Check that we don't fall off the end of a /// function that should return a value. Check that we don't fall off the end /// of a noreturn function. We assume that functions and blocks not marked /// noreturn will return. static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body, const BlockExpr *blkExpr, -const CheckFallThroughDiagnostics &CD, -AnalysisDeclContext &AC, -sema::FunctionScopeInfo *FSI) { +const CheckFallThroughDiagnostics& CD, +AnalysisDeclContext &AC) { bool ReturnsVoid = false; bool HasNoReturn = false; - bool IsCoroutine = FSI->isCoroutine(); + bool IsCoroutine = S.getCurFunction() && S.getCurFunction()->isCoroutine(); if (const auto *FD = dyn_cast(D)) { if (const auto *CBody = dyn_cast(Body)) @@ -676,7 +675,7 @@ static void CheckFallThroughForBody(Sema SourceLocation LBrace = Body->getLocStart(), RBrace = Body->getLocEnd(); auto EmitDiag = [&](SourceLocation Loc, unsigned DiagID) { if (IsCoroutine) - S.Diag(Loc, DiagID) << FSI->CoroutinePromise->getType(); + S.Diag(Loc, DiagID) << S.getCurFunction()->CoroutinePromise->getType(); else S.Diag(Loc, DiagID); }; @@ -2144,7 +2143,7 @@ AnalysisBasedWarnings::IssueWarnings(sem : (fscope->isCoroutine() ? CheckFallThroughDiagnostics::MakeForCoroutine(D) : CheckFallThroughDiagnostics::MakeForFunction(D))); -CheckFallThroughForBody(S, D, Body, blkExpr, CD, AC, fscope); +CheckFallThroughForBody(S, D, Body, blkExpr, CD, AC); } // Warning: check for unreachable code Modified: cfe/trunk/lib/Sema/Sema.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=326974&r1=326973&r2=326974&view=diff == --- cfe/trunk/lib/Sema/Sema.cpp (original) +++ cfe/trunk/lib/Sema/Sema.cpp Wed Mar 7 17:12:22 2018 @@ -162,7 +162,7 @@ Sema::Sema(Preprocessor &pp, ASTContext ExpressionEvaluationContext::PotentiallyEvaluated, 0, CleanupInfo{}, nullptr, false); - PreallocatedFunctionScope.reset(new FunctionScopeInfo(Diags)); + FunctionScopes.push_back(new FunctionScopeInfo(Diags)); // Initilization of data sharing attributes stack for OpenMP InitDataSharingAttributesStack(); @@ -332,11 +332,11 @@ void Sema::Initialize() { Sema::~Sema() { if (VisContext) FreeVisContext(); - // Kill all the active scopes. - for (sema::FunctionScopeInfo *FSI : FunctionScopes) -if (FSI != PreallocatedFun
r327334 - Re-land "[Sema] Make getCurFunction() return null outside function parsing"
Author: rnk Date: Mon Mar 12 14:43:02 2018 New Revision: 327334 URL: http://llvm.org/viewvc/llvm-project?rev=327334&view=rev Log: Re-land "[Sema] Make getCurFunction() return null outside function parsing" This relands r326965. There was a null dereference in typo correction that was triggered in Sema/diagnose_if.c. We are not always in a function scope when doing typo correction. The fix is to add a null check. LLVM's optimizer made it hard to find this bug. I wrote it up in a not-very-well-editted blog post here: http://qinsb.blogspot.com/2018/03/ub-will-delete-your-null-checks.html Modified: cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp cfe/trunk/lib/Sema/Sema.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/lib/Sema/SemaLookup.cpp cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/lib/Sema/SemaStmt.cpp cfe/trunk/lib/Sema/SemaStmtAsm.cpp Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=327334&r1=327333&r2=327334&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Mon Mar 12 14:43:02 2018 @@ -528,12 +528,10 @@ public: /// full expression. llvm::SmallPtrSet MaybeODRUseExprs; + std::unique_ptr PreallocatedFunctionScope; + /// \brief Stack containing information about each of the nested /// function, block, and method scopes that are currently active. - /// - /// This array is never empty. Clients should ignore the first - /// element, which is used to cache a single FunctionScopeInfo - /// that's used to parse every top-level function. SmallVector FunctionScopes; typedef LazyVectorhttp://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=327334&r1=327333&r2=327334&view=diff == --- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original) +++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Mon Mar 12 14:43:02 2018 @@ -632,18 +632,19 @@ struct CheckFallThroughDiagnostics { } // anonymous namespace -/// CheckFallThroughForFunctionDef - Check that we don't fall off the end of a +/// CheckFallThroughForBody - Check that we don't fall off the end of a /// function that should return a value. Check that we don't fall off the end /// of a noreturn function. We assume that functions and blocks not marked /// noreturn will return. static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body, const BlockExpr *blkExpr, -const CheckFallThroughDiagnostics& CD, -AnalysisDeclContext &AC) { +const CheckFallThroughDiagnostics &CD, +AnalysisDeclContext &AC, +sema::FunctionScopeInfo *FSI) { bool ReturnsVoid = false; bool HasNoReturn = false; - bool IsCoroutine = S.getCurFunction() && S.getCurFunction()->isCoroutine(); + bool IsCoroutine = FSI->isCoroutine(); if (const auto *FD = dyn_cast(D)) { if (const auto *CBody = dyn_cast(Body)) @@ -675,7 +676,7 @@ static void CheckFallThroughForBody(Sema SourceLocation LBrace = Body->getLocStart(), RBrace = Body->getLocEnd(); auto EmitDiag = [&](SourceLocation Loc, unsigned DiagID) { if (IsCoroutine) - S.Diag(Loc, DiagID) << S.getCurFunction()->CoroutinePromise->getType(); + S.Diag(Loc, DiagID) << FSI->CoroutinePromise->getType(); else S.Diag(Loc, DiagID); }; @@ -2143,7 +2144,7 @@ AnalysisBasedWarnings::IssueWarnings(sem : (fscope->isCoroutine() ? CheckFallThroughDiagnostics::MakeForCoroutine(D) : CheckFallThroughDiagnostics::MakeForFunction(D))); -CheckFallThroughForBody(S, D, Body, blkExpr, CD, AC); +CheckFallThroughForBody(S, D, Body, blkExpr, CD, AC, fscope); } // Warning: check for unreachable code Modified: cfe/trunk/lib/Sema/Sema.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=327334&r1=327333&r2=327334&view=diff == --- cfe/trunk/lib/Sema/Sema.cpp (original) +++ cfe/trunk/lib/Sema/Sema.cpp Mon Mar 12 14:43:02 2018 @@ -162,7 +162,7 @@ Sema::Sema(Preprocessor &pp, ASTContext ExpressionEvaluationContext::PotentiallyEvaluated, 0, CleanupInfo{}, nullptr, false); - FunctionScopes.push_back(new FunctionScopeInfo(Diags)); + PreallocatedFunctionScope.reset(new FunctionScopeInfo(Diags)); // Initilization of data sharing attributes stack for OpenMP InitDataSharingAttributesStack(); @@ -332,11 +332,11 @@ void Sema::I
r327732 - [MS] Always use base dtors in place of complete/vbase dtors when possible
Author: rnk Date: Fri Mar 16 12:40:50 2018 New Revision: 327732 URL: http://llvm.org/viewvc/llvm-project?rev=327732&view=rev Log: [MS] Always use base dtors in place of complete/vbase dtors when possible Summary: Previously we tried too hard to uphold the fiction that destructor variants work like they do on Itanium throughout the ABI-neutral parts of clang. This lead to MS C++ ABI incompatiblities and other bugs. Now, -mconstructor-aliases will no longer control this ABI detail, and clang -cc1's LLVM IR output will be this much closer to the clang driver's. Based on a patch by Zahira Ammarguellat: https://reviews.llvm.org/D39063 I've tried to move the logic that Zahira added into MicrosoftCXXABI.cpp. There is only one ABI-specific detail sticking out, and that is in CodeGenModule::getAddrOfCXXStructor, where we collapse complete dtors to base dtors in the MS ABI. This fixes PR32990. Reviewers: erichkeane, zahiraam, majnemer, rjmccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D44505 Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp cfe/trunk/lib/CodeGen/CGCXXABI.cpp cfe/trunk/lib/CodeGen/CGCXXABI.h cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp cfe/trunk/test/CodeGenCXX/cxx2a-destroying-delete.cpp cfe/trunk/test/CodeGenCXX/debug-info-ms-dtor-thunks.cpp cfe/trunk/test/CodeGenCXX/dllexport-dtor-thunks.cpp cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp cfe/trunk/test/CodeGenCXX/inheriting-constructor.cpp cfe/trunk/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp cfe/trunk/test/CodeGenCXX/microsoft-abi-methods.cpp cfe/trunk/test/CodeGenCXX/regcall.cpp cfe/trunk/test/CodeGenCoroutines/coro-eh-cleanup.cpp cfe/trunk/test/CodeGenCoroutines/coro-promise-dtor.cpp cfe/trunk/test/CodeGenCoroutines/coro-unhandled-exception.cpp Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=327732&r1=327731&r2=327732&view=diff == --- cfe/trunk/lib/CodeGen/CGCXX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCXX.cpp Fri Mar 16 12:40:50 2018 @@ -242,6 +242,11 @@ llvm::Constant *CodeGenModule::getAddrOf if (auto *CD = dyn_cast(MD)) { GD = GlobalDecl(CD, toCXXCtorType(Type)); } else { +// Always alias equivalent complete destructors to base destructors in the +// MS ABI. +if (getTarget().getCXXABI().isMicrosoft() && +Type == StructorType::Complete && MD->getParent()->getNumVBases() == 0) + Type = StructorType::Base; GD = GlobalDecl(cast(MD), toCXXDtorType(Type)); } Modified: cfe/trunk/lib/CodeGen/CGCXXABI.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXXABI.cpp?rev=327732&r1=327731&r2=327732&view=diff == --- cfe/trunk/lib/CodeGen/CGCXXABI.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCXXABI.cpp Fri Mar 16 12:40:50 2018 @@ -287,6 +287,20 @@ CGCXXABI::EmitCtorCompleteObjectHandler( return nullptr; } +void CGCXXABI::setCXXDestructorDLLStorage(llvm::GlobalValue *GV, + const CXXDestructorDecl *Dtor, + CXXDtorType DT) const { + // Assume the base C++ ABI has no special rules for destructor variants. + CGM.setDLLImportDLLExport(GV, Dtor); +} + +llvm::GlobalValue::LinkageTypes CGCXXABI::getCXXDestructorLinkage( +GVALinkage Linkage, const CXXDestructorDecl *Dtor, CXXDtorType DT) const { + // Delegate back to CGM by default. + return CGM.getLLVMLinkageForDeclarator(Dtor, Linkage, + /*isConstantVariable=*/false); +} + bool CGCXXABI::NeedsVTTParameter(GlobalDecl GD) { return false; } Modified: cfe/trunk/lib/CodeGen/CGCXXABI.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXXABI.h?rev=327732&r1=327731&r2=327732&view=diff == --- cfe/trunk/lib/CodeGen/CGCXXABI.h (original) +++ cfe/trunk/lib/CodeGen/CGCXXABI.h Fri Mar 16 12:40:50 2018 @@ -319,6 +319,14 @@ public: virtual bool useThunkForDtorVariant(const CXXDestructorDecl *Dtor, CXXDtorType DT) const = 0; + virtual void setCXXDestructorDLLStorage(llvm::GlobalValue *GV, + const CXXDestructorDecl *Dtor, + CXXDtorType DT) const; + + virtual llvm::GlobalValue::LinkageTypes + getCXXDestructorLinkage(GVALinkage Linkage, const CXXDestructorDecl *Dtor, + CXXDtorType DT) const; + /// Emit destructor variants required by this ABI. virtual void EmitCXXDestructors(const CXXDestructorDecl *D) = 0; Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: htt
r327739 - [MS] Commit some changes that were intended to be part of r327738
Author: rnk Date: Fri Mar 16 13:37:59 2018 New Revision: 327739 URL: http://llvm.org/viewvc/llvm-project?rev=327739&view=rev Log: [MS] Commit some changes that were intended to be part of r327738 Modified: cfe/trunk/test/CodeGenCXX/regcall.cpp Modified: cfe/trunk/test/CodeGenCXX/regcall.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/regcall.cpp?rev=327739&r1=327738&r2=327739&view=diff == --- cfe/trunk/test/CodeGenCXX/regcall.cpp (original) +++ cfe/trunk/test/CodeGenCXX/regcall.cpp Fri Mar 16 13:37:59 2018 @@ -76,8 +76,8 @@ bool __regcall operator ==(const test_cl test_class __regcall operator""_test_class (unsigned long long) { ++x; return test_class{};} // CHECK-LIN64-DAG: define x86_regcallcc void @_Zli11_test_classy(%class.test_class* noalias sret %agg.result, i64) // CHECK-LIN32-DAG: define x86_regcallcc void @_Zli11_test_classy(%class.test_class* inreg noalias sret %agg.result, i64) -// CHECK-WIN64-DAG: \01??__K_test_class@@Yw?AVtest_class@@_K@Z" -// CHECK-WIN32-DAG: \01??__K_test_class@@Yw?AVtest_class@@_K@Z" +// CHECK-WIN64-DAG: ??__K_test_class@@Yw?AVtest_class@@_K@Z" +// CHECK-WIN32-DAG: ??__K_test_class@@Yw?AVtest_class@@_K@Z" template void __regcall freeTempFunc(T i){} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r327741 - [MS] Fix tests after r327738 that only fail with a default Windows target
Author: rnk Date: Fri Mar 16 13:53:13 2018 New Revision: 327741 URL: http://llvm.org/viewvc/llvm-project?rev=327741&view=rev Log: [MS] Fix tests after r327738 that only fail with a default Windows target Modified: cfe/trunk/test/CodeGenCXX/trap-fnattr.cpp cfe/trunk/test/PCH/chain-openmp-threadprivate.cpp Modified: cfe/trunk/test/CodeGenCXX/trap-fnattr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/trap-fnattr.cpp?rev=327741&r1=327740&r2=327741&view=diff == --- cfe/trunk/test/CodeGenCXX/trap-fnattr.cpp (original) +++ cfe/trunk/test/CodeGenCXX/trap-fnattr.cpp Fri Mar 16 13:53:13 2018 @@ -1,29 +1,29 @@ // RUN: %clang_cc1 -O0 -emit-llvm -ftrapv -ftrap-function=mytrap %s -o - | FileCheck %s -check-prefix=TRAPFUNC // RUN: %clang_cc1 -O0 -emit-llvm -ftrapv %s -o - | FileCheck %s -check-prefix=NOOPTION -// TRAPFUNC-LABEL: define {{(dso_local )?}}void @{{_Z12test_builtinv|\"\\01\?test_builtin@@YAXXZ\"}} +// TRAPFUNC-LABEL: define {{(dso_local )?}}void @{{_Z12test_builtinv|\"\?test_builtin@@YAXXZ\"}} // TRAPFUNC: call void @llvm.trap() [[ATTR0:#[0-9]+]] -// NOOPTION-LABEL: define {{(dso_local )?}}void @{{_Z12test_builtinv|\"\\01\?test_builtin@@YAXXZ\"}} +// NOOPTION-LABEL: define {{(dso_local )?}}void @{{_Z12test_builtinv|\"\?test_builtin@@YAXXZ\"}} // NOOPTION: call void @llvm.trap(){{$}} void test_builtin(void) { __builtin_trap(); } -// TRAPFUNC-LABEL: define {{.*}}i32 @{{_Z13test_noreturnv|\"\\01\?test_noreturn@@YAHXZ\"}} +// TRAPFUNC-LABEL: define {{.*}}i32 @{{_Z13test_noreturnv|\"\?test_noreturn@@YAHXZ\"}} // TRAPFUNC: call void @llvm.trap() [[ATTR0]] -// NOOPTION-LABEL: define {{.*}}i32 @{{_Z13test_noreturnv|\"\\01\?test_noreturn@@YAHXZ\"}} +// NOOPTION-LABEL: define {{.*}}i32 @{{_Z13test_noreturnv|\"\?test_noreturn@@YAHXZ\"}} // NOOPTION: call void @llvm.trap(){{$}} int test_noreturn(void) { } -// TRAPFUNC-LABEL: define {{.*}}i32 @{{_Z17test_add_overflowii|\"\\01\?test_add_overflow@@YAHHH@Z\"}} +// TRAPFUNC-LABEL: define {{.*}}i32 @{{_Z17test_add_overflowii|\"\?test_add_overflow@@YAHHH@Z\"}} // TRAPFUNC: call void @llvm.trap() [[ATTR1:#[0-9]+]] -// NOOPTION-LABEL: define {{.*}}i32 @{{_Z17test_add_overflowii|\"\\01\?test_add_overflow@@YAHHH@Z\"}} +// NOOPTION-LABEL: define {{.*}}i32 @{{_Z17test_add_overflowii|\"\?test_add_overflow@@YAHHH@Z\"}} // NOOPTION: call void @llvm.trap() [[ATTR2:#[0-9]+]] int test_add_overflow(int a, int b) { Modified: cfe/trunk/test/PCH/chain-openmp-threadprivate.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/chain-openmp-threadprivate.cpp?rev=327741&r1=327740&r2=327741&view=diff == --- cfe/trunk/test/PCH/chain-openmp-threadprivate.cpp (original) +++ cfe/trunk/test/PCH/chain-openmp-threadprivate.cpp Fri Mar 16 13:53:13 2018 @@ -23,7 +23,7 @@ int *a = malloc(20); #else // CHECK: call {{.*}} @__kmpc_threadprivate_register( -// CHECK-TLS-1: @{{a|\"\\01\?a@@3PE?AHE?A\"}} = {{.*}}thread_local {{.*}}global {{.*}}i32* +// CHECK-TLS-1: @{{a|\"\?a@@3PE?AHE?A\"}} = {{.*}}thread_local {{.*}}global {{.*}}i32* // CHECK-LABEL: foo // CHECK-TLS-LABEL: foo @@ -31,9 +31,9 @@ int foo() { return *a; // CHECK: call {{.*}} @__kmpc_global_thread_num( // CHECK: call {{.*}} @__kmpc_threadprivate_cached( - // CHECK-TLS-1: call {{.*}} @{{_ZTW1a|\"\\01\?\?__Ea@@YAXXZ\"}}() + // CHECK-TLS-1: call {{.*}} @{{_ZTW1a|\"\?\?__Ea@@YAXXZ\"}}() } -// CHECK-TLS-2: define {{.*}} @{{_ZTW1a|\"\\01\?\?__Ea@@YAXXZ\"}}() +// CHECK-TLS-2: define {{.*}} @{{_ZTW1a|\"\?\?__Ea@@YAXXZ\"}}() #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r327754 - [MS] Fix bug in r327732 with devirtualized complete destructor calls
Author: rnk Date: Fri Mar 16 15:20:57 2018 New Revision: 327754 URL: http://llvm.org/viewvc/llvm-project?rev=327754&view=rev Log: [MS] Fix bug in r327732 with devirtualized complete destructor calls Added: cfe/trunk/test/CodeGenCXX/devirtualize-ms-dtor.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=327754&r1=327753&r2=327754&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Mar 16 15:20:57 2018 @@ -2550,6 +2550,16 @@ llvm::Constant *CodeGenModule::GetAddrOf Ty = getTypes().ConvertFunctionType(CanonTy, FD); } + // Devirtualized destructor calls may come through here instead of via + // getAddrOfCXXStructor. Make sure we use the MS ABI base destructor instead + // of the complete destructor when necessary. + if (const auto *DD = dyn_cast(GD.getDecl())) { +if (getTarget().getCXXABI().isMicrosoft() && +GD.getDtorType() == Dtor_Complete && +DD->getParent()->getNumVBases() == 0) + GD = GlobalDecl(DD, Dtor_Base); + } + StringRef MangledName = getMangledName(GD); return GetOrCreateLLVMFunction(MangledName, Ty, GD, ForVTable, DontDefer, /*IsThunk=*/false, llvm::AttributeList(), Added: cfe/trunk/test/CodeGenCXX/devirtualize-ms-dtor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/devirtualize-ms-dtor.cpp?rev=327754&view=auto == --- cfe/trunk/test/CodeGenCXX/devirtualize-ms-dtor.cpp (added) +++ cfe/trunk/test/CodeGenCXX/devirtualize-ms-dtor.cpp Fri Mar 16 15:20:57 2018 @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -std=c++11 -triple x86_64-windows-msvc %s -emit-llvm -o - | FileCheck %s + +// If we de-virtualize ~Foo, we still need to call ??1Foo, not ??_DFoo. + +struct Base { + virtual ~Base(); +}; +struct Foo final : Base { +}; +void f(Foo *p) { + p->~Foo(); +} + +// CHECK-LABEL: define{{.*}} void @"?f@@YAXPEAUFoo@@@Z"(%struct.Foo* %p) +// CHECK: call void @"??1Foo@@UEAA@XZ" +// CHECK: ret void ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r327738 - [MS] Don't escape MS C++ names with \01
Yes: https://reviews.llvm.org/D7775 This side is very mechanical, so I did not send it for review. On Sun, Mar 18, 2018, 3:54 AM Nico Weber wrote: > Was this discussed or reviewed somewhere? (It looks like a good change to > me, I'm just wondering if there was something that triggered this and would > like to read about the background if there's anything to read.) > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r333680 - Fix null MSInheritanceAttr deref in CXXRecordDecl::getMSInheritanceModel()
Author: rnk Date: Thu May 31 11:42:29 2018 New Revision: 333680 URL: http://llvm.org/viewvc/llvm-project?rev=333680&view=rev Log: Fix null MSInheritanceAttr deref in CXXRecordDecl::getMSInheritanceModel() Ensure latest MPT decl has a MSInheritanceAttr when instantiating templates, to avoid null MSInheritanceAttr deref in CXXRecordDecl::getMSInheritanceModel(). See PR#37399 for repo / details. Patch by Andrew Rogers! Differential Revision: https://reviews.llvm.org/D46664 Modified: cfe/trunk/include/clang/AST/DeclCXX.h cfe/trunk/include/clang/AST/DeclTemplate.h cfe/trunk/lib/AST/MicrosoftMangle.cpp cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp Modified: cfe/trunk/include/clang/AST/DeclCXX.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=333680&r1=333679&r2=333680&view=diff == --- cfe/trunk/include/clang/AST/DeclCXX.h (original) +++ cfe/trunk/include/clang/AST/DeclCXX.h Thu May 31 11:42:29 2018 @@ -751,6 +751,21 @@ public: return const_cast(this)->getMostRecentDecl(); } + CXXRecordDecl *getMostRecentNonInjectedDecl() { +CXXRecordDecl *Recent = +static_cast(this)->getMostRecentDecl(); +while (Recent->isInjectedClassName()) { + // FIXME: Does injected class name need to be in the redeclarations chain? + assert(Recent->getPreviousDecl()); + Recent = Recent->getPreviousDecl(); +} +return Recent; + } + + const CXXRecordDecl *getMostRecentNonInjectedDecl() const { +return const_cast(this)->getMostRecentNonInjectedDecl(); + } + CXXRecordDecl *getDefinition() const { // We only need an update if we don't already know which // declaration is the definition. Modified: cfe/trunk/include/clang/AST/DeclTemplate.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=333680&r1=333679&r2=333680&view=diff == --- cfe/trunk/include/clang/AST/DeclTemplate.h (original) +++ cfe/trunk/include/clang/AST/DeclTemplate.h Thu May 31 11:42:29 2018 @@ -1720,14 +1720,8 @@ public: // it's not clear that we should override that, because the most recent // declaration as a CXXRecordDecl sometimes is the injected-class-name. ClassTemplateSpecializationDecl *getMostRecentDecl() { -CXXRecordDecl *Recent = static_cast( - this)->getMostRecentDecl(); -while (!isa(Recent)) { - // FIXME: Does injected class name need to be in the redeclarations chain? - assert(Recent->isInjectedClassName() && Recent->getPreviousDecl()); - Recent = Recent->getPreviousDecl(); -} -return cast(Recent); +return cast( +getMostRecentNonInjectedDecl()); } /// Retrieve the template that this specialization specializes. Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=333680&r1=333679&r2=333680&view=diff == --- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original) +++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Thu May 31 11:42:29 2018 @@ -1370,12 +1370,12 @@ void MicrosoftCXXNameMangler::mangleTemp const NamedDecl *ND = TA.getAsDecl(); if (isa(ND) || isa(ND)) { mangleMemberDataPointer( - cast(ND->getDeclContext())->getMostRecentDecl(), + cast(ND->getDeclContext())->getMostRecentNonInjectedDecl(), cast(ND)); } else if (const FunctionDecl *FD = dyn_cast(ND)) { const CXXMethodDecl *MD = dyn_cast(FD); if (MD && MD->isInstance()) { -mangleMemberFunctionPointer(MD->getParent()->getMostRecentDecl(), MD); + mangleMemberFunctionPointer(MD->getParent()->getMostRecentNonInjectedDecl(), MD); } else { Out << "$1?"; mangleName(FD); Modified: cfe/trunk/lib/AST/Type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=333680&r1=333679&r2=333680&view=diff == --- cfe/trunk/lib/AST/Type.cpp (original) +++ cfe/trunk/lib/AST/Type.cpp Thu May 31 11:42:29 2018 @@ -2040,7 +2040,7 @@ bool Type::isIncompleteType(NamedDecl ** return false; // The inheritance attribute might only be present on the most recent // CXXRecordDecl, use that one. -RD = RD->getMostRecentDecl(); +RD = RD->getMostRecentNonInjectedDecl(); // Nothing interesting to do if the inheritance attribute is already set. if (RD->hasAttr()) return false; @@ -3936,5 +3936,5 @@ QualType::DestructionKind QualType::isDe } CXXRecordDecl *MemberPointerType::getMostRecentCXXRecordDecl() const { - return getClass()->getAsCXX
r333958 - Revert r333791 "Cap "voluntary" vector alignment at 16 for all Darwin platforms."
Author: rnk Date: Mon Jun 4 14:39:20 2018 New Revision: 333958 URL: http://llvm.org/viewvc/llvm-project?rev=333958&view=rev Log: Revert r333791 "Cap "voluntary" vector alignment at 16 for all Darwin platforms." Adding __attribute__((aligned(32))) to __m256 breaks the implementation of _mm256_loadu_ps on Windows. On Windows, alignment attributes have higher precedence than packing attributes. We also might want to carefully consider the consequences of changing our vector typedefs, since many users copy them and invent their own new, non-Intel specific vector type names. Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h cfe/trunk/lib/Basic/Targets/X86.h cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/Headers/avx512fintrin.h cfe/trunk/lib/Headers/avxintrin.h cfe/trunk/test/CodeGen/arm-swiftcall.c cfe/trunk/test/CodeGen/vector-alignment.c cfe/trunk/test/CodeGenCXX/align-avx-complete-objects.cpp Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=333958&r1=333957&r2=333958&view=diff == --- cfe/trunk/lib/Basic/Targets/OSTargets.h (original) +++ cfe/trunk/lib/Basic/Targets/OSTargets.h Mon Jun 4 14:39:20 2018 @@ -113,9 +113,6 @@ public: } this->MCountName = "\01mcount"; - -// Cap vector alignment at 16 bytes for all Darwin platforms. -this->MaxVectorAlign = 128; } std::string isValidSectionSpecifier(StringRef SR) const override { Modified: cfe/trunk/lib/Basic/Targets/X86.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.h?rev=333958&r1=333957&r2=333958&view=diff == --- cfe/trunk/lib/Basic/Targets/X86.h (original) +++ cfe/trunk/lib/Basic/Targets/X86.h Mon Jun 4 14:39:20 2018 @@ -421,6 +421,7 @@ public: LongDoubleWidth = 128; LongDoubleAlign = 128; SuitableAlign = 128; +MaxVectorAlign = 256; // The watchOS simulator uses the builtin bool type for Objective-C. llvm::Triple T = llvm::Triple(Triple); if (T.isWatchOS()) @@ -436,6 +437,9 @@ public: if (!DarwinTargetInfo::handleTargetFeatures(Features, Diags)) return false; +// We now know the features we have: we can decide how to align vectors. +MaxVectorAlign = +hasFeature("avx512f") ? 512 : hasFeature("avx") ? 256 : 128; return true; } }; @@ -798,6 +802,9 @@ public: if (!DarwinTargetInfo::handleTargetFeatures(Features, Diags)) return false; +// We now know the features we have: we can decide how to align vectors. +MaxVectorAlign = +hasFeature("avx512f") ? 512 : hasFeature("avx") ? 256 : 128; return true; } }; Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=333958&r1=333957&r2=333958&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Jun 4 14:39:20 2018 @@ -8885,20 +8885,18 @@ Value *CodeGenFunction::EmitX86BuiltinEx case X86::BI__builtin_ia32_movdqa64store128_mask: case X86::BI__builtin_ia32_storeaps128_mask: case X86::BI__builtin_ia32_storeapd128_mask: -return EmitX86MaskedStore(*this, Ops, 16); - case X86::BI__builtin_ia32_movdqa32store256_mask: case X86::BI__builtin_ia32_movdqa64store256_mask: case X86::BI__builtin_ia32_storeaps256_mask: case X86::BI__builtin_ia32_storeapd256_mask: -return EmitX86MaskedStore(*this, Ops, 32); - case X86::BI__builtin_ia32_movdqa32store512_mask: case X86::BI__builtin_ia32_movdqa64store512_mask: case X86::BI__builtin_ia32_storeaps512_mask: - case X86::BI__builtin_ia32_storeapd512_mask: -return EmitX86MaskedStore(*this, Ops, 64); - + case X86::BI__builtin_ia32_storeapd512_mask: { +unsigned Align = + getContext().getTypeAlignInChars(E->getArg(1)->getType()).getQuantity(); +return EmitX86MaskedStore(*this, Ops, Align); + } case X86::BI__builtin_ia32_loadups128_mask: case X86::BI__builtin_ia32_loadups256_mask: case X86::BI__builtin_ia32_loadups512_mask: @@ -8919,25 +8917,26 @@ Value *CodeGenFunction::EmitX86BuiltinEx case X86::BI__builtin_ia32_loaddqudi512_mask: return EmitX86MaskedLoad(*this, Ops, 1); - case X86::BI__builtin_ia32_loadaps128_mask: - case X86::BI__builtin_ia32_loadapd128_mask: case X86::BI__builtin_ia32_loadss128_mask: case X86::BI__builtin_ia32_loadsd128_mask: - case X86::BI__builtin_ia32_movdqa32load128_mask: - case X86::BI__builtin_ia32_movdqa64load128_mask: -return EmitX86MaskedLoad(*this, Ops, 16); +return EmitX86MaskedLoad(*this, Ops, 1); + case
r333978 - Reimplement the bittest intrinsic family as builtins with inline asm
Author: rnk Date: Mon Jun 4 18:33:40 2018 New Revision: 333978 URL: http://llvm.org/viewvc/llvm-project?rev=333978&view=rev Log: Reimplement the bittest intrinsic family as builtins with inline asm We need to implement _interlockedbittestandset as a builtin for windows.h, so we might as well do the whole family. It reduces code duplication anyway. Fixes PR33188, a long standing bug in our bittest implementation encountered by Chakra. Added: cfe/trunk/test/CodeGen/bittest-intrin.c Modified: cfe/trunk/include/clang/Basic/Builtins.def cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/Headers/intrin.h cfe/trunk/test/CodeGen/ms-intrinsics-other.c cfe/trunk/test/CodeGen/ms-intrinsics.c Modified: cfe/trunk/include/clang/Basic/Builtins.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=333978&r1=333977&r2=333978&view=diff == --- cfe/trunk/include/clang/Basic/Builtins.def (original) +++ cfe/trunk/include/clang/Basic/Builtins.def Mon Jun 4 18:33:40 2018 @@ -744,6 +744,14 @@ BUILTIN(__builtin_rindex, "c*cC*i", "Fn" LANGBUILTIN(_alloca, "v*z", "n", ALL_MS_LANGUAGES) LANGBUILTIN(__annotation, "wC*.","n", ALL_MS_LANGUAGES) LANGBUILTIN(__assume, "vb", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_bittest,"UcNiC*Ni", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_bittestandcomplement, "UcNi*Ni", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_bittestandreset,"UcNi*Ni", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_bittestandset, "UcNi*Ni", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_bittest64, "UcWiC*Wi", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_bittestandcomplement64, "UcWi*Wi", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_bittestandreset64, "UcWi*Wi", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_bittestandset64,"UcWi*Wi", "n", ALL_MS_LANGUAGES) LIBBUILTIN(_byteswap_ushort, "UsUs", "fnc", "stdlib.h", ALL_MS_LANGUAGES) LIBBUILTIN(_byteswap_ulong, "UNiUNi", "fnc", "stdlib.h", ALL_MS_LANGUAGES) LIBBUILTIN(_byteswap_uint64, "ULLiULLi", "fnc", "stdlib.h", ALL_MS_LANGUAGES) @@ -783,7 +791,10 @@ LANGBUILTIN(_InterlockedOr, "NiNiD*Ni" LANGBUILTIN(_InterlockedXor8, "ccD*c", "n", ALL_MS_LANGUAGES) LANGBUILTIN(_InterlockedXor16, "ssD*s", "n", ALL_MS_LANGUAGES) LANGBUILTIN(_InterlockedXor, "NiNiD*Ni","n", ALL_MS_LANGUAGES) -LANGBUILTIN(_interlockedbittestandset, "UcNiD*Ni", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_interlockedbittestandreset, "UcNiD*Ni", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_interlockedbittestandreset64, "UcWiD*Wi", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_interlockedbittestandset, "UcNiD*Ni", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_interlockedbittestandset64, "UcWiD*Wi", "n", ALL_MS_LANGUAGES) LANGBUILTIN(__noop, "i.", "n", ALL_MS_LANGUAGES) LANGBUILTIN(__popcnt16, "UsUs", "nc", ALL_MS_LANGUAGES) LANGBUILTIN(__popcnt, "UiUi", "nc", ALL_MS_LANGUAGES) Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=333978&r1=333977&r2=333978&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Jun 4 18:33:40 2018 @@ -484,6 +484,37 @@ CodeGenFunction::emitBuiltinObjectSize(c return Builder.CreateCall(F, {Ptr, Min, NullIsUnknown}); } +static RValue EmitBitTestIntrinsic(CodeGenFunction &CGF, const CallExpr *E, + char TestAnd, char Size, + bool Locked = false) { + Value *BitBase = CGF.EmitScalarExpr(E->getArg(0)); + Value *BitPos = CGF.EmitScalarExpr(E->getArg(1)); + + // Build the assembly. + SmallString<64> Asm; + raw_svector_ostream AsmOS(Asm); + if (Locked) +AsmOS << "lock "; + AsmOS << "bt"; + if (TestAnd) +AsmOS << TestAnd; + AsmOS << Size << " $2, ($1)\n\tsetc ${0:b}"; + + // Build the constraints. FIXME: We should support immediates when possible. + std::string Constraints = "=r,r,r,~{cc},~{flags},~{memory},~{fpsr}"; + llvm::IntegerType *IntType = llvm::IntegerType::get( + CGF.getLLVMContext(), + CGF.getContext().getTypeSize(E->getArg(1)->getType())); + llvm::Type *IntPtrType = IntType->getPointerTo(); + llvm::FunctionType *FTy = + llvm::FunctionType::get(CGF.Int8Ty, {IntPtrType, IntType}, false); + + llvm::InlineAsm *IA = + llvm::InlineAsm::get(FTy, Asm, Constraints, /*SideEffects=*/true); + CallSite CS = CGF.Builder.CreateCall(IA, {BitBase, BitPos}); + return RValue::get(CS.getInstruction()); +} + // Many of MSVC builtins are on both x64 and ARM; to avoid repeating code, we // handle them here. enum class CodeGenFunction::MSVCIntrin { @@ -497,7 +528,6 @@ enum class CodeGenFunction::MSVCIntrin { _InterlockedIncrement, _InterlockedOr, _InterlockedXor, - _interlockedbittestandse
Re: r333978 - Reimplement the bittest intrinsic family as builtins with inline asm
On Tue, Jun 5, 2018 at 2:33 AM Martin Storsjö wrote: > > // Many of MSVC builtins are on both x64 and ARM; to avoid repeating > code, we > > // handle them here. > > This doesn't seem thought through wrt non-x86 architectures. I'm not sure > if there's any similar suitable instruction to use on ARM/AArch64, but we > should at the very least fall back to doing whatever we did before this > change for anything not x86. > I'll go back and take a look, but I'm not convinced that what we did before was correct for ARM either. I'm installing the Visual C++ aarch64 compiler now so I can make sure we get it right. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r334059 - Implement bittest intrinsics generically for non-x86 platforms
Author: rnk Date: Tue Jun 5 18:35:08 2018 New Revision: 334059 URL: http://llvm.org/viewvc/llvm-project?rev=334059&view=rev Log: Implement bittest intrinsics generically for non-x86 platforms I tested these locally on an x86 machine by disabling the inline asm codepath and confirming that it does the same bitflips as we do with the inline asm. Addresses code review feedback. Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGen/bittest-intrin.c Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=334059&r1=334058&r2=334059&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Jun 5 18:35:08 2018 @@ -484,11 +484,48 @@ CodeGenFunction::emitBuiltinObjectSize(c return Builder.CreateCall(F, {Ptr, Min, NullIsUnknown}); } -static RValue EmitBitTestIntrinsic(CodeGenFunction &CGF, const CallExpr *E, - char TestAnd, char Size, - bool Locked = false) { - Value *BitBase = CGF.EmitScalarExpr(E->getArg(0)); - Value *BitPos = CGF.EmitScalarExpr(E->getArg(1)); +// Get properties of an X86 BT* assembly instruction. The first returned value +// is the action character code, which can be for complement, reset, or set. The +// second is the size suffix which our assembler needs. The last is whether to +// add the lock prefix. +static std::tuple +getBitTestActionSizeAndLocking(unsigned BuiltinID) { + switch (BuiltinID) { + case Builtin::BI_bittest: +return {'\0', 'l', false}; + case Builtin::BI_bittestandcomplement: +return {'c', 'l', false}; + case Builtin::BI_bittestandreset: +return {'r', 'l', false}; + case Builtin::BI_bittestandset: +return {'s', 'l', false}; + case Builtin::BI_interlockedbittestandreset: +return {'r', 'l', /*Locked=*/true}; + case Builtin::BI_interlockedbittestandset: +return {'s', 'l', /*Locked=*/true}; + + case Builtin::BI_bittest64: +return {'\0', 'q', false}; + case Builtin::BI_bittestandcomplement64: +return {'c', 'q', false}; + case Builtin::BI_bittestandreset64: +return {'r', 'q', false}; + case Builtin::BI_bittestandset64: +return {'s', 'q', false}; + case Builtin::BI_interlockedbittestandreset64: +return {'r', 'q', /*Locked=*/true}; + case Builtin::BI_interlockedbittestandset64: +return {'s', 'q', /*Locked=*/true}; + } + llvm_unreachable("expected only bittest builtins"); +} + +static RValue EmitX86BitTestIntrinsic(CodeGenFunction &CGF, unsigned BuiltinID, + const CallExpr *E, Value *BitBase, + Value *BitPos) { + char Action, Size; + bool Locked; + std::tie(Action, Size, Locked) = getBitTestActionSizeAndLocking(BuiltinID); // Build the assembly. SmallString<64> Asm; @@ -496,12 +533,12 @@ static RValue EmitBitTestIntrinsic(CodeG if (Locked) AsmOS << "lock "; AsmOS << "bt"; - if (TestAnd) -AsmOS << TestAnd; + if (Action) +AsmOS << Action; AsmOS << Size << " $2, ($1)\n\tsetc ${0:b}"; // Build the constraints. FIXME: We should support immediates when possible. - std::string Constraints = "=r,r,r,~{cc},~{flags},~{memory},~{fpsr}"; + std::string Constraints = "=r,r,r,~{cc},~{flags},~{fpsr}"; llvm::IntegerType *IntType = llvm::IntegerType::get( CGF.getLLVMContext(), CGF.getContext().getTypeSize(E->getArg(1)->getType())); @@ -515,6 +552,97 @@ static RValue EmitBitTestIntrinsic(CodeG return RValue::get(CS.getInstruction()); } +/// Emit a _bittest* intrinsic. These intrinsics take a pointer to an array of +/// bits and a bit position and read and optionally modify the bit at that +/// position. The position index can be arbitrarily large, i.e. it can be larger +/// than 31 or 63, so we need an indexed load in the general case. +static RValue EmitBitTestIntrinsic(CodeGenFunction &CGF, unsigned BuiltinID, + const CallExpr *E) { + Value *BitBase = CGF.EmitScalarExpr(E->getArg(0)); + Value *BitPos = CGF.EmitScalarExpr(E->getArg(1)); + + // X86 has special BT, BTC, BTR, and BTS instructions that handle the array + // indexing operation internally. Use them if possible. + llvm::Triple::ArchType Arch = CGF.getTarget().getTriple().getArch(); + if (Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64) +return EmitX86BitTestIntrinsic(CGF, BuiltinID, E, BitBase, BitPos); + + // Otherwise, use generic code to load one byte and test the bit. Use all but + // the bottom three bits as the array index, and the bottom three bits to form + // a mask. + // Bit = BitBaseI8[BitPos >> 3] & (1 << (BitPos & 0x7)) != 0; + Value *ByteIndex = CGF.Builder.CreateAShr( + BitPos, llvm::ConstantInt::get(BitPos->getType(), 3), "bittest.byteidx"); + Value *BitBaseI8 = CGF.B
r334060 - Fix std::tuple errors
Author: rnk Date: Tue Jun 5 18:44:10 2018 New Revision: 334060 URL: http://llvm.org/viewvc/llvm-project?rev=334060&view=rev Log: Fix std::tuple errors Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=334060&r1=334059&r2=334060&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Jun 5 18:44:10 2018 @@ -492,30 +492,30 @@ static std::tuple getBitTestActionSizeAndLocking(unsigned BuiltinID) { switch (BuiltinID) { case Builtin::BI_bittest: -return {'\0', 'l', false}; +return std::make_tuple('\0', 'l', false); case Builtin::BI_bittestandcomplement: -return {'c', 'l', false}; +return std::make_tuple('c', 'l', false); case Builtin::BI_bittestandreset: -return {'r', 'l', false}; +return std::make_tuple('r', 'l', false); case Builtin::BI_bittestandset: -return {'s', 'l', false}; +return std::make_tuple('s', 'l', false); case Builtin::BI_interlockedbittestandreset: -return {'r', 'l', /*Locked=*/true}; +return std::make_tuple('r', 'l', /*Locked=*/true); case Builtin::BI_interlockedbittestandset: -return {'s', 'l', /*Locked=*/true}; +return std::make_tuple('s', 'l', /*Locked=*/true); case Builtin::BI_bittest64: -return {'\0', 'q', false}; +return std::make_tuple('\0', 'q', false); case Builtin::BI_bittestandcomplement64: -return {'c', 'q', false}; +return std::make_tuple('c', 'q', false); case Builtin::BI_bittestandreset64: -return {'r', 'q', false}; +return std::make_tuple('r', 'q', false); case Builtin::BI_bittestandset64: -return {'s', 'q', false}; +return std::make_tuple('s', 'q', false); case Builtin::BI_interlockedbittestandreset64: -return {'r', 'q', /*Locked=*/true}; +return std::make_tuple('r', 'q', /*Locked=*/true); case Builtin::BI_interlockedbittestandset64: -return {'s', 'q', /*Locked=*/true}; +return std::make_tuple('s', 'q', /*Locked=*/true); } llvm_unreachable("expected only bittest builtins"); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r334112 - [MS][ARM64]: Promote _setjmp to_setjmpex as there is no _setjmp in the ARM64 libvcruntime.lib
Author: rnk Date: Wed Jun 6 11:39:47 2018 New Revision: 334112 URL: http://llvm.org/viewvc/llvm-project?rev=334112&view=rev Log: [MS][ARM64]: Promote _setjmp to_setjmpex as there is no _setjmp in the ARM64 libvcruntime.lib Factor out the common setjmp call emission code. Based on a patch by Chris January Differential Revision: https://reviews.llvm.org/D47784 Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGen/ms-setjmp.c Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=334112&r1=334111&r2=334112&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Jun 6 11:39:47 2018 @@ -643,6 +643,52 @@ static RValue EmitBitTestIntrinsic(CodeG ShiftedByte, llvm::ConstantInt::get(CGF.Int8Ty, 1), "bittest.res")); } +namespace { +enum class MSVCSetJmpKind { + _setjmpex, + _setjmp3, + _setjmp +}; +} + +/// MSVC handles setjmp a bit differently on different platforms. On every +/// architecture except 32-bit x86, the frame address is passed. On x86, extra +/// parameters can be passed as variadic arguments, but we always pass none. +static RValue EmitMSVCRTSetJmp(CodeGenFunction &CGF, MSVCSetJmpKind SJKind, + const CallExpr *E) { + llvm::Value *Arg1 = nullptr; + llvm::Type *Arg1Ty = nullptr; + StringRef Name; + bool IsVarArg = false; + if (SJKind == MSVCSetJmpKind::_setjmp3) { +Name = "_setjmp3"; +Arg1Ty = CGF.Int32Ty; +Arg1 = llvm::ConstantInt::get(CGF.IntTy, 0); +IsVarArg = true; + } else { +Name = SJKind == MSVCSetJmpKind::_setjmp ? "_setjmp" : "_setjmpex"; +Arg1Ty = CGF.Int8PtrTy; +Arg1 = CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(Intrinsic::frameaddress), + llvm::ConstantInt::get(CGF.Int32Ty, 0)); + } + + // Mark the call site and declaration with ReturnsTwice. + llvm::Type *ArgTypes[2] = {CGF.Int8PtrTy, Arg1Ty}; + llvm::AttributeList ReturnsTwiceAttr = llvm::AttributeList::get( + CGF.getLLVMContext(), llvm::AttributeList::FunctionIndex, + llvm::Attribute::ReturnsTwice); + llvm::Constant *SetJmpFn = CGF.CGM.CreateRuntimeFunction( + llvm::FunctionType::get(CGF.IntTy, ArgTypes, IsVarArg), Name, + ReturnsTwiceAttr, /*Local=*/true); + + llvm::Value *Buf = CGF.Builder.CreateBitOrPointerCast( + CGF.EmitScalarExpr(E->getArg(0)), CGF.Int8PtrTy); + llvm::Value *Args[] = {Buf, Arg1}; + llvm::CallSite CS = CGF.EmitRuntimeCallOrInvoke(SetJmpFn, Args); + CS.setAttributes(ReturnsTwiceAttr); + return RValue::get(CS.getInstruction()); +} + // Many of MSVC builtins are on both x64 and ARM; to avoid repeating code, we // handle them here. enum class CodeGenFunction::MSVCIntrin { @@ -2957,59 +3003,19 @@ RValue CodeGenFunction::EmitBuiltinExpr( case Builtin::BI__abnormal_termination: case Builtin::BI_abnormal_termination: return RValue::get(EmitSEHAbnormalTermination()); - case Builtin::BI_setjmpex: { -if (getTarget().getTriple().isOSMSVCRT()) { - llvm::Type *ArgTypes[] = {Int8PtrTy, Int8PtrTy}; - llvm::AttributeList ReturnsTwiceAttr = llvm::AttributeList::get( - getLLVMContext(), llvm::AttributeList::FunctionIndex, - llvm::Attribute::ReturnsTwice); - llvm::Constant *SetJmpEx = CGM.CreateRuntimeFunction( - llvm::FunctionType::get(IntTy, ArgTypes, /*isVarArg=*/false), - "_setjmpex", ReturnsTwiceAttr, /*Local=*/true); - llvm::Value *Buf = Builder.CreateBitOrPointerCast( - EmitScalarExpr(E->getArg(0)), Int8PtrTy); - llvm::Value *FrameAddr = - Builder.CreateCall(CGM.getIntrinsic(Intrinsic::frameaddress), - ConstantInt::get(Int32Ty, 0)); - llvm::Value *Args[] = {Buf, FrameAddr}; - llvm::CallSite CS = EmitRuntimeCallOrInvoke(SetJmpEx, Args); - CS.setAttributes(ReturnsTwiceAttr); - return RValue::get(CS.getInstruction()); -} + case Builtin::BI_setjmpex: +if (getTarget().getTriple().isOSMSVCRT()) + return EmitMSVCRTSetJmp(*this, MSVCSetJmpKind::_setjmpex, E); break; - } - case Builtin::BI_setjmp: { + case Builtin::BI_setjmp: if (getTarget().getTriple().isOSMSVCRT()) { - llvm::AttributeList ReturnsTwiceAttr = llvm::AttributeList::get( - getLLVMContext(), llvm::AttributeList::FunctionIndex, - llvm::Attribute::ReturnsTwice); - llvm::Value *Buf = Builder.CreateBitOrPointerCast( - EmitScalarExpr(E->getArg(0)), Int8PtrTy); - llvm::CallSite CS; - if (getTarget().getTriple().getArch() == llvm::Triple::x86) { -llvm::Type *ArgTypes[] = {Int8PtrTy, IntTy}; -llvm::Constant *SetJmp3 = CGM.CreateRuntimeFunction( -llvm::FunctionType::get(IntTy, ArgTypes, /*isVarArg=*/true), -"_setjmp3", ReturnsTwiceAttr, /*Local=*/true); -
r334239 - [MS] Re-add support for the ARM interlocked bittest intrinscs
Author: rnk Date: Thu Jun 7 14:39:04 2018 New Revision: 334239 URL: http://llvm.org/viewvc/llvm-project?rev=334239&view=rev Log: [MS] Re-add support for the ARM interlocked bittest intrinscs Adds support for these intrinsics, which are ARM and ARM64 only: _interlockedbittestandreset_acq _interlockedbittestandreset_rel _interlockedbittestandreset_nf _interlockedbittestandset_acq _interlockedbittestandset_rel _interlockedbittestandset_nf Refactor the bittest intrinsic handling to decompose each intrinsic into its action, its width, and its atomicity. Added: cfe/trunk/test/Sema/bittest-intrinsics.c Modified: cfe/trunk/include/clang/Basic/Builtins.def cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/Headers/intrin.h cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/CodeGen/bittest-intrin.c Modified: cfe/trunk/include/clang/Basic/Builtins.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=334239&r1=334238&r2=334239&view=diff == --- cfe/trunk/include/clang/Basic/Builtins.def (original) +++ cfe/trunk/include/clang/Basic/Builtins.def Thu Jun 7 14:39:04 2018 @@ -791,10 +791,16 @@ LANGBUILTIN(_InterlockedOr, "NiNiD*Ni" LANGBUILTIN(_InterlockedXor8, "ccD*c", "n", ALL_MS_LANGUAGES) LANGBUILTIN(_InterlockedXor16, "ssD*s", "n", ALL_MS_LANGUAGES) LANGBUILTIN(_InterlockedXor, "NiNiD*Ni","n", ALL_MS_LANGUAGES) -LANGBUILTIN(_interlockedbittestandreset, "UcNiD*Ni", "n", ALL_MS_LANGUAGES) -LANGBUILTIN(_interlockedbittestandreset64, "UcWiD*Wi", "n", ALL_MS_LANGUAGES) -LANGBUILTIN(_interlockedbittestandset, "UcNiD*Ni", "n", ALL_MS_LANGUAGES) -LANGBUILTIN(_interlockedbittestandset64, "UcWiD*Wi", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_interlockedbittestandreset, "UcNiD*Ni", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_interlockedbittestandreset64, "UcWiD*Wi", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_interlockedbittestandreset_acq, "UcNiD*Ni", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_interlockedbittestandreset_nf, "UcNiD*Ni", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_interlockedbittestandreset_rel, "UcNiD*Ni", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_interlockedbittestandset, "UcNiD*Ni", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_interlockedbittestandset64, "UcWiD*Wi", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_interlockedbittestandset_acq, "UcNiD*Ni", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_interlockedbittestandset_nf,"UcNiD*Ni", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_interlockedbittestandset_rel, "UcNiD*Ni", "n", ALL_MS_LANGUAGES) LANGBUILTIN(__noop, "i.", "n", ALL_MS_LANGUAGES) LANGBUILTIN(__popcnt16, "UsUs", "nc", ALL_MS_LANGUAGES) LANGBUILTIN(__popcnt, "UiUi", "nc", ALL_MS_LANGUAGES) Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=334239&r1=334238&r2=334239&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jun 7 14:39:04 2018 @@ -8154,6 +8154,8 @@ def err_x86_builtin_invalid_rounding : E "invalid rounding argument">; def err_x86_builtin_invalid_scale : Error< "scale argument must be 1, 2, 4, or 8">; +def err_builtin_target_unsupported : Error< + "builtin is not supported on this target">; def err_builtin_longjmp_unsupported : Error< "__builtin_longjmp is not supported for the current target">; Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=334239&r1=334238&r2=334239&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Jun 7 14:39:04 2018 @@ -484,58 +484,99 @@ CodeGenFunction::emitBuiltinObjectSize(c return Builder.CreateCall(F, {Ptr, Min, NullIsUnknown}); } -// Get properties of an X86 BT* assembly instruction. The first returned value -// is the action character code, which can be for complement, reset, or set. The -// second is the size suffix which our assembler needs. The last is whether to -// add the lock prefix. -static std::tuple -getBitTestActionSizeAndLocking(unsigned BuiltinID) { +namespace { +/// A struct to generically desribe a bit test intrinsic. +struct BitTest { + enum ActionKind : uint8_t { TestOnly, Complement, Reset, Set }; + enum InterlockingKind : uint8_t { +Unlocked, +Sequential, +Acquire, +Release, +NoFence + }; + + ActionKind Action; + InterlockingKind Interlocking; + bool Is64Bit; + + static BitTest decodeBitTestBuiltin(unsigned BuiltinID); +}; +} // namespace + +BitTest BitTest::decodeBitTestBuiltin(unsigned Builti
Re: r333978 - Reimplement the bittest intrinsic family as builtins with inline asm
This should be fixed now with r334239. In for a penny, in for a pound. On Wed, Jun 6, 2018 at 6:09 PM Grang, Mandeep Singh wrote: > @rnk I tried building spec2000/eon for Windows ARM64 and ran into these > errors: > > use of undeclared identifier '_interlockedbittestandset_acq' > use of undeclared identifier '_interlockedbittestandset_rel' > use of undeclared identifier '_interlockedbittestandset_nf' > > I see that you have removed them in your patch. Apparently they are needed > (at least for ARM64 Win). > > --Mandeep > > On 6/5/2018 11:01 AM, Reid Kleckner via cfe-commits wrote: > > On Tue, Jun 5, 2018 at 2:33 AM Martin Storsjö wrote: > >> > // Many of MSVC builtins are on both x64 and ARM; to avoid repeating >> code, we >> > // handle them here. >> >> This doesn't seem thought through wrt non-x86 architectures. I'm not sure >> if there's any similar suitable instruction to use on ARM/AArch64, but we >> should at the very least fall back to doing whatever we did before this >> change for anything not x86. >> > > I'll go back and take a look, but I'm not convinced that what we did > before was correct for ARM either. I'm installing the Visual C++ aarch64 > compiler now so I can make sure we get it right. > > > ___ > cfe-commits mailing > listcfe-comm...@lists.llvm.orghttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r334417 - [MS] Use mangled names and comdats for string merging with ASan
Author: rnk Date: Mon Jun 11 09:49:43 2018 New Revision: 334417 URL: http://llvm.org/viewvc/llvm-project?rev=334417&view=rev Log: [MS] Use mangled names and comdats for string merging with ASan This should reduce the binary size penalty of ASan on Windows. After r334313, ASan will add red zones to globals in comdats, so we will still find OOB accesses to string literals. Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=334417&r1=334416&r2=334417&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Jun 11 09:49:43 2018 @@ -4114,15 +4114,13 @@ CodeGenModule::GetAddrOfConstantStringFr StringRef GlobalVariableName; llvm::GlobalValue::LinkageTypes LT; - // Mangle the string literal if the ABI allows for it. However, we cannot - // do this if we are compiling with ASan or -fwritable-strings because they - // rely on strings having normal linkage. - if (!LangOpts.WritableStrings && - !LangOpts.Sanitize.has(SanitizerKind::Address) && - getCXXABI().getMangleContext().shouldMangleStringLiteral(S)) { + // Mangle the string literal if that's how the ABI merges duplicate strings. + // Don't do it if they are writable, since we don't want writes in one TU to + // affect strings in another. + if (getCXXABI().getMangleContext().shouldMangleStringLiteral(S) && + !LangOpts.WritableStrings) { llvm::raw_svector_ostream Out(MangledNameBuffer); getCXXABI().getMangleContext().mangleStringLiteral(S, Out); - LT = llvm::GlobalValue::LinkOnceODRLinkage; GlobalVariableName = MangledNameBuffer; } else { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r334418 - Enable crash recovery tests on Windows, globs work in the lit internal shell now
Author: rnk Date: Mon Jun 11 09:50:07 2018 New Revision: 334418 URL: http://llvm.org/viewvc/llvm-project?rev=334418&view=rev Log: Enable crash recovery tests on Windows, globs work in the lit internal shell now Modified: cfe/trunk/test/Driver/crash-report-header.h cfe/trunk/test/Driver/crash-report-modules.m cfe/trunk/test/Driver/crash-report-spaces.c cfe/trunk/test/Driver/crash-report.c Modified: cfe/trunk/test/Driver/crash-report-header.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/crash-report-header.h?rev=334418&r1=334417&r2=334418&view=diff == --- cfe/trunk/test/Driver/crash-report-header.h (original) +++ cfe/trunk/test/Driver/crash-report-header.h Mon Jun 11 09:50:07 2018 @@ -5,9 +5,6 @@ // RUN: cat %t/crash-report-header-*.sh | FileCheck --check-prefix=CHECKSH "%s" // REQUIRES: crash-recovery -// because of the glob (*.h, *.sh) -// REQUIRES: shell - #pragma clang __debug parser_crash // CHECK: Preprocessed source(s) and associated run script(s) are located at: // CHECK-NEXT: note: diagnostic msg: {{.*}}.h Modified: cfe/trunk/test/Driver/crash-report-modules.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/crash-report-modules.m?rev=334418&r1=334417&r2=334418&view=diff == --- cfe/trunk/test/Driver/crash-report-modules.m (original) +++ cfe/trunk/test/Driver/crash-report-modules.m Mon Jun 11 09:50:07 2018 @@ -9,12 +9,6 @@ // RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-report-*.sh // REQUIRES: crash-recovery -// because of the glob (*.m, *.sh) -// REQUIRES: shell - -// FIXME: This XFAIL is cargo-culted from crash-report.c. Do we need it? -// XFAIL: mingw32 - @import simple; const int x = MODULE_MACRO; @@ -34,4 +28,4 @@ const int x = MODULE_MACRO; // CHECKSH: "-D" "FOO=BAR" // CHECKSH-NOT: "-fmodules-cache-path=" // CHECKSH: "crash-report-modules-{{[^ ]*}}.m" -// CHECKSH: "-ivfsoverlay" "crash-report-modules-{{[^ ]*}}.cache/vfs/vfs.yaml" +// CHECKSH: "-ivfsoverlay" "crash-report-modules-{{[^ ]*}}.cache{{(/|)}}vfs{{(/|)}}vfs.yaml" Modified: cfe/trunk/test/Driver/crash-report-spaces.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/crash-report-spaces.c?rev=334418&r1=334417&r2=334418&view=diff == --- cfe/trunk/test/Driver/crash-report-spaces.c (original) +++ cfe/trunk/test/Driver/crash-report-spaces.c Mon Jun 11 09:50:07 2018 @@ -6,9 +6,6 @@ // RUN: cat "%t/crash report spaces"-*.sh | FileCheck --check-prefix=CHECKSH "%s" // REQUIRES: crash-recovery -// because of the glob (*.c, *.sh) -// REQUIRES: shell - #pragma clang __debug parser_crash // CHECK: Preprocessed source(s) and associated run script(s) are located at: // CHECK-NEXT: note: diagnostic msg: {{.*}}.c Modified: cfe/trunk/test/Driver/crash-report.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/crash-report.c?rev=334418&r1=334417&r2=334418&view=diff == --- cfe/trunk/test/Driver/crash-report.c (original) +++ cfe/trunk/test/Driver/crash-report.c Mon Jun 11 09:50:07 2018 @@ -13,9 +13,6 @@ // RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s // REQUIRES: crash-recovery -// because of the glob (*.c, *.sh) -// REQUIRES: shell - #pragma clang __debug parser_crash // CHECK: Preprocessed source(s) and associated run script(s) are located at: // CHECK-NEXT: note: diagnostic msg: {{.*}}crash-report-{{.*}}.c ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r334418 - Enable crash recovery tests on Windows, globs work in the lit internal shell now
On Tue, Jun 12, 2018 at 4:43 AM Hans Wennborg wrote: > Actually, maybe switching the order from "not env ... %clang" to "env > ... not %clang" might work... > Thanks, I was going to try that next. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r334494 - Re-apply r334418 "Enable crash recovery tests on Windows, globs work in the lit internal shell now"
The length of that path is about 257, or very near MAX_PATH, which suggests that the version of rm you are using does not tolerate deep paths. This has been a long standing problem, and our solution to it was to install a special version of rm.exe on all of our buildbots that reliably handles long paths and copes with virus scanners and things. We may try to fix this in lit by reimplementing 'rm' in python, but that is not a near term solution. On Tue, Jun 12, 2018 at 1:30 PM Galina Kistanova wrote: > Hello Hans, > > The test Driver/crash-report-modules.m still fails on one of windows > builder: > > > http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/10221 > > . . . > Failing Tests (1): > Clang :: Driver/crash-report-modules.m > > Please have a look? > > Thanks > > Galina > > > > On Tue, Jun 12, 2018 at 4:51 AM, Hans Wennborg via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: hans >> Date: Tue Jun 12 04:51:22 2018 >> New Revision: 334494 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=334494&view=rev >> Log: >> Re-apply r334418 "Enable crash recovery tests on Windows, globs work in >> the lit internal shell now" >> >> Plus change run lines from >> >> not env FOO=bar %clang >> >> to >> >> env FOO=bar not %clang >> >> To not confuse the internal shell. >> >> Modified: >> cfe/trunk/test/Driver/crash-report-header.h >> cfe/trunk/test/Driver/crash-report-modules.m >> cfe/trunk/test/Driver/crash-report-spaces.c >> cfe/trunk/test/Driver/crash-report.c >> >> Modified: cfe/trunk/test/Driver/crash-report-header.h >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/crash-report-header.h?rev=334494&r1=334493&r2=334494&view=diff >> >> == >> --- cfe/trunk/test/Driver/crash-report-header.h (original) >> +++ cfe/trunk/test/Driver/crash-report-header.h Tue Jun 12 04:51:22 2018 >> @@ -1,13 +1,10 @@ >> // RUN: rm -rf %t >> // RUN: mkdir %t >> -// RUN: not env TMPDIR="%t" TEMP="%t" TMP="%t" RC_DEBUG_OPTIONS=1 %clang >> -fsyntax-only %s 2>&1 | FileCheck %s >> +// RUN: env TMPDIR="%t" TEMP="%t" TMP="%t" RC_DEBUG_OPTIONS=1 not %clang >> -fsyntax-only %s 2>&1 | FileCheck %s >> // RUN: cat %t/crash-report-header-*.h | FileCheck >> --check-prefix=CHECKSRC "%s" >> // RUN: cat %t/crash-report-header-*.sh | FileCheck >> --check-prefix=CHECKSH "%s" >> // REQUIRES: crash-recovery >> >> -// because of the glob (*.h, *.sh) >> -// REQUIRES: shell >> - >> #pragma clang __debug parser_crash >> // CHECK: Preprocessed source(s) and associated run script(s) are >> located at: >> // CHECK-NEXT: note: diagnostic msg: {{.*}}.h >> >> Modified: cfe/trunk/test/Driver/crash-report-modules.m >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/crash-report-modules.m?rev=334494&r1=334493&r2=334494&view=diff >> >> == >> --- cfe/trunk/test/Driver/crash-report-modules.m (original) >> +++ cfe/trunk/test/Driver/crash-report-modules.m Tue Jun 12 04:51:22 2018 >> @@ -1,20 +1,14 @@ >> // RUN: rm -rf %t >> // RUN: mkdir -p %t/i %t/m %t >> >> -// RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \ >> -// RUN: %clang -fsyntax-only %s -I %S/Inputs/module -isysroot %/t/i/\ >> +// RUN: env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t >> \ >> +// RUN: not %clang -fsyntax-only %s -I %S/Inputs/module -isysroot %/t/i/ >> \ >> // RUN: -fmodules -fmodules-cache-path=%t/m/ -DFOO=BAR 2>&1 | FileCheck >> %s >> >> // RUN: FileCheck --check-prefix=CHECKSRC %s -input-file >> %t/crash-report-*.m >> // RUN: FileCheck --check-prefix=CHECKSH %s -input-file >> %t/crash-report-*.sh >> // REQUIRES: crash-recovery >> >> -// because of the glob (*.m, *.sh) >> -// REQUIRES: shell >> - >> -// FIXME: This XFAIL is cargo-culted from crash-report.c. Do we need it? >> -// XFAIL: mingw32 >> - >> @import simple; >> const int x = MODULE_MACRO; >> >> @@ -34,4 +28,4 @@ const int x = MODULE_MACRO; >> // CHECKSH: "-D" "FOO=BAR" >> // CHECKSH-NOT: "-fmodules-cache-path=" >> // CHECKSH: "crash-report-modules-{{[^ ]*}}.m" >> -// CHECKSH: "-ivfsoverlay" "crash-report-modules-{{[^ >> ]*}}.cache/vfs/vfs.yaml" >> +// CHECKSH: "-ivfsoverlay" "crash-report-modules-{{[^ >> ]*}}.cache{{(/|)}}vfs{{(/|)}}vfs.yaml" >> >> Modified: cfe/trunk/test/Driver/crash-report-spaces.c >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/crash-report-spaces.c?rev=334494&r1=334493&r2=334494&view=diff >> >> == >> --- cfe/trunk/test/Driver/crash-report-spaces.c (original) >> +++ cfe/trunk/test/Driver/crash-report-spaces.c Tue Jun 12 04:51:22 2018 >> @@ -1,14 +1,11 @@ >> // RUN: rm -rf "%t" >> // RUN: mkdir "%t" >> // RUN: cp "%s" "%t/crash report spaces.c" >> -// RUN: not env TMPDIR="%t" TEMP="%t" TMP="%t" RC_DEBUG_OP
Re: [clang-tools-extra] r334807 - [clangd] Do not report comments that only have special chars.
This test has been failing on Windows since it has been added: http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/12549 I took a look at the unittest code, but I'm not familiar enough with this code to debug it. Can you take a look at this? On Fri, Jun 15, 2018 at 1:35 AM Ilya Biryukov via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: ibiryukov > Date: Fri Jun 15 01:31:17 2018 > New Revision: 334807 > > URL: http://llvm.org/viewvc/llvm-project?rev=334807&view=rev > Log: > [clangd] Do not report comments that only have special chars. > > Summary: > Like the following: > // --- > // === > // *** > > It does not cover all the cases, but those are definitely not very > useful. > > Reviewers: sammccall, ioeric, hokein > > Reviewed By: sammccall > > Subscribers: MaskRay, jkorous, cfe-commits > > Differential Revision: https://reviews.llvm.org/D48171 > > Modified: > clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp > clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp > > Modified: clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp?rev=334807&r1=334806&r2=334807&view=diff > > == > --- clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp (original) > +++ clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp Fri Jun 15 > 01:31:17 2018 > @@ -151,6 +151,16 @@ bool canRequestComment(const ASTContext >const ObjCPropertyDecl *PDecl = M ? M->findPropertyDecl() : nullptr; >return !PDecl || canRequestForDecl(*PDecl); > } > + > +bool LooksLikeDocComment(llvm::StringRef CommentText) { > + // We don't report comments that only contain "special" chars. > + // This avoids reporting various delimiters, like: > + // = > + // - > + // * > + return CommentText.find_first_not_of("/*-= \t\r\n") != > llvm::StringRef::npos; > +} > + > } // namespace > > std::string getDocComment(const ASTContext &Ctx, > @@ -167,7 +177,10 @@ std::string getDocComment(const ASTConte >const RawComment *RC = getCompletionComment(Ctx, Decl); >if (!RC) > return ""; > - return RC->getFormattedText(Ctx.getSourceManager(), > Ctx.getDiagnostics()); > + std::string Doc = RC->getFormattedText(Ctx.getSourceManager(), > Ctx.getDiagnostics()); > + if (!LooksLikeDocComment(Doc)) > +return ""; > + return Doc; > } > > std::string > @@ -180,7 +193,10 @@ getParameterDocComment(const ASTContext >const RawComment *RC = getParameterComment(Ctx, Result, ArgIndex); >if (!RC) > return ""; > - return RC->getFormattedText(Ctx.getSourceManager(), > Ctx.getDiagnostics()); > + std::string Doc = RC->getFormattedText(Ctx.getSourceManager(), > Ctx.getDiagnostics()); > + if (!LooksLikeDocComment(Doc)) > +return ""; > + return Doc; > } > > void getLabelAndInsertText(const CodeCompletionString &CCS, std::string > *Label, > > Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=334807&r1=334806&r2=334807&view=diff > > == > --- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp > (original) > +++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Fri Jun > 15 01:31:17 2018 > @@ -1100,6 +1100,65 @@ TEST(CompletionTest, DocumentationFromCh >Contains(AllOf(Not(IsDocumented()), Named("func"; > } > > +TEST(CompletionTest, NonDocComments) { > + MockFSProvider FS; > + auto FooCpp = testPath("foo.cpp"); > + FS.Files[FooCpp] = ""; > + > + MockCompilationDatabase CDB; > + IgnoreDiagnostics DiagConsumer; > + ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest()); > + > + Annotations Source(R"cpp( > +// -- > +int comments_foo(); > + > +// A comment and a decl are separated by newlines. > +// Therefore, the comment shouldn't show up as doc comment. > + > +int comments_bar(); > + > +// this comment should be in the results. > +int comments_baz(); > + > + > +template > +struct Struct { > + int comments_qux(); > + int comments_quux(); > +}; > + > + > +// This comment should not be there. > + > +template > +int Struct::comments_qux() { > +} > + > +// This comment **should** be in results. > +template > +int Struct::comments_quux() { > + int a = comments^; > +} > + )cpp"); > + Server.addDocument(FooCpp, Source.code(), WantDiagnostics::Yes); > + CompletionList Completions = cantFail(runCodeComplete( > + Server, FooCpp, Source.point(), clangd::CodeCompleteOptions())); > + > + // We should not get any of those comments in completion. > + EXPECT_THA
[clang-tools-extra] r334973 - Fix clangd test to pass when delayed template parsing is on by default
Author: rnk Date: Mon Jun 18 11:55:10 2018 New Revision: 334973 URL: http://llvm.org/viewvc/llvm-project?rev=334973&view=rev Log: Fix clangd test to pass when delayed template parsing is on by default Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=334973&r1=334972&r2=334973&view=diff == --- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Mon Jun 18 11:55:10 2018 @@ -1212,6 +1212,9 @@ TEST(CompletionTest, NonDocComments) { int a = comments^; } )cpp"); + // FIXME: Auto-completion in a template requires disabling delayed template + // parsing. + CDB.ExtraClangFlags.push_back("-fno-delayed-template-parsing"); Server.addDocument(FooCpp, Source.code(), WantDiagnostics::Yes); CompletionList Completions = cantFail(runCodeComplete( Server, FooCpp, Source.point(), clangd::CodeCompleteOptions())); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang-tools-extra] r334807 - [clangd] Do not report comments that only have special chars.
And, as soon as I sent that, I realized what was up. Apparently auto-complete is driven by the parser, and delayed template parsing means we don't parse templates. That seems like a serious issue that should get fixed eventually. Anyway, I landed a crummy workaround in r334973 to green the bots. On Mon, Jun 18, 2018 at 11:53 AM Reid Kleckner wrote: > This test has been failing on Windows since it has been added: > http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/12549 > > I took a look at the unittest code, but I'm not familiar enough with this > code to debug it. Can you take a look at this? > > On Fri, Jun 15, 2018 at 1:35 AM Ilya Biryukov via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: ibiryukov >> Date: Fri Jun 15 01:31:17 2018 >> New Revision: 334807 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=334807&view=rev >> Log: >> [clangd] Do not report comments that only have special chars. >> >> Summary: >> Like the following: >> // --- >> // === >> // *** >> >> It does not cover all the cases, but those are definitely not very >> useful. >> >> Reviewers: sammccall, ioeric, hokein >> >> Reviewed By: sammccall >> >> Subscribers: MaskRay, jkorous, cfe-commits >> >> Differential Revision: https://reviews.llvm.org/D48171 >> >> Modified: >> clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp >> clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp >> >> Modified: clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp?rev=334807&r1=334806&r2=334807&view=diff >> >> == >> --- clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp (original) >> +++ clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp Fri Jun 15 >> 01:31:17 2018 >> @@ -151,6 +151,16 @@ bool canRequestComment(const ASTContext >>const ObjCPropertyDecl *PDecl = M ? M->findPropertyDecl() : nullptr; >>return !PDecl || canRequestForDecl(*PDecl); >> } >> + >> +bool LooksLikeDocComment(llvm::StringRef CommentText) { >> + // We don't report comments that only contain "special" chars. >> + // This avoids reporting various delimiters, like: >> + // = >> + // - >> + // * >> + return CommentText.find_first_not_of("/*-= \t\r\n") != >> llvm::StringRef::npos; >> +} >> + >> } // namespace >> >> std::string getDocComment(const ASTContext &Ctx, >> @@ -167,7 +177,10 @@ std::string getDocComment(const ASTConte >>const RawComment *RC = getCompletionComment(Ctx, Decl); >>if (!RC) >> return ""; >> - return RC->getFormattedText(Ctx.getSourceManager(), >> Ctx.getDiagnostics()); >> + std::string Doc = RC->getFormattedText(Ctx.getSourceManager(), >> Ctx.getDiagnostics()); >> + if (!LooksLikeDocComment(Doc)) >> +return ""; >> + return Doc; >> } >> >> std::string >> @@ -180,7 +193,10 @@ getParameterDocComment(const ASTContext >>const RawComment *RC = getParameterComment(Ctx, Result, ArgIndex); >>if (!RC) >> return ""; >> - return RC->getFormattedText(Ctx.getSourceManager(), >> Ctx.getDiagnostics()); >> + std::string Doc = RC->getFormattedText(Ctx.getSourceManager(), >> Ctx.getDiagnostics()); >> + if (!LooksLikeDocComment(Doc)) >> +return ""; >> + return Doc; >> } >> >> void getLabelAndInsertText(const CodeCompletionString &CCS, std::string >> *Label, >> >> Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=334807&r1=334806&r2=334807&view=diff >> >> == >> --- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp >> (original) >> +++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Fri >> Jun 15 01:31:17 2018 >> @@ -1100,6 +1100,65 @@ TEST(CompletionTest, DocumentationFromCh >>Contains(AllOf(Not(IsDocumented()), Named("func"; >> } >> >> +TEST(CompletionTest, NonDocComments) { >> +
r335175 - [MS] Make sure __GetExceptionInfo works on types with no linkage
Author: rnk Date: Wed Jun 20 14:12:20 2018 New Revision: 335175 URL: http://llvm.org/viewvc/llvm-project?rev=335175&view=rev Log: [MS] Make sure __GetExceptionInfo works on types with no linkage Fixes PR36327 Modified: cfe/trunk/lib/Sema/Sema.cpp cfe/trunk/test/CodeGenCXX/microsoft-abi-throw.cpp Modified: cfe/trunk/lib/Sema/Sema.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=335175&r1=335174&r2=335175&view=diff == --- cfe/trunk/lib/Sema/Sema.cpp (original) +++ cfe/trunk/lib/Sema/Sema.cpp Wed Jun 20 14:12:20 2018 @@ -645,6 +645,8 @@ void Sema::getUndefinedButUsed( !isExternalWithNoLinkageType(FD) && !FD->getMostRecentDecl()->isInlined()) continue; + if (FD->getBuiltinID()) +continue; } else { auto *VD = cast(ND); if (VD->hasDefinition() != VarDecl::DeclarationOnly) Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-throw.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-throw.cpp?rev=335175&r1=335174&r2=335175&view=diff == --- cfe/trunk/test/CodeGenCXX/microsoft-abi-throw.cpp (original) +++ cfe/trunk/test/CodeGenCXX/microsoft-abi-throw.cpp Wed Jun 20 14:12:20 2018 @@ -22,6 +22,7 @@ // CHECK-DAG: @_TI1P6AXXZ = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i8* null, i8* null, i8* bitcast (%eh.CatchableTypeArray.1* @_CTA1P6AXXZ to i8*) }, section ".xdata", comdat // CHECK-DAG: @_TIU2PAPFAH = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 4, i8* null, i8* null, i8* bitcast (%eh.CatchableTypeArray.2* @_CTA2PAPFAH to i8*) }, section ".xdata", comdat // CHECK-DAG: @_CTA2PAPFAH = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.2 { i32 2, [2 x %eh.CatchableType*] [%eh.CatchableType* @"_CT??_R0PAPFAH@84", %eh.CatchableType* @"_CT??_R0PAX@84"] }, section ".xdata", comdat +// CHECK-DAG: @"_TI1?AUFoo@?A@@" = internal unnamed_addr constant %eh.ThrowInfo { i32 0, i8* null, i8* null, i8* bitcast (%eh.CatchableTypeArray.1* @"_CTA1?AUFoo@?A@@" to i8*) }, section ".xdata" struct N { ~N(); }; @@ -128,3 +129,12 @@ void *GetExceptionInfo_test1() { // CHECK: ret i8* bitcast (%eh.ThrowInfo* @_TI1P6AXXZ to i8*) return __GetExceptionInfo(&h); } + +// PR36327: Try an exception type with no linkage. +namespace { struct Foo { } foo_exc; } + +void *GetExceptionInfo_test2() { +// CHECK-LABEL: @"?GetExceptionInfo_test2@@YAPAXXZ" +// CHECK: ret i8* bitcast (%eh.ThrowInfo* @"_TI1?AUFoo@?A@@" to i8*) + return __GetExceptionInfo(foo_exc); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r335419 - Attempt to fix latent tablegen dependency issue
Author: rnk Date: Sat Jun 23 10:32:51 2018 New Revision: 335419 URL: http://llvm.org/viewvc/llvm-project?rev=335419&view=rev Log: Attempt to fix latent tablegen dependency issue Modified: cfe/trunk/tools/clang-fuzzer/handle-llvm/CMakeLists.txt Modified: cfe/trunk/tools/clang-fuzzer/handle-llvm/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/handle-llvm/CMakeLists.txt?rev=335419&r1=335418&r2=335419&view=diff == --- cfe/trunk/tools/clang-fuzzer/handle-llvm/CMakeLists.txt (original) +++ cfe/trunk/tools/clang-fuzzer/handle-llvm/CMakeLists.txt Sat Jun 23 10:32:51 2018 @@ -4,8 +4,17 @@ set(LLVM_LINK_COMPONENTS MC Support Analysis -) + ) + +# Depend on LLVM IR intrinsic generation. +set(handle_llvm_deps intrinsics_gen) +if (CLANG_BUILT_STANDALONE) + set(handle_llvm_deps) +endif() add_clang_library(clangHandleLLVM handle_llvm.cpp + + DEPENDS + ${handle_llvm_deps} ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits