r341655 - Differential Revision: https://reviews.llvm.org/D50246
Author: kristina Date: Fri Sep 7 06:03:31 2018 New Revision: 341655 URL: http://llvm.org/viewvc/llvm-project?rev=341655&view=rev Log: Differential Revision: https://reviews.llvm.org/D50246 [RISCV] Add support for computing sysroot for riscv32-unknown-elf Extends r338385 to allow the driver to compute the sysroot when an explicit path is not provided. This allows the linker to find C runtime files and the correct include directory for header files. Patch by lewis-revill (Lewis Revill) Modified: cfe/trunk/lib/Driver/ToolChains/RISCV.cpp cfe/trunk/lib/Driver/ToolChains/RISCV.h cfe/trunk/test/Driver/riscv32-toolchain.c Modified: cfe/trunk/lib/Driver/ToolChains/RISCV.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/RISCV.cpp?rev=341655&r1=341654&r2=341655&view=diff == --- cfe/trunk/lib/Driver/ToolChains/RISCV.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/RISCV.cpp Fri Sep 7 06:03:31 2018 @@ -13,6 +13,7 @@ #include "clang/Driver/Compilation.h" #include "clang/Driver/Options.h" #include "llvm/Option/ArgList.h" +#include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" @@ -27,7 +28,7 @@ RISCVToolChain::RISCVToolChain(const Dri const ArgList &Args) : Generic_ELF(D, Triple, Args) { GCCInstallation.init(Triple, Args); - getFilePaths().push_back(D.SysRoot + "/lib"); + getFilePaths().push_back(computeSysRoot() + "/lib"); if (GCCInstallation.isValid()) { getFilePaths().push_back(GCCInstallation.getInstallPath().str()); getProgramPaths().push_back( @@ -39,13 +40,21 @@ Tool *RISCVToolChain::buildLinker() cons return new tools::RISCV::Linker(*this); } +void RISCVToolChain::addClangTargetOptions( +const llvm::opt::ArgList &DriverArgs, +llvm::opt::ArgStringList &CC1Args, +Action::OffloadKind) const { + CC1Args.push_back("-nostdsysteminc"); + CC1Args.push_back("-fuse-init-array"); +} + void RISCVToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs, ArgStringList &CC1Args) const { if (DriverArgs.hasArg(options::OPT_nostdinc)) return; if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) { -SmallString<128> Dir(getDriver().SysRoot); +SmallString<128> Dir(computeSysRoot()); llvm::sys::path::append(Dir, "include"); addSystemInclude(DriverArgs, CC1Args, Dir.str()); } @@ -54,15 +63,30 @@ void RISCVToolChain::AddClangSystemInclu void RISCVToolChain::addLibStdCxxIncludePaths( const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const { - StringRef LibDir = GCCInstallation.getParentLibPath(); const GCCVersion &Version = GCCInstallation.getVersion(); StringRef TripleStr = GCCInstallation.getTriple().str(); const Multilib &Multilib = GCCInstallation.getMultilib(); - addLibStdCXXIncludePaths( - LibDir.str() + "/../" + TripleStr.str() + "/include/c++/" + Version.Text, + addLibStdCXXIncludePaths(computeSysRoot() + "/include/c++/" + Version.Text, "", TripleStr, "", "", Multilib.includeSuffix(), DriverArgs, CC1Args); } +std::string RISCVToolChain::computeSysRoot() const { + if (!getDriver().SysRoot.empty()) +return getDriver().SysRoot; + + if (!GCCInstallation.isValid()) +return std::string(); + + StringRef LibDir = GCCInstallation.getParentLibPath(); + StringRef TripleStr = GCCInstallation.getTriple().str(); + std::string SysRootDir = LibDir.str() + "/../" + TripleStr.str(); + + if (!llvm::sys::fs::exists(SysRootDir)) +return std::string(); + + return SysRootDir; +} + void RISCV::Linker::ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, const InputInfoList &Inputs, Modified: cfe/trunk/lib/Driver/ToolChains/RISCV.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/RISCV.h?rev=341655&r1=341654&r2=341655&view=diff == --- cfe/trunk/lib/Driver/ToolChains/RISCV.h (original) +++ cfe/trunk/lib/Driver/ToolChains/RISCV.h Fri Sep 7 06:03:31 2018 @@ -23,6 +23,9 @@ public: const llvm::opt::ArgList &Args); bool IsIntegratedAssemblerDefault() const override { return true; } + void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args, + Action::OffloadKind) const override; void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; @@ -32,6 +35,9 @@ public: protected: Tool *buildLinker() const override; + +private: + std::string computeSysRoot() const; }; } // end namespace toolchains Modified: cfe/trunk/test/Driver/r
r342231 - [Driver] Fix missing MultiArch include dir on powerpcspe
Author: kristina Date: Fri Sep 14 05:42:13 2018 New Revision: 342231 URL: http://llvm.org/viewvc/llvm-project?rev=342231&view=rev Log: [Driver] Fix missing MultiArch include dir on powerpcspe On powerpc-linux-gnuspe, the header files are located in their own include directory named /usr/lib/powerpc-linux-gnuspe, so add this directory to PPCMultiarchIncludeDirs. Patch by glaubitz (John Paul Adrian Glaubitz) Differential Revision: https://reviews.llvm.org/D52066 Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=342231&r1=342230&r2=342231&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Fri Sep 14 05:42:13 2018 @@ -699,7 +699,8 @@ void Linux::AddClangSystemIncludeArgs(co "/usr/include/mips64el-linux-gnu", "/usr/include/mips64el-linux-gnuabi64"}; const StringRef PPCMultiarchIncludeDirs[] = { - "/usr/include/powerpc-linux-gnu"}; + "/usr/include/powerpc-linux-gnu", + "/usr/include/powerpc-linux-gnuspe"}; const StringRef PPC64MultiarchIncludeDirs[] = { "/usr/include/powerpc64-linux-gnu"}; const StringRef PPC64LEMultiarchIncludeDirs[] = { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344739 - Add support for -mno-tls-direct-seg-refs to Clang
Author: kristina Date: Thu Oct 18 07:07:02 2018 New Revision: 344739 URL: http://llvm.org/viewvc/llvm-project?rev=344739&view=rev Log: Add support for -mno-tls-direct-seg-refs to Clang This patch exposes functionality added in rL344723 to the Clang driver/frontend as a flag and adds appropriate metadata. Driver tests pass: ``` ninja check-clang-driver -snip- Expected Passes: 472 Expected Failures : 3 Unsupported Tests : 65 ``` Odd failure in CodeGen tests but unrelated to this: ``` ninja check-clang-codegen -snip- /SourceCache/llvm-trunk-8.0/tools/clang/test/CodeGen/builtins-wasm.c:87:10: error: cannot compile this builtin function yet -snip- Failing Tests (1): Clang :: CodeGen/builtins-wasm.c Expected Passes: 1250 Expected Failures : 2 Unsupported Tests : 120 Unexpected Failures: 1 ``` Original commit: [X86] Support for the mno-tls-direct-seg-refs flag Allows to disable direct TLS segment access (%fs or %gs). GCC supports a similar flag, it can be useful in some circumstances, e.g. when a thread context block needs to be updated directly from user space. More info and specific use cases: https://bugs.llvm.org/show_bug.cgi?id=16145 Patch by nruslan (Ruslan Nikolaev). Differential Revision: https://reviews.llvm.org/D53102 Added: cfe/trunk/test/CodeGen/indirect-tls-seg-refs.c cfe/trunk/test/Driver/indirect-tls-seg-refs.c Modified: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/include/clang/Frontend/CodeGenOptions.def cfe/trunk/lib/CodeGen/CGCall.cpp cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=344739&r1=344738&r2=344739&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Thu Oct 18 07:07:02 2018 @@ -2011,6 +2011,8 @@ def mno_global_merge : Flag<["-"], "mno- def mno_pascal_strings : Flag<["-"], "mno-pascal-strings">, Alias; def mno_red_zone : Flag<["-"], "mno-red-zone">, Group; +def mno_tls_direct_seg_refs : Flag<["-"], "mno-tls-direct-seg-refs">, Group, Flags<[CC1Option]>, + HelpText<"Disable direct TLS access through segment registers">; def mno_relax_all : Flag<["-"], "mno-relax-all">, Group; def mno_rtd: Flag<["-"], "mno-rtd">, Group; def mno_soft_float : Flag<["-"], "mno-soft-float">, Group; @@ -2171,6 +2173,8 @@ def momit_leaf_frame_pointer : Flag<["-" def moslib_EQ : Joined<["-"], "moslib=">, Group; def mpascal_strings : Flag<["-"], "mpascal-strings">, Alias; def mred_zone : Flag<["-"], "mred-zone">, Group; +def mtls_direct_seg_refs : Flag<["-"], "mtls-direct-seg-refs">, Group, + HelpText<"Enable direct TLS access through segment registers (default)">; def mregparm_EQ : Joined<["-"], "mregparm=">, Group; def mrelax_all : Flag<["-"], "mrelax-all">, Group, Flags<[CC1Option,CC1AsOption]>, HelpText<"(integrated-as) Relax all machine instructions">; Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=344739&r1=344738&r2=344739&view=diff == --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original) +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Thu Oct 18 07:07:02 2018 @@ -62,6 +62,8 @@ CODEGENOPT(ExperimentalNewPassManager, 1 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new ///< pass manager. CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled. +CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs + ///< is specified. CODEGENOPT(DisableTailCalls , 1, 0) ///< Do not emit tail calls. CODEGENOPT(NoEscapingBlockTailCalls, 1, 0) ///< Do not emit tail calls from ///< escaping blocks. Modified: cfe/trunk/lib/CodeGen/CGCall.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=344739&r1=344738&r2=344739&view=diff == --- cfe/trunk/lib/CodeGen/CGCall.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Oct 18 07:07:02 2018 @@ -1709,6 +1709,8 @@ void CodeGenModule::ConstructDefaultFnAt if (CodeGenOpts.DisableRedZone) FuncAttrs.addAttribute(llvm::Attribute::NoRedZone); + if (CodeGenOpts.IndirectTlsSegRefs) +FuncAttrs.addAttribute("indirect-tls-seg-refs"); if (CodeGenOpts.NoImplicitFloat) FuncAttrs.addAttribute(llvm::Attribute::NoImplicitFloat); Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=3447
r344742 - [X86][Tests] Make sure tls-direct-seg-refs tests only run where supported
Author: kristina Date: Thu Oct 18 07:44:25 2018 New Revision: 344742 URL: http://llvm.org/viewvc/llvm-project?rev=344742&view=rev Log: [X86][Tests] Make sure tls-direct-seg-refs tests only run where supported This flag is only supported for x86 targets, make sure the tests only run for those. Modified: cfe/trunk/test/CodeGen/indirect-tls-seg-refs.c cfe/trunk/test/Driver/indirect-tls-seg-refs.c Modified: cfe/trunk/test/CodeGen/indirect-tls-seg-refs.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/indirect-tls-seg-refs.c?rev=344742&r1=344741&r2=344742&view=diff == --- cfe/trunk/test/CodeGen/indirect-tls-seg-refs.c (original) +++ cfe/trunk/test/CodeGen/indirect-tls-seg-refs.c Thu Oct 18 07:44:25 2018 @@ -1,5 +1,7 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - -mno-tls-direct-seg-refs | FileCheck %s -check-prefix=NO-TLSDIRECT -// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s -check-prefix=TLSDIRECT +// REQUIRES: x86-registered-target + +// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-unknown-linux -o - -mno-tls-direct-seg-refs | FileCheck %s -check-prefix=NO-TLSDIRECT +// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-unknown-linux -o - | FileCheck %s -check-prefix=TLSDIRECT // NO-TLSDIRECT: attributes #{{[0-9]+}} = {{{.*}} "indirect-tls-seg-refs" // TLSDIRECT-NOT: attributes #{{[0-9]+}} = {{{.*}} "indirect-tls-seg-refs" Modified: cfe/trunk/test/Driver/indirect-tls-seg-refs.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/indirect-tls-seg-refs.c?rev=344742&r1=344741&r2=344742&view=diff == --- cfe/trunk/test/Driver/indirect-tls-seg-refs.c (original) +++ cfe/trunk/test/Driver/indirect-tls-seg-refs.c Thu Oct 18 07:44:25 2018 @@ -1,7 +1,8 @@ -// RUN: %clang -### %s 2>&1 | FileCheck %s -check-prefix=TLSDIRECT -// RUN: %clang -### -mno-tls-direct-seg-refs -mtls-direct-seg-refs %s 2>&1 | FileCheck %s -check-prefix=TLSDIRECT -// RUN: %clang -### -mtls-direct-seg-refs -mno-tls-direct-seg-refs %s 2>&1 | FileCheck %s -check-prefix=NO-TLSDIRECT -// REQUIRES: clang-driver +// REQUIRES: clang-driver, x86-registered-target + +// RUN: %clang -### -target x86_64-unknown-linux %s 2>&1 | FileCheck %s -check-prefix=TLSDIRECT +// RUN: %clang -### -target x86_64-unknown-linux -mno-tls-direct-seg-refs -mtls-direct-seg-refs %s 2>&1 | FileCheck %s -check-prefix=TLSDIRECT +// RUN: %clang -### -target x86_64-unknown-linux -mtls-direct-seg-refs -mno-tls-direct-seg-refs %s 2>&1 | FileCheck %s -check-prefix=NO-TLSDIRECT // NO-TLSDIRECT: -mno-tls-direct-seg-refs // TLSDIRECT-NOT: -mno-tls-direct-seg-refs ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r351082 - [Sema] Expose a control flag for integer to pointer ext warning
Author: kristina Date: Mon Jan 14 10:16:51 2019 New Revision: 351082 URL: http://llvm.org/viewvc/llvm-project?rev=351082&view=rev Log: [Sema] Expose a control flag for integer to pointer ext warning While building openJDK11u, it seems that some of the code in the native core libraries make liberal use of integer to pointer comparisons. We currently have no flag to disabled this warning. This add such a flag. Patch by Kader (abdoul-kader keita) Differential Revision: https://reviews.llvm.org/D56241 Added: cfe/trunk/test/Sema/ext-typecheck-comparison-of-pointer-integer.c Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/test/Misc/warning-flags.c Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=351082&r1=351081&r2=351082&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Jan 14 10:16:51 2019 @@ -5875,7 +5875,8 @@ def ext_typecheck_comparison_of_fptr_to_ def err_typecheck_comparison_of_fptr_to_void : Error< "equality comparison between function pointer and void pointer (%0 and %1)">; def ext_typecheck_comparison_of_pointer_integer : ExtWarn< - "comparison between pointer and integer (%0 and %1)">; + "comparison between pointer and integer (%0 and %1)">, + InGroup>; def err_typecheck_comparison_of_pointer_integer : Error< "comparison between pointer and integer (%0 and %1)">; def ext_typecheck_comparison_of_distinct_pointers : ExtWarn< Modified: cfe/trunk/test/Misc/warning-flags.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/warning-flags.c?rev=351082&r1=351081&r2=351082&view=diff == --- cfe/trunk/test/Misc/warning-flags.c (original) +++ cfe/trunk/test/Misc/warning-flags.c Mon Jan 14 10:16:51 2019 @@ -18,7 +18,7 @@ This test serves two purposes: The list of warnings below should NEVER grow. It should gradually shrink to 0. -CHECK: Warnings without flags (75): +CHECK: Warnings without flags (74): CHECK-NEXT: ext_excess_initializers CHECK-NEXT: ext_excess_initializers_in_char_array_initializer CHECK-NEXT: ext_expected_semi_decl_list @@ -29,7 +29,6 @@ CHECK-NEXT: ext_missing_whitespace_aft CHECK-NEXT: ext_new_paren_array_nonconst CHECK-NEXT: ext_plain_complex CHECK-NEXT: ext_template_arg_extra_parens -CHECK-NEXT: ext_typecheck_comparison_of_pointer_integer CHECK-NEXT: ext_typecheck_cond_incompatible_operands CHECK-NEXT: ext_typecheck_ordered_comparison_of_pointer_integer CHECK-NEXT: ext_using_undefined_std Added: cfe/trunk/test/Sema/ext-typecheck-comparison-of-pointer-integer.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/ext-typecheck-comparison-of-pointer-integer.c?rev=351082&view=auto == --- cfe/trunk/test/Sema/ext-typecheck-comparison-of-pointer-integer.c (added) +++ cfe/trunk/test/Sema/ext-typecheck-comparison-of-pointer-integer.c Mon Jan 14 10:16:51 2019 @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -verify -DEXPECTWARNING %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -verify -Wno-pointer-integer-compare %s + +#ifdef EXPECTWARNING +// expected-warning@+6 {{comparison between pointer and integer ('int' and 'int *')}} +#else +// expected-no-diagnostics +#endif + +int test_ext_typecheck_comparison_of_pointer_integer(int integer, int * pointer) { + return integer != pointer; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r346582 - Correct naming conventions and 80 col rule violation in CGDeclCXX.cpp. NFC.
Author: kristina Date: Fri Nov 9 23:53:47 2018 New Revision: 346582 URL: http://llvm.org/viewvc/llvm-project?rev=346582&view=rev Log: Correct naming conventions and 80 col rule violation in CGDeclCXX.cpp. NFC. Differential Revision: https://reviews.llvm.org/D54373 Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=346582&r1=346581&r2=346582&view=diff == --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Fri Nov 9 23:53:47 2018 @@ -68,10 +68,10 @@ static void EmitDeclDestroy(CodeGenFunct // FIXME: __attribute__((cleanup)) ? - QualType type = D.getType(); - QualType::DestructionKind dtorKind = type.isDestructedType(); + QualType Type = D.getType(); + QualType::DestructionKind DtorKind = Type.isDestructedType(); - switch (dtorKind) { + switch (DtorKind) { case QualType::DK_none: return; @@ -86,13 +86,14 @@ static void EmitDeclDestroy(CodeGenFunct return; } - llvm::Constant *function; - llvm::Constant *argument; + llvm::Constant *Func; + llvm::Constant *Argument; // Special-case non-array C++ destructors, if they have the right signature. // Under some ABIs, destructors return this instead of void, and cannot be - // passed directly to __cxa_atexit if the target does not allow this mismatch. - const CXXRecordDecl *Record = type->getAsCXXRecordDecl(); + // passed directly to __cxa_atexit if the target does not allow this + // mismatch. + const CXXRecordDecl *Record = Type->getAsCXXRecordDecl(); bool CanRegisterDestructor = Record && (!CGM.getCXXABI().HasThisReturn( GlobalDecl(Record->getDestructor(), Dtor_Complete)) || @@ -103,21 +104,21 @@ static void EmitDeclDestroy(CodeGenFunct bool UsingExternalHelper = !CGM.getCodeGenOpts().CXAAtExit; if (Record && (CanRegisterDestructor || UsingExternalHelper)) { assert(!Record->hasTrivialDestructor()); -CXXDestructorDecl *dtor = Record->getDestructor(); +CXXDestructorDecl *Dtor = Record->getDestructor(); -function = CGM.getAddrOfCXXStructor(dtor, StructorType::Complete); -argument = llvm::ConstantExpr::getBitCast( -addr.getPointer(), CGF.getTypes().ConvertType(type)->getPointerTo()); +Func = CGM.getAddrOfCXXStructor(Dtor, StructorType::Complete); +Argument = llvm::ConstantExpr::getBitCast( +Addr.getPointer(), CGF.getTypes().ConvertType(Type)->getPointerTo()); // Otherwise, the standard logic requires a helper function. } else { -function = CodeGenFunction(CGM) -.generateDestroyHelper(addr, type, CGF.getDestroyer(dtorKind), - CGF.needsEHCleanup(dtorKind), &D); -argument = llvm::Constant::getNullValue(CGF.Int8PtrTy); +Func = CodeGenFunction(CGM) + .generateDestroyHelper(Addr, Type, CGF.getDestroyer(DtorKind), + CGF.needsEHCleanup(DtorKind), &D); +Argument = llvm::Constant::getNullValue(CGF.Int8PtrTy); } - CGM.getCXXABI().registerGlobalDtor(CGF, D, function, argument); + CGM.getCXXABI().registerGlobalDtor(CGF, D, Func, Argument); } /// Emit code to cause the variable at the given address to be considered as ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r346583 - [clang]: Fix misapplied patch in 346582.
Author: kristina Date: Sat Nov 10 00:04:38 2018 New Revision: 346583 URL: http://llvm.org/viewvc/llvm-project?rev=346583&view=rev Log: [clang]: Fix misapplied patch in 346582. Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=346583&r1=346582&r2=346583&view=diff == --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Sat Nov 10 00:04:38 2018 @@ -63,7 +63,7 @@ static void EmitDeclInit(CodeGenFunction /// Emit code to cause the destruction of the given variable with /// static storage duration. static void EmitDeclDestroy(CodeGenFunction &CGF, const VarDecl &D, -ConstantAddress addr) { +ConstantAddress Addr) { CodeGenModule &CGM = CGF.CGM; // FIXME: __attribute__((cleanup)) ? ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r346628 - [CodeGen][CXX]: Fix no_destroy CG bug under specific circumstances
Author: kristina Date: Sun Nov 11 17:19:16 2018 New Revision: 346628 URL: http://llvm.org/viewvc/llvm-project?rev=346628&view=rev Log: [CodeGen][CXX]: Fix no_destroy CG bug under specific circumstances Summary: Class with no user-defined destructor that has an inherited member that has a non-trivial destructor and a non-default constructor will attempt to emit a destructor despite being marked as __attribute((no_destroy)) in which case it would trigger an assertion due to an incorrect assumption. In addition this adds missing test coverage for IR generation for no_destroy. (Note that here use of no_destroy is synonymous with its global flag counterpart `-fno-c++-static-destructors` being enabled) Differential Revision: https://reviews.llvm.org/D54344 Added: cfe/trunk/test/CodeGenCXX/attr-no-destroy-d54344.cpp Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=346628&r1=346627&r2=346628&view=diff == --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Sun Nov 11 17:19:16 2018 @@ -64,6 +64,15 @@ static void EmitDeclInit(CodeGenFunction /// static storage duration. static void EmitDeclDestroy(CodeGenFunction &CGF, const VarDecl &D, ConstantAddress Addr) { + // Honor __attribute__((no_destroy)) and bail instead of attempting + // to emit a reference to a possibly nonexistent destructor, which + // in turn can cause a crash. This will result in a global constructor + // that isn't balanced out by a destructor call as intended by the + // attribute. This also checks for -fno-c++-static-destructors and + // bails even if the attribute is not present. + if (D.isNoDestroy(CGF.getContext())) +return; + CodeGenModule &CGM = CGF.CGM; // FIXME: __attribute__((cleanup)) ? Added: cfe/trunk/test/CodeGenCXX/attr-no-destroy-d54344.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/attr-no-destroy-d54344.cpp?rev=346628&view=auto == --- cfe/trunk/test/CodeGenCXX/attr-no-destroy-d54344.cpp (added) +++ cfe/trunk/test/CodeGenCXX/attr-no-destroy-d54344.cpp Sun Nov 11 17:19:16 2018 @@ -0,0 +1,42 @@ +// RUN: %clang_cc1 -std=c++2a -emit-llvm -O0 -triple x86_64-unknown-linux-gnu -DNOATTR %s -o - | FileCheck %s +// RUN: %clang_cc1 -std=c++2a -emit-llvm -O0 -triple x86_64-unknown-linux-gnu %s -o - | FileCheck %s --check-prefix=CHECK-ATTR +// RUN: %clang_cc1 -std=c++2a -emit-llvm -O0 -triple x86_64-unknown-linux-gnu -DNOATTR -fno-c++-static-destructors %s -o - | FileCheck %s --check-prefix=CHECK-FLAG + +// Regression test for D54344. Class with no user-defined destructor +// that has an inherited member that has a non-trivial destructor +// and a non-default constructor will attempt to emit a destructor +// despite being marked as __attribute((no_destroy)) in which case +// it would trigger an assertion due to an incorrect assumption. + +// This test is more reliable with asserts to work as without +// the crash may (unlikely) could generate working but semantically +// incorrect code. + +class a { +public: + ~a(); +}; +class logger_base { + a d; +}; +class e : logger_base {}; +#ifndef NOATTR +__attribute((no_destroy)) +#endif +e g; + +// In the absence of the attribute and flag, both ctor and dtor should +// be emitted, check for that. +// CHECK: @__cxx_global_var_init +// CHECK: @__cxa_atexit + +// When attribute is enabled, the constructor should not be balanced +// by a destructor. Make sure we have the ctor but not the dtor +// registration. +// CHECK-ATTR: @__cxx_global_var_init +// CHECK-ATTR-NOT: @__cxa_atexit + +// Same scenario except with global flag (-fno-c++-static-destructors) +// supressing it instead of the attribute. +// CHECK-FLAG: @__cxx_global_var_init +// CHECK-FLAG-NOT: @__cxa_atexit ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r347833 - Add Hurd target to Clang driver (2/2)
Author: kristina Date: Wed Nov 28 19:49:14 2018 New Revision: 347833 URL: http://llvm.org/viewvc/llvm-project?rev=347833&view=rev Log: Add Hurd target to Clang driver (2/2) This adds Hurd toolchain support to Clang's driver in addition to handling translating the triple from Hurd-compatible form to the actual triple registered in LLVM. (Phabricator was stripping the empty files from the patch so I manually created them) Patch by sthibaul (Samuel Thibault) Differential Revision: https://reviews.llvm.org/D54379 Added: cfe/trunk/lib/Driver/ToolChains/Hurd.cpp cfe/trunk/lib/Driver/ToolChains/Hurd.h cfe/trunk/test/Driver/Inputs/basic_hurd_tree/ cfe/trunk/test/Driver/Inputs/basic_hurd_tree/include/ cfe/trunk/test/Driver/Inputs/basic_hurd_tree/include/.keep cfe/trunk/test/Driver/Inputs/basic_hurd_tree/lib/ cfe/trunk/test/Driver/Inputs/basic_hurd_tree/lib/i386-gnu/ cfe/trunk/test/Driver/Inputs/basic_hurd_tree/lib/i386-gnu/.keep cfe/trunk/test/Driver/Inputs/basic_hurd_tree/lib32/ cfe/trunk/test/Driver/Inputs/basic_hurd_tree/lib32/.keep cfe/trunk/test/Driver/Inputs/basic_hurd_tree/usr/ cfe/trunk/test/Driver/Inputs/basic_hurd_tree/usr/include/ cfe/trunk/test/Driver/Inputs/basic_hurd_tree/usr/include/i386-gnu/ cfe/trunk/test/Driver/Inputs/basic_hurd_tree/usr/include/i386-gnu/.keep cfe/trunk/test/Driver/Inputs/basic_hurd_tree/usr/lib/ cfe/trunk/test/Driver/Inputs/basic_hurd_tree/usr/lib/i386-gnu/ cfe/trunk/test/Driver/Inputs/basic_hurd_tree/usr/lib/i386-gnu/.keep cfe/trunk/test/Driver/Inputs/basic_hurd_tree/usr/lib32/ cfe/trunk/test/Driver/Inputs/basic_hurd_tree/usr/lib32/.keep cfe/trunk/test/Driver/hurd.c Modified: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/lib/Basic/Targets/OSTargets.h cfe/trunk/lib/Driver/CMakeLists.txt cfe/trunk/lib/Driver/Driver.cpp cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/lib/Driver/ToolChains/Gnu.cpp cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=347833&r1=347832&r2=347833&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Wed Nov 28 19:49:14 2018 @@ -499,6 +499,8 @@ TargetInfo *AllocateTarget(const llvm::T return new NaClTargetInfo(Triple, Opts); case llvm::Triple::ELFIAMCU: return new MCUX86_32TargetInfo(Triple, Opts); +case llvm::Triple::Hurd: + return new HurdTargetInfo(Triple, Opts); default: return new X86_32TargetInfo(Triple, Opts); } Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=347833&r1=347832&r2=347833&view=diff == --- cfe/trunk/lib/Basic/Targets/OSTargets.h (original) +++ cfe/trunk/lib/Basic/Targets/OSTargets.h Wed Nov 28 19:49:14 2018 @@ -270,6 +270,29 @@ public: } }; +// Hurd target +template +class LLVM_LIBRARY_VISIBILITY HurdTargetInfo : public OSTargetInfo { +protected: + void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, +MacroBuilder &Builder) const override { +// Hurd defines; list based off of gcc output. +DefineStd(Builder, "unix", Opts); +Builder.defineMacro("__GNU__"); +Builder.defineMacro("__gnu_hurd__"); +Builder.defineMacro("__MACH__"); +Builder.defineMacro("__GLIBC__"); +Builder.defineMacro("__ELF__"); +if (Opts.POSIXThreads) + Builder.defineMacro("_REENTRANT"); +if (Opts.CPlusPlus) + Builder.defineMacro("_GNU_SOURCE"); + } +public: + HurdTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) + : OSTargetInfo(Triple, Opts) {} +}; + // Minix Target template class LLVM_LIBRARY_VISIBILITY MinixTargetInfo : public OSTargetInfo { Modified: cfe/trunk/lib/Driver/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/CMakeLists.txt?rev=347833&r1=347832&r2=347833&view=diff == --- cfe/trunk/lib/Driver/CMakeLists.txt (original) +++ cfe/trunk/lib/Driver/CMakeLists.txt Wed Nov 28 19:49:14 2018 @@ -47,6 +47,7 @@ add_clang_library(clangDriver ToolChains/Haiku.cpp ToolChains/HIP.cpp ToolChains/Hexagon.cpp + ToolChains/Hurd.cpp ToolChains/Linux.cpp ToolChains/MipsLinux.cpp ToolChains/MinGW.cpp Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=347833&r1=347832&r2=347833&view=diff == --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Wed Nov 28 19:49:14 2018 @@ -26,6 +26,7 @@ #include "ToolChains/HIP.h" #include
r348368 - [Haiku] Support __float128 for x86 and x86_64
Author: kristina Date: Wed Dec 5 07:05:06 2018 New Revision: 348368 URL: http://llvm.org/viewvc/llvm-project?rev=348368&view=rev Log: [Haiku] Support __float128 for x86 and x86_64 This patch addresses a compilation error with clang when running in Haiku being unable to compile code using float128 (throws compilation error such as 'float128 is not supported on this target'). Patch by kallisti5 (Alexander von Gluck IV) Differential Revision: https://reviews.llvm.org/D54901 Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h cfe/trunk/test/CodeGenCXX/float128-declarations.cpp Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=348368&r1=348367&r2=348368&view=diff == --- cfe/trunk/lib/Basic/Targets/OSTargets.h (original) +++ cfe/trunk/lib/Basic/Targets/OSTargets.h Wed Dec 5 07:05:06 2018 @@ -257,6 +257,8 @@ protected: Builder.defineMacro("__HAIKU__"); Builder.defineMacro("__ELF__"); DefineStd(Builder, "unix", Opts); +if (this->HasFloat128) + Builder.defineMacro("__FLOAT128__"); } public: @@ -267,6 +269,14 @@ public: this->PtrDiffType = TargetInfo::SignedLong; this->ProcessIDType = TargetInfo::SignedLong; this->TLSSupported = false; +switch (Triple.getArch()) { +default: + break; +case llvm::Triple::x86: +case llvm::Triple::x86_64: + this->HasFloat128 = true; + break; +} } }; Modified: cfe/trunk/test/CodeGenCXX/float128-declarations.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/float128-declarations.cpp?rev=348368&r1=348367&r2=348368&view=diff == --- cfe/trunk/test/CodeGenCXX/float128-declarations.cpp (original) +++ cfe/trunk/test/CodeGenCXX/float128-declarations.cpp Wed Dec 5 07:05:06 2018 @@ -14,6 +14,10 @@ // RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86 // RUN: %clang_cc1 -emit-llvm -triple x86_64-pc-solaris2.11 -std=c++11 \ // RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86 +// RUN: %clang_cc1 -emit-llvm -triple i586-pc-haiku -std=c++11 \ +// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86 +// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-haiku -std=c++11 \ +// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-X86 // /* Various contexts where type __float128 can appear. The different check prefixes are due to different mangling on X86. */ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r357793 - [docs] Fix rst title in clang langext docs. NFCI
Author: kristina Date: Fri Apr 5 11:26:43 2019 New Revision: 357793 URL: http://llvm.org/viewvc/llvm-project?rev=357793&view=rev Log: [docs] Fix rst title in clang langext docs. NFCI Fix an odd line in LanguageExtensions.rst which rendered incorrectly due to an underscore being mixed in with dashes. Modified: cfe/trunk/docs/LanguageExtensions.rst Modified: cfe/trunk/docs/LanguageExtensions.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=357793&r1=357792&r2=357793&view=diff == --- cfe/trunk/docs/LanguageExtensions.rst (original) +++ cfe/trunk/docs/LanguageExtensions.rst Fri Apr 5 11:26:43 2019 @@ -1791,7 +1791,7 @@ the arguments. Both arguments and the re by the name of the builtin. ``__builtin_rotateright`` -_ +- * ``__builtin_rotateright8`` * ``__builtin_rotateright16`` ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r342883 - [Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with `-fconstant-cfstrings`.
Author: kristina Date: Mon Sep 24 07:06:47 2018 New Revision: 342883 URL: http://llvm.org/viewvc/llvm-project?rev=342883&view=rev Log: [Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with `-fconstant-cfstrings`. [Clang][CodeGen][ObjC]: Fix non-bridged CoreFoundation builds on ELF targets that use `-fconstant-cfstrings`. The original changes from differential for a similar patch to PE/COFF (https://reviews.llvm.org/D44491) did not check for an edge case where the global could be a constant which surfaced as an issue when building for ELF because of different linkage semantics. This patch addresses several issues with crashes related to CF builds on ELF as well as improves data layout by ensuring string literals that back the actual CFConstStrings end up in .rodata in line with Mach-O. Change itself tested with CoreFoundation on Linux x86_64 but should be valid for BSD-like systems as well that use ELF as the native object format. Differential Revision: https://reviews.llvm.org/D52344 Added: cfe/trunk/test/CodeGen/cfstring-elf.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=342883&r1=342882&r2=342883&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Sep 24 07:06:47 2018 @@ -4109,37 +4109,48 @@ CodeGenModule::GetAddrOfConstantCFString llvm::Constant *Zero = llvm::Constant::getNullValue(Int32Ty); llvm::Constant *Zeros[] = { Zero, Zero }; - + // If we don't already have it, get __CFConstantStringClassReference. if (!CFConstantStringClassRef) { llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy); Ty = llvm::ArrayType::get(Ty, 0); -llvm::GlobalValue *GV = cast( -CreateRuntimeVariable(Ty, "__CFConstantStringClassReference")); - -if (getTriple().isOSBinFormatCOFF()) { - IdentifierInfo &II = getContext().Idents.get(GV->getName()); - TranslationUnitDecl *TUDecl = getContext().getTranslationUnitDecl(); - DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl); - - const VarDecl *VD = nullptr; - for (const auto &Result : DC->lookup(&II)) -if ((VD = dyn_cast(Result))) - break; - - if (!VD || !VD->hasAttr()) { -GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass); -GV->setLinkage(llvm::GlobalValue::ExternalLinkage); - } else { -GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); -GV->setLinkage(llvm::GlobalValue::ExternalLinkage); +llvm::Constant *C = +CreateRuntimeVariable(Ty, "__CFConstantStringClassReference"); + +if (getTriple().isOSBinFormatELF() || getTriple().isOSBinFormatCOFF()) { + llvm::GlobalValue *GV = nullptr; + + if ((GV = dyn_cast(C))) { +IdentifierInfo &II = getContext().Idents.get(GV->getName()); +TranslationUnitDecl *TUDecl = getContext().getTranslationUnitDecl(); +DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl); + +const VarDecl *VD = nullptr; +for (const auto &Result : DC->lookup(&II)) + if ((VD = dyn_cast(Result))) +break; + +if (getTriple().isOSBinFormatELF()) { + if (!VD) +GV->setLinkage(llvm::GlobalValue::ExternalLinkage); +} +else { + if (!VD || !VD->hasAttr()) { +GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass); +GV->setLinkage(llvm::GlobalValue::ExternalLinkage); + } else { +GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); +GV->setLinkage(llvm::GlobalValue::ExternalLinkage); + } +} + +setDSOLocal(GV); } } -setDSOLocal(GV); - + // Decay array -> ptr CFConstantStringClassRef = -llvm::ConstantExpr::getGetElementPtr(Ty, GV, Zeros); +llvm::ConstantExpr::getGetElementPtr(Ty, C, Zeros); } QualType CFTy = getContext().getCFConstantStringType(); @@ -4185,7 +4196,11 @@ CodeGenModule::GetAddrOfConstantCFString if (getTriple().isOSBinFormatMachO()) GV->setSection(isUTF16 ? "__TEXT,__ustring" : "__TEXT,__cstring,cstring_literals"); - + // Make sure the literal ends up in .rodata to allow for safe ICF and for + // the static linker to adjust permissions to read-only later on. + else if (getTriple().isOSBinFormatELF()) +GV->setSection(".rodata"); + // String. llvm::Constant *Str = llvm::ConstantExpr::getGetElementPtr(GV->getValueType(), GV, Zeros); Added: cfe/trunk/test/CodeGen/cfstring-elf.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cfstring-elf.c?rev=342883&view=auto =
r342890 - [CFString][ELF] Fix a missed test causing buildbot failures from 342883.
Author: kristina Date: Mon Sep 24 07:52:48 2018 New Revision: 342890 URL: http://llvm.org/viewvc/llvm-project?rev=342890&view=rev Log: [CFString][ELF] Fix a missed test causing buildbot failures from 342883. Accidetanlly forgot to update it, big sorry. Modified: cfe/trunk/test/CodeGen/CFStrings.c Modified: cfe/trunk/test/CodeGen/CFStrings.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/CFStrings.c?rev=342890&r1=342889&r2=342890&view=diff == --- cfe/trunk/test/CodeGen/CFStrings.c (original) +++ cfe/trunk/test/CodeGen/CFStrings.c Mon Sep 24 07:52:48 2018 @@ -22,7 +22,7 @@ const CFStringRef one = (CFStringRef)__b const CFStringRef two = (CFStringRef)__builtin___CFStringMakeConstantString("\xef\xbf\xbd\x74\xef\xbf\xbd\x77\xef\xbf\xbd\x6f"); // CHECK-COFF: @.str = private unnamed_addr constant [4 x i8] c"one\00", align 1 -// CHECK-ELF: @.str = private unnamed_addr constant [4 x i8] c"one\00", align 1 +// CHECK-ELF: @.str = private unnamed_addr constant [4 x i8] c"one\00", section ".rodata", align 1 // CHECK-MACHO: @.str = private unnamed_addr constant [4 x i8] c"one\00", section "__TEXT,__cstring,cstring_literals", align 1 // CHECK-COFF: @_unnamed_cfstring_ = private global %struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 3 }, section "cfstring", align {{[48]}} @@ -32,7 +32,7 @@ const CFStringRef two = (CFStringRef)__b // CHECK-MACHO64: @_unnamed_cfstring_ = private global %struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i64 3 }, section "__DATA,__cfstring", align 8 // CHECK-COFF: @.str.1 = private unnamed_addr constant [7 x i16] [i16 -3, i16 116, i16 -3, i16 119, i16 -3, i16 111, i16 0], align 2 -// CHECK-ELF: @.str.1 = private unnamed_addr constant [7 x i16] [i16 -3, i16 116, i16 -3, i16 119, i16 -3, i16 111, i16 0], align 2 +// CHECK-ELF: @.str.1 = private unnamed_addr constant [7 x i16] [i16 -3, i16 116, i16 -3, i16 119, i16 -3, i16 111, i16 0], section ".rodata", align 2 // CHECK-MACHO: @.str.1 = private unnamed_addr constant [7 x i16] [i16 -3, i16 116, i16 -3, i16 119, i16 -3, i16 111, i16 0], section "__TEXT,__ustring", align 2 // CHECK-COFF: @_unnamed_cfstring_.2 = private global %struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 2000, i8* bitcast ([7 x i16]* @.str.1 to i8*), i32 6 }, section "cfstring", align {{[48]}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r342893 - Revert "rL342883: [Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with `-fconstant-cfstrings`."
Author: kristina Date: Mon Sep 24 08:26:08 2018 New Revision: 342893 URL: http://llvm.org/viewvc/llvm-project?rev=342893&view=rev Log: Revert "rL342883: [Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with `-fconstant-cfstrings`." Seems to be causing buildbot failures, need to look into it. Removed: cfe/trunk/test/CodeGen/cfstring-elf.c Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/test/CodeGen/CFStrings.c Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=342893&r1=342892&r2=342893&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Sep 24 08:26:08 2018 @@ -4109,48 +4109,37 @@ CodeGenModule::GetAddrOfConstantCFString llvm::Constant *Zero = llvm::Constant::getNullValue(Int32Ty); llvm::Constant *Zeros[] = { Zero, Zero }; - + // If we don't already have it, get __CFConstantStringClassReference. if (!CFConstantStringClassRef) { llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy); Ty = llvm::ArrayType::get(Ty, 0); -llvm::Constant *C = -CreateRuntimeVariable(Ty, "__CFConstantStringClassReference"); - -if (getTriple().isOSBinFormatELF() || getTriple().isOSBinFormatCOFF()) { - llvm::GlobalValue *GV = nullptr; - - if ((GV = dyn_cast(C))) { -IdentifierInfo &II = getContext().Idents.get(GV->getName()); -TranslationUnitDecl *TUDecl = getContext().getTranslationUnitDecl(); -DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl); - -const VarDecl *VD = nullptr; -for (const auto &Result : DC->lookup(&II)) - if ((VD = dyn_cast(Result))) -break; - -if (getTriple().isOSBinFormatELF()) { - if (!VD) -GV->setLinkage(llvm::GlobalValue::ExternalLinkage); -} -else { - if (!VD || !VD->hasAttr()) { -GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass); -GV->setLinkage(llvm::GlobalValue::ExternalLinkage); - } else { -GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); -GV->setLinkage(llvm::GlobalValue::ExternalLinkage); - } -} - -setDSOLocal(GV); +llvm::GlobalValue *GV = cast( +CreateRuntimeVariable(Ty, "__CFConstantStringClassReference")); + +if (getTriple().isOSBinFormatCOFF()) { + IdentifierInfo &II = getContext().Idents.get(GV->getName()); + TranslationUnitDecl *TUDecl = getContext().getTranslationUnitDecl(); + DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl); + + const VarDecl *VD = nullptr; + for (const auto &Result : DC->lookup(&II)) +if ((VD = dyn_cast(Result))) + break; + + if (!VD || !VD->hasAttr()) { +GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass); +GV->setLinkage(llvm::GlobalValue::ExternalLinkage); + } else { +GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); +GV->setLinkage(llvm::GlobalValue::ExternalLinkage); } } - +setDSOLocal(GV); + // Decay array -> ptr CFConstantStringClassRef = -llvm::ConstantExpr::getGetElementPtr(Ty, C, Zeros); +llvm::ConstantExpr::getGetElementPtr(Ty, GV, Zeros); } QualType CFTy = getContext().getCFConstantStringType(); @@ -4196,11 +4185,7 @@ CodeGenModule::GetAddrOfConstantCFString if (getTriple().isOSBinFormatMachO()) GV->setSection(isUTF16 ? "__TEXT,__ustring" : "__TEXT,__cstring,cstring_literals"); - // Make sure the literal ends up in .rodata to allow for safe ICF and for - // the static linker to adjust permissions to read-only later on. - else if (getTriple().isOSBinFormatELF()) -GV->setSection(".rodata"); - + // String. llvm::Constant *Str = llvm::ConstantExpr::getGetElementPtr(GV->getValueType(), GV, Zeros); Modified: cfe/trunk/test/CodeGen/CFStrings.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/CFStrings.c?rev=342893&r1=342892&r2=342893&view=diff == --- cfe/trunk/test/CodeGen/CFStrings.c (original) +++ cfe/trunk/test/CodeGen/CFStrings.c Mon Sep 24 08:26:08 2018 @@ -22,7 +22,7 @@ const CFStringRef one = (CFStringRef)__b const CFStringRef two = (CFStringRef)__builtin___CFStringMakeConstantString("\xef\xbf\xbd\x74\xef\xbf\xbd\x77\xef\xbf\xbd\x6f"); // CHECK-COFF: @.str = private unnamed_addr constant [4 x i8] c"one\00", align 1 -// CHECK-ELF: @.str = private unnamed_addr constant [4 x i8] c"one\00", section ".rodata", align 1 +// CHECK-ELF: @.str = private unnamed_addr constant [4 x i8] c"one\00", align 1 // CHECK-MACHO: @.str = private unnamed_addr constant
r343038 - Reland "[Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with `-fconstant-cfstrings`"
Author: kristina Date: Tue Sep 25 15:27:40 2018 New Revision: 343038 URL: http://llvm.org/viewvc/llvm-project?rev=343038&view=rev Log: Reland "[Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with `-fconstant-cfstrings`" Relanding rL342883 with more fragmented tests to test ELF-specific section emission separately from broad-scope CFString tests. Now this tests the following separately 1). CoreFoundation builds and linkage for ELF while building it. 2). CFString ELF section emission outside CF in assembly output. 3). Broad scope `cfstring3.c` tests which cover all object formats at bitcode level and assembly level (including ELF). This fixes non-bridged CoreFoundation builds on ELF targets that use -fconstant-cfstrings. The original changes from differential for a similar patch to PE/COFF (https://reviews.llvm.org/D44491) did not check for an edge case where the global could be a constant which surfaced as an issue when building for ELF because of different linkage semantics. This patch addresses several issues with crashes related to CF builds on ELF as well as improves data layout by ensuring string literals that back the actual CFConstStrings end up in .rodata in line with Mach-O. Change itself tested with CoreFoundation on Linux x86_64 but should be valid for BSD-like systems as well that use ELF as the native object format. Differential Revision: https://reviews.llvm.org/D52344 Added: cfe/trunk/test/CodeGen/cfstring-elf-cfbuild-x86_64.c cfe/trunk/test/CodeGen/cfstring-elf-sections-x86_64.c cfe/trunk/test/CodeGen/cfstring3.c Removed: cfe/trunk/test/CodeGen/CFStrings.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=343038&r1=343037&r2=343038&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Sep 25 15:27:40 2018 @@ -4109,37 +4109,48 @@ CodeGenModule::GetAddrOfConstantCFString llvm::Constant *Zero = llvm::Constant::getNullValue(Int32Ty); llvm::Constant *Zeros[] = { Zero, Zero }; - + // If we don't already have it, get __CFConstantStringClassReference. if (!CFConstantStringClassRef) { llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy); Ty = llvm::ArrayType::get(Ty, 0); -llvm::GlobalValue *GV = cast( -CreateRuntimeVariable(Ty, "__CFConstantStringClassReference")); - -if (getTriple().isOSBinFormatCOFF()) { - IdentifierInfo &II = getContext().Idents.get(GV->getName()); - TranslationUnitDecl *TUDecl = getContext().getTranslationUnitDecl(); - DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl); - - const VarDecl *VD = nullptr; - for (const auto &Result : DC->lookup(&II)) -if ((VD = dyn_cast(Result))) - break; - - if (!VD || !VD->hasAttr()) { -GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass); -GV->setLinkage(llvm::GlobalValue::ExternalLinkage); - } else { -GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); -GV->setLinkage(llvm::GlobalValue::ExternalLinkage); +llvm::Constant *C = +CreateRuntimeVariable(Ty, "__CFConstantStringClassReference"); + +if (getTriple().isOSBinFormatELF() || getTriple().isOSBinFormatCOFF()) { + llvm::GlobalValue *GV = nullptr; + + if ((GV = dyn_cast(C))) { +IdentifierInfo &II = getContext().Idents.get(GV->getName()); +TranslationUnitDecl *TUDecl = getContext().getTranslationUnitDecl(); +DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl); + +const VarDecl *VD = nullptr; +for (const auto &Result : DC->lookup(&II)) + if ((VD = dyn_cast(Result))) +break; + +if (getTriple().isOSBinFormatELF()) { + if (!VD) +GV->setLinkage(llvm::GlobalValue::ExternalLinkage); +} +else { + if (!VD || !VD->hasAttr()) { +GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass); +GV->setLinkage(llvm::GlobalValue::ExternalLinkage); + } else { +GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); +GV->setLinkage(llvm::GlobalValue::ExternalLinkage); + } +} + +setDSOLocal(GV); } } -setDSOLocal(GV); - + // Decay array -> ptr CFConstantStringClassRef = -llvm::ConstantExpr::getGetElementPtr(Ty, GV, Zeros); +llvm::ConstantExpr::getGetElementPtr(Ty, C, Zeros); } QualType CFTy = getContext().getCFConstantStringType(); @@ -4185,7 +4196,11 @@ CodeGenModule::GetAddrOfConstantCFString if (getTriple().isOSBinFormatMachO()) GV->setSection(isUTF16 ? "__TEXT,__ustring" : "__TEX
r343044 - [clang-check-codegen][cfstring] Accept either @ or % for progbits to make ppc64be bots happy.
Author: kristina Date: Tue Sep 25 16:17:09 2018 New Revision: 343044 URL: http://llvm.org/viewvc/llvm-project?rev=343044&view=rev Log: [clang-check-codegen][cfstring] Accept either @ or % for progbits to make ppc64be bots happy. PPC64BE bots use % instead of @ for directives like progbits. Since CFString tests also check asm output, they fail on the following: cfstring3.c:44:19: error: CHECK-ASM-ELF: expected string not found in input // CHECK-ASM-ELF: .section cfstring,"aw",@progbits :30:2: note: possible intended match here .section cfstring,"aw",%progbits Updating that check with a {{[@%]}}progbits regex to make those bots happy. Modified: cfe/trunk/test/CodeGen/cfstring3.c Modified: cfe/trunk/test/CodeGen/cfstring3.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cfstring3.c?rev=343044&r1=343043&r2=343044&view=diff == --- cfe/trunk/test/CodeGen/cfstring3.c (original) +++ cfe/trunk/test/CodeGen/cfstring3.c Tue Sep 25 16:17:09 2018 @@ -41,5 +41,5 @@ const CFStringRef two = (CFStringRef)__b // CHECK-MACHO64: @_unnamed_cfstring_.2 = private global %struct.__NSConstantString_tag { i32* getelementptr inbounds ([0 x i32], [0 x i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 2000, i8* bitcast ([7 x i16]* @.str.1 to i8*), i64 6 }, section "__DATA,__cfstring", align 8 // CHECK-ASM-COFF: .section cfstring,"dw" -// CHECK-ASM-ELF: .section cfstring,"aw",@progbits +// CHECK-ASM-ELF: .section cfstring,"aw",{{[@%]}}progbits // CHECK-ASM-MACHO: .section __DATA,__cfstring ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r343372 - [clang][www] Fix typo. NFC
Author: kristina Date: Sat Sep 29 02:45:21 2018 New Revision: 343372 URL: http://llvm.org/viewvc/llvm-project?rev=343372&view=rev Log: [clang][www] Fix typo. NFC Fix a one letter typo in diagnostics.html. (Wanted to try it with arcanist). Patch by king6cong Differential Revision: https://reviews.llvm.org/D52511 Modified: cfe/trunk/www/diagnostics.html Modified: cfe/trunk/www/diagnostics.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/diagnostics.html?rev=343372&r1=343371&r2=343372&view=diff == --- cfe/trunk/www/diagnostics.html (original) +++ cfe/trunk/www/diagnostics.html Sat Sep 29 02:45:21 2018 @@ -244,7 +244,7 @@ Default: template diff with type elision t.cc:4:5: note: candidate function not viable: no known conversion for 1st argument; vector< map< - [...], + [...], [float != double]>> -fdiagnostics-show-template-tree -fno-elide-type: template tree printing with no elision @@ -252,7 +252,7 @@ Default: template diff with type elision t.cc:4:5: note: candidate function not viable: no known conversion for 1st argument; vector< map< - int, + int, [float != double]>> @@ -292,7 +292,7 @@ implements the "wwopen" class of APIs):< In practice, we've found that Clang's treatment of macros is actually more useful in multiply nested -macros that in simple ones. +macros than in simple ones. Quality of Implementation and Attention to Detail ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r354751 - Wrap code for builtin_assume_aligned at 80 col.NFC
Author: kristina Date: Sun Feb 24 09:57:33 2019 New Revision: 354751 URL: http://llvm.org/viewvc/llvm-project?rev=354751&view=rev Log: Wrap code for builtin_assume_aligned at 80 col.NFC Minor style fix to avoid going over 80 cols in handling of case for Builtin::BI__builtin_assume_aligned. NFC. 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=354751&r1=354750&r2=354751&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sun Feb 24 09:57:33 2019 @@ -2006,7 +2006,8 @@ RValue CodeGenFunction::EmitBuiltinExpr( ConstantInt *AlignmentCI = cast(AlignmentValue); unsigned Alignment = (unsigned)AlignmentCI->getZExtValue(); -EmitAlignmentAssumption(PtrValue, Ptr, /*The expr loc is sufficient.*/ SourceLocation(), +EmitAlignmentAssumption(PtrValue, Ptr, + /*The expr loc is sufficient.*/ SourceLocation(), Alignment, OffsetValue); return RValue::get(PtrValue); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r354752 - Fix accidentally used hard tabs. NFC
Author: kristina Date: Sun Feb 24 10:06:10 2019 New Revision: 354752 URL: http://llvm.org/viewvc/llvm-project?rev=354752&view=rev Log: Fix accidentally used hard tabs. NFC Big sorry. This undoes the indentation mess I made in r354751. 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=354752&r1=354751&r2=354752&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sun Feb 24 10:06:10 2019 @@ -2007,7 +2007,7 @@ RValue CodeGenFunction::EmitBuiltinExpr( unsigned Alignment = (unsigned)AlignmentCI->getZExtValue(); EmitAlignmentAssumption(PtrValue, Ptr, - /*The expr loc is sufficient.*/ SourceLocation(), +/*The expr loc is sufficient.*/ SourceLocation(), Alignment, OffsetValue); return RValue::get(PtrValue); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r362581 - Add __FILE_NAME__ to ReleaseNotes. NFC
Author: kristina Date: Tue Jun 4 20:47:02 2019 New Revision: 362581 URL: http://llvm.org/viewvc/llvm-project?rev=362581&view=rev Log: Add __FILE_NAME__ to ReleaseNotes. NFC Added it under C language changes as a nonstandard extension for the time being. Modified: cfe/trunk/docs/ReleaseNotes.rst Modified: cfe/trunk/docs/ReleaseNotes.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=362581&r1=362580&r2=362581&view=diff == --- cfe/trunk/docs/ReleaseNotes.rst (original) +++ cfe/trunk/docs/ReleaseNotes.rst Tue Jun 4 20:47:02 2019 @@ -101,9 +101,11 @@ Windows Support C Language Changes in Clang --- -- ... +- ``__FILE_NAME__`` macro has been added as a Clang specific extension supported + in all C-family languages. This macro is similar to ``__FILE__`` except it + will always provide the last path component when possible. -... +- ... C11 Feature Support ^^^ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r368508 - [modulemap] Add AArch64SVEACLETypes.def
Author: kristina Date: Sat Aug 10 01:21:14 2019 New Revision: 368508 URL: http://llvm.org/viewvc/llvm-project?rev=368508&view=rev Log: [modulemap] Add AArch64SVEACLETypes.def Update modulemap with a new textual header. Modified: cfe/trunk/include/clang/module.modulemap Modified: cfe/trunk/include/clang/module.modulemap URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/module.modulemap?rev=368508&r1=368507&r2=368508&view=diff == --- cfe/trunk/include/clang/module.modulemap (original) +++ cfe/trunk/include/clang/module.modulemap Sat Aug 10 01:21:14 2019 @@ -31,6 +31,7 @@ module Clang_Basic { requires cplusplus umbrella "Basic" + textual header "Basic/AArch64SVEACLETypes.def" textual header "Basic/BuiltinsAArch64.def" textual header "Basic/BuiltinsAMDGPU.def" textual header "Basic/BuiltinsARM.def" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r360833 - [Clang][PP] Add the __FILE_NAME__ builtin macro.
Author: kristina Date: Wed May 15 17:52:41 2019 New Revision: 360833 URL: http://llvm.org/viewvc/llvm-project?rev=360833&view=rev Log: [Clang][PP] Add the __FILE_NAME__ builtin macro. This patch adds the `__FILE_NAME__` macro that expands to the last component of the path, similar to `__FILE__` except with a guarantee that only the last path component (without the separator) will be rendered. I intend to follow through with discussion of this with WG14 as a potential inclusion in the C standard or failing that, try to discuss this with GCC developers since this extension is desired by GCC and Clang users/developers alike. Differential Revision: https://reviews.llvm.org/D61756 Added: cfe/trunk/test/Preprocessor/Inputs/include-subdir/ cfe/trunk/test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h cfe/trunk/test/Preprocessor/Inputs/include-subdir/h cfe/trunk/test/Preprocessor/Inputs/include-subdir/subdir1/ cfe/trunk/test/Preprocessor/Inputs/include-subdir/subdir1/hdr1.h cfe/trunk/test/Preprocessor/Inputs/include-subdir/subdir1/hdr2.h cfe/trunk/test/Preprocessor/file_name_macro.c Modified: cfe/trunk/include/clang/Lex/Preprocessor.h cfe/trunk/lib/Lex/PPMacroExpansion.cpp Modified: cfe/trunk/include/clang/Lex/Preprocessor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=360833&r1=360832&r2=360833&view=diff == --- cfe/trunk/include/clang/Lex/Preprocessor.h (original) +++ cfe/trunk/include/clang/Lex/Preprocessor.h Wed May 15 17:52:41 2019 @@ -147,6 +147,7 @@ class Preprocessor { IdentifierInfo *Ident__DATE__, *Ident__TIME__; // __DATE__, __TIME__ IdentifierInfo *Ident__INCLUDE_LEVEL__; // __INCLUDE_LEVEL__ IdentifierInfo *Ident__BASE_FILE__; // __BASE_FILE__ + IdentifierInfo *Ident__FILE_NAME__; // __FILE_NAME__ IdentifierInfo *Ident__TIMESTAMP__; // __TIMESTAMP__ IdentifierInfo *Ident__COUNTER__;// __COUNTER__ IdentifierInfo *Ident_Pragma, *Ident__pragma;// _Pragma, __pragma Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=360833&r1=360832&r2=360833&view=diff == --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original) +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Wed May 15 17:52:41 2019 @@ -363,6 +363,7 @@ void Preprocessor::RegisterBuiltinMacros } // Clang Extensions. + Ident__FILE_NAME__ = RegisterBuiltinMacro(*this, "__FILE_NAME__"); Ident__has_feature = RegisterBuiltinMacro(*this, "__has_feature"); Ident__has_extension= RegisterBuiltinMacro(*this, "__has_extension"); Ident__has_builtin = RegisterBuiltinMacro(*this, "__has_builtin"); @@ -1474,7 +1475,8 @@ void Preprocessor::ExpandBuiltinMacro(To // __LINE__ expands to a simple numeric value. OS << (PLoc.isValid()? PLoc.getLine() : 1); Tok.setKind(tok::numeric_constant); - } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__) { + } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__ || + II == Ident__FILE_NAME__) { // C99 6.10.8: "__FILE__: The presumed name of the current source file (a // character string literal)". This can be affected by #line. PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation()); @@ -1495,7 +1497,21 @@ void Preprocessor::ExpandBuiltinMacro(To // Escape this filename. Turn '\' -> '\\' '"' -> '\"' SmallString<128> FN; if (PLoc.isValid()) { - FN += PLoc.getFilename(); + // __FILE_NAME__ is a Clang-specific extension that expands to the + // the last part of __FILE__. + if (II == Ident__FILE_NAME__) { +// Try to get the last path component. +StringRef PLFileName = PLoc.getFilename(); +size_t LastSep = PLFileName.find_last_of('/'); +// Skip the separator and get the last part, otherwise fall back on +// returning the original full filename. +if (LastSep != StringRef::npos) + FN += PLFileName.substr(LastSep+1); +else + FN += PLFileName; + } else { +FN += PLoc.getFilename(); + } Lexer::Stringify(FN); OS << '"' << FN << '"'; } Added: cfe/trunk/test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h?rev=360833&view=auto == --- cfe/trunk/test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h (added) +++ cfe/trunk/test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h Wed May 15 17:52:41 2019 @@ -0,0 +1,6 @@ +3: __FILE_NAME__ +4: "file_name_macro_include.h" +#
Re: r360833 - [Clang][PP] Add the __FILE_NAME__ builtin macro.
Yes, sorry about that, I did notice, just re-testing it, should have a fix for Windows bots in a few minutes. On Thu, May 16, 2019 at 3:26 AM wrote: > Hi Kristina, > > Your change does not seem to be working on Windows. Can you take a look? > > http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/6860 > > FAIL: Clang :: Preprocessor/file_name_macro.c (7959 of 14753) > TEST 'Clang :: Preprocessor/file_name_macro.c' FAILED > > Script: > -- > : 'RUN: at line 1'; > c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\clang.exe -cc1 > -internal-isystem > c:\b\slave\clang-x64-windows-msvc\build\build\stage1\lib\clang\9.0.0\include > -nostdsysteminc -E > C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c > -IC:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor/Inputs > | c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\filecheck.exe > -strict-whitespace > C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c > : 'RUN: at line 2'; > c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\clang.exe -cc1 > -internal-isystem > c:\b\slave\clang-x64-windows-msvc\build\build\stage1\lib\clang\9.0.0\include > -nostdsysteminc -fms-compatibility -DMS -E > C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c > -IC:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor/Inputs > | c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\filecheck.exe > -check-prefix=CHECK-MS -strict-whitespace > C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c > : 'RUN: at line 3'; > c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\clang.exe -cc1 > -internal-isystem > c:\b\slave\clang-x64-windows-msvc\build\build\stage1\lib\clang\9.0.0\include > -nostdsysteminc -E > C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c > -IC:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor/Inputs > -DBADINC -verify > -- > Exit Code: 1 > > Command Output (stdout): > -- > $ ":" "RUN: at line 1" > $ "c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\clang.exe" > "-cc1" "-internal-isystem" > "c:\b\slave\clang-x64-windows-msvc\build\build\stage1\lib\clang\9.0.0\include" > "-nostdsysteminc" "-E" > "C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c" > "-IC:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor/Inputs" > $ "c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\filecheck.exe" > "-strict-whitespace" > "C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c" > # command stderr: > C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\Preprocessor\file_name_macro.c:22:11: > error: CHECK: expected string not found in input > > // CHECK: {{^}}2: "file_name_macro.c" > > ^ > > :12:1: note: scanning from here > > 2: > "C:\\b\\slave\\clang-x64-windows-msvc\\build\\llvm.src\\tools\\clang\\test\\Preprocessor\\file_name_macro.c" > > ^ > > :12:87: note: possible intended match here > > 2: > "C:\\b\\slave\\clang-x64-windows-msvc\\build\\llvm.src\\tools\\clang\\test\\Preprocessor\\file_name_macro.c" > > > ^ > > > error: command failed with exit status: 1 > > Douglas Yung > > -Original Message- > From: cfe-commits On Behalf Of > Kristina Brooks via cfe-commits > Sent: Wednesday, May 15, 2019 17:53 > To: cfe-commits@lists.llvm.org > Subject: r360833 - [Clang][PP] Add the __FILE_NAME__ builtin macro. > > Author: kristina > Date: Wed May 15 17:52:41 2019 > New Revision: 360833 > > URL: http://llvm.org/viewvc/llvm-project?rev=360833&view=rev > Log: > [Clang][PP] Add the __FILE_NAME__ builtin macro. > > This patch adds the `__FILE_NAME__` macro that expands to the last > component of the path, similar to `__FILE__` except with a guarantee that > only the last path component (without the > separator) will be rendered. > > I intend to follow through with discussion of this with WG14 as a > potential inclusion in the C standard or failing that, try to discuss this > with GCC developers since this extension is desired by GCC and Clang > users/developers alike. > > Differential Revision: https://reviews.llvm.org/D61756
r360839 - Fix assumption about Win32 paths in r360833
Author: kristina Date: Wed May 15 19:46:12 2019 New Revision: 360839 URL: http://llvm.org/viewvc/llvm-project?rev=360839&view=rev Log: Fix assumption about Win32 paths in r360833 Attempt to fix Windows buildbots due to differences in path handling (caused by r360833). Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=360839&r1=360838&r2=360839&view=diff == --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original) +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Wed May 15 19:46:12 2019 @@ -1501,8 +1501,14 @@ void Preprocessor::ExpandBuiltinMacro(To // the last part of __FILE__. if (II == Ident__FILE_NAME__) { // Try to get the last path component. -StringRef PLFileName = PLoc.getFilename(); -size_t LastSep = PLFileName.find_last_of('/'); +StringRef PLFileName = PLoc.getFilename(); +size_t LastSep = PLFileName.find_last_of('/'); +#ifdef _WIN32 +// On Windows targets, absolute paths can be normalized to use +// backslashes instead - handle this potential case here. +if (LastSep == StringRef::npos) + LastSep = PLFileName.find_last_of('\\'); +#endif // Skip the separator and get the last part, otherwise fall back on // returning the original full filename. if (LastSep != StringRef::npos) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r360842 - Revert r360833 until I can work out the issue with Win32 bots
Author: kristina Date: Wed May 15 20:30:08 2019 New Revision: 360842 URL: http://llvm.org/viewvc/llvm-project?rev=360842&view=rev Log: Revert r360833 until I can work out the issue with Win32 bots This reverts "r360833: [Clang][PP] Add the __FILE_NAME__ builtin macro." The tests are failing on Windows bots, reverting the patchset until I can work out why. Removed: cfe/trunk/test/Preprocessor/Inputs/include-subdir/ cfe/trunk/test/Preprocessor/file_name_macro.c Modified: cfe/trunk/include/clang/Lex/Preprocessor.h cfe/trunk/lib/Lex/PPMacroExpansion.cpp Modified: cfe/trunk/include/clang/Lex/Preprocessor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=360842&r1=360841&r2=360842&view=diff == --- cfe/trunk/include/clang/Lex/Preprocessor.h (original) +++ cfe/trunk/include/clang/Lex/Preprocessor.h Wed May 15 20:30:08 2019 @@ -147,7 +147,6 @@ class Preprocessor { IdentifierInfo *Ident__DATE__, *Ident__TIME__; // __DATE__, __TIME__ IdentifierInfo *Ident__INCLUDE_LEVEL__; // __INCLUDE_LEVEL__ IdentifierInfo *Ident__BASE_FILE__; // __BASE_FILE__ - IdentifierInfo *Ident__FILE_NAME__; // __FILE_NAME__ IdentifierInfo *Ident__TIMESTAMP__; // __TIMESTAMP__ IdentifierInfo *Ident__COUNTER__;// __COUNTER__ IdentifierInfo *Ident_Pragma, *Ident__pragma;// _Pragma, __pragma Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=360842&r1=360841&r2=360842&view=diff == --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original) +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Wed May 15 20:30:08 2019 @@ -363,7 +363,6 @@ void Preprocessor::RegisterBuiltinMacros } // Clang Extensions. - Ident__FILE_NAME__ = RegisterBuiltinMacro(*this, "__FILE_NAME__"); Ident__has_feature = RegisterBuiltinMacro(*this, "__has_feature"); Ident__has_extension= RegisterBuiltinMacro(*this, "__has_extension"); Ident__has_builtin = RegisterBuiltinMacro(*this, "__has_builtin"); @@ -1475,8 +1474,7 @@ void Preprocessor::ExpandBuiltinMacro(To // __LINE__ expands to a simple numeric value. OS << (PLoc.isValid()? PLoc.getLine() : 1); Tok.setKind(tok::numeric_constant); - } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__ || - II == Ident__FILE_NAME__) { + } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__) { // C99 6.10.8: "__FILE__: The presumed name of the current source file (a // character string literal)". This can be affected by #line. PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation()); @@ -1497,27 +1495,7 @@ void Preprocessor::ExpandBuiltinMacro(To // Escape this filename. Turn '\' -> '\\' '"' -> '\"' SmallString<128> FN; if (PLoc.isValid()) { - // __FILE_NAME__ is a Clang-specific extension that expands to the - // the last part of __FILE__. - if (II == Ident__FILE_NAME__) { -// Try to get the last path component. -StringRef PLFileName = PLoc.getFilename(); -size_t LastSep = PLFileName.find_last_of('/'); -#ifdef _WIN32 -// On Windows targets, absolute paths can be normalized to use -// backslashes instead - handle this potential case here. -if (LastSep == StringRef::npos) - LastSep = PLFileName.find_last_of('\\'); -#endif -// Skip the separator and get the last part, otherwise fall back on -// returning the original full filename. -if (LastSep != StringRef::npos) - FN += PLFileName.substr(LastSep+1); -else - FN += PLFileName; - } else { -FN += PLoc.getFilename(); - } + FN += PLoc.getFilename(); Lexer::Stringify(FN); OS << '"' << FN << '"'; } Removed: cfe/trunk/test/Preprocessor/file_name_macro.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/file_name_macro.c?rev=360841&view=auto == --- cfe/trunk/test/Preprocessor/file_name_macro.c (original) +++ cfe/trunk/test/Preprocessor/file_name_macro.c (removed) @@ -1,44 +0,0 @@ -// RUN: %clang_cc1 -E %s -I%S/Inputs | FileCheck -strict-whitespace %s -// RUN: %clang_cc1 -fms-compatibility -DMS -E %s -I%S/Inputs | FileCheck -check-prefix=CHECK-MS -strict-whitespace %s -// RUN: %clang_cc1 -E %s -I%S/Inputs -DBADINC -verify - -#ifdef BADINC - -// Paranoia. - -__FILE_NAME__ -#include // expected-error {{file not found}} -__FILE_NAME__ - -#else - -// Reference. -1: "file_name_macro.c" - -// Ensure it expands correctly for this file. -2: __FILE_NAME__ - -// CHECK: {{^}}1: "file_name_macro.c" -// CHECK: {{^}}2: "file_name_macro.c" - -// Test if inclusion works right. -#ifde
r360938 - Reland "[Clang][PP] Add the __FILE_NAME__ builtin macro"
Author: kristina Date: Thu May 16 14:13:49 2019 New Revision: 360938 URL: http://llvm.org/viewvc/llvm-project?rev=360938&view=rev Log: Reland "[Clang][PP] Add the __FILE_NAME__ builtin macro" This relands commit rL360833 which caused issues on Win32 bots due to path handling/normalization differences. Now this uses `sys::path::filename` which should handle additional edge cases on Win32. Original commit: "[Clang][PP] Add the __FILE_NAME__ builtin macro" This patch adds the __FILE_NAME__ macro that expands to the last component of the path, similar to __FILE__ except with a guarantee that only the last path component (without the separator) will be rendered. I intend to follow through with discussion of this with WG14 as a potential inclusion in the C standard or failing that, try to discuss this with GCC developers since this extension is desired by GCC and Clang users/developers alike. Differential Revision: https://reviews.llvm.org/D61756 Added: cfe/trunk/test/Preprocessor/Inputs/include-subdir/ cfe/trunk/test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h cfe/trunk/test/Preprocessor/Inputs/include-subdir/h cfe/trunk/test/Preprocessor/Inputs/include-subdir/subdir1/ cfe/trunk/test/Preprocessor/Inputs/include-subdir/subdir1/hdr1.h cfe/trunk/test/Preprocessor/Inputs/include-subdir/subdir1/hdr2.h cfe/trunk/test/Preprocessor/file_name_macro.c Modified: cfe/trunk/include/clang/Lex/Preprocessor.h cfe/trunk/lib/Lex/PPMacroExpansion.cpp Modified: cfe/trunk/include/clang/Lex/Preprocessor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=360938&r1=360937&r2=360938&view=diff == --- cfe/trunk/include/clang/Lex/Preprocessor.h (original) +++ cfe/trunk/include/clang/Lex/Preprocessor.h Thu May 16 14:13:49 2019 @@ -147,6 +147,7 @@ class Preprocessor { IdentifierInfo *Ident__DATE__, *Ident__TIME__; // __DATE__, __TIME__ IdentifierInfo *Ident__INCLUDE_LEVEL__; // __INCLUDE_LEVEL__ IdentifierInfo *Ident__BASE_FILE__; // __BASE_FILE__ + IdentifierInfo *Ident__FILE_NAME__; // __FILE_NAME__ IdentifierInfo *Ident__TIMESTAMP__; // __TIMESTAMP__ IdentifierInfo *Ident__COUNTER__;// __COUNTER__ IdentifierInfo *Ident_Pragma, *Ident__pragma;// _Pragma, __pragma Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=360938&r1=360937&r2=360938&view=diff == --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original) +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Thu May 16 14:13:49 2019 @@ -43,6 +43,7 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Format.h" +#include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" #include #include @@ -363,6 +364,7 @@ void Preprocessor::RegisterBuiltinMacros } // Clang Extensions. + Ident__FILE_NAME__ = RegisterBuiltinMacro(*this, "__FILE_NAME__"); Ident__has_feature = RegisterBuiltinMacro(*this, "__has_feature"); Ident__has_extension= RegisterBuiltinMacro(*this, "__has_extension"); Ident__has_builtin = RegisterBuiltinMacro(*this, "__has_builtin"); @@ -1474,7 +1476,8 @@ void Preprocessor::ExpandBuiltinMacro(To // __LINE__ expands to a simple numeric value. OS << (PLoc.isValid()? PLoc.getLine() : 1); Tok.setKind(tok::numeric_constant); - } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__) { + } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__ || + II == Ident__FILE_NAME__) { // C99 6.10.8: "__FILE__: The presumed name of the current source file (a // character string literal)". This can be affected by #line. PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation()); @@ -1495,7 +1498,19 @@ void Preprocessor::ExpandBuiltinMacro(To // Escape this filename. Turn '\' -> '\\' '"' -> '\"' SmallString<128> FN; if (PLoc.isValid()) { - FN += PLoc.getFilename(); + // __FILE_NAME__ is a Clang-specific extension that expands to the + // the last part of __FILE__. + if (II == Ident__FILE_NAME__) { +// Try to get the last path component, failing that return the original +// presumed location. +StringRef PLFileName = llvm::sys::path::filename(PLoc.getFilename()); +if (PLFileName != "") + FN += PLFileName; +else + FN += PLoc.getFilename(); + } else { +FN += PLoc.getFilename(); + } Lexer::Stringify(FN); OS << '"' << FN << '"'; } Added: cfe/trunk/test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/Inputs/include-subdir/file_name_macro
Re: r360974 - Refactor constant evaluation of typeid(T) to track a symbolic type_info
It seems to have been causing asserts to trip on 64-bit hosts while running tests (ppc64be, ppc64le and x86_64 were all affected), ie: http://lab.llvm.org:8011/builders/clang-cmake-x86_64-avx2-linux/builds/9528/steps/test-suite/logs/test.log On Fri, May 17, 2019 at 6:51 AM via cfe-commits wrote: > I'm not sure that is problem. Our internal linux build bot also hit the > same problem and it has a 64-bit CPU. > > Douglas Yung > > -Original Message- > From: cfe-commits On Behalf Of Chris > Bieneman via cfe-commits > Sent: Thursday, May 16, 2019 22:45 > To: Chris Bieneman > Cc: Richard Smith ; cfe-commits@lists.llvm.org > Subject: Re: r360974 - Refactor constant evaluation of typeid(T) to track > a symbolic type_info > > I did some digging before reverting. The bots your patch is failing on are > 32-bit CPUs. It looks like your static_assert is assuming 8-byte aligned > pointers, so it always fails on the 32-bit builders. > > -Chris > > > On May 16, 2019, at 10:14 PM, Chris Bieneman > wrote: > > > > Sorry to do this, but I'm also reverting r360977, because it seems to be > on top of this one. > > > > -Chris > > > >> On May 16, 2019, at 9:58 PM, Chris Bieneman via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> > >> Hey Richard, > >> > >> This change is tripping up a bunch of the bots: > >> > >> http://lab.llvm.org:8011/builders/clang-cmake-armv8-lld/builds/1397 > >> > >> I'm going to revert it so that we don't leave the bots broken overnight. > >> > >> -Chris > >> > >>> On May 16, 2019, at 6:46 PM, Richard Smith via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >>> > >>> Author: rsmith > >>> Date: Thu May 16 18:46:05 2019 > >>> New Revision: 360974 > >>> > >>> URL: http://llvm.org/viewvc/llvm-project?rev=360974&view=rev > >>> Log: > >>> Refactor constant evaluation of typeid(T) to track a symbolic > >>> type_info object rather than tracking the originating expression. > >>> > >>> This is groundwork for supporting polymorphic typeid expressions. > >>> (Note that this somewhat regresses our support for DR1968, but it > >>> turns out that that never actually worked anyway, at least in > >>> non-trivial cases.) > >>> > >>> Modified: > >>> cfe/trunk/include/clang/AST/APValue.h > >>> cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td > >>> cfe/trunk/lib/AST/APValue.cpp > >>> cfe/trunk/lib/AST/ExprConstant.cpp > >>> cfe/trunk/lib/CodeGen/CGExprConstant.cpp > >>> cfe/trunk/lib/Sema/SemaTemplate.cpp > >>> cfe/trunk/test/CXX/drs/dr19xx.cpp > >>> cfe/trunk/test/Parser/MicrosoftExtensions.cpp > >>> cfe/trunk/test/SemaCXX/builtin-constant-p.cpp > >>> cfe/trunk/test/SemaCXX/typeid.cpp > >>> cfe/trunk/www/cxx_dr_status.html > >>> > >>> Modified: cfe/trunk/include/clang/AST/APValue.h > >>> URL: > >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/APVa > >>> lue.h?rev=360974&r1=360973&r2=360974&view=diff > >>> > >>> == > >>> --- cfe/trunk/include/clang/AST/APValue.h (original) > >>> +++ cfe/trunk/include/clang/AST/APValue.h Thu May 16 18:46:05 2019 > >>> @@ -24,14 +24,52 @@ namespace clang { class AddrLabelExpr; class > >>> ASTContext; class CharUnits; > >>> + class CXXRecordDecl; > >>> + class Decl; > >>> class DiagnosticBuilder; > >>> class Expr; > >>> class FieldDecl; > >>> - class Decl; > >>> + struct PrintingPolicy; > >>> + class Type; > >>> class ValueDecl; > >>> - class CXXRecordDecl; > >>> - class QualType; > >>> > >>> +/// Symbolic representation of typeid(T) for some type T. > >>> +class TypeInfoLValue { > >>> + const Type *T; > >>> + > >>> +public: > >>> + TypeInfoLValue() : T() {} > >>> + explicit TypeInfoLValue(const Type *T); > >>> + > >>> + const Type *getType() const { return T; } explicit operator > >>> + bool() const { return T; } > >>> + > >>> + void *getOpaqueValue() { return const_cast(T); } static > >>> + TypeInfoLValue getFromOpaqueValue(void *Value) { > >>> +TypeInfoLValue V; > >>> +V.T = reinterpret_cast(Value); > >>> +return V; > >>> + } > >>> + > >>> + void print(llvm::raw_ostream &Out, const PrintingPolicy &Policy) > >>> +const; }; } > >>> + > >>> +namespace llvm { > >>> +template<> struct PointerLikeTypeTraits { > >>> + static void *getAsVoidPointer(clang::TypeInfoLValue V) { > >>> +return V.getOpaqueValue(); > >>> + } > >>> + static clang::TypeInfoLValue getFromVoidPointer(void *P) { > >>> +return clang::TypeInfoLValue::getFromOpaqueValue(P); > >>> + } > >>> + // Validated by static_assert in APValue.cpp; hardcoded to avoid > >>> +needing > >>> + // to include Type.h. > >>> + static constexpr int NumLowBitsAvailable = 3; }; } > >>> + > >>> +namespace clang { > >>> /// APValue - This class implements a discriminated union of > >>> [uninitialized] /// [APSInt] [APFloat], [Complex APSInt] [Complex > >>> APFloat], [Expr + Offset], /// [Vector: N * APValue], [Array: N * > >>> APValue] @@ -57,13 +95,18 @@ public: > >>> > >>> c
r360994 - [Clang][Docs] Document __FILE_NAME__. NFC
Author: kristina Date: Thu May 16 23:46:12 2019 New Revision: 360994 URL: http://llvm.org/viewvc/llvm-project?rev=360994&view=rev Log: [Clang][Docs] Document __FILE_NAME__. NFC Document the `__FILE_NAME__` preprocessor extension. Modified: cfe/trunk/docs/LanguageExtensions.rst Modified: cfe/trunk/docs/LanguageExtensions.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=360994&r1=360993&r2=360994&view=diff == --- cfe/trunk/docs/LanguageExtensions.rst (original) +++ cfe/trunk/docs/LanguageExtensions.rst Thu May 16 23:46:12 2019 @@ -330,6 +330,11 @@ Builtin Macros ``__BASE_FILE__`` Defined to a string that contains the name of the main input file passed to Clang. + +``__FILE_NAME__`` + Clang-specific extension that functions similar to ``__FILE__`` but only + renders the last path component (the filename) instead of an invocation + dependent full path to that file. ``__COUNTER__`` Defined to an integer value that starts at zero and is incremented each time ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] b18cb9c - [Gnu toolchain] Look at standard GCC paths for libstdcxx by default
Author: Kristina Brooks Date: 2020-01-05T21:43:18Z New Revision: b18cb9c4716677b048a88125be14d59a56865b9c URL: https://github.com/llvm/llvm-project/commit/b18cb9c4716677b048a88125be14d59a56865b9c DIFF: https://github.com/llvm/llvm-project/commit/b18cb9c4716677b048a88125be14d59a56865b9c.diff LOG: [Gnu toolchain] Look at standard GCC paths for libstdcxx by default Linux' current addLibCxxIncludePaths and addLibStdCxxIncludePaths are actually almost non-Linux-specific at all, and can be reused almost as such for all gcc toolchains. Only keep Android/Freescale/Cray hacks in Linux's version. Patch by sthibaul (Samuel Thibault) Differential Revision: https://reviews.llvm.org/D69758 Added: Modified: clang/lib/Driver/ToolChains/Gnu.cpp clang/lib/Driver/ToolChains/Gnu.h clang/lib/Driver/ToolChains/Hurd.cpp clang/lib/Driver/ToolChains/Hurd.h clang/lib/Driver/ToolChains/Linux.cpp clang/lib/Driver/ToolChains/Linux.h Removed: diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index 7c0bcdcaf074..91076709fd76 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -2686,19 +2686,49 @@ void Generic_GCC::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, } } -void -Generic_GCC::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, - llvm::opt::ArgStringList &CC1Args) const { - // FIXME: The Linux behavior would probaby be a better approach here. - addSystemInclude(DriverArgs, CC1Args, - getDriver().SysRoot + "/usr/include/c++/v1"); +static std::string DetectLibcxxIncludePath(llvm::vfs::FileSystem &vfs, + StringRef base) { + std::error_code EC; + int MaxVersion = 0; + std::string MaxVersionString; + for (llvm::vfs::directory_iterator LI = vfs.dir_begin(base, EC), LE; + !EC && LI != LE; LI = LI.increment(EC)) { +StringRef VersionText = llvm::sys::path::filename(LI->path()); +int Version; +if (VersionText[0] == 'v' && +!VersionText.slice(1, StringRef::npos).getAsInteger(10, Version)) { + if (Version > MaxVersion) { +MaxVersion = Version; +MaxVersionString = VersionText; + } +} + } + return MaxVersion ? (base + "/" + MaxVersionString).str() : ""; } void -Generic_GCC::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, - llvm::opt::ArgStringList &CC1Args) const { - // By default, we don't assume we know where libstdc++ might be installed. - // FIXME: If we have a valid GCCInstallation, use it. +Generic_GCC::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const { + const std::string& SysRoot = getDriver().SysRoot; + auto AddIncludePath = [&](std::string Path) { +std::string IncludePath = DetectLibcxxIncludePath(getVFS(), Path); +if (IncludePath.empty() || !getVFS().exists(IncludePath)) + return false; +addSystemInclude(DriverArgs, CC1Args, IncludePath); +return true; + }; + // Android never uses the libc++ headers installed alongside the toolchain, + // which are generally incompatible with the NDK libraries anyway. + if (!getTriple().isAndroid()) +if (AddIncludePath(getDriver().Dir + "/../include/c++")) + return; + // If this is a development, non-installed, clang, libcxx will + // not be found at ../include/c++ but it likely to be found at + // one of the following two locations: + if (AddIncludePath(SysRoot + "/usr/local/include/c++")) +return; + if (AddIncludePath(SysRoot + "/usr/include/c++")) +return; } /// Helper to add the variant paths of a libstdc++ installation. @@ -2734,6 +2764,60 @@ bool Generic_GCC::addLibStdCXXIncludePaths( return true; } +bool +Generic_GCC::addGCCLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const { + // Use GCCInstallation to know where libstdc++ headers are installed. + if (!GCCInstallation.isValid()) +return false; + + // By default, look for the C++ headers in an include directory adjacent to + // the lib directory of the GCC installation. Note that this is expect to be + // equivalent to '/usr/include/c++/X.Y' in almost all cases. + StringRef LibDir = GCCInstallation.getParentLibPath(); + StringRef InstallDir = GCCInstallation.getInstallPath(); + StringRef TripleStr = GCCInstallation.getTriple().str(); + const Multilib &Multilib = GCCInstallation.getMultilib(); + const std::string GCCMultiarchTriple = getMultiarchTriple( + getDriver(), GCCInstallation.getTriple(), getDriver().SysRoot); + const std::string TargetMultiarchTriple = + getMultiarchTriple(getDriver(), getTriple(), getDriver().SysRoot); + const G
[clang] ce67db4 - [Clang] Force rtlib=platform in test to avoid fails with CLANG_DEFAULT_RTLIB
Author: Kristina Brooks Date: 2020-01-06T07:21:15Z New Revision: ce67db4185374016a9f5745869f9dbedfc12e6d2 URL: https://github.com/llvm/llvm-project/commit/ce67db4185374016a9f5745869f9dbedfc12e6d2 DIFF: https://github.com/llvm/llvm-project/commit/ce67db4185374016a9f5745869f9dbedfc12e6d2.diff LOG: [Clang] Force rtlib=platform in test to avoid fails with CLANG_DEFAULT_RTLIB Driver test `cross-linux.c` fails when CLANG_DEFAULT_RTLIB is "compiler-rt" as the it expects a GCC-style `"crtbegin.o"` after `"crti.o"` but instead receives something akin to this in the frontend invocation: ``` "crt1.o" "crti.o" "/o/b/llvm/bin/../lib/clang/10.0.0/lib/linux/clang_rt.crtbegin-x86_64.o" ``` This patch adds an override to `cross-linux.c` tests so the expected result is produced regardless of the compile-time default rtlib, as having tests fail due to that is fairly confusing. After applying the patch, the test passes regardless of the CLANG_DEFAULT_RTLIB setting. Differential Revision: https://reviews.llvm.org/D72236 Added: Modified: clang/test/Driver/cross-linux.c Removed: diff --git a/clang/test/Driver/cross-linux.c b/clang/test/Driver/cross-linux.c index a5ea832e77ea..6c2dab260695 100644 --- a/clang/test/Driver/cross-linux.c +++ b/clang/test/Driver/cross-linux.c @@ -52,6 +52,7 @@ // RUN: %clang -### -o %t %s 2>&1 -no-integrated-as -fuse-ld=ld \ // RUN: --gcc-toolchain=%S/Inputs/multilib_32bit_linux_tree/usr \ // RUN: --target=x86_64-unknown-linux \ +// RUN: --rtlib=platform \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-MULTI32-X86-64 %s // CHECK-MULTI32-X86-64: "-cc1" "-triple" "x86_64-unknown-linux" @@ -70,6 +71,7 @@ // RUN: %clang -### -o %t %s 2>&1 -no-integrated-as -fuse-ld=ld \ // RUN: --gcc-toolchain=%S/Inputs/multilib_64bit_linux_tree/usr \ // RUN: --target=i386-unknown-linux \ +// RUN: --rtlib=platform \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-MULTI64-I386 %s // CHECK-MULTI64-I386: "-cc1" "-triple" "i386-unknown-linux" @@ -88,6 +90,7 @@ // RUN: %clang -### -o %t %s 2>&1 -no-integrated-as -fuse-ld=ld \ // RUN: --gcc-toolchain=%S/Inputs/multilib_64bit_linux_tree/usr \ // RUN: --target=x86_64-unknown-linux \ +// RUN: --rtlib=platform \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-MULTI64-X86-64 %s // CHECK-MULTI64-X86-64: "-cc1" "-triple" "x86_64-unknown-linux" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits