[clang-tools-extra] r337527 - [clangd] FuzzyMatch exposes an API for its word segmentation. NFC
Author: sammccall Date: Fri Jul 20 01:01:37 2018 New Revision: 337527 URL: http://llvm.org/viewvc/llvm-project?rev=337527&view=rev Log: [clangd] FuzzyMatch exposes an API for its word segmentation. NFC Summary: This is intended to be used for indexing, e.g. in D49417 Reviewers: ioeric, omtcyfz Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D49540 Modified: clang-tools-extra/trunk/clangd/FuzzyMatch.cpp clang-tools-extra/trunk/clangd/FuzzyMatch.h clang-tools-extra/trunk/unittests/clangd/FuzzyMatchTests.cpp Modified: clang-tools-extra/trunk/clangd/FuzzyMatch.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FuzzyMatch.cpp?rev=337527&r1=337526&r2=337527&view=diff == --- clang-tools-extra/trunk/clangd/FuzzyMatch.cpp (original) +++ clang-tools-extra/trunk/clangd/FuzzyMatch.cpp Fri Jul 20 01:01:37 2018 @@ -87,8 +87,8 @@ FuzzyMatcher::FuzzyMatcher(StringRef Pat for (int W = 0; W < P; ++W) for (Action A : {Miss, Match}) Scores[P][W][A] = {AwfulScore, Miss}; - if (PatN > 0) -calculateRoles(Pat, PatRole, PatTypeSet, PatN); + PatTypeSet = + calculateRoles(StringRef(Pat, PatN), makeMutableArrayRef(PatRole, PatN)); } Optional FuzzyMatcher::match(StringRef Word) { @@ -110,25 +110,6 @@ Optional FuzzyMatcher::match(Stri return Score; } -// Segmentation of words and patterns. -// A name like "fooBar_baz" consists of several parts foo, bar, baz. -// Aligning segmentation of word and pattern improves the fuzzy-match. -// For example: [lol] matches "LaughingOutLoud" better than "LionPopulation" -// -// First we classify each character into types (uppercase, lowercase, etc). -// Then we look at the sequence: e.g. [upper, lower] is the start of a segment. - -// We only distinguish the types of characters that affect segmentation. -// It's not obvious how to segment digits, we treat them as lowercase letters. -// As we don't decode UTF-8, we treat bytes over 127 as lowercase too. -// This means we require exact (case-sensitive) match. -enum FuzzyMatcher::CharType : unsigned char { - Empty = 0, // Before-the-start and after-the-end (and control chars). - Lower = 1, // Lowercase letters, digits, and non-ASCII bytes. - Upper = 2, // Uppercase letters. - Punctuation = 3, // ASCII punctuation (including Space) -}; - // We get CharTypes from a lookup table. Each is 2 bits, 4 fit in each byte. // The top 6 bits of the char select the byte, the bottom 2 select the offset. // e.g. 'q' = 010100 01 = byte 28 (55), bits 3-2 (01) -> Lower. @@ -147,17 +128,6 @@ constexpr static uint8_t CharTypes[] = { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, }; -// Each character's Role is the Head or Tail of a segment, or a Separator. -// e.g. XMLHttpRequest_Async -// +--+---+-- + -// ^Head ^Tail ^Separator -enum FuzzyMatcher::CharRole : unsigned char { - Unknown = 0, // Stray control characters or impossible states. - Tail = 1, // Part of a word segment, but not the first character. - Head = 2, // The first character of a word segment. - Separator = 3, // Punctuation characters that separate word segments. -}; - // The Role can be determined from the Type of a character and its neighbors: // // Example | Chars | Type | Role @@ -183,26 +153,28 @@ constexpr static uint8_t CharRoles[] = { template static T packedLookup(const uint8_t *Data, int I) { return static_cast((Data[I >> 2] >> ((I & 3) * 2)) & 3); } -void FuzzyMatcher::calculateRoles(const char *Text, CharRole *Out, int &TypeSet, - int N) { - assert(N > 0); +CharTypeSet calculateRoles(StringRef Text, MutableArrayRef Roles) { + assert(Text.size() == Roles.size()); + if (Text.size() == 0) +return 0; CharType Type = packedLookup(CharTypes, Text[0]); - TypeSet = 1 << Type; + CharTypeSet TypeSet = 1 << Type; // Types holds a sliding window of (Prev, Curr, Next) types. // Initial value is (Empty, Empty, type of Text[0]). int Types = Type; // Rotate slides in the type of the next character. auto Rotate = [&](CharType T) { Types = ((Types << 2) | T) & 0x3f; }; - for (int I = 0; I < N - 1; ++I) { + for (unsigned I = 0; I < Text.size() - 1; ++I) { // For each character, rotate in the next, and look up the role. Type = packedLookup(CharTypes, Text[I + 1]); TypeSet |= 1 << Type; Rotate(Type); -*Out++ = packedLookup(CharRoles, Types); +Roles[I] = packedLookup(CharRoles, Types); } // For the last character, the "next character" is Empty. Rotate(Empty); - *Out++ = packedLookup(CharRoles, Types); + Roles[Text.size() - 1] = packedLookup(CharRoles, Types); + return TypeSet; } // Sets up the data structures matching Word. @@ -228,7 +200,8 @@ bool FuzzyMatcher::init(StringRef NewWor // FIXME: some wor
[PATCH] D49540: [clangd] FuzzyMatch exposes an API for its word segmentation. NFC
This revision was automatically updated to reflect the committed changes. Closed by commit rL337527: [clangd] FuzzyMatch exposes an API for its word segmentation. NFC (authored by sammccall, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D49540 Files: clang-tools-extra/trunk/clangd/FuzzyMatch.cpp clang-tools-extra/trunk/clangd/FuzzyMatch.h clang-tools-extra/trunk/unittests/clangd/FuzzyMatchTests.cpp Index: clang-tools-extra/trunk/unittests/clangd/FuzzyMatchTests.cpp === --- clang-tools-extra/trunk/unittests/clangd/FuzzyMatchTests.cpp +++ clang-tools-extra/trunk/unittests/clangd/FuzzyMatchTests.cpp @@ -273,6 +273,29 @@ EXPECT_THAT("Abs", matches("[abs]", 2.f)); } +// Returns pretty-printed segmentation of Text. +// e.g. std::basic_string --> +-- + +- +std::string segment(StringRef Text) { + std::vector Roles(Text.size()); + calculateRoles(Text, Roles); + std::string Printed; + for (unsigned I = 0; I < Text.size(); ++I) +Printed.push_back("?-+ "[static_cast(Roles[I])]); + return Printed; +} + +// this is a no-op hack so clang-format will vertically align our testcases. +StringRef returns(StringRef Text) { return Text; } + +TEST(FuzzyMatch, Segmentation) { + EXPECT_THAT(segment("std::basic_string"), // + returns("+-- + +-")); + EXPECT_THAT(segment("XMLHttpRequest"), // + returns("+--+---+--")); + EXPECT_THAT(segment("t3h PeNgU1N oF d00m"), // + returns("+-- +-+-+-+ ++ +---")); +} + } // namespace } // namespace clangd } // namespace clang Index: clang-tools-extra/trunk/clangd/FuzzyMatch.h === --- clang-tools-extra/trunk/clangd/FuzzyMatch.h +++ clang-tools-extra/trunk/clangd/FuzzyMatch.h @@ -16,14 +16,57 @@ #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUZZYMATCH_H #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUZZYMATCH_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/raw_ostream.h" namespace clang { namespace clangd { +// Utilities for word segmentation. +// FuzzyMatcher already incorporates this logic, so most users don't need this. +// +// A name like "fooBar_baz" consists of several parts foo, bar, baz. +// Aligning segmentation of word and pattern improves the fuzzy-match. +// For example: [lol] matches "LaughingOutLoud" better than "LionPopulation" +// +// First we classify each character into types (uppercase, lowercase, etc). +// Then we look at the sequence: e.g. [upper, lower] is the start of a segment. + +// We distinguish the types of characters that affect segmentation. +// It's not obvious how to segment digits, we treat them as lowercase letters. +// As we don't decode UTF-8, we treat bytes over 127 as lowercase too. +// This means we require exact (case-sensitive) match for those characters. +enum CharType : unsigned char { + Empty = 0, // Before-the-start and after-the-end (and control chars). + Lower = 1, // Lowercase letters, digits, and non-ASCII bytes. + Upper = 2, // Uppercase letters. + Punctuation = 3, // ASCII punctuation (including Space) +}; +// A CharTypeSet is a bitfield representing all the character types in a word. +// Its bits are 1< Roles); + // A matcher capable of matching and scoring strings against a single pattern. // It's optimized for matching against many strings - match() does not allocate. class FuzzyMatcher { @@ -48,8 +91,6 @@ private: // We truncate the pattern and the word to bound the cost of matching. constexpr static int MaxPat = 63, MaxWord = 127; - enum CharRole : unsigned char; // For segmentation. - enum CharType : unsigned char; // For segmentation. // Action describes how a word character was matched to the pattern. // It should be an enum, but this causes bitfield problems: // - for MSVC the enum type must be explicitly unsigned for correctness @@ -60,7 +101,6 @@ bool init(llvm::StringRef Word); void buildGraph(); - void calculateRoles(const char *Text, CharRole *Out, int &Types, int N); bool allowMatch(int P, int W, Action Last) const; int skipPenalty(int W, Action Last) const; int matchBonus(int P, int W, Action Last) const; @@ -70,15 +110,15 @@ int PatN; // Length char LowPat[MaxPat]; // Pattern in lowercase CharRole PatRole[MaxPat]; // Pattern segmentation info - int PatTypeSet; // Bitmask of 1< 0) -calculateRoles(Pat, PatRole, PatTypeSet, PatN); + PatTypeSet = + calculateRoles(StringRef(Pat, PatN), makeMutableArrayRef(PatRole, PatN)); } Optional FuzzyMatcher::match(StringRef Word) { @@ -110,25 +110,6 @@ return Score; } -// Segmentation of words and patterns. -// A name like "fooBar_baz" consists of several parts foo, bar, baz. -// Aligni
r337529 - [Index] Set OrigD before D is changed.
Author: ioeric Date: Fri Jul 20 01:08:56 2018 New Revision: 337529 URL: http://llvm.org/viewvc/llvm-project?rev=337529&view=rev Log: [Index] Set OrigD before D is changed. Reviewers: akyrtzi, arphaman Reviewed By: akyrtzi Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49476 Added: cfe/trunk/test/Index/index-template-specialization.cpp Modified: cfe/trunk/lib/Index/IndexingContext.cpp cfe/trunk/tools/c-index-test/c-index-test.c cfe/trunk/tools/libclang/Indexing.cpp Modified: cfe/trunk/lib/Index/IndexingContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexingContext.cpp?rev=337529&r1=337528&r2=337529&view=diff == --- cfe/trunk/lib/Index/IndexingContext.cpp (original) +++ cfe/trunk/lib/Index/IndexingContext.cpp Fri Jul 20 01:08:56 2018 @@ -350,6 +350,9 @@ bool IndexingContext::handleDeclOccurren } } + if (!OrigD) +OrigD = D; + if (isTemplateImplicitInstantiation(D)) { if (!IsRef) return true; @@ -359,9 +362,6 @@ bool IndexingContext::handleDeclOccurren assert(!isTemplateImplicitInstantiation(D)); } - if (!OrigD) -OrigD = D; - if (IsRef) Roles |= (unsigned)SymbolRole::Reference; else if (isDeclADefinition(OrigD, ContainerDC, *Ctx)) Added: cfe/trunk/test/Index/index-template-specialization.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-template-specialization.cpp?rev=337529&view=auto == --- cfe/trunk/test/Index/index-template-specialization.cpp (added) +++ cfe/trunk/test/Index/index-template-specialization.cpp Fri Jul 20 01:08:56 2018 @@ -0,0 +1,19 @@ +template +class Foo { +public: + void f(T t) {} +}; + +void g() { + Foo foo; + foo.f(0); +} + +// FIXME: if c-index-test uses OrigD for symbol info, refererences below should +// refer to template specialization decls. +// RUN: env CINDEXTEST_INDEXIMPLICITTEMPLATEINSTANTIATIONS=1 c-index-test -index-file %s | FileCheck %s +// CHECK: [indexDeclaration]: kind: c++-class-template | name: Foo +// CHECK-NEXT: [indexDeclaration]: kind: c++-instance-method | name: f +// CHECK-NEXT: [indexDeclaration]: kind: function | name: g +// CHECK-NEXT: [indexEntityReference]: kind: c++-class-template | name: Foo | USR: c:@ST>1#T@Foo +// CHECK-NEXT: [indexEntityReference]: kind: c++-instance-method | name: f | USR: c:@ST>1#T@Foo@F@f#t0.0# Modified: cfe/trunk/tools/c-index-test/c-index-test.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=337529&r1=337528&r2=337529&view=diff == --- cfe/trunk/tools/c-index-test/c-index-test.c (original) +++ cfe/trunk/tools/c-index-test/c-index-test.c Fri Jul 20 01:08:56 2018 @@ -3652,6 +3652,8 @@ static unsigned getIndexOptions(void) { index_opts |= CXIndexOpt_IndexFunctionLocalSymbols; if (!getenv("CINDEXTEST_DISABLE_SKIPPARSEDBODIES")) index_opts |= CXIndexOpt_SkipParsedBodiesInSession; + if (getenv("CINDEXTEST_INDEXIMPLICITTEMPLATEINSTANTIATIONS")) +index_opts |= CXIndexOpt_IndexImplicitTemplateInstantiations; return index_opts; } Modified: cfe/trunk/tools/libclang/Indexing.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/Indexing.cpp?rev=337529&r1=337528&r2=337529&view=diff == --- cfe/trunk/tools/libclang/Indexing.cpp (original) +++ cfe/trunk/tools/libclang/Indexing.cpp Fri Jul 20 01:08:56 2018 @@ -402,6 +402,8 @@ static IndexingOptions getIndexingOption IndexingOptions IdxOpts; if (index_options & CXIndexOpt_IndexFunctionLocalSymbols) IdxOpts.IndexFunctionLocals = true; + if (index_options & CXIndexOpt_IndexImplicitTemplateInstantiations) +IdxOpts.IndexImplicitInstantiation = true; return IdxOpts; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49476: [Index] Set OrigD before D is changed.
This revision was automatically updated to reflect the committed changes. Closed by commit rL337529: [Index] Set OrigD before D is changed. (authored by ioeric, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D49476 Files: cfe/trunk/lib/Index/IndexingContext.cpp cfe/trunk/test/Index/index-template-specialization.cpp cfe/trunk/tools/c-index-test/c-index-test.c cfe/trunk/tools/libclang/Indexing.cpp Index: cfe/trunk/lib/Index/IndexingContext.cpp === --- cfe/trunk/lib/Index/IndexingContext.cpp +++ cfe/trunk/lib/Index/IndexingContext.cpp @@ -350,6 +350,9 @@ } } + if (!OrigD) +OrigD = D; + if (isTemplateImplicitInstantiation(D)) { if (!IsRef) return true; @@ -359,9 +362,6 @@ assert(!isTemplateImplicitInstantiation(D)); } - if (!OrigD) -OrigD = D; - if (IsRef) Roles |= (unsigned)SymbolRole::Reference; else if (isDeclADefinition(OrigD, ContainerDC, *Ctx)) Index: cfe/trunk/tools/libclang/Indexing.cpp === --- cfe/trunk/tools/libclang/Indexing.cpp +++ cfe/trunk/tools/libclang/Indexing.cpp @@ -402,6 +402,8 @@ IndexingOptions IdxOpts; if (index_options & CXIndexOpt_IndexFunctionLocalSymbols) IdxOpts.IndexFunctionLocals = true; + if (index_options & CXIndexOpt_IndexImplicitTemplateInstantiations) +IdxOpts.IndexImplicitInstantiation = true; return IdxOpts; } Index: cfe/trunk/tools/c-index-test/c-index-test.c === --- cfe/trunk/tools/c-index-test/c-index-test.c +++ cfe/trunk/tools/c-index-test/c-index-test.c @@ -3652,6 +3652,8 @@ index_opts |= CXIndexOpt_IndexFunctionLocalSymbols; if (!getenv("CINDEXTEST_DISABLE_SKIPPARSEDBODIES")) index_opts |= CXIndexOpt_SkipParsedBodiesInSession; + if (getenv("CINDEXTEST_INDEXIMPLICITTEMPLATEINSTANTIATIONS")) +index_opts |= CXIndexOpt_IndexImplicitTemplateInstantiations; return index_opts; } Index: cfe/trunk/test/Index/index-template-specialization.cpp === --- cfe/trunk/test/Index/index-template-specialization.cpp +++ cfe/trunk/test/Index/index-template-specialization.cpp @@ -0,0 +1,19 @@ +template +class Foo { +public: + void f(T t) {} +}; + +void g() { + Foo foo; + foo.f(0); +} + +// FIXME: if c-index-test uses OrigD for symbol info, refererences below should +// refer to template specialization decls. +// RUN: env CINDEXTEST_INDEXIMPLICITTEMPLATEINSTANTIATIONS=1 c-index-test -index-file %s | FileCheck %s +// CHECK: [indexDeclaration]: kind: c++-class-template | name: Foo +// CHECK-NEXT: [indexDeclaration]: kind: c++-instance-method | name: f +// CHECK-NEXT: [indexDeclaration]: kind: function | name: g +// CHECK-NEXT: [indexEntityReference]: kind: c++-class-template | name: Foo | USR: c:@ST>1#T@Foo +// CHECK-NEXT: [indexEntityReference]: kind: c++-instance-method | name: f | USR: c:@ST>1#T@Foo@F@f#t0.0# Index: cfe/trunk/lib/Index/IndexingContext.cpp === --- cfe/trunk/lib/Index/IndexingContext.cpp +++ cfe/trunk/lib/Index/IndexingContext.cpp @@ -350,6 +350,9 @@ } } + if (!OrigD) +OrigD = D; + if (isTemplateImplicitInstantiation(D)) { if (!IsRef) return true; @@ -359,9 +362,6 @@ assert(!isTemplateImplicitInstantiation(D)); } - if (!OrigD) -OrigD = D; - if (IsRef) Roles |= (unsigned)SymbolRole::Reference; else if (isDeclADefinition(OrigD, ContainerDC, *Ctx)) Index: cfe/trunk/tools/libclang/Indexing.cpp === --- cfe/trunk/tools/libclang/Indexing.cpp +++ cfe/trunk/tools/libclang/Indexing.cpp @@ -402,6 +402,8 @@ IndexingOptions IdxOpts; if (index_options & CXIndexOpt_IndexFunctionLocalSymbols) IdxOpts.IndexFunctionLocals = true; + if (index_options & CXIndexOpt_IndexImplicitTemplateInstantiations) +IdxOpts.IndexImplicitInstantiation = true; return IdxOpts; } Index: cfe/trunk/tools/c-index-test/c-index-test.c === --- cfe/trunk/tools/c-index-test/c-index-test.c +++ cfe/trunk/tools/c-index-test/c-index-test.c @@ -3652,6 +3652,8 @@ index_opts |= CXIndexOpt_IndexFunctionLocalSymbols; if (!getenv("CINDEXTEST_DISABLE_SKIPPARSEDBODIES")) index_opts |= CXIndexOpt_SkipParsedBodiesInSession; + if (getenv("CINDEXTEST_INDEXIMPLICITTEMPLATEINSTANTIATIONS")) +index_opts |= CXIndexOpt_IndexImplicitTemplateInstantiations; return index_opts; } Index: cfe/trunk/test/Index/index-template-specialization.cpp === --- cfe/trunk/test/Index/index-template-specialization.cpp +++ cfe/trunk/test/Index/index-template-specialization.cpp @@ -0,
r337530 - Change \t to spaces
Author: maskray Date: Fri Jul 20 01:19:20 2018 New Revision: 337530 URL: http://llvm.org/viewvc/llvm-project?rev=337530&view=rev Log: Change \t to spaces Modified: cfe/trunk/include/clang-c/BuildSystem.h cfe/trunk/include/clang/Basic/Attr.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Basic/arm_neon.td cfe/trunk/include/clang/Driver/CC1Options.td cfe/trunk/include/clang/Frontend/CodeGenOptions.def cfe/trunk/lib/AST/TypeLoc.cpp cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/CodeGen/CodeGenAction.cpp cfe/trunk/lib/Driver/Distro.cpp cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/lib/Sema/SemaLambda.cpp cfe/trunk/lib/Sema/SemaLookup.cpp cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp Modified: cfe/trunk/include/clang-c/BuildSystem.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/BuildSystem.h?rev=337530&r1=337529&r2=337530&view=diff == --- cfe/trunk/include/clang-c/BuildSystem.h (original) +++ cfe/trunk/include/clang-c/BuildSystem.h Fri Jul 20 01:19:20 2018 @@ -66,7 +66,7 @@ clang_VirtualFileOverlay_addFileMapping( */ CINDEX_LINKAGE enum CXErrorCode clang_VirtualFileOverlay_setCaseSensitivity(CXVirtualFileOverlay, - int caseSensitive); +int caseSensitive); /** * Write out the \c CXVirtualFileOverlay object to a char buffer. Modified: cfe/trunk/include/clang/Basic/Attr.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=337530&r1=337529&r2=337530&view=diff == --- cfe/trunk/include/clang/Basic/Attr.td (original) +++ cfe/trunk/include/clang/Basic/Attr.td Fri Jul 20 01:19:20 2018 @@ -1932,7 +1932,7 @@ def Target : InheritableAttr { // overall feature validity for the function with the rest of the // attributes on the function. if (Feature.startswith("fpmath=") || Feature.startswith("tune=")) - continue; + continue; // While we're here iterating check for a different target cpu. if (Feature.startswith("arch=")) { Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=337530&r1=337529&r2=337530&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jul 20 01:19:20 2018 @@ -9102,9 +9102,9 @@ def note_equivalent_internal_linkage_dec "declared here%select{ in module '%1'|}0">; def note_redefinition_modules_same_file : Note< - "'%0' included multiple times, additional include site in header from module '%1'">; + "'%0' included multiple times, additional include site in header from module '%1'">; def note_redefinition_include_same_file : Note< - "'%0' included multiple times, additional include site here">; + "'%0' included multiple times, additional include site here">; } let CategoryName = "Coroutines Issue" in { Modified: cfe/trunk/include/clang/Basic/arm_neon.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=337530&r1=337529&r2=337530&view=diff == --- cfe/trunk/include/clang/Basic/arm_neon.td (original) +++ cfe/trunk/include/clang/Basic/arm_neon.td Fri Jul 20 01:19:20 2018 @@ -1438,12 +1438,12 @@ let ArchGuard = "defined(__ARM_FEATURE_F // Comparison let InstName = "vacge" in { - def VCAGEH : SInst<"vcage", "udd", "hQh">; - def VCALEH : SInst<"vcale", "udd", "hQh">; +def VCAGEH : SInst<"vcage", "udd", "hQh">; +def VCALEH : SInst<"vcale", "udd", "hQh">; } let InstName = "vacgt" in { def VCAGTH : SInst<"vcagt", "udd", "hQh">; - def VCALTH : SInst<"vcalt", "udd", "hQh">; +def VCALTH : SInst<"vcalt", "udd", "hQh">; } def VCEQH: SOpInst<"vceq", "udd", "hQh", OP_EQ>; def VCGEH: SOpInst<"vcge", "udd", "hQh", OP_GE>; Modified: cfe/trunk/include/clang/Driver/CC1Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=337530&r1=337529&r2=337530&view=diff
[PATCH] D49417: [clangd] Implement trigram generation algorithm for new symbol index
omtcyfz updated this revision to Diff 156443. omtcyfz marked 35 inline comments as done. omtcyfz added a comment. Addressed most comments (aside from reusing fuzzy matching segmentation routine and making data + hash a separate structure). Since I already submitted my next revision (https://reviews.llvm.org/D49546) through another account with more verbose and less confusing username I will remove everyone from this revision and create this revision under the latter account. https://reviews.llvm.org/D49417 Files: clang-tools-extra/clangd/CMakeLists.txt clang-tools-extra/clangd/index/dex/Token.cpp clang-tools-extra/clangd/index/dex/Token.h clang-tools-extra/clangd/index/dex/Trigram.cpp clang-tools-extra/clangd/index/dex/Trigram.h clang-tools-extra/unittests/clangd/CMakeLists.txt clang-tools-extra/unittests/clangd/DexIndexTests.cpp Index: clang-tools-extra/unittests/clangd/DexIndexTests.cpp === --- /dev/null +++ clang-tools-extra/unittests/clangd/DexIndexTests.cpp @@ -0,0 +1,92 @@ +//===-- DexIndexTests.cpp *- C++ -*---===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "index/dex/Token.h" +#include "index/dex/Trigram.h" +#include "gtest/gtest.h" + +#include +#include + +using std::string; +using std::vector; + +namespace clang { +namespace clangd { +namespace dex { + +vector getTrigrams(std::initializer_list Trigrams) { + vector Result; + for (const auto &Symbols : Trigrams) { +Result.push_back(Token(Symbols, Token::Kind::Trigram)); + } + return Result; +} + +TEST(DexIndexTokens, TrigramSymbolNameTokenization) { + EXPECT_EQ(segmentIdentifier("unique_ptr"), vector({"unique", "ptr"})); + + EXPECT_EQ(segmentIdentifier("TUDecl"), vector({"TU", "Decl"})); + + EXPECT_EQ(segmentIdentifier("table_name_"), +vector({"table", "name"})); + + EXPECT_EQ(segmentIdentifier("kDaysInAWeek"), +vector({"k", "Days", "In", "A", "Week"})); + + EXPECT_EQ(segmentIdentifier("AlternateUrlTableErrors"), +vector({"Alternate", "Url", "Table", "Errors"})); + + EXPECT_EQ(segmentIdentifier("IsOK"), vector({"Is", "OK"})); + + EXPECT_EQ(segmentIdentifier("ABSL_FALLTHROUGH_INTENDED"), +vector({"ABSL", "FALLTHROUGH", "INTENDED"})); + + EXPECT_EQ(segmentIdentifier("SystemZ"), vector({"System", "Z"})); + + EXPECT_EQ(segmentIdentifier("X86"), vector({"X86"})); + + EXPECT_EQ(segmentIdentifier("ASTNodeKind"), +vector({"AST", "Node", "Kind"})); + + EXPECT_EQ(segmentIdentifier("ObjCDictionaryElement"), +vector({"Obj", "C", "Dictionary", "Element"})); + + EXPECT_EQ(segmentIdentifier("multiple__underscores___everywhere"), +vector({"multiple", "underscores", "everywhere"})); + + EXPECT_EQ(segmentIdentifier("__cuda_builtin_threadIdx_t"), +vector({"cuda", "builtin", "thread", "Idx", "t"})); + + EXPECT_EQ(segmentIdentifier("longUPPERCASESequence"), +vector({"long", "UPPERCASE", "Sequence"})); +} + +// FIXME(kbobyrev): Add a test for "ab_cd_ef_gh". +TEST(DexIndexTrigrams, TrigramGeneration) { + EXPECT_EQ( + generateTrigrams(segmentIdentifier("a_b_c_d_e_")), + getTrigrams({"abc", "abd", "acd", "ace", "bcd", "bce", "bde", "cde"})); + + EXPECT_EQ(generateTrigrams(segmentIdentifier("clangd")), +getTrigrams({"cla", "lan", "ang", "ngd"})); + + EXPECT_EQ(generateTrigrams(segmentIdentifier("abc_def")), +getTrigrams({"abc", "def", "abd", "ade", "bcd", "bde", "cde"})); + + EXPECT_EQ(generateTrigrams(segmentIdentifier("unique_ptr")), +getTrigrams({"uni", "niq", "iqu", "que", "ptr", "unp", "upt", "nip", + "npt", "iqp", "ipt", "qup", "qpt", "uep", "ept"})); + + EXPECT_EQ(generateTrigrams(segmentIdentifier("nl")), getTrigrams({})); +} + +} // namespace dex +} // namespace clangd +} // namespace clang Index: clang-tools-extra/unittests/clangd/CMakeLists.txt === --- clang-tools-extra/unittests/clangd/CMakeLists.txt +++ clang-tools-extra/unittests/clangd/CMakeLists.txt @@ -15,9 +15,10 @@ CodeCompleteTests.cpp CodeCompletionStringsTests.cpp ContextTests.cpp + DexIndexTests.cpp DraftStoreTests.cpp - FileIndexTests.cpp FileDistanceTests.cpp + FileIndexTests.cpp FindSymbolsTests.cpp FuzzyMatchTests.cpp GlobalCompilationDatabaseTests.cpp @@ -27,11 +28,11 @@ SourceCodeTests.cpp SymbolCollectorTests.cpp SyncAPI.cpp + TUSchedulerTests.cpp TestFS.cpp TestTU.cpp ThreadingTests.cpp TraceTests.cpp - TUSchedulerTests.cpp URITests.cpp XRefsTests.cpp ) Index: clang-tools-extra/clangd/index/dex/Trigram.h ==
[PATCH] D49417: [clangd] Implement trigram generation algorithm for new symbol index
omtcyfz added inline comments. Comment at: clang-tools-extra/clangd/index/noctem/SearchAtom.h:53 + SearchAtom(llvm::StringRef Data, Namespace Type = Namespace::Trigram) + : Data(Data), Hash(std::hash{}(Data)), Type(Type) {} + ioeric wrote: > ioeric wrote: > > Should we also incorporate `Type` into hash? > I'm wondering if we should use different hashes for different token types. > For example, a trigram token "xyz" can be encoded in a 4 -byte int with > `('x'<<16) & ('y'<<8) & 'z'`, which seems cheaper than `std::hash`. Discussed internally: we probably shouldn't since there will be collisions even inside a single token namespace when Data will be too long. Comment at: clang-tools-extra/clangd/index/noctem/SearchToken.cpp:44 +generateTrigrams(const std::vector> &Segments) { + llvm::DenseSet UniqueTrigrams; + std::vector Trigrams; ioeric wrote: > Could we replace `UniqaueTrigrams`+`Trigrams` with a dense map from hash to > token? I'm not sure how to iterate through the result then. Basically, having Trigrams ensures that these trigrams can be iterated after the function execution and inserted into the inverted index. Otherwise I should either expose a callback to add the generated trigrams or do something similar. Should I do that instead? Comment at: clang-tools-extra/clangd/index/noctem/SearchToken.cpp:57 + // this case. + for (auto FirstSegment = Segments.begin(); FirstSegment != Segments.end(); + ++FirstSegment) { ioeric wrote: > nit: Maybe S1, S2, S3 instead of FirstSegment, ...? I think it's way less explicit and slightly more confusing. I try not to have one-letter names so I guess it's better to have full names instead. Comment at: clang-tools-extra/clangd/index/noctem/SearchToken.cpp:68 +SearchToken Trigram( +(*FirstSegment + *SecondSegment + *ThirdSegment).str(), +SearchToken::Kind::Trigram); ioeric wrote: > ioeric wrote: > > This seems wrong... wouldn't this give you a concatenation of three > > segments? > For trigrams, it might make sense to put 3 chars into a `SmallVector<3>` (can > be reused) and std::move it into the constructor. Might be cheaper than > creating a std::string But `std::string` would be created anyway, wouldn't it be? Comment at: clang-tools-extra/clangd/index/noctem/SearchToken.cpp:87 + +for (size_t Position = 0; Position + 2 < Segment.size(); ++Position) + Trigrams.push_back( ioeric wrote: > nit: `Position < Segment.size() - 2` seems more commonly used. If `Segment.size()` is 1 then this would be `1U - 2U`, which would be something very large. Comment at: clang-tools-extra/clangd/index/noctem/SearchToken.cpp:138 + + for (size_t Index = SegmentStart; Index + 1 < SymbolName.size(); ++Index) { +const char CurrentSymbol = SymbolName[Index]; ioeric wrote: > Maybe first split name on `_` and them run further upper-lower segmentation > on the split segments? Resolving both of these for now (though they're not really fixed) since I will rethink the algorithm given Sam's patch. Comment at: clang-tools-extra/clangd/index/noctem/SearchToken.h:52 + +Custom, + }; sammccall wrote: > what is this for? Tags, for example. But yes, for now it's not very clear and probably not needed. Dropped this one. https://reviews.llvm.org/D49417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49591: [clangd] Introduce search Tokens and trigram generation algorithms
kbobyrev created this revision. kbobyrev added reviewers: ioeric, sammccall. kbobyrev added a project: clang-tools-extra. Herald added subscribers: arphaman, jkorous, MaskRay, mgorny. This patch introduces trigram generation algorithm for the symbol index proposed in a recent design document. RFC in the mailing list: http://lists.llvm.org/pipermail/clangd-dev/2018-July/22.html The trigram generation algorithm is described in detail in the proposal: https://docs.google.com/document/d/1C-A6PGT6TynyaX4PXyExNMiGmJ2jL1UwV91Kyx11gOI/edit#heading=h.903u1zon9nkj https://reviews.llvm.org/D49591 Files: clang-tools-extra/clangd/CMakeLists.txt clang-tools-extra/clangd/index/dex/Token.cpp clang-tools-extra/clangd/index/dex/Token.h clang-tools-extra/clangd/index/dex/Trigram.cpp clang-tools-extra/clangd/index/dex/Trigram.h clang-tools-extra/unittests/clangd/CMakeLists.txt clang-tools-extra/unittests/clangd/DexIndexTests.cpp Index: clang-tools-extra/unittests/clangd/DexIndexTests.cpp === --- /dev/null +++ clang-tools-extra/unittests/clangd/DexIndexTests.cpp @@ -0,0 +1,92 @@ +//===-- DexIndexTests.cpp *- C++ -*---===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "index/dex/Token.h" +#include "index/dex/Trigram.h" +#include "gtest/gtest.h" + +#include +#include + +using std::string; +using std::vector; + +namespace clang { +namespace clangd { +namespace dex { + +vector getTrigrams(std::initializer_list Trigrams) { + vector Result; + for (const auto &Symbols : Trigrams) { +Result.push_back(Token(Symbols, Token::Kind::Trigram)); + } + return Result; +} + +TEST(DexIndexTokens, TrigramSymbolNameTokenization) { + EXPECT_EQ(segmentIdentifier("unique_ptr"), vector({"unique", "ptr"})); + + EXPECT_EQ(segmentIdentifier("TUDecl"), vector({"TU", "Decl"})); + + EXPECT_EQ(segmentIdentifier("table_name_"), +vector({"table", "name"})); + + EXPECT_EQ(segmentIdentifier("kDaysInAWeek"), +vector({"k", "Days", "In", "A", "Week"})); + + EXPECT_EQ(segmentIdentifier("AlternateUrlTableErrors"), +vector({"Alternate", "Url", "Table", "Errors"})); + + EXPECT_EQ(segmentIdentifier("IsOK"), vector({"Is", "OK"})); + + EXPECT_EQ(segmentIdentifier("ABSL_FALLTHROUGH_INTENDED"), +vector({"ABSL", "FALLTHROUGH", "INTENDED"})); + + EXPECT_EQ(segmentIdentifier("SystemZ"), vector({"System", "Z"})); + + EXPECT_EQ(segmentIdentifier("X86"), vector({"X86"})); + + EXPECT_EQ(segmentIdentifier("ASTNodeKind"), +vector({"AST", "Node", "Kind"})); + + EXPECT_EQ(segmentIdentifier("ObjCDictionaryElement"), +vector({"Obj", "C", "Dictionary", "Element"})); + + EXPECT_EQ(segmentIdentifier("multiple__underscores___everywhere"), +vector({"multiple", "underscores", "everywhere"})); + + EXPECT_EQ(segmentIdentifier("__cuda_builtin_threadIdx_t"), +vector({"cuda", "builtin", "thread", "Idx", "t"})); + + EXPECT_EQ(segmentIdentifier("longUPPERCASESequence"), +vector({"long", "UPPERCASE", "Sequence"})); +} + +// FIXME(kbobyrev): Add a test for "ab_cd_ef_gh". +TEST(DexIndexTrigrams, TrigramGeneration) { + EXPECT_EQ( + generateTrigrams(segmentIdentifier("a_b_c_d_e_")), + getTrigrams({"abc", "abd", "acd", "ace", "bcd", "bce", "bde", "cde"})); + + EXPECT_EQ(generateTrigrams(segmentIdentifier("clangd")), +getTrigrams({"cla", "lan", "ang", "ngd"})); + + EXPECT_EQ(generateTrigrams(segmentIdentifier("abc_def")), +getTrigrams({"abc", "def", "abd", "ade", "bcd", "bde", "cde"})); + + EXPECT_EQ(generateTrigrams(segmentIdentifier("unique_ptr")), +getTrigrams({"uni", "niq", "iqu", "que", "ptr", "unp", "upt", "nip", + "npt", "iqp", "ipt", "qup", "qpt", "uep", "ept"})); + + EXPECT_EQ(generateTrigrams(segmentIdentifier("nl")), getTrigrams({})); +} + +} // namespace dex +} // namespace clangd +} // namespace clang Index: clang-tools-extra/unittests/clangd/CMakeLists.txt === --- clang-tools-extra/unittests/clangd/CMakeLists.txt +++ clang-tools-extra/unittests/clangd/CMakeLists.txt @@ -15,9 +15,10 @@ CodeCompleteTests.cpp CodeCompletionStringsTests.cpp ContextTests.cpp + DexIndexTests.cpp DraftStoreTests.cpp - FileIndexTests.cpp FileDistanceTests.cpp + FileIndexTests.cpp FindSymbolsTests.cpp FuzzyMatchTests.cpp GlobalCompilationDatabaseTests.cpp @@ -27,11 +28,11 @@ SourceCodeTests.cpp SymbolCollectorTests.cpp SyncAPI.cpp + TUSchedulerTests.cpp TestFS.cpp TestTU.cpp ThreadingTests.cpp TraceTests.cpp - TUSchedulerTests.cpp URITests.cp
[libcxx] r337532 - adjust incorrect comment
Author: ericwf Date: Fri Jul 20 01:36:45 2018 New Revision: 337532 URL: http://llvm.org/viewvc/llvm-project?rev=337532&view=rev Log: adjust incorrect comment Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/operations.cpp?rev=337532&r1=337531&r2=337532&view=diff == --- libcxx/trunk/src/experimental/filesystem/operations.cpp (original) +++ libcxx/trunk/src/experimental/filesystem/operations.cpp Fri Jul 20 01:36:45 2018 @@ -1426,7 +1426,8 @@ error_code directory_entry::__do_refresh __data_.__cache_type_ = directory_entry::_RefreshSymlinkUnresolved; return error_code{}; } -// Otherwise, we resolved the link as not existing. That's OK. +// Otherwise, we either resolved the link, potentially as not existing. +// That's OK. __data_.__cache_type_ = directory_entry::_RefreshSymlink; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49591: [clangd] Introduce search Tokens and trigram generation algorithms
kbobyrev planned changes to this revision. kbobyrev added a comment. The upcoming changes: - Use segmentation API exposed in https://reviews.llvm.org/rL337527 - Create a separate structure for Data and Hash as suggested by Sam - Fix the bug with whole segments concatenation https://reviews.llvm.org/D49591 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41458: [libc++][C++17] Elementary string conversions for integral types
lichray added a comment. Ping. Any more comments? Repository: rCXX libc++ https://reviews.llvm.org/D41458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49594: [DebugInfo] Emit diagnostics when enabling -fdebug-types-section on non-linux target.
JDevlieghere created this revision. JDevlieghere added reviewers: labath, dblaikie, probinson. Currently, support for debug_types is only present for ELF and trying to pass -fdebug-types-section for other targets results in a crash in the backend. Until this is fixed, we should emit a diagnostic in the front end when the option is passed for non-linux targets. Repository: rC Clang https://reviews.llvm.org/D49594 Files: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/debug-options.c Index: clang/test/Driver/debug-options.c === --- clang/test/Driver/debug-options.c +++ clang/test/Driver/debug-options.c @@ -139,12 +139,18 @@ // // RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=GARANGE %s // -// RUN: %clang -### -fdebug-types-section %s 2>&1 \ +// RUN: %clang -### -fdebug-types-section -target x86_64-unknown-linux %s 2>&1 \ // RUN:| FileCheck -check-prefix=FDTS %s // -// RUN: %clang -### -fdebug-types-section -fno-debug-types-section %s 2>&1 \ +// RUN: %clang -### -fdebug-types-section -fno-debug-types-section -target x86_64-unknown-linux %s 2>&1 \ // RUN:| FileCheck -check-prefix=NOFDTS %s // +// RUN: %clang -### -fdebug-types-section -target x86_64-apple-darwin %s 2>&1 \ +// RUN:| FileCheck -check-prefix=FDTSE %s +// +// RUN: %clang -### -fdebug-types-section -fno-debug-types-section -target x86_64-apple-darwin %s 2>&1 \ +// RUN:| FileCheck -check-prefix=NOFDTSE %s +// // RUN: %clang -### -g -gno-column-info %s 2>&1 \ // RUN:| FileCheck -check-prefix=NOCI %s // @@ -229,8 +235,10 @@ // GARANGE: -generate-arange-section // // FDTS: "-mllvm" "-generate-type-units" +// FDTSE: error: unsupported option '-fdebug-types-section' for target 'x86_64-apple-darwin' // // NOFDTS-NOT: "-mllvm" "-generate-type-units" +// NOFDTSE-NOT: error: unsupported option '-fdebug-types-section' for target 'x86_64-apple-darwin' // // CI: "-dwarf-column-info" // Index: clang/lib/Driver/ToolChains/Clang.cpp === --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -3028,6 +3028,11 @@ if (Args.hasFlag(options::OPT_fdebug_types_section, options::OPT_fno_debug_types_section, false)) { +if (!T.isOSLinux()) + D.Diag(diag::err_drv_unsupported_opt_for_target) + << Args.getLastArg(options::OPT_fdebug_types_section) + ->getAsString(Args) + << T.getTriple(); CmdArgs.push_back("-mllvm"); CmdArgs.push_back("-generate-type-units"); } Index: clang/test/Driver/debug-options.c === --- clang/test/Driver/debug-options.c +++ clang/test/Driver/debug-options.c @@ -139,12 +139,18 @@ // // RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=GARANGE %s // -// RUN: %clang -### -fdebug-types-section %s 2>&1 \ +// RUN: %clang -### -fdebug-types-section -target x86_64-unknown-linux %s 2>&1 \ // RUN:| FileCheck -check-prefix=FDTS %s // -// RUN: %clang -### -fdebug-types-section -fno-debug-types-section %s 2>&1 \ +// RUN: %clang -### -fdebug-types-section -fno-debug-types-section -target x86_64-unknown-linux %s 2>&1 \ // RUN:| FileCheck -check-prefix=NOFDTS %s // +// RUN: %clang -### -fdebug-types-section -target x86_64-apple-darwin %s 2>&1 \ +// RUN:| FileCheck -check-prefix=FDTSE %s +// +// RUN: %clang -### -fdebug-types-section -fno-debug-types-section -target x86_64-apple-darwin %s 2>&1 \ +// RUN:| FileCheck -check-prefix=NOFDTSE %s +// // RUN: %clang -### -g -gno-column-info %s 2>&1 \ // RUN:| FileCheck -check-prefix=NOCI %s // @@ -229,8 +235,10 @@ // GARANGE: -generate-arange-section // // FDTS: "-mllvm" "-generate-type-units" +// FDTSE: error: unsupported option '-fdebug-types-section' for target 'x86_64-apple-darwin' // // NOFDTS-NOT: "-mllvm" "-generate-type-units" +// NOFDTSE-NOT: error: unsupported option '-fdebug-types-section' for target 'x86_64-apple-darwin' // // CI: "-dwarf-column-info" // Index: clang/lib/Driver/ToolChains/Clang.cpp === --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -3028,6 +3028,11 @@ if (Args.hasFlag(options::OPT_fdebug_types_section, options::OPT_fno_debug_types_section, false)) { +if (!T.isOSLinux()) + D.Diag(diag::err_drv_unsupported_opt_for_target) + << Args.getLastArg(options::OPT_fdebug_types_section) + ->getAsString(Args) + << T.getTriple(); CmdArgs.push_back("-mllvm"); CmdArgs.push_back("-generate-type-units"); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo
[PATCH] D46190: For a used declaration, mark any associated usings as referenced.
CarlosAlbertoEnciso updated this revision to Diff 156456. CarlosAlbertoEnciso added a comment. Used `clang-format-diff` as indicated by @probinson: - The lib and include files follow the clang format. - The tests mostly follow the clang format. I removed some extra formatting which was introduced and disturb their readability. https://reviews.llvm.org/D46190 Files: include/clang/Sema/Lookup.h include/clang/Sema/Sema.h include/clang/Sema/SemaInternal.h lib/Sema/SemaCXXScopeSpec.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaExprCXX.cpp lib/Sema/SemaLookup.cpp lib/Sema/SemaTemplate.cpp test/PCH/cxx-templates.cpp test/SemaCXX/referenced_alias_declaration_1.cpp test/SemaCXX/referenced_alias_declaration_2.cpp test/SemaCXX/referenced_using_all.cpp test/SemaCXX/referenced_using_declaration_1.cpp test/SemaCXX/referenced_using_declaration_2.cpp test/SemaCXX/referenced_using_directive.cpp Index: test/SemaCXX/referenced_using_directive.cpp === --- test/SemaCXX/referenced_using_directive.cpp +++ test/SemaCXX/referenced_using_directive.cpp @@ -0,0 +1,55 @@ +// RUN: %clang_cc1 -std=c++11 -ast-dump %s | FileCheck %s --strict-whitespace + +namespace N { +typedef int Integer; +int var; +} // namespace N + +void Fa() { + using namespace N; // Referenced + var = 1; +} + +void Fb() { + using namespace N; + N::var = 1; +} + +void Fc() { + using namespace N; // Referenced + Integer var = 1; +} + +void Fd() { + using namespace N; + N::Integer var = 1; +} + +//CHECK: |-FunctionDecl {{.*}} Fa 'void ()' +//CHECK-NEXT: | `-CompoundStmt {{.*}} +//CHECK-NEXT: | |-DeclStmt {{.*}} +//CHECK-NEXT: | | `-UsingDirectiveDecl {{.*}} referenced Namespace {{.*}} 'N' +//CHECK-NEXT: | `-BinaryOperator {{.*}} 'int' lvalue '=' +//CHECK-NEXT: | |-DeclRefExpr {{.*}} 'int' lvalue Var {{.*}} 'var' 'int' +//CHECK-NEXT: | `-IntegerLiteral {{.*}} 'int' 1 +//CHECK-NEXT: |-FunctionDecl {{.*}} Fb 'void ()' +//CHECK-NEXT: | `-CompoundStmt {{.*}} +//CHECK-NEXT: | |-DeclStmt {{.*}} +//CHECK-NEXT: | | `-UsingDirectiveDecl {{.*}} Namespace {{.*}} 'N' +//CHECK-NEXT: | `-BinaryOperator {{.*}} 'int' lvalue '=' +//CHECK-NEXT: | |-DeclRefExpr {{.*}} 'int' lvalue Var {{.*}} 'var' 'int' +//CHECK-NEXT: | `-IntegerLiteral {{.*}} 'int' 1 +//CHECK-NEXT: |-FunctionDecl {{.*}} Fc 'void ()' +//CHECK-NEXT: | `-CompoundStmt {{.*}} +//CHECK-NEXT: | |-DeclStmt {{.*}} +//CHECK-NEXT: | | `-UsingDirectiveDecl {{.*}} referenced Namespace {{.*}} 'N' +//CHECK-NEXT: | `-DeclStmt {{.*}} +//CHECK-NEXT: | `-VarDecl {{.*}} var 'N::Integer':'int' cinit +//CHECK-NEXT: | `-IntegerLiteral {{.*}} 'int' 1 +//CHECK-NEXT: `-FunctionDecl {{.*}} Fd 'void ()' +//CHECK-NEXT: `-CompoundStmt {{.*}} +//CHECK-NEXT: |-DeclStmt {{.*}} +//CHECK-NEXT: | `-UsingDirectiveDecl {{.*}} Namespace {{.*}} 'N' +//CHECK-NEXT: `-DeclStmt {{.*}} +//CHECK-NEXT: `-VarDecl {{.*}} var 'N::Integer':'int' cinit +//CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1 Index: test/SemaCXX/referenced_using_declaration_2.cpp === --- test/SemaCXX/referenced_using_declaration_2.cpp +++ test/SemaCXX/referenced_using_declaration_2.cpp @@ -0,0 +1,52 @@ +// RUN: %clang_cc1 -std=c++11 -ast-dump %s | FileCheck %s --strict-whitespace + +namespace N { +typedef int Integer; +typedef char Char; +} // namespace N + +using N::Char; // Referenced +using N::Integer; + +void Foo(int p1, N::Integer p2, Char p3) { + N::Integer var; + var = 0; +} + +using N::Integer; // Referenced +Integer Bar() { + using N::Char; + return 0; +} + +//CHECK: |-UsingDecl {{.*}} referenced N::Char +//CHECK-NEXT: |-UsingShadowDecl {{.*}} implicit referenced Typedef {{.*}} 'Char' +//CHECK-NEXT: | `-TypedefType {{.*}} 'N::Char' sugar +//CHECK-NEXT: | |-Typedef {{.*}} 'Char' +//CHECK-NEXT: | `-BuiltinType {{.*}} 'char' +//CHECK-NEXT: |-UsingDecl {{.*}} N::Integer +//CHECK-NEXT: |-UsingShadowDecl {{.*}} implicit Typedef {{.*}} 'Integer' +//CHECK-NEXT: | `-TypedefType {{.*}} 'N::Integer' sugar +//CHECK-NEXT: | |-Typedef {{.*}} 'Integer' +//CHECK-NEXT: | `-BuiltinType {{.*}} 'int' +//CHECK-NEXT: |-FunctionDecl {{.*}} Foo 'void (int, N::Integer, N::Char)' +//CHECK-NEXT: | |-ParmVarDecl {{.*}} p1 'int' +//CHECK-NEXT: | |-ParmVarDecl {{.*}} p2 'N::Integer':'int' +//CHECK-NEXT: | |-ParmVarDecl {{.*}} p3 'N::Char':'char' +//CHECK-NEXT: | `-CompoundStmt {{.*}} +//CHECK-NEXT: | |-DeclStmt {{.*}} +//CHECK-NEXT: | | `-VarDecl {{.*}} used var 'N::Integer':'int' +//CHECK-NEXT: | `-BinaryOperator {{.*}} 'N::Integer':'int' lvalue '=' +//CHECK-NEXT: | |-DeclRefExpr {{.*}} 'N::Integer':'int' lvalue Var {{.*}} 'var' 'N::Integer':'int' +//CHECK-NEXT: | `-IntegerLiteral {{.*}} 'int' 0 +//CHECK-NEXT: |-UsingDecl {{.*}} referenced N::Integer +//CHECK-NEXT: |-UsingShadowDecl {{.*}} implicit
[PATCH] D49274: [CUDA] Provide integer SIMD functions for CUDA-9.2
bkramer accepted this revision. bkramer added a comment. This revision is now accepted and ready to land. lg https://reviews.llvm.org/D49274 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49594: [DebugInfo] Emit diagnostics when enabling -fdebug-types-section on non-linux target.
JDevlieghere added a comment. Please see PR38190 for more details. Repository: rC Clang https://reviews.llvm.org/D49594 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46190: For a used declaration, mark any associated usings as referenced.
CarlosAlbertoEnciso updated this revision to Diff 156460. CarlosAlbertoEnciso marked an inline comment as done. CarlosAlbertoEnciso added a comment. A minor modification to allow the comments for `MarkNamespaceAliasReferenced` to be picked up by doxygen. https://reviews.llvm.org/D46190 Files: include/clang/Sema/Lookup.h include/clang/Sema/Sema.h include/clang/Sema/SemaInternal.h lib/Sema/SemaCXXScopeSpec.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaExprCXX.cpp lib/Sema/SemaLookup.cpp lib/Sema/SemaTemplate.cpp test/PCH/cxx-templates.cpp test/SemaCXX/referenced_alias_declaration_1.cpp test/SemaCXX/referenced_alias_declaration_2.cpp test/SemaCXX/referenced_using_all.cpp test/SemaCXX/referenced_using_declaration_1.cpp test/SemaCXX/referenced_using_declaration_2.cpp test/SemaCXX/referenced_using_directive.cpp Index: test/SemaCXX/referenced_using_directive.cpp === --- test/SemaCXX/referenced_using_directive.cpp +++ test/SemaCXX/referenced_using_directive.cpp @@ -0,0 +1,55 @@ +// RUN: %clang_cc1 -std=c++11 -ast-dump %s | FileCheck %s --strict-whitespace + +namespace N { +typedef int Integer; +int var; +} // namespace N + +void Fa() { + using namespace N; // Referenced + var = 1; +} + +void Fb() { + using namespace N; + N::var = 1; +} + +void Fc() { + using namespace N; // Referenced + Integer var = 1; +} + +void Fd() { + using namespace N; + N::Integer var = 1; +} + +//CHECK: |-FunctionDecl {{.*}} Fa 'void ()' +//CHECK-NEXT: | `-CompoundStmt {{.*}} +//CHECK-NEXT: | |-DeclStmt {{.*}} +//CHECK-NEXT: | | `-UsingDirectiveDecl {{.*}} referenced Namespace {{.*}} 'N' +//CHECK-NEXT: | `-BinaryOperator {{.*}} 'int' lvalue '=' +//CHECK-NEXT: | |-DeclRefExpr {{.*}} 'int' lvalue Var {{.*}} 'var' 'int' +//CHECK-NEXT: | `-IntegerLiteral {{.*}} 'int' 1 +//CHECK-NEXT: |-FunctionDecl {{.*}} Fb 'void ()' +//CHECK-NEXT: | `-CompoundStmt {{.*}} +//CHECK-NEXT: | |-DeclStmt {{.*}} +//CHECK-NEXT: | | `-UsingDirectiveDecl {{.*}} Namespace {{.*}} 'N' +//CHECK-NEXT: | `-BinaryOperator {{.*}} 'int' lvalue '=' +//CHECK-NEXT: | |-DeclRefExpr {{.*}} 'int' lvalue Var {{.*}} 'var' 'int' +//CHECK-NEXT: | `-IntegerLiteral {{.*}} 'int' 1 +//CHECK-NEXT: |-FunctionDecl {{.*}} Fc 'void ()' +//CHECK-NEXT: | `-CompoundStmt {{.*}} +//CHECK-NEXT: | |-DeclStmt {{.*}} +//CHECK-NEXT: | | `-UsingDirectiveDecl {{.*}} referenced Namespace {{.*}} 'N' +//CHECK-NEXT: | `-DeclStmt {{.*}} +//CHECK-NEXT: | `-VarDecl {{.*}} var 'N::Integer':'int' cinit +//CHECK-NEXT: | `-IntegerLiteral {{.*}} 'int' 1 +//CHECK-NEXT: `-FunctionDecl {{.*}} Fd 'void ()' +//CHECK-NEXT: `-CompoundStmt {{.*}} +//CHECK-NEXT: |-DeclStmt {{.*}} +//CHECK-NEXT: | `-UsingDirectiveDecl {{.*}} Namespace {{.*}} 'N' +//CHECK-NEXT: `-DeclStmt {{.*}} +//CHECK-NEXT: `-VarDecl {{.*}} var 'N::Integer':'int' cinit +//CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1 Index: test/SemaCXX/referenced_using_declaration_2.cpp === --- test/SemaCXX/referenced_using_declaration_2.cpp +++ test/SemaCXX/referenced_using_declaration_2.cpp @@ -0,0 +1,52 @@ +// RUN: %clang_cc1 -std=c++11 -ast-dump %s | FileCheck %s --strict-whitespace + +namespace N { +typedef int Integer; +typedef char Char; +} // namespace N + +using N::Char; // Referenced +using N::Integer; + +void Foo(int p1, N::Integer p2, Char p3) { + N::Integer var; + var = 0; +} + +using N::Integer; // Referenced +Integer Bar() { + using N::Char; + return 0; +} + +//CHECK: |-UsingDecl {{.*}} referenced N::Char +//CHECK-NEXT: |-UsingShadowDecl {{.*}} implicit referenced Typedef {{.*}} 'Char' +//CHECK-NEXT: | `-TypedefType {{.*}} 'N::Char' sugar +//CHECK-NEXT: | |-Typedef {{.*}} 'Char' +//CHECK-NEXT: | `-BuiltinType {{.*}} 'char' +//CHECK-NEXT: |-UsingDecl {{.*}} N::Integer +//CHECK-NEXT: |-UsingShadowDecl {{.*}} implicit Typedef {{.*}} 'Integer' +//CHECK-NEXT: | `-TypedefType {{.*}} 'N::Integer' sugar +//CHECK-NEXT: | |-Typedef {{.*}} 'Integer' +//CHECK-NEXT: | `-BuiltinType {{.*}} 'int' +//CHECK-NEXT: |-FunctionDecl {{.*}} Foo 'void (int, N::Integer, N::Char)' +//CHECK-NEXT: | |-ParmVarDecl {{.*}} p1 'int' +//CHECK-NEXT: | |-ParmVarDecl {{.*}} p2 'N::Integer':'int' +//CHECK-NEXT: | |-ParmVarDecl {{.*}} p3 'N::Char':'char' +//CHECK-NEXT: | `-CompoundStmt {{.*}} +//CHECK-NEXT: | |-DeclStmt {{.*}} +//CHECK-NEXT: | | `-VarDecl {{.*}} used var 'N::Integer':'int' +//CHECK-NEXT: | `-BinaryOperator {{.*}} 'N::Integer':'int' lvalue '=' +//CHECK-NEXT: | |-DeclRefExpr {{.*}} 'N::Integer':'int' lvalue Var {{.*}} 'var' 'N::Integer':'int' +//CHECK-NEXT: | `-IntegerLiteral {{.*}} 'int' 0 +//CHECK-NEXT: |-UsingDecl {{.*}} referenced N::Integer +//CHECK-NEXT: |-UsingShadowDecl {{.*}} implicit referenced Typedef {{.*}} 'Integer' +//CHECK-NEXT: | `-TypedefType {{.*}} '
[PATCH] D49591: [clangd] Introduce search Tokens and trigram generation algorithms
sammccall added inline comments. Comment at: clang-tools-extra/clangd/index/dex/Token.cpp:25 + Data.size() == 3 && "Trigram should contain three characters."); + switch (TokenKind) { + case Kind::Trigram: specializing the hash function looks like premature optimization (or possibly pessimisation) One the one hand, it's a perfect hash! On the other hand, when used with a power-of-two sized hashtable (particularly 256 is a fun example), all the trigrams are going to hash into the alphanumeric buckets, and other buckets will be empty! DenseMap is a power-of-two hashtable! Comment at: clang-tools-extra/clangd/index/dex/Token.cpp:30 + default: +Hash = std::hash{}(Data); +break; llvm::hash_combine(static_cast(TokenKind),Data) Comment at: clang-tools-extra/clangd/index/dex/Token.h:10 +// +// Tokens are keys for inverted index which are mapped to the +// corresponding posting lists. Token objects represent a characteristic nit: swap these sentences around? conceptual explanation first, how they're used later? could even give an example: ``` // The symbol std::cout might have the tokens: // * Scope "std::" // * Trigram "cou" // * Trigram "out" // * Type "std::ostream" ``` Comment at: clang-tools-extra/clangd/index/dex/Token.h:28 + +/// Hashable Token, which represents a search token primitive, such as +/// trigram for fuzzy search on unqualified symbol names. nit: "Hashable" isn't really important here. nit: it doesn't *represent* a search primitive, it *is* a search primitive. Maybe ``` /// A Token represents an attribute of a symbol, such as a particular /// trigram present in the name (used for fuzzy search). ``` Comment at: clang-tools-extra/clangd/index/dex/Token.h:33 +/// constructing complex iterator trees. +class Token { +public: As discussed offline: think we misunderstood each other about the separate struct. I rather meant *this* class could just be a struct. Comment at: clang-tools-extra/clangd/index/dex/Token.h:36 + /// Kind specifies Token type which defines semantics for the internal + /// representation (Data field), examples of such types are: + /// don't give examples of the enum values immediately before defining the enum values :-) Just put the comments on the values themselves, and omit the ones that aren't here yet (or leave a TODO) Comment at: clang-tools-extra/clangd/index/dex/Token.h:47 + /// + /// * Trigram: 3 bytes containing trigram characters + /// * Scope: full scope name, such as "foo::bar::baz::" or "" (global scope) move these to enum values Comment at: clang-tools-extra/clangd/index/dex/Token.h:58 + + Token(llvm::StringRef Data, Kind TokenKind); + nit: probably reverse the order here since Token(TRIGRAM, "str") reads more naturally than Token("str", TRIGRAM) - context is present to understand the data Comment at: clang-tools-extra/clangd/index/dex/Token.h:60 + + // Returns precomputed hash. + size_t hash(const Token &T) const { return Hash; } can we just use the standard hash_value() function? Why this accessor? Comment at: clang-tools-extra/clangd/index/dex/Token.h:79 + /// Precomputed hash which is used as a key for inverted index. + size_t Hash; + Kind TokenKind; as discussed offline: this precomputed hash looks like premature optimization to me. Comment at: clang-tools-extra/clangd/index/dex/Trigram.cpp:35 + llvm::DenseSet UniqueTrigrams; + std::vector Trigrams; + just iterate at the end and collect them? order shouldn't matter here. Comment at: clang-tools-extra/clangd/index/dex/Trigram.cpp:37 + + // Extract trigrams consisting of first characters of tokens sorted bytoken + // positions. Trigram generator is allowed to skip 1 word between each token. ah, you're also handling this by cases here. This doesn't seem necessary. In fact I think there's a fairly simple way to express this that works naturally with the segmentation structure produced by fuzzymatch (so doesn't need a version of segmentIdentifier to wrap it). But it's taking me too long to work out the details, will write a followup comment or discuss offline. Comment at: clang-tools-extra/clangd/index/dex/Trigram.cpp:46 + // this case. + for (auto FirstSegment = Segments.begin(); FirstSegment != Segments.end(); + ++FirstSegment) { please use short names like I, S1, etc for iterators and loop counters. Comment at: clang-tools-extra/clangd/index/dex/Trigram.cpp:90 + ++SecondSegment) { + for (size_t FirstSegmentIndex = 0; + FirstSegmentIndex < FirstSegment->size
[PATCH] D49589: [UBSan] Strengthen pointer checks in 'new' expressions
ikudrin added a comment. You may want to add a test for placement new, no? Repository: rC Clang https://reviews.llvm.org/D49589 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49508: [Sema] Mark implicitly-inserted ICE's as being part of explicit cast (PR38166)
lebedev.ri updated this revision to Diff 156465. lebedev.ri retitled this revision from "[Sema] Expr::skipRValueSubobjectAdjustments(): record skipped NoOp casts." to "[Sema] Mark implicitly-inserted ICE's as being part of explicit cast (PR38166)". lebedev.ri edited the summary of this revision. lebedev.ri added a comment. Moved to the flag approach, which was my initial thought. This ended up being rather too simple, of all the alternative solutions. Oh well, that was rather sad waste of time. Repository: rC Clang https://reviews.llvm.org/D49508 Files: include/clang/AST/Expr.h include/clang/AST/Stmt.h lib/AST/ASTDumper.cpp lib/Sema/SemaCast.cpp test/Sema/multistep-explicit-cast.c test/SemaCXX/multistep-explicit-cast.cpp Index: test/SemaCXX/multistep-explicit-cast.cpp === --- /dev/null +++ test/SemaCXX/multistep-explicit-cast.cpp @@ -0,0 +1,155 @@ +// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -ast-dump %s | FileCheck %s + +// We are checking that implicit casts don't get marked with 'PartOfExplicitCast', +// while in explicit casts, the implicitly-inserted implicit casts are marked with 'PartOfExplicitCast' + +unsigned char implicitcast_0(unsigned int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} implicitcast_0 'unsigned char (unsigned int)'{{$}} + // CHECK: ImplicitCastExpr {{.*}} 'unsigned char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' {{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int' lvalue ParmVar {{.*}} 'x' 'unsigned int'{{$}} + return x; +} + +signed char implicitcast_1(unsigned int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} implicitcast_1 'signed char (unsigned int)'{{$}} + // CHECK: ImplicitCastExpr {{.*}} 'signed char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' {{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int' lvalue ParmVar {{.*}} 'x' 'unsigned int'{{$}} + return x; +} + +unsigned char implicitcast_2(signed int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} implicitcast_2 'unsigned char (int)'{{$}} + // CHECK: ImplicitCastExpr {{.*}} 'unsigned char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'int' {{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} 'x' 'int'{{$}} + return x; +} + +signed char implicitcast_3(signed int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} implicitcast_3 'signed char (int)'{{$}} + // CHECK: ImplicitCastExpr {{.*}} 'signed char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'int' {{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} 'x' 'int'{{$}} + return x; +} + +//// + +unsigned char cstylecast_0(unsigned int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} cstylecast_0 'unsigned char (unsigned int)'{{$}} + // CHECK: CStyleCastExpr {{.*}} 'unsigned char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned char' PartOfExplicitCast{{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' PartOfExplicitCast{{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int' lvalue ParmVar {{.*}} 'x' 'unsigned int'{{$}} + return (unsigned char)x; +} + +signed char cstylecast_1(unsigned int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} cstylecast_1 'signed char (unsigned int)'{{$}} + // CHECK: CStyleCastExpr {{.*}} 'signed char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'signed char' PartOfExplicitCast{{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' PartOfExplicitCast{{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int' lvalue ParmVar {{.*}} 'x' 'unsigned int'{{$}} + return (signed char)x; +} + +unsigned char cstylecast_2(signed int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} cstylecast_2 'unsigned char (int)'{{$}} + // CHECK: CStyleCastExpr {{.*}} 'unsigned char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned char' PartOfExplicitCast{{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'int' PartOfExplicitCast{{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} 'x' 'int'{{$}} + return (unsigned char)x; +} + +signed char cstylecast_3(signed int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} cstylecast_3 'signed char (int)'{{$}} + // CHECK: CStyleCastExpr {{.*}} 'signed char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'signed char' PartOfExplicitCast{{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'int' PartOfExplicitCast{{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} 'x' 'int'{{$}} + return (signed char)x; +} + +//// + +unsigned char cxxstaticcast_0(unsigned int x) { + // CHECK: FunctionDecl {{.*}} <{{
r337540 - Sema: Fix explicit address space cast in C++
Author: yaxunl Date: Fri Jul 20 04:32:51 2018 New Revision: 337540 URL: http://llvm.org/viewvc/llvm-project?rev=337540&view=rev Log: Sema: Fix explicit address space cast in C++ Currently clang does not allow implicit cast of a pointer to a pointer type in different address space but allows C-style cast of a pointer to a pointer type in different address space. However, there is a bug in Sema causing incorrect Cast Expr in AST for the latter case, which in turn results in invalid LLVM IR in codegen. This is because Sema::IsQualificationConversion returns true for a cast of pointer to a pointer type in different address space, which in turn allows a standard conversion and results in a cast expression with no op in AST. This patch fixes that by let Sema::IsQualificationConversion returns false for a cast of pointer to a pointer type in different address space, which in turn disallows standard conversion, implicit cast, and static cast. Finally it results in an reinterpret cast and correct conversion kind is set. Differential Revision: https://reviews.llvm.org/D49294 Added: cfe/trunk/test/CodeGenCXX/address-space-cast.cpp Modified: cfe/trunk/lib/Sema/SemaCast.cpp cfe/trunk/lib/Sema/SemaOverload.cpp Modified: cfe/trunk/lib/Sema/SemaCast.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=337540&r1=337539&r2=337540&view=diff == --- cfe/trunk/lib/Sema/SemaCast.cpp (original) +++ cfe/trunk/lib/Sema/SemaCast.cpp Fri Jul 20 04:32:51 2018 @@ -1955,6 +1955,12 @@ static bool fixOverloadedReinterpretCast return Result.isUsable(); } +static bool IsAddressSpaceConversion(QualType SrcType, QualType DestType) { + return SrcType->isPointerType() && DestType->isPointerType() && + SrcType->getAs()->getPointeeType().getAddressSpace() != + DestType->getAs()->getPointeeType().getAddressSpace(); +} + static TryCastResult TryReinterpretCast(Sema &Self, ExprResult &SrcExpr, QualType DestType, bool CStyle, SourceRange OpRange, @@ -2198,6 +2204,8 @@ static TryCastResult TryReinterpretCast( } else { Kind = CK_BitCast; } + } else if (IsAddressSpaceConversion(SrcType, DestType)) { +Kind = CK_AddressSpaceConversion; } else { Kind = CK_BitCast; } Modified: cfe/trunk/lib/Sema/SemaOverload.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=337540&r1=337539&r2=337540&view=diff == --- cfe/trunk/lib/Sema/SemaOverload.cpp (original) +++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Jul 20 04:32:51 2018 @@ -3150,6 +3150,15 @@ Sema::IsQualificationConversion(QualType = PreviousToQualsIncludeConst && ToQuals.hasConst(); } + // Allows address space promotion by language rules implemented in + // Type::Qualifiers::isAddressSpaceSupersetOf. + Qualifiers FromQuals = FromType.getQualifiers(); + Qualifiers ToQuals = ToType.getQualifiers(); + if (!ToQuals.isAddressSpaceSupersetOf(FromQuals) && + !FromQuals.isAddressSpaceSupersetOf(ToQuals)) { +return false; + } + // We are left with FromType and ToType being the pointee types // after unwrapping the original FromType and ToType the same number // of types. If we unwrapped any pointers, and if FromType and Added: cfe/trunk/test/CodeGenCXX/address-space-cast.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/address-space-cast.cpp?rev=337540&view=auto == --- cfe/trunk/test/CodeGenCXX/address-space-cast.cpp (added) +++ cfe/trunk/test/CodeGenCXX/address-space-cast.cpp Fri Jul 20 04:32:51 2018 @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck %s + +#define __private__ __attribute__((address_space(5))) + +void func_pchar(__private__ char *x); + +void test_cast(char *gen_ptr) { + // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i8 addrspace(5)* + // CHECK-NEXT: store i8 addrspace(5)* %[[cast]] + __private__ char *priv_ptr = (__private__ char *)gen_ptr; + + // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i8 addrspace(5)* + // CHECK-NEXT: call void @_Z10func_pcharPU3AS5c(i8 addrspace(5)* %[[cast]]) + func_pchar((__private__ char *)gen_ptr); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49294: Sema: Fix explicit address space cast in C++
This revision was automatically updated to reflect the committed changes. Closed by commit rL337540: Sema: Fix explicit address space cast in C++ (authored by yaxunl, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D49294?vs=156403&id=156469#toc Repository: rL LLVM https://reviews.llvm.org/D49294 Files: cfe/trunk/lib/Sema/SemaCast.cpp cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/test/CodeGenCXX/address-space-cast.cpp Index: cfe/trunk/test/CodeGenCXX/address-space-cast.cpp === --- cfe/trunk/test/CodeGenCXX/address-space-cast.cpp +++ cfe/trunk/test/CodeGenCXX/address-space-cast.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck %s + +#define __private__ __attribute__((address_space(5))) + +void func_pchar(__private__ char *x); + +void test_cast(char *gen_ptr) { + // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i8 addrspace(5)* + // CHECK-NEXT: store i8 addrspace(5)* %[[cast]] + __private__ char *priv_ptr = (__private__ char *)gen_ptr; + + // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i8 addrspace(5)* + // CHECK-NEXT: call void @_Z10func_pcharPU3AS5c(i8 addrspace(5)* %[[cast]]) + func_pchar((__private__ char *)gen_ptr); +} Index: cfe/trunk/lib/Sema/SemaCast.cpp === --- cfe/trunk/lib/Sema/SemaCast.cpp +++ cfe/trunk/lib/Sema/SemaCast.cpp @@ -1955,6 +1955,12 @@ return Result.isUsable(); } +static bool IsAddressSpaceConversion(QualType SrcType, QualType DestType) { + return SrcType->isPointerType() && DestType->isPointerType() && + SrcType->getAs()->getPointeeType().getAddressSpace() != + DestType->getAs()->getPointeeType().getAddressSpace(); +} + static TryCastResult TryReinterpretCast(Sema &Self, ExprResult &SrcExpr, QualType DestType, bool CStyle, SourceRange OpRange, @@ -2198,6 +2204,8 @@ } else { Kind = CK_BitCast; } + } else if (IsAddressSpaceConversion(SrcType, DestType)) { +Kind = CK_AddressSpaceConversion; } else { Kind = CK_BitCast; } Index: cfe/trunk/lib/Sema/SemaOverload.cpp === --- cfe/trunk/lib/Sema/SemaOverload.cpp +++ cfe/trunk/lib/Sema/SemaOverload.cpp @@ -3150,6 +3150,15 @@ = PreviousToQualsIncludeConst && ToQuals.hasConst(); } + // Allows address space promotion by language rules implemented in + // Type::Qualifiers::isAddressSpaceSupersetOf. + Qualifiers FromQuals = FromType.getQualifiers(); + Qualifiers ToQuals = ToType.getQualifiers(); + if (!ToQuals.isAddressSpaceSupersetOf(FromQuals) && + !FromQuals.isAddressSpaceSupersetOf(ToQuals)) { +return false; + } + // We are left with FromType and ToType being the pointee types // after unwrapping the original FromType and ToType the same number // of types. If we unwrapped any pointers, and if FromType and Index: cfe/trunk/test/CodeGenCXX/address-space-cast.cpp === --- cfe/trunk/test/CodeGenCXX/address-space-cast.cpp +++ cfe/trunk/test/CodeGenCXX/address-space-cast.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck %s + +#define __private__ __attribute__((address_space(5))) + +void func_pchar(__private__ char *x); + +void test_cast(char *gen_ptr) { + // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i8 addrspace(5)* + // CHECK-NEXT: store i8 addrspace(5)* %[[cast]] + __private__ char *priv_ptr = (__private__ char *)gen_ptr; + + // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i8 addrspace(5)* + // CHECK-NEXT: call void @_Z10func_pcharPU3AS5c(i8 addrspace(5)* %[[cast]]) + func_pchar((__private__ char *)gen_ptr); +} Index: cfe/trunk/lib/Sema/SemaCast.cpp === --- cfe/trunk/lib/Sema/SemaCast.cpp +++ cfe/trunk/lib/Sema/SemaCast.cpp @@ -1955,6 +1955,12 @@ return Result.isUsable(); } +static bool IsAddressSpaceConversion(QualType SrcType, QualType DestType) { + return SrcType->isPointerType() && DestType->isPointerType() && + SrcType->getAs()->getPointeeType().getAddressSpace() != + DestType->getAs()->getPointeeType().getAddressSpace(); +} + static TryCastResult TryReinterpretCast(Sema &Self, ExprResult &SrcExpr, QualType DestType, bool CStyle, SourceRange OpRange, @@ -2198,6 +2204,8 @@ } else { Kind = CK_BitCast; } + } else if (IsAddressSpaceConversion(SrcType, DestType)) { +Kind = CK_AddressSpaceConversion; } else { Kind = CK_BitCast; } Index: cfe/trunk/lib/Sema/SemaOverload.cpp ===
[PATCH] D49591: [clangd] Introduce search Tokens and trigram generation algorithms
sammccall added inline comments. Comment at: clang-tools-extra/clangd/index/dex/Trigram.cpp:37 + + // Extract trigrams consisting of first characters of tokens sorted bytoken + // positions. Trigram generator is allowed to skip 1 word between each token. sammccall wrote: > ah, you're also handling this by cases here. > > This doesn't seem necessary. > In fact I think there's a fairly simple way to express this that works > naturally with the segmentation structure produced by fuzzymatch (so doesn't > need a version of segmentIdentifier to wrap it). > But it's taking me too long to work out the details, will write a followup > comment or discuss offline. The idea is to precompute the list of "legal next chars" after each char. This can in fact be done in one backwards pass. Then actually computing the trigram set is very easy. ``` generateTrigrams(StringRef Text) { // Segment the text. vector Roles(Text.size()); calculateRoles(Text, makeMutableArrayRef(Roles)); // Calculate legal next characters after each character. vector Next(Text.size()); // 0 entries mean "nothing" unsigned NextTail = 0, NextSeg = 0, NextNextSeg = 0; for (int I = Text.size() - 1; i >= 0; --I) { Next[I] = {NextTail, NextSeg, NextNextSeg}; NextTail = Roles[I] == Tail ? I : 0; if (Roles[I] == Head) { NextNextHead = NextHead; NextHead = I; } } // Compute trigrams. They can start at head or tail chars. DenseSet Tokens. for (int I = 0; I < Text.size(); ++I) { if (Roles[I] != Head && Roles[I] != Tail) continue; for (unsigned J : Next[I]) { if (!J) continue; for (unsigned K : Next[K]) { if (!K) continue; char Trigram[] = {Text[I], Text[J], Text[K]}; Tokens.emplate(TRIGRAM, Trigram); } } } // Return deduplicated trigrams. std::vector TokensV; for (const auto& E : Tokens) TokensV.push_back(E.second); return TokensV; ``` https://reviews.llvm.org/D49591 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49594: [DebugInfo] Emit diagnostics when enabling -fdebug-types-section on non-linux target.
labath added a comment. I believe debug_types is used on non-linux targets as well. Judging by the other review all ELF targets should at least have a chance of working, so maybe key the error off of that? Repository: rC Clang https://reviews.llvm.org/D49594 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49502: [CMake] Support statically linking dependencies only to shared or static library
ldionne added a comment. LGTM Repository: rL LLVM https://reviews.llvm.org/D49502 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48958: [clang][ubsan] Implicit Cast Sanitizer - integer truncation - clang part
lebedev.ri updated this revision to Diff 156470. lebedev.ri marked 6 inline comments as done. lebedev.ri added a comment. Rebased ontop of yet-again rewritten https://reviews.llvm.org/D49508. Addressed all @vsk's review notes. More review notes wanted :) Repository: rC Clang https://reviews.llvm.org/D48958 Files: docs/ReleaseNotes.rst docs/UndefinedBehaviorSanitizer.rst include/clang/Basic/Sanitizers.def include/clang/Basic/Sanitizers.h lib/CodeGen/CGExprScalar.cpp lib/CodeGen/CodeGenFunction.h lib/Driver/SanitizerArgs.cpp lib/Driver/ToolChain.cpp test/CodeGen/catch-implicit-integer-truncations.c test/CodeGenCXX/catch-implicit-integer-truncations.cpp test/Driver/fsanitize.c Index: test/Driver/fsanitize.c === --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -31,6 +31,21 @@ // RUN: %clang -target x86_64-linux-gnu -fsanitize=integer %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-INTEGER -implicit-check-not="-fsanitize-address-use-after-scope" // CHECK-INTEGER: "-fsanitize={{((signed-integer-overflow|unsigned-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent),?){5}"}} +// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-cast %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-IMPLICIT-CAST,CHECK-IMPLICIT-CAST-RECOVER +// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-cast -fsanitize-recover=implicit-cast %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-IMPLICIT-CAST,CHECK-IMPLICIT-CAST-RECOVER +// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-cast -fno-sanitize-recover=implicit-cast %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-IMPLICIT-CAST,CHECK-IMPLICIT-CAST-NORECOVER +// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-cast -fsanitize-trap=implicit-cast %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-IMPLICIT-CAST,CHECK-IMPLICIT-CAST-TRAP +// CHECK-IMPLICIT-CAST: "-fsanitize={{((implicit-integer-truncation),?){1}"}} +// CHECK-IMPLICIT-CAST-RECOVER: "-fsanitize-recover={{((implicit-integer-truncation),?){1}"}} +// CHECK-IMPLICIT-CAST-RECOVER-NOT: "-fno-sanitize-recover={{((implicit-integer-truncation),?){1}"}} +// CHECK-IMPLICIT-CAST-RECOVER-NOT: "-fsanitize-trap={{((implicit-integer-truncation),?){1}"}} +// CHECK-IMPLICIT-CAST-NORECOVER-NOT: "-fno-sanitize-recover={{((implicit-integer-truncation),?){1}"}} // ??? +// CHECK-IMPLICIT-CAST-NORECOVER-NOT: "-fsanitize-recover={{((implicit-integer-truncation),?){1}"}} +// CHECK-IMPLICIT-CAST-NORECOVER-NOT: "-fsanitize-trap={{((implicit-integer-truncation),?){1}"}} +// CHECK-IMPLICIT-CAST-TRAP: "-fsanitize-trap={{((implicit-integer-truncation),?){1}"}} +// CHECK-IMPLICIT-CAST-TRAP-NOT: "-fsanitize-recover={{((implicit-integer-truncation),?){1}"}} +// CHECK-IMPLICIT-CAST-TRAP-NOT: "-fno-sanitize-recover={{((implicit-integer-truncation),?){1}"}} + // RUN: %clang -fsanitize=bounds -### -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix=CHECK-BOUNDS // CHECK-BOUNDS: "-fsanitize={{((array-bounds|local-bounds),?){2}"}} Index: test/CodeGenCXX/catch-implicit-integer-truncations.cpp === --- /dev/null +++ test/CodeGenCXX/catch-implicit-integer-truncations.cpp @@ -0,0 +1,256 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK +// RUN: %clang_cc1 -fsanitize=implicit-integer-truncation -fno-sanitize-recover=implicit-integer-truncation -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-NORECOVER +// RUN: %clang_cc1 -fsanitize=implicit-integer-truncation -fsanitize-recover=implicit-integer-truncation -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-RECOVER +// RUN: %clang_cc1 -fsanitize=implicit-integer-truncation -fsanitize-trap=implicit-integer-truncation -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-TRAP + +extern "C" { // Disable name mangling. + +// == // +// Check that explicit cast does not interfere with implicit cast +// == // +// These contain one implicit truncating cast, and one explicit truncating cast. +// We want to make sure that we still diagnose the implicit cast. + +// Implicit truncation after explicit truncation. +// CHECK-LABEL: @explicit_cast_interference0 +unsigned char explicit_cast_interference0(unsigned int c) { + // CHECK-SANITIZE: %[[ANYEXT:.*]] = zext i8 %[[DST:.*]] to i16, !nosanitize + // CHECK-SANITIZE: call + // CHECK-SANITIZE-NOT: call + // CHECK: } + return (unsigned short)c; +} + +// Implicit truncation before explicit truncation. +// CHECK-LABEL: @explicit_cast_interfere
[PATCH] D48958: [clang][ubsan] Implicit Cast Sanitizer - integer truncation - clang part
lebedev.ri added inline comments. Comment at: docs/UndefinedBehaviorSanitizer.rst:134 + integer promotions, as those may result in an unexpected computation + results, even though no overflow happens (signed or unsigned). - ``-fsanitize=unreachable``: If control flow reaches an unreachable vsk wrote: > Could you make this more explicit? It would help to point out that this check > does not diagnose lossy implicit integer conversions, but that the new check > does. Ditto for the comment in the unsigned-integer-overflow section. Is this better? Comment at: lib/CodeGen/CodeGenFunction.h:383 + // This stack is used/maintained exclusively by the implicit cast sanitizer. + llvm::SmallVector CastExprStack; + vsk wrote: > Why not 0 instead of 8, given that in the common case, this stack is unused? No longer relevant. Comment at: lib/CodeGen/CodeGenFunction.h:388 + +llvm::SmallVector GuardedCasts; + vsk wrote: > I'm not sure the cost of maintaining an extra vector is worth the benefit of > the added assertion. Wouldn't it be cheaper to just store the number of > pushed casts? You'd only need one constructor which accepts an ArrayRef CastExpr *>. No longer relevant. Comment at: test/CodeGen/catch-implicit-integer-truncations.c:29 + // CHECK-SANITIZE-NEXT: %[[TRUNCHECK:.*]] = icmp eq i32 %[[ANYEXT]], %[[SRC]], !nosanitize + // CHECK-SANITIZE-ANYRECOVER-NEXT: br i1 %[[TRUNCHECK]], label %[[CONT:.*]], label %[[HANDLER_IMPLICIT_CAST:.*]], !prof ![[WEIGHT_MD:.*]], !nosanitize + // CHECK-SANITIZE-TRAP-NEXT: br i1 %[[TRUNCHECK]], label %[[CONT:.*]], label %[[HANDLER_IMPLICIT_CAST:.*]], !nosanitize vsk wrote: > There's no need to check the profile metadata here. I was checking it because otherwise `HANDLER_IMPLICIT_CAST` would have over-eagerly consumed `, !prof !3` too. But there is actually a way around that.. Comment at: test/CodeGen/catch-implicit-integer-truncations.c:159 +// == // +// The expected false-negatives. +// == // vsk wrote: > nit, aren't these true-negatives because we expect to see no errors? Right. Repository: rC Clang https://reviews.llvm.org/D48958 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49573: [CMake] Option to control whether shared/static library is installed
ldionne added a comment. I don't like the fact that we're adding options like crazy, thus making the build more complicated. If you don't want to have some libraries that were built, why not just remove them afterwards? Repository: rL LLVM https://reviews.llvm.org/D49573 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49523: [clangd] Add support for per-file override compilation command
jkorous added a comment. Hi Marc-Andre, what is a structure of data you are passing as parameter of didChangeConfiguration message? All we need is to pass per-file compilation command to clangd. Maybe we could send didChangeConfiguration message right after didOpen. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D49523 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49523: [clangd] Add support for per-file override compilation command
jkorous added a comment. Alex, I am just wondering if we shouldn't rather create another implementation of GlobalCompilationDatabase interface (something like InMemoryGlobalCompilationDatabase), add it to ClangdServer and use it as the first place to be searched in ClangdServer::getCompileCommand(PathRef File). What do you think? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D49523 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49594: [DebugInfo] Emit diagnostics when enabling -fdebug-types-section on non-linux target.
JDevlieghere updated this revision to Diff 156471. JDevlieghere added a comment. Thanks, I meant to use `isOSBinFormatELF` but I think it got lost in an accidental undo. The test didn't capture that because it's using a linux target triple. https://reviews.llvm.org/D49594 Files: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/debug-options.c Index: clang/test/Driver/debug-options.c === --- clang/test/Driver/debug-options.c +++ clang/test/Driver/debug-options.c @@ -139,12 +139,18 @@ // // RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=GARANGE %s // -// RUN: %clang -### -fdebug-types-section %s 2>&1 \ +// RUN: %clang -### -fdebug-types-section -target x86_64-unknown-linux %s 2>&1 \ // RUN:| FileCheck -check-prefix=FDTS %s // -// RUN: %clang -### -fdebug-types-section -fno-debug-types-section %s 2>&1 \ +// RUN: %clang -### -fdebug-types-section -fno-debug-types-section -target x86_64-unknown-linux %s 2>&1 \ // RUN:| FileCheck -check-prefix=NOFDTS %s // +// RUN: %clang -### -fdebug-types-section -target x86_64-apple-darwin %s 2>&1 \ +// RUN:| FileCheck -check-prefix=FDTSE %s +// +// RUN: %clang -### -fdebug-types-section -fno-debug-types-section -target x86_64-apple-darwin %s 2>&1 \ +// RUN:| FileCheck -check-prefix=NOFDTSE %s +// // RUN: %clang -### -g -gno-column-info %s 2>&1 \ // RUN:| FileCheck -check-prefix=NOCI %s // @@ -229,8 +235,10 @@ // GARANGE: -generate-arange-section // // FDTS: "-mllvm" "-generate-type-units" +// FDTSE: error: unsupported option '-fdebug-types-section' for target 'x86_64-apple-darwin' // // NOFDTS-NOT: "-mllvm" "-generate-type-units" +// NOFDTSE-NOT: error: unsupported option '-fdebug-types-section' for target 'x86_64-apple-darwin' // // CI: "-dwarf-column-info" // Index: clang/lib/Driver/ToolChains/Clang.cpp === --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -3028,6 +3028,11 @@ if (Args.hasFlag(options::OPT_fdebug_types_section, options::OPT_fno_debug_types_section, false)) { +if (!T.isOSBinFormatELF()) + D.Diag(diag::err_drv_unsupported_opt_for_target) + << Args.getLastArg(options::OPT_fdebug_types_section) + ->getAsString(Args) + << T.getTriple(); CmdArgs.push_back("-mllvm"); CmdArgs.push_back("-generate-type-units"); } Index: clang/test/Driver/debug-options.c === --- clang/test/Driver/debug-options.c +++ clang/test/Driver/debug-options.c @@ -139,12 +139,18 @@ // // RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=GARANGE %s // -// RUN: %clang -### -fdebug-types-section %s 2>&1 \ +// RUN: %clang -### -fdebug-types-section -target x86_64-unknown-linux %s 2>&1 \ // RUN:| FileCheck -check-prefix=FDTS %s // -// RUN: %clang -### -fdebug-types-section -fno-debug-types-section %s 2>&1 \ +// RUN: %clang -### -fdebug-types-section -fno-debug-types-section -target x86_64-unknown-linux %s 2>&1 \ // RUN:| FileCheck -check-prefix=NOFDTS %s // +// RUN: %clang -### -fdebug-types-section -target x86_64-apple-darwin %s 2>&1 \ +// RUN:| FileCheck -check-prefix=FDTSE %s +// +// RUN: %clang -### -fdebug-types-section -fno-debug-types-section -target x86_64-apple-darwin %s 2>&1 \ +// RUN:| FileCheck -check-prefix=NOFDTSE %s +// // RUN: %clang -### -g -gno-column-info %s 2>&1 \ // RUN:| FileCheck -check-prefix=NOCI %s // @@ -229,8 +235,10 @@ // GARANGE: -generate-arange-section // // FDTS: "-mllvm" "-generate-type-units" +// FDTSE: error: unsupported option '-fdebug-types-section' for target 'x86_64-apple-darwin' // // NOFDTS-NOT: "-mllvm" "-generate-type-units" +// NOFDTSE-NOT: error: unsupported option '-fdebug-types-section' for target 'x86_64-apple-darwin' // // CI: "-dwarf-column-info" // Index: clang/lib/Driver/ToolChains/Clang.cpp === --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -3028,6 +3028,11 @@ if (Args.hasFlag(options::OPT_fdebug_types_section, options::OPT_fno_debug_types_section, false)) { +if (!T.isOSBinFormatELF()) + D.Diag(diag::err_drv_unsupported_opt_for_target) + << Args.getLastArg(options::OPT_fdebug_types_section) + ->getAsString(Args) + << T.getTriple(); CmdArgs.push_back("-mllvm"); CmdArgs.push_back("-generate-type-units"); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48559: [clangd] refactoring for XPC transport layer [NFCI]
jkorous added a comment. Hi Sam, we discussed a bit more with Alex offline. Ultimately we don't mind using JSON as part of the generic interface but we'd like to optimize specific cases in the future (thinking only about code completion so far) which might need to "work-around" the abstraction. What is your opinion about this - does it ruin the whole point of having the abstraction or do you consider pragmatic to have abstraction covering most of the functionality with maybe couple exceptions? I kind of assume (please correct me if I am wrong) that you might have done something similar with profobuf interface so we're definitely happy to discuss. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48559 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48560: [clangd] JSON <-> XPC conversions
jkorous added a comment. BTW Just for the record - I put the rebased & updated patch here: [clangd] XPC WIP https://reviews.llvm.org/D49548 Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48560 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48562: [clangd] XPC transport layer
jkorous added a comment. BTW Just for the record - I put the rebased & updated patch here: [clangd] XPC WIP https://reviews.llvm.org/D49548 https://reviews.llvm.org/D48562 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48559: [clangd] refactoring for XPC transport layer [NFCI]
jkorous added a comment. BTW Just for the record - I put the rebased & updated patch here: [clangd] XPC WIP https://reviews.llvm.org/D49548 Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48559 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49584: [CMake] Install C++ ABI headers into the right location
ldionne added a comment. This change LGTM. However, I do have a question about the overall change (including r335809 and r337118). Why is it that we're not simply relying on the `CMAKE_INSTALL_PREFIX` being set to the path where we should install instead of using all these custom variables like `LIBCXX_INSTALL_HEADER_PREFIX`? I'm curious to understand what's special about your use case, since it does seem like we're doing things differently in a few places for Fuchsia. Repository: rCXX libc++ https://reviews.llvm.org/D49584 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49597: [ms] Fix mangling of vector types in QMM_Result contexts.
thakis created this revision. thakis added a reviewer: zturner. If QMM_Result is set (which it is for return types, RTTI descriptors, and exception type descriptors), tag types (structs, enums, classes, unions) get their qualifiers mangled in. __m64 and friends is a struct/union thingy in MSVC, but not in clang's headers. To make mangling work, we call `mangleArtificalTagType(TTK_Union/TTK_Struct` for the vector types to mangle them as tag types -- but the isa check when mangling in QMM_Result mode isn't true these vector types. Add an isArtificialTagType() function and check for that too. Fixes PR37276 and some other issues. I tried to audit all references to TagDecl and TagType in MicrosoftMangle.cpp to see if there are other places where we need to call mangleArtificalTagType(), but I couldn't find other places. I tried to audit all calls to mangleArtificalTagType() to see if isArtificialTagType() needs to handle more than just the vector types, but as far as I can tell all other types we use it for are types that MSVC can't handle at all (Objective-C types etc). https://reviews.llvm.org/D49597 Files: clang/lib/AST/MicrosoftMangle.cpp clang/test/CodeGenCXX/mangle-ms-vector-types.cpp Index: clang/test/CodeGenCXX/mangle-ms-vector-types.cpp === --- clang/test/CodeGenCXX/mangle-ms-vector-types.cpp +++ clang/test/CodeGenCXX/mangle-ms-vector-types.cpp @@ -1,30 +1,91 @@ -// RUN: %clang_cc1 -fms-extensions -ffreestanding -target-feature +avx -emit-llvm %s -o - -triple=i686-pc-win32 | FileCheck %s +// RUN: %clang_cc1 -fms-extensions -fcxx-exceptions -ffreestanding -target-feature +avx -emit-llvm %s -o - -triple=i686-pc-win32 | FileCheck %s #include #include #include +void thow(int i) { + switch (i) { +case 0: throw __m64(); +// CHECK: ??_R0?AT__m64@@@8 +// CHECK: _CT??_R0?AT__m64@@@88 +// CHECK: _CTA1?AT__m64@@ +// CHECK: _TI1?AT__m64@@ +case 1: throw __m128(); +// CHECK: ??_R0?AT__m128@@@8 +// CHECK: _CT??_R0?AT__m128@@@816 +// CHECK: _CTA1?AT__m128@@ +// CHECK: _TI1?AT__m128@@ +case 2: throw __m128d(); +// CHECK: ??_R0?AU__m128d@@@8 +// CHECK: _CT??_R0?AU__m128d@@@816 +// CHECK: _CTA1?AU__m128d@@ +// CHECK: _TI1?AU__m128d@@ +case 3: throw __m128i(); +// CHECK: ??_R0?AT__m128i@@@8 +// CHECK: _CT??_R0?AT__m128i@@@816 +// CHECK: _CTA1?AT__m128i@@ +// CHECK: _TI1?AT__m128i@@ +case 4: throw __m256(); +// CHECK: ??_R0?AT__m256@@@8 +// CHECK: _CT??_R0?AT__m256@@@832 +// CHECK: _CTA1?AT__m256@@ +// CHECK: _TI1?AT__m256@@ +case 5: throw __m256d(); +// CHECK: ??_R0?AU__m256d@@@8 +// CHECK: _CT??_R0?AU__m256d@@@832 +// CHECK: _CTA1?AU__m256d@@ +// CHECK: _TI1?AU__m256d@@ +case 6: throw __m256i(); +// CHECK: ??_R0?AT__m256@@@8 +// CHECK: _CT??_R0?AT__m256@@@832 +// CHECK: _CTA1?AT__m256@@ +// CHECK: _TI1?AT__m256@@ + } +} + void foo64(__m64) {} // CHECK: define dso_local void @"?foo64@@YAXT__m64@@@Z" +__m64 rfoo64() { return __m64(); } +// CHECK: define dso_local <1 x i64> @"?rfoo64@@YA?AT__m64@@XZ" + void foo128(__m128) {} // CHECK: define dso_local void @"?foo128@@YAXT__m128@@@Z" +__m128 rfoo128() { return __m128(); } +// CHECK: define dso_local <4 x float> @"?rfoo128@@YA?AT__m128@@XZ" + void foo128d(__m128d) {} // CHECK: define dso_local void @"?foo128d@@YAXU__m128d@@@Z" +__m128d rfoo128d() { return __m128d(); } +// CHECK: define dso_local <2 x double> @"?rfoo128d@@YA?AU__m128d@@XZ" + void foo128i(__m128i) {} // CHECK: define dso_local void @"?foo128i@@YAXT__m128i@@@Z" +__m128i rfoo128i() { return __m128i(); } +// CHECK: define dso_local <2 x i64> @"?rfoo128i@@YA?AT__m128i@@XZ" + void foo256(__m256) {} // CHECK: define dso_local void @"?foo256@@YAXT__m256@@@Z" +__m256 rfoo256() { return __m256(); } +// CHECK: define dso_local <8 x float> @"?rfoo256@@YA?AT__m256@@XZ" + void foo256d(__m256d) {} // CHECK: define dso_local void @"?foo256d@@YAXU__m256d@@@Z" +__m256d rfoo256d() { return __m256d(); } +// CHECK: define dso_local <4 x double> @"?rfoo256d@@YA?AU__m256d@@XZ" + void foo256i(__m256i) {} // CHECK: define dso_local void @"?foo256i@@YAXT__m256i@@@Z" +__m256i rfoo256i() { return __m256i(); } +// CHECK: define dso_local <4 x i64> @"?rfoo256i@@YA?AT__m256i@@XZ" + // We have a custom mangling for vector types not standardized by Intel. void foov8hi(__v8hi) {} // CHECK: define dso_local void @"?foov8hi@@YAXT?$__vector@F$07@__clang@@@Z" Index: clang/lib/AST/MicrosoftMangle.cpp === --- clang/lib/AST/MicrosoftMangle.cpp +++ clang/lib/AST/MicrosoftMangle.cpp @@ -337,6 +337,8 @@ void mangleArgumentType(QualType T, SourceRange Range); void manglePassObjectSizeArg(const PassObjectSizeAttr *POSA); + bool isArtificialTagType(QualType T) const; + // Declare manglers for every type class. #de
[PATCH] D49597: [ms] Fix mangling of vector types in QMM_Result contexts.
thakis added a comment. If you want to compare the CHECK lines to MSVC's output: https://godbolt.org/g/Cvf4p4 https://reviews.llvm.org/D49597 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r337552 - Implement cpu_dispatch/cpu_specific Multiversioning
Author: erichkeane Date: Fri Jul 20 07:13:28 2018 New Revision: 337552 URL: http://llvm.org/viewvc/llvm-project?rev=337552&view=rev Log: Implement cpu_dispatch/cpu_specific Multiversioning As documented here: https://software.intel.com/en-us/node/682969 and https://software.intel.com/en-us/node/523346. cpu_dispatch multiversioning is an ICC feature that provides for function multiversioning. This feature is implemented with two attributes: First, cpu_specific, which specifies the individual function versions. Second, cpu_dispatch, which specifies the location of the resolver function and the list of resolvable functions. This is valuable since it provides a mechanism where the resolver's TU can be specified in one location, and the individual implementions each in their own translation units. The goal of this patch is to be source-compatible with ICC, so this implementation diverges from the ICC implementation in a few ways: 1- Linux x86/64 only: This implementation uses ifuncs in order to properly dispatch functions. This is is a valuable performance benefit over the ICC implementation. A future patch will be provided to enable this feature on Windows, but it will obviously more closely fit ICC's implementation. 2- CPU Identification functions: ICC uses a set of custom functions to identify the feature list of the host processor. This patch uses the cpu_supports functionality in order to better align with 'target' multiversioning. 1- cpu_dispatch function def/decl: ICC's cpu_dispatch requires that the function marked cpu_dispatch be an empty definition. This patch supports that as well, however declarations are also permitted, since the linker will solve the issue of multiple emissions. Differential Revision: https://reviews.llvm.org/D47474 Added: cfe/trunk/test/CodeGen/attr-cpuspecific.c cfe/trunk/test/Sema/attr-cpuspecific.c cfe/trunk/test/SemaCXX/attr-cpuspecific.cpp Modified: cfe/trunk/include/clang/AST/Decl.h cfe/trunk/include/clang/Basic/Attr.td cfe/trunk/include/clang/Basic/AttrDocs.td cfe/trunk/include/clang/Basic/DiagnosticGroups.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Basic/TargetInfo.h cfe/trunk/include/clang/Basic/X86Target.def cfe/trunk/lib/AST/Decl.cpp cfe/trunk/lib/Basic/Targets/X86.cpp cfe/trunk/lib/Basic/Targets/X86.h cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp cfe/trunk/lib/Sema/Sema.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Modified: cfe/trunk/include/clang/AST/Decl.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=337552&r1=337551&r2=337552&view=diff == --- cfe/trunk/include/clang/AST/Decl.h (original) +++ cfe/trunk/include/clang/AST/Decl.h Fri Jul 20 07:13:28 2018 @@ -2209,6 +2209,13 @@ public: getCanonicalDecl()->IsMultiVersion = V; } + /// True if this function is a multiversioned dispatch function as a part of + /// the cpu_specific/cpu_dispatch functionality. + bool isCPUDispatchMultiVersion() const; + /// True if this function is a multiversioned processor specific function as a + /// part of the cpu_specific/cpu_dispatch functionality. + bool isCPUSpecificMultiVersion() const; + void setPreviousDeclaration(FunctionDecl * PrevDecl); FunctionDecl *getCanonicalDecl() override; Modified: cfe/trunk/include/clang/Basic/Attr.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=337552&r1=337551&r2=337552&view=diff == --- cfe/trunk/include/clang/Basic/Attr.td (original) +++ cfe/trunk/include/clang/Basic/Attr.td Fri Jul 20 07:13:28 2018 @@ -168,6 +168,7 @@ class UnsignedArgument : Argument; class VariadicExprArgument : Argument; class VariadicStringArgument : Argument; +class VariadicIdentifierArgument : Argument; // Like VariadicUnsignedArgument except values are ParamIdx. class VariadicParamIdxArgument : Argument; @@ -845,6 +846,27 @@ def Constructor : InheritableAttr { let Documentation = [Undocumented]; } +def CPUSpecific : InheritableAttr { + let Spellings = [Clang<"cpu_specific">]; + let Args = [VariadicIdentifierArgument<"Cpus">]; + let Subjects = SubjectList<[Function]>; + let Documentation = [CPUSpecificCPUDispatchDocs]; + let AdditionalMembers = [{ +unsigned ActiveArgIndex = 0; + +IdentifierInfo *getCurCPUName() const { +
[PATCH] D47474: Implement cpu_dispatch/cpu_specific Multiversioning
This revision was automatically updated to reflect the committed changes. Closed by commit rC337552: Implement cpu_dispatch/cpu_specific Multiversioning (authored by erichkeane, committed by ). Repository: rC Clang https://reviews.llvm.org/D47474 Files: include/clang/AST/Decl.h include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td include/clang/Basic/TargetInfo.h include/clang/Basic/X86Target.def lib/AST/Decl.cpp lib/Basic/Targets/X86.cpp lib/Basic/Targets/X86.h lib/CodeGen/CGBuiltin.cpp lib/CodeGen/CodeGenFunction.cpp lib/CodeGen/CodeGenFunction.h lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h lib/Parse/ParseDecl.cpp lib/Sema/AnalysisBasedWarnings.cpp lib/Sema/Sema.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclAttr.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaOverload.cpp test/CodeGen/attr-cpuspecific.c test/Misc/pragma-attribute-supported-attributes-list.test test/Sema/attr-cpuspecific.c test/SemaCXX/attr-cpuspecific.cpp utils/TableGen/ClangAttrEmitter.cpp Index: lib/AST/Decl.cpp === --- lib/AST/Decl.cpp +++ lib/AST/Decl.cpp @@ -2873,6 +2873,14 @@ return false; } +bool FunctionDecl::isCPUDispatchMultiVersion() const { + return isMultiVersion() && hasAttr(); +} + +bool FunctionDecl::isCPUSpecificMultiVersion() const { + return isMultiVersion() && hasAttr(); +} + void FunctionDecl::setPreviousDeclaration(FunctionDecl *PrevDecl) { redeclarable_base::setPreviousDecl(PrevDecl); Index: lib/Sema/AnalysisBasedWarnings.cpp === --- lib/Sema/AnalysisBasedWarnings.cpp +++ lib/Sema/AnalysisBasedWarnings.cpp @@ -658,6 +658,11 @@ else S.Diag(Loc, DiagID); }; + + // cpu_dispatch functions permit empty function bodies for ICC compatibility. + if (D->getAsFunction() && D->getAsFunction()->isCPUDispatchMultiVersion()) +return; + // Either in a function body compound statement, or a function-try-block. switch (CheckFallThrough(AC)) { case UnknownFallThrough: Index: lib/Sema/Sema.cpp === --- lib/Sema/Sema.cpp +++ lib/Sema/Sema.cpp @@ -1585,6 +1585,7 @@ } bool Ambiguous = false; + bool IsMV = false; if (Overloads) { for (OverloadExpr::decls_iterator it = Overloads->decls_begin(), @@ -1598,11 +1599,16 @@ if (const FunctionDecl *OverloadDecl = dyn_cast((*it)->getUnderlyingDecl())) { if (OverloadDecl->getMinRequiredArguments() == 0) { - if (!ZeroArgCallReturnTy.isNull() && !Ambiguous) { + if (!ZeroArgCallReturnTy.isNull() && !Ambiguous && + (!IsMV || !(OverloadDecl->isCPUDispatchMultiVersion() || + OverloadDecl->isCPUSpecificMultiVersion( { ZeroArgCallReturnTy = QualType(); Ambiguous = true; - } else + } else { ZeroArgCallReturnTy = OverloadDecl->getReturnType(); +IsMV = OverloadDecl->isCPUDispatchMultiVersion() || + OverloadDecl->isCPUSpecificMultiVersion(); + } } } } @@ -1683,7 +1689,7 @@ NamedDecl *Fn = (*It)->getUnderlyingDecl(); // Don't print overloads for non-default multiversioned functions. if (const auto *FD = Fn->getAsFunction()) { - if (FD->isMultiVersion() && + if (FD->isMultiVersion() && FD->hasAttr() && !FD->getAttr()->isDefaultVersion()) continue; } @@ -1725,6 +1731,21 @@ !isa(E)); } +static bool IsCPUDispatchCPUSpecificMultiVersion(const Expr *E) { + if (const auto *UO = dyn_cast(E)) +E = UO->getSubExpr(); + + if (const auto *ULE = dyn_cast(E)) { +if (ULE->getNumDecls() == 0) + return false; + +const NamedDecl *ND = *ULE->decls_begin(); +if (const auto *FD = dyn_cast(ND)) + return FD->isCPUDispatchMultiVersion() || FD->isCPUSpecificMultiVersion(); + } + return false; +} + bool Sema::tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD, bool ForceComplain, bool (*IsPlausibleResult)(QualType)) { @@ -1741,12 +1762,13 @@ // so we can emit a fixit and carry on pretending that E was // actually a CallExpr. SourceLocation ParenInsertionLoc = getLocForEndOfToken(Range.getEnd()); -Diag(Loc, PD) - << /*zero-arg*/ 1 << Range - << (IsCallableWithAppend(E.get()) - ? FixItHint::CreateInsertion(ParenInsertionLoc, "()") - : FixItHint()); -notePlausibleOverloads(*this, Loc, Overloads, IsPlausibleResult); +bool IsMV = IsCPUDispatchCPUSpecificMultiVersion(E.get()); +Diag(Loc, PD) << /*zero-arg*/ 1 << IsMV << Range + << (IsCallableWithAppend(E.get()) + ? FixItHi
[PATCH] D49546: [clangd] Implement query iterators for Dex symbol index
kbobyrev updated this revision to Diff 156483. kbobyrev marked 9 inline comments as done. kbobyrev added a comment. - Switched from `std::shared_ptr` to `std::unique_ptr` for iterator's children: iterators own their subtrees, the lifetime should depend on the root - Store `PostingListRef`in `DocumentIterator`: the lifetime of underlying `PostingList` should be longer than the `DocumentIterator` anyway, `DocumentIterator` can not retrieve results from an incomplete inverted index - Refined API of different iterators: wipe `getIndex()`, `reset()` from `DocumentIterator`, `getChildren` from `AndIterator` and `OrIterator` - Not exposing `DocumentIterator`, `AndIterator`, `OrIterator` to the User API anymore: helper functions like `std::unique_ptr constructDocumentIterator` which return a unique pointer and perform type erasure are provided instead - Improved variable naming, applied refactorings where necessary https://reviews.llvm.org/D49546 Files: clang-tools-extra/clangd/CMakeLists.txt clang-tools-extra/clangd/index/dex/QueryIterator.cpp clang-tools-extra/clangd/index/dex/QueryIterator.h clang-tools-extra/unittests/clangd/CMakeLists.txt clang-tools-extra/unittests/clangd/DexIndexTests.cpp Index: clang-tools-extra/unittests/clangd/DexIndexTests.cpp === --- /dev/null +++ clang-tools-extra/unittests/clangd/DexIndexTests.cpp @@ -0,0 +1,430 @@ +//===--- DexIndexTests.cpp *- C++ -*---===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "index/dex/QueryIterator.h" +#include "gtest/gtest.h" + +namespace clang { +namespace clangd { +namespace dex { + +using std::make_shared; +using std::move; +using std::unique_ptr; +using std::vector; + +TEST(DexIndexIterators, DocumentIterator) { + const PostingList Symbols = {4, 7, 8, 20, 42, 100}; + auto DocIterator = constructDocumentIterator(Symbols); + + EXPECT_EQ(DocIterator->peek(), 4U); + EXPECT_EQ(DocIterator->reachedEnd(), false); + + EXPECT_EQ(DocIterator->advance(), false); + EXPECT_EQ(DocIterator->peek(), 7U); + EXPECT_EQ(DocIterator->reachedEnd(), false); + + EXPECT_EQ(DocIterator->advanceTo(20), false); + EXPECT_EQ(DocIterator->peek(), 20U); + EXPECT_EQ(DocIterator->reachedEnd(), false); + + EXPECT_EQ(DocIterator->advanceTo(65), false); + EXPECT_EQ(DocIterator->peek(), 100U); + EXPECT_EQ(DocIterator->reachedEnd(), false); + + EXPECT_EQ(DocIterator->advanceTo(420), true); + EXPECT_EQ(DocIterator->reachedEnd(), true); +} + +TEST(DexIndexIterators, AndIterator) { + const PostingList EmptyList; + const PostingList FirstList = {0, 5, 7, 10, 42, 320, 9000}; + const PostingList SecondList = {0, 4, 7, 10, 30, 60, 320, 9000}; + const PostingList ThirdList = {1, 4, 7, 11, 30, 60, 320, 9000}; + const PostingList FourthList = {4, 7, 10, 30, 60, 320, 9000}; + const PostingList FifthList = {1, 4, 7, 10, 30, 60, 320, 9000, 100}; + + vector> Children; + + Children.push_back(constructDocumentIterator(EmptyList)); + auto And = constructAndIterator(move(Children)); + EXPECT_EQ(And->reachedEnd(), true); + + Children.clear(); + Children.push_back(constructDocumentIterator(EmptyList)); + Children.push_back(constructDocumentIterator(FirstList)); + And = constructAndIterator(move(Children)); + + EXPECT_EQ(And->reachedEnd(), true); + + Children.clear(); + Children.push_back(constructDocumentIterator(SecondList)); + Children.push_back(constructDocumentIterator(FirstList)); + And = constructAndIterator(move(Children)); + + EXPECT_EQ(And->reachedEnd(), false); + EXPECT_EQ(And->peek(), 0U); + EXPECT_EQ(And->advance(), false); + EXPECT_EQ(And->peek(), 7U); + EXPECT_EQ(And->advance(), false); + EXPECT_EQ(And->peek(), 10U); + EXPECT_EQ(And->advance(), false); + EXPECT_EQ(And->peek(), 320U); + EXPECT_EQ(And->advance(), false); + EXPECT_EQ(And->peek(), 9000U); + EXPECT_EQ(And->advance(), true); + + Children.clear(); + Children.push_back(constructDocumentIterator(SecondList)); + Children.push_back(constructDocumentIterator(FirstList)); + And = constructAndIterator(move(Children)); + + EXPECT_EQ(And->advanceTo(0), false); + EXPECT_EQ(And->peek(), 0U); + EXPECT_EQ(And->advanceTo(5), false); + EXPECT_EQ(And->peek(), 7U); + EXPECT_EQ(And->advanceTo(10), false); + EXPECT_EQ(And->peek(), 10U); + EXPECT_EQ(And->advanceTo(42), false); + EXPECT_EQ(And->peek(), 320U); + EXPECT_EQ(And->advanceTo(8999), false); + EXPECT_EQ(And->peek(), 9000U); + EXPECT_EQ(And->advanceTo(9001), true); + + Children.clear(); + Children.push_back(constructDocumentIterator(SecondList)); + Children.push_back(constructDocumentIterator(FirstList)); + And = constructAndIterator(move(Children)); + + EXPECT_EQ(And->advanceTo
[PATCH] D49546: [clangd] Implement query iterators for Dex symbol index
kbobyrev planned changes to this revision. kbobyrev added a comment. Upcoming changes: - Improve debugging experience by providing `llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, std::unique_ptr Iterator` to recursively pretty print queries in human-readable format: e.g. `(& [0, 1, 2, 3] ([3, 4, 6, 8] || [0, 1]))`. This can be later used for debugging and making sure optimizations were correct. - Properly document the interface and implementation. The current documentation is just a draft, it should be refined. - Think about introducing iterator `cost` and applying cheap optimizations like pre-sorting children of `AndIterator` before performing `advance()`: this way the iterator doesn't spend too much time iterating through long posting lists when it has are short/empty children Comment at: clang-tools-extra/clangd/index/dex/QueryIterator.h:39 +public: + virtual bool reachedEnd() const = 0; + // FIXME(kbobyrev): Should advance() and advanceTo() return size_t peek() sammccall wrote: > or have peek return an InvalidID == size_t{-1}? Tried to do that, but that creates additional complexity for the `AndIterator` which stores `ReachedEnd` anyway. Otherwise I would either have to spend `O(Children.size())` to understand that `AndIterator` reached the end or have inconsistent APIs across the classes, I think it's better to leave it as it is. Comment at: clang-tools-extra/clangd/index/dex/QueryIterator.h:44 + virtual bool advanceTo(size_t Rank) = 0; + virtual size_t peek() const = 0; + sammccall wrote: > could reasonably call this operator* As discussed offline, `*(*Child)` would be probably not very clean. https://reviews.llvm.org/D49546 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49523: [clangd] Add support for per-file override compilation command
malaperle added a comment. In https://reviews.llvm.org/D49523#1169000, @arphaman wrote: > In https://reviews.llvm.org/D49523#1167553, @malaperle wrote: > > > Interesting! We also have a need for passing compilation commands in a > > context where there is no compile_commands.json, but we were thinking of > > putting this in a "didChangeConfiguration" message so that all the commands > > would be available even before files are opened. This would be allow Clangd > > to have the necessary information for background indexing which would > > include unopened files. Subsequent changes to compilation commands would > > probably go through a similar didChangeConfiguration and the appropriate > > (opened) files would get reparsed (not unlike > > https://reviews.llvm.org/D49267). I'm making a few guesses here: I assume > > that in the context of XCode, you would not do background indexing in > > Clangd but let XCode do it as it can also coordinate (and not overlap) with > > build tasks. Is that correct? In any case, I think the approach in the > > patch is not incompatible with what we had in mind, i.e. we could also > > reuse "overrideCompilationCommandForFile" for each file specified in > > didChangeConfiguration. I'm point this out because if you *do* end up > > needing all the compilation commands beforehand like I mentioned, then > > maybe we can skip the approach of specifying them with didOpen and send > > them all with didChangeConfiguration from start. > > > Thanks for your response, > As it stands right now we will not run the indexer in Clangd for our use > case, and it's unclear if we can even assemble a set of compile commands, so > we would like to provide the commands when a file is open. We might be > interested in a "didChangeConfiguration" message extension in the future > (ideally it would be possible to change the subset of the constructed > compilation database). Sounds good, I think sending it in didOpen makes sense then. And yes, I agree that we would need to support changing a subset of commands through didChangeConfiguration, eventually! In https://reviews.llvm.org/D49523#1169620, @jkorous wrote: > Hi Marc-Andre, what is a structure of data you are passing as parameter of > didChangeConfiguration message? We don't yet :) But we will need to send the information per-file through it instead of using the compile_commands.json. Right now, what is supported in the didChangeConfiguration is pointing to a different compile_commands.json, in order to support multiple configuration (actually pointing to the folder containing the json file). > All we need is to pass per-file compilation command to clangd. Maybe we could > send didChangeConfiguration message right after didOpen. > > EDIT: Well, provided we would find a way how not to parse the file twice. The idea would be to send the per-file commands to clangd *before* anything is opened. So the didOpen would just read the latest command in memory. And subsequent changes to commands would be communicated with didChangeConfiguration and then files would get reparsed. I'm actually thinking we might want to send the commands in the "initialize" request for all the initial commands and then update them with didChangeConfiguration whenever they change. That way, there is no risk for reparsing as we should not do anything (indexing!) before the initialize. But it doesn't sounds like you need this right now :) Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D49523 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49523: [clangd] Add support for per-file override compilation command
jkorous added a comment. BTW it looks like we already had kind of support for compilation command before (extra flags). commit 5ec1f7ca32eb85077a22ce81d41aa02a017d4852 Author: Krasimir Georgiev Date: Thu Jul 6 08:44:54 2017 + [clangd] Add support for per-file extra flags There is even an LSP extension proposal: https://github.com/Microsoft/language-server-protocol/issues/255 But it seems as if we lost access to it here: commit aa49372548ff984ae9c48879a0d05833538a76b3 Author: Sam McCall Date: Mon Dec 4 10:08:45 2017 + [clangd] GlobalCompilationDatabase interface changes Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D49523 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r337555 - [www] Add CodeCompass and CodeChecker to Clang Related Projects page
Author: bruno Date: Fri Jul 20 07:46:10 2018 New Revision: 337555 URL: http://llvm.org/viewvc/llvm-project?rev=337555&view=rev Log: [www] Add CodeCompass and CodeChecker to Clang Related Projects page Modified: cfe/trunk/www/related.html Modified: cfe/trunk/www/related.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/related.html?rev=337555&r1=337554&r2=337555&view=diff == --- cfe/trunk/www/related.html (original) +++ cfe/trunk/www/related.html Fri Jul 20 07:46:10 2018 @@ -93,6 +93,28 @@ + CodeCompass + + + Site: +http://github.com/Ericsson/CodeCompass";>http://github.com/Ericsson/CodeCompass + + +CodeCompass is an open-source, extensible code comprehension framework which uses LLVM/Clang to analyze and visualize C and C++ projects. It also supports both regex-based text search, discovering complex C/C++ language elements, with advanced navigation and visualisation. + + + + CodeChecker + + + Site: +http://github.com/Ericsson/CodeChecker";>http://github.com/Ericsson/CodeChecker + + +CodeChecker is a static analysis infrastructure built on the LLVM/Clang Static Analyzer toolchain. It provides a user interface to execute analysis of C/C++ projects with Clang SA and Clang-Tidy, which outputs are then stored into a database navigable via a web application. This web application and a corresponding command-line tool supports a variety of report management and issue triaging options, such as difference view between analyses, automatic incremental analysis, marking and commenting on individual reports. + + + ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r337559 - [analyzer] Rename DanglingInternalBufferChecker to InnerPointerChecker.
Author: rkovacs Date: Fri Jul 20 08:14:49 2018 New Revision: 337559 URL: http://llvm.org/viewvc/llvm-project?rev=337559&view=rev Log: [analyzer] Rename DanglingInternalBufferChecker to InnerPointerChecker. Differential Revision: https://reviews.llvm.org/D49553 Added: cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp - copied, changed from r337555, cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp cfe/trunk/test/Analysis/inner-pointer.cpp - copied, changed from r337555, cfe/trunk/test/Analysis/dangling-internal-buffer.cpp Removed: cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp cfe/trunk/test/Analysis/dangling-internal-buffer.cpp Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td cfe/trunk/lib/StaticAnalyzer/Checkers/AllocationState.h cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=337559&r1=337558&r2=337559&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Fri Jul 20 08:14:49 2018 @@ -300,16 +300,15 @@ def VirtualCallChecker : Checker<"Virtua let ParentPackage = CplusplusAlpha in { -def DanglingInternalBufferChecker : Checker<"DanglingInternalBuffer">, - HelpText<"Check for internal raw pointers of C++ standard library containers " - "used after deallocation">, - DescFile<"DanglingInternalBufferChecker.cpp">; - def DeleteWithNonVirtualDtorChecker : Checker<"DeleteWithNonVirtualDtor">, HelpText<"Reports destructions of polymorphic objects with a non-virtual " "destructor in their base class">, DescFile<"DeleteWithNonVirtualDtorChecker.cpp">; +def InnerPointerChecker : Checker<"InnerPointer">, + HelpText<"Check for inner pointers of C++ containers used after re/deallocation">, + DescFile<"InnerPointerChecker.cpp">; + def IteratorRangeChecker : Checker<"IteratorRange">, HelpText<"Check for iterators used outside their valid ranges">, DescFile<"IteratorChecker.cpp">; Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/AllocationState.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/AllocationState.h?rev=337559&r1=337558&r2=337559&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/AllocationState.h (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/AllocationState.h Fri Jul 20 08:14:49 2018 @@ -23,8 +23,8 @@ ProgramStateRef markReleased(ProgramStat /// This function provides an additional visitor that augments the bug report /// with information relevant to memory errors caused by the misuse of -/// AF_InternalBuffer symbols. -std::unique_ptr getDanglingBufferBRVisitor(SymbolRef Sym); +/// AF_InnerBuffer symbols. +std::unique_ptr getInnerPointerBRVisitor(SymbolRef Sym); } // end namespace allocation_state Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=337559&r1=337558&r2=337559&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Fri Jul 20 08:14:49 2018 @@ -27,7 +27,6 @@ add_clang_library(clangStaticAnalyzerChe CloneChecker.cpp ConversionChecker.cpp CXXSelfAssignmentChecker.cpp - DanglingInternalBufferChecker.cpp DeadStoresChecker.cpp DebugCheckers.cpp DeleteWithNonVirtualDtorChecker.cpp @@ -42,6 +41,7 @@ add_clang_library(clangStaticAnalyzerChe GenericTaintChecker.cpp GTestChecker.cpp IdenticalExprChecker.cpp + InnerPointerChecker.cpp IteratorChecker.cpp IvarInvalidationChecker.cpp LLVMConventionsChecker.cpp Removed: cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp?rev=337558&view=auto == --- cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp (removed) @@ -1,253 +0,0 @@ -//=== DanglingInternalBufferChecker.cpp ---*- C++ -*--// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===---
[PATCH] D49553: [analyzer] Rename DanglingInternalBufferChecker to InnerPointerChecker
This revision was automatically updated to reflect the committed changes. Closed by commit rL337559: [analyzer] Rename DanglingInternalBufferChecker to InnerPointerChecker. (authored by rkovacs, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D49553?vs=156291&id=156491#toc Repository: rL LLVM https://reviews.llvm.org/D49553 Files: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td cfe/trunk/lib/StaticAnalyzer/Checkers/AllocationState.h cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt cfe/trunk/lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp cfe/trunk/test/Analysis/dangling-internal-buffer.cpp cfe/trunk/test/Analysis/inner-pointer.cpp Index: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td === --- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td +++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td @@ -300,16 +300,15 @@ let ParentPackage = CplusplusAlpha in { -def DanglingInternalBufferChecker : Checker<"DanglingInternalBuffer">, - HelpText<"Check for internal raw pointers of C++ standard library containers " - "used after deallocation">, - DescFile<"DanglingInternalBufferChecker.cpp">; - def DeleteWithNonVirtualDtorChecker : Checker<"DeleteWithNonVirtualDtor">, HelpText<"Reports destructions of polymorphic objects with a non-virtual " "destructor in their base class">, DescFile<"DeleteWithNonVirtualDtorChecker.cpp">; +def InnerPointerChecker : Checker<"InnerPointer">, + HelpText<"Check for inner pointers of C++ containers used after re/deallocation">, + DescFile<"InnerPointerChecker.cpp">; + def IteratorRangeChecker : Checker<"IteratorRange">, HelpText<"Check for iterators used outside their valid ranges">, DescFile<"IteratorChecker.cpp">; Index: cfe/trunk/test/Analysis/inner-pointer.cpp === --- cfe/trunk/test/Analysis/inner-pointer.cpp +++ cfe/trunk/test/Analysis/inner-pointer.cpp @@ -0,0 +1,291 @@ +//RUN: %clang_analyze_cc1 -analyzer-checker=alpha.cplusplus.InnerPointer %s -analyzer-output=text -verify + +namespace std { + +typedef int size_type; + +template +class basic_string { +public: + basic_string(); + basic_string(const CharT *s); + + ~basic_string(); + void clear(); + + basic_string &operator=(const basic_string &str); + basic_string &operator+=(const basic_string &str); + + const CharT *c_str() const; + const CharT *data() const; + CharT *data(); + + basic_string &append(size_type count, CharT ch); + basic_string &assign(size_type count, CharT ch); + basic_string &erase(size_type index, size_type count); + basic_string &insert(size_type index, size_type count, CharT ch); + basic_string &replace(size_type pos, size_type count, const basic_string &str); + void pop_back(); + void push_back(CharT ch); + void reserve(size_type new_cap); + void resize(size_type count); + void shrink_to_fit(); + void swap(basic_string &other); +}; + +typedef basic_string string; +typedef basic_string wstring; +typedef basic_string u16string; +typedef basic_string u32string; + +} // end namespace std + +void consume(const char *) {} +void consume(const wchar_t *) {} +void consume(const char16_t *) {} +void consume(const char32_t *) {} + +void deref_after_scope_char(bool cond) { + const char *c, *d; + { +std::string s; +c = s.c_str(); // expected-note {{Dangling inner pointer obtained here}} +d = s.data(); // expected-note {{Dangling inner pointer obtained here}} + }// expected-note {{Inner pointer invalidated by call to destructor}} + // expected-note@-1 {{Inner pointer invalidated by call to destructor}} + std::string s; + const char *c2 = s.c_str(); + if (cond) { +// expected-note@-1 {{Assuming 'cond' is not equal to 0}} +// expected-note@-2 {{Taking true branch}} +// expected-note@-3 {{Assuming 'cond' is 0}} +// expected-note@-4 {{Taking false branch}} +consume(c); // expected-warning {{Use of memory after it is freed}} +// expected-note@-1 {{Use of memory after it is freed}} + } else { +consume(d); // expected-warning {{Use of memory after it is freed}} +// expected-note@-1 {{Use of memory after it is freed}} + } +} + +void deref_after_scope_char_data_non_const() { + char *c; + { +std::string s; +c = s.data(); // expected-note {{Dangling inner pointer obtained here}} + } // expected-note {{Inner pointer invalidated by call to destructor}} + std::string s; + char *c2 = s.data(); + consume(c); // expected-warning {{Use of memory after it is freed}} + // expected-note@-1 {{Use of memory after it is freed}} +} + +void deref_after_scope_wchar_t(bool cond) { + const wchar_t
[PATCH] D49594: [DebugInfo] Emit diagnostics when enabling -fdebug-types-section on non-linux target.
probinson added a comment. Is this because type units depend on COMDAT support? I had a vague idea that COFF also supports COMDAT. https://reviews.llvm.org/D49594 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49543: [clangd] Penalize non-instance members when accessed via class instances.
sammccall accepted this revision. sammccall added inline comments. This revision is now accepted and ready to land. Comment at: clangd/CodeComplete.h:148 bool HasMore = false; + CodeCompletionContext::Kind SemaContext = CodeCompletionContext::CCC_Other; }; nit: "sema" is a bit down-in-the-weeds here, maybe just 'Context' or 'DetectedContext'? Comment at: clangd/CodeComplete.h:148 bool HasMore = false; + CodeCompletionContext::Kind SemaContext = CodeCompletionContext::CCC_Other; }; sammccall wrote: > nit: "sema" is a bit down-in-the-weeds here, maybe just 'Context' or > 'DetectedContext'? can you add an a test to CodeCompleteTests for this new API? Comment at: clangd/Quality.cpp:146 +return false; + if (const auto *CM = dyn_cast(ND)) +return !CM->isStatic(); I think we also have to consider template functions too? And ideally I think we want to exclude constructors (but include destructors). Comment at: clangd/Quality.cpp:325 + SemaContext == CodeCompletionContext::CCC_ArrowMemberAccess)) { +Score *= 0.5; + } could be even harsher here, but this is fine for now Comment at: clangd/Quality.h:102 + CodeCompletionContext::Kind SemaContext = CodeCompletionContext::CCC_Other; + again, I'd drop "sema" here. It's not as though we can get several contexts from different sources. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D49543 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49594: [DebugInfo] Emit diagnostics when enabling -fdebug-types-section on non-linux target.
JDevlieghere added a comment. In https://reviews.llvm.org/D49594#1169809, @probinson wrote: > Is this because type units depend on COMDAT support? I had a vague idea that > COFF also supports COMDAT. It's more that I want to reflect the current situation and prevent MC from crashing while we come up with a solution. This was very little work and we can always revert it once things are fixed. https://reviews.llvm.org/D49594 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics
thakis created this revision. thakis added a reviewer: craig.topper. cl.exe maps these to shld / shrd, so let's do the same. ISel has `Subtarget->isSHLDSlow()` to prevent use of these intrinsics on some machines, but honoring them feels a bit like trying to outsmart the intrinsics user, and there's n good way to get at that bit from here anyways. Fixes PR37755. (I tried for a while to implement this in C so that ISel could just do its thing, but couldn't hit the right pattern -- and ISel only does shld64, not shrd64, as far as I can tell.) https://reviews.llvm.org/D49606 Files: clang/lib/Headers/intrin.h clang/test/Headers/ms-intrin.cpp Index: clang/test/Headers/ms-intrin.cpp === --- clang/test/Headers/ms-intrin.cpp +++ clang/test/Headers/ms-intrin.cpp @@ -42,6 +42,8 @@ __stosw(0, 0, 0); #ifdef _M_X64 + __shiftleft128(1, 2, 3); + __shiftright128(1, 2, 3); __movsq(0, 0, 0); __stosq(0, 0, 0); #endif Index: clang/lib/Headers/intrin.h === --- clang/lib/Headers/intrin.h +++ clang/lib/Headers/intrin.h @@ -853,6 +853,18 @@ __asm__ volatile ("nop"); } #endif +#if defined(__x86_64__) +static __inline__ unsigned __int64 __DEFAULT_FN_ATTRS +__shiftleft128(unsigned __int64 l, unsigned __int64 h, unsigned char d) { + __asm__ __volatile__ ("shldq %1, %2, %0" : "+r"(h) : "c"(d), "r"(l)); + return h; +} +static __inline__ unsigned __int64 __DEFAULT_FN_ATTRS +__shiftright128(unsigned __int64 l, unsigned __int64 h, unsigned char d) { + __asm__ __volatile__ ("shrdq %1, %2, %0" : "+r"(l) : "c"(d), "r"(h)); + return l; +} +#endif /**\ |* Privileged intrinsics Index: clang/test/Headers/ms-intrin.cpp === --- clang/test/Headers/ms-intrin.cpp +++ clang/test/Headers/ms-intrin.cpp @@ -42,6 +42,8 @@ __stosw(0, 0, 0); #ifdef _M_X64 + __shiftleft128(1, 2, 3); + __shiftright128(1, 2, 3); __movsq(0, 0, 0); __stosq(0, 0, 0); #endif Index: clang/lib/Headers/intrin.h === --- clang/lib/Headers/intrin.h +++ clang/lib/Headers/intrin.h @@ -853,6 +853,18 @@ __asm__ volatile ("nop"); } #endif +#if defined(__x86_64__) +static __inline__ unsigned __int64 __DEFAULT_FN_ATTRS +__shiftleft128(unsigned __int64 l, unsigned __int64 h, unsigned char d) { + __asm__ __volatile__ ("shldq %1, %2, %0" : "+r"(h) : "c"(d), "r"(l)); + return h; +} +static __inline__ unsigned __int64 __DEFAULT_FN_ATTRS +__shiftright128(unsigned __int64 l, unsigned __int64 h, unsigned char d) { + __asm__ __volatile__ ("shrdq %1, %2, %0" : "+r"(l) : "c"(d), "r"(h)); + return l; +} +#endif /**\ |* Privileged intrinsics ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r337572 - Rewrite the VS integration scripts.
Author: zturner Date: Fri Jul 20 09:30:02 2018 New Revision: 337572 URL: http://llvm.org/viewvc/llvm-project?rev=337572&view=rev Log: Rewrite the VS integration scripts. This is a new modernized VS integration installer. It adds a Visual Studio .sln file which, when built, outputs a VSIX that can be used to install ourselves as a "real" Visual Studio Extension. We can even upload this extension to the visual studio marketplace. This fixes a longstanding problem where we didn't support installing into VS 2017 and higher. In addition to supporting VS 2017, due to the way this is written we now longer need to do anything special to support future versions of VS as well. Everything should "just work". This also fixes several bugs with our old integration, such as MSBuild triggering full rebuilds when /Zi was used. Finally, we add a new UI page called "LLVM" which becomes visible when the LLVM toolchain is selected. For now this only contains one option which is the path to clang-cl.exe, but in the future we can add more things here. Differential Revision: https://reviews.llvm.org/D42762 Modified: cfe/trunk/tools/driver/CMakeLists.txt Modified: cfe/trunk/tools/driver/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/CMakeLists.txt?rev=337572&r1=337571&r2=337572&view=diff == --- cfe/trunk/tools/driver/CMakeLists.txt (original) +++ cfe/trunk/tools/driver/CMakeLists.txt Fri Jul 20 09:30:02 2018 @@ -63,10 +63,6 @@ add_dependencies(clang clang-headers) if(NOT CLANG_LINKS_TO_CREATE) set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp) - - if (MSVC) -list(APPEND CLANG_LINKS_TO_CREATE ../msbuild-bin/cl) - endif() endif() foreach(link ${CLANG_LINKS_TO_CREATE}) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42762: Rewrite the VS Integration Scripts
This revision was automatically updated to reflect the committed changes. Closed by commit rC337572: Rewrite the VS integration scripts. (authored by zturner, committed by ). Herald added a subscriber: cfe-commits. Changed prior to commit: https://reviews.llvm.org/D42762?vs=156387&id=156520#toc Repository: rC Clang https://reviews.llvm.org/D42762 Files: tools/driver/CMakeLists.txt Index: tools/driver/CMakeLists.txt === --- tools/driver/CMakeLists.txt +++ tools/driver/CMakeLists.txt @@ -63,10 +63,6 @@ if(NOT CLANG_LINKS_TO_CREATE) set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp) - - if (MSVC) -list(APPEND CLANG_LINKS_TO_CREATE ../msbuild-bin/cl) - endif() endif() foreach(link ${CLANG_LINKS_TO_CREATE}) Index: tools/driver/CMakeLists.txt === --- tools/driver/CMakeLists.txt +++ tools/driver/CMakeLists.txt @@ -63,10 +63,6 @@ if(NOT CLANG_LINKS_TO_CREATE) set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp) - - if (MSVC) -list(APPEND CLANG_LINKS_TO_CREATE ../msbuild-bin/cl) - endif() endif() foreach(link ${CLANG_LINKS_TO_CREATE}) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics
craig.topper added a comment. @spatel, should this ultimately use funnel shift? https://reviews.llvm.org/D49606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48559: [clangd] refactoring for XPC transport layer [NFCI]
sammccall added a comment. Sorry for the delay here, and I'm sorry I haven't been into the patches in detail again yet - crazy week. After experiments, I am convinced the Transport abstraction patch can turn into something nice **if** we want XPC vs JSON to be a pure transport-level difference with the same semantics. But you need to decide the approach here based on your requirements. In https://reviews.llvm.org/D48559#1168204, @jkorous wrote: > Sam, just out of curiosity - would it be possible for you to share any > relevant experience gained by using porting clangd to protobuf-based > transport layer? Sure! (and sorry for the delay here). This is done as part of an internal-only editor that's a hosted web application with tight integration to our internal source control, build system etc. That's not my immediate team, but we talk a lot and collaborate on the integration, which is different than a typical LSP server/editor integration in a few ways. (I expect some of these aspects will apply to XCode+clangd, and others won't). This is kind of a brain dump... - like a regular LSP client, the editor wants to run clangd out-of-process for isolation reasons, and because of cross-language issues. Because of our hosted datacenter environment, a network RPC server was the most obvious choice, and protobufs are our lingua franca for such servers. This sounds analagous to the choice of XPC to me. - the editor is multi-language, so the idea of using the existing LSP is appealing (reuse servers, we can't rewrite the world). - adapting to protobuf is some work (write a wrapper for each LSP server). In principle a generic one is possible, but not for us due to VFS needs etc. - you can wrap at the LSP level (CompletionList -> CompletionListProto) or at the transport level (json::Value --> JsonValueProto). Editor team team went for the former. - consuming clangd as a C++ API rather than as an external process or opaque JSON stream, gives lots more flexibility, and we can add extension points relatively easily. Robust VFS support, performance tracing, logging, different threading model are examples of this outside the scope of LSP. The internal code uses unmodified upstream clangd code, but provides its own main(). - Inside the scope of LSP, changes are tempting too due to LSP limitations. Since the editor team controls the protocol and the frontend, they can add features. This is a source of tension: we (clangd folks) don't want to support two divergent APIs. So in **limited** cases we added to clangd a richer/more semantic C++ API that provides extra features over more-presentational LSP. Best examples are diagnostics (C++ API includes fixits and 'note' stack, before LSP supported these), and code completion (C++ API includes semantic things like "name of include to insert"). We've tried to keep this limited to what's both valuable and sensible. - adding LSP extensions to the *protocol* causes skew across languages. So the divergences at that level tend to be more presentational (e.g. "completion item documentation subtitle"). The clangd-wrapper decides how to map the semantic Clangd C++ API fields onto the presentational mutant-LSP fields, in the same way that regular clangd decides how to map them onto regular LSP. - it's annoying that the issues you run into with this setup need to be carefully dissected (editor vs wrapper vs clangd) to work out where the bug belongs. Compare to "plain" clangd where you can just check with a different editor and then know the bug is in clangd. In summary: - speaking a different wire protocol that's semantically identical to LSP is an easy win - owning a separate `main()` so you can plug in cross-cutting facilities (logging, tracing, index) is very manageable and worthwhile - maintaining a separate protocol is a bunch more work and decisions all the time, even if divergences from LSP are small. It *is* more flexible though. One halfway possibility if you're on the fence: we could support some limited extensions to the protocol behind an option (e.g. extra fields serialized with the option, whether XPC or JSON is used). It's less flexibility than full ownership of the protocol semantics on Apple's side though. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48559 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r337580 - [CodeGen][ObjC] Make copying and disposing of a non-escaping block
Author: ahatanak Date: Fri Jul 20 10:10:32 2018 New Revision: 337580 URL: http://llvm.org/viewvc/llvm-project?rev=337580&view=rev Log: [CodeGen][ObjC] Make copying and disposing of a non-escaping block no-ops. A non-escaping block on the stack will never be called after its lifetime ends, so it doesn't have to be copied to the heap. To prevent a non-escaping block from being copied to the heap, this patch sets field 'isa' of the block object to NSConcreteGlobalBlock and sets the BLOCK_IS_GLOBAL bit of field 'flags', which causes the runtime to treat the block as if it were a global block (calling _Block_copy on the block just returns the original block and calling _Block_release is a no-op). Also, a new flag bit 'BLOCK_IS_NOESCAPE' is added, which allows the runtime or tools to distinguish between true global blocks and non-escaping blocks. rdar://problem/39352313 Differential Revision: https://reviews.llvm.org/D49303 Modified: cfe/trunk/docs/Block-ABI-Apple.rst cfe/trunk/lib/CodeGen/CGBlocks.cpp cfe/trunk/lib/CodeGen/CGBlocks.h cfe/trunk/test/CodeGenObjC/noescape.m Modified: cfe/trunk/docs/Block-ABI-Apple.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Block-ABI-Apple.rst?rev=337580&r1=337579&r2=337580&view=diff == --- cfe/trunk/docs/Block-ABI-Apple.rst (original) +++ cfe/trunk/docs/Block-ABI-Apple.rst Fri Jul 20 10:10:32 2018 @@ -61,6 +61,14 @@ The following flags bits are in use thus .. code-block:: c enum { +// Set to true on blocks that have captures (and thus are not true +// global blocks) but are known not to escape for various other +// reasons. For backward compatiblity with old runtimes, whenever +// BLOCK_IS_NOESCAPE is set, BLOCK_IS_GLOBAL is set too. Copying a +// non-escaping block returns the original block and releasing such a +// block is a no-op, which is exactly how global blocks are handled. +BLOCK_IS_NOESCAPE = (1 << 23), + BLOCK_HAS_COPY_DISPOSE = (1 << 25), BLOCK_HAS_CTOR = (1 << 26), // helpers have C++ code BLOCK_IS_GLOBAL = (1 << 28), Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=337580&r1=337579&r2=337580&view=diff == --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Fri Jul 20 10:10:32 2018 @@ -104,7 +104,7 @@ static llvm::Constant *buildBlockDescrip elements.addInt(ulong, blockInfo.BlockSize.getQuantity()); // Optional copy/dispose helpers. - if (blockInfo.NeedsCopyDispose) { + if (blockInfo.needsCopyDisposeHelpers()) { // copy_func_helper_decl elements.add(buildCopyHelper(CGM, blockInfo)); @@ -159,6 +159,7 @@ static llvm::Constant *buildBlockDescrip /// These are the flags (with corresponding bit number) that the /// compiler is actually supposed to know about. +/// 23. BLOCK_IS_NOESCAPE - indicates that the block is non-escaping /// 25. BLOCK_HAS_COPY_DISPOSE - indicates that the block /// descriptor provides copy and dispose helper functions /// 26. BLOCK_HAS_CXX_OBJ - indicates that there's a captured @@ -778,8 +779,13 @@ llvm::Value *CodeGenFunction::EmitBlockL llvm::Constant *descriptor; BlockFlags flags; if (!IsOpenCL) { -isa = llvm::ConstantExpr::getBitCast(CGM.getNSConcreteStackBlock(), - VoidPtrTy); +// If the block is non-escaping, set field 'isa 'to NSConcreteGlobalBlock +// and set the BLOCK_IS_GLOBAL bit of field 'flags'. Copying a non-escaping +// block just returns the original block and releasing it is a no-op. +llvm::Constant *blockISA = blockInfo.getBlockDecl()->doesNotEscape() + ? CGM.getNSConcreteGlobalBlock() + : CGM.getNSConcreteStackBlock(); +isa = llvm::ConstantExpr::getBitCast(blockISA, VoidPtrTy); // Build the block descriptor. descriptor = buildBlockDescriptor(CGM, blockInfo); @@ -788,12 +794,14 @@ llvm::Value *CodeGenFunction::EmitBlockL flags = BLOCK_HAS_SIGNATURE; if (blockInfo.HasCapturedVariableLayout) flags |= BLOCK_HAS_EXTENDED_LAYOUT; -if (blockInfo.NeedsCopyDispose) +if (blockInfo.needsCopyDisposeHelpers()) flags |= BLOCK_HAS_COPY_DISPOSE; if (blockInfo.HasCXXObject) flags |= BLOCK_HAS_CXX_OBJ; if (blockInfo.UsesStret) flags |= BLOCK_USE_STRET; +if (blockInfo.getBlockDecl()->doesNotEscape()) + flags |= BLOCK_IS_NOESCAPE | BLOCK_IS_GLOBAL; } auto projectField = Modified: cfe/trunk/lib/CodeGen/CGBlocks.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.h?rev=337580&r1=337579&r2=337580&view=diff ==
[PATCH] D49303: [CodeGen][ObjC] Treat non-escaping blocks as global blocks to make copy/dispose a no-op
This revision was automatically updated to reflect the committed changes. ahatanak marked an inline comment as done. Closed by commit rL337580: [CodeGen][ObjC] Make copying and disposing of a non-escaping block (authored by ahatanak, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D49303?vs=156404&id=156530#toc Repository: rL LLVM https://reviews.llvm.org/D49303 Files: cfe/trunk/docs/Block-ABI-Apple.rst cfe/trunk/lib/CodeGen/CGBlocks.cpp cfe/trunk/lib/CodeGen/CGBlocks.h cfe/trunk/test/CodeGenObjC/noescape.m Index: cfe/trunk/test/CodeGenObjC/noescape.m === --- cfe/trunk/test/CodeGenObjC/noescape.m +++ cfe/trunk/test/CodeGenObjC/noescape.m @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin -fblocks -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -fblocks -emit-llvm -o - %s | FileCheck -check-prefix CHECK -check-prefix CHECK-NOARC %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -fblocks -emit-llvm -fobjc-arc -o - %s | FileCheck -check-prefix CHECK -check-prefix CHECK-ARC %s typedef void (^BlockTy)(void); @@ -12,6 +13,12 @@ void noescapeFunc2(__attribute__((noescape)) id); void noescapeFunc3(__attribute__((noescape)) union U); +// Block descriptors of non-escaping blocks don't need pointers to copy/dispose +// helper functions. + +// CHECK: %[[STRUCT_BLOCK_DESCRIPTOR:.*]] = type { i64, i64 } +// CHECK: @[[BLOCK_DESCIPTOR_TMP_2:.*]] = internal constant { i64, i64, i8*, i64 } { i64 0, i64 40, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @{{.*}}, i32 0, i32 0), i64 256 }, align 8 + // CHECK-LABEL: define void @test0( // CHECK: call void @noescapeFunc0({{.*}}, {{.*}} nocapture {{.*}}) // CHECK: declare void @noescapeFunc0(i8*, {{.*}} nocapture) @@ -69,3 +76,41 @@ ^(int *__attribute__((noescape)) p0){}(p); b(p); } + +// If the block is non-escaping, set the BLOCK_IS_NOESCAPE and BLOCK_IS_GLOBAL +// bits of field 'flags' and set the 'isa' field to 'NSConcreteGlobalBlock'. + +// CHECK: define void @test6(i8* %{{.*}}, i8* %[[B:.*]]) +// CHECK: %{{.*}} = alloca i8*, align 8 +// CHECK: %[[B_ADDR:.*]] = alloca i8*, align 8 +// CHECK: %[[BLOCK:.*]] = alloca <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, align 8 +// CHECK-NOARC: store i8* %[[B]], i8** %[[B_ADDR]], align 8 +// CHECK-ARC: store i8* null, i8** %[[B_ADDR]], align 8 +// CHECK-ARC: call void @objc_storeStrong(i8** %[[B_ADDR]], i8* %[[B]]) +// CHECK-ARC: %[[V0:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>* %[[BLOCK]], i32 0, i32 5 +// CHECK: %[[BLOCK_ISA:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>* %[[BLOCK]], i32 0, i32 0 +// CHECK: store i8* bitcast (i8** @_NSConcreteGlobalBlock to i8*), i8** %[[BLOCK_ISA]], align 8 +// CHECK: %[[BLOCK_FLAGS:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>* %[[BLOCK]], i32 0, i32 1 +// CHECK: store i32 -796917760, i32* %[[BLOCK_FLAGS]], align 8 +// CHECK: %[[BLOCK_DESCRIPTOR:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>* %[[BLOCK]], i32 0, i32 4 +// CHECK: store %[[STRUCT_BLOCK_DESCRIPTOR]]* bitcast ({ i64, i64, i8*, i64 }* @[[BLOCK_DESCIPTOR_TMP_2]] to %[[STRUCT_BLOCK_DESCRIPTOR]]*), %[[STRUCT_BLOCK_DESCRIPTOR]]** %[[BLOCK_DESCRIPTOR]], align 8 +// CHECK: %[[BLOCK_CAPTURED:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>* %[[BLOCK]], i32 0, i32 5 +// CHECK-NOARC: %[[V1:.*]] = load i8*, i8** %[[B_ADDR]], align 8 +// CHECK-NOARC: store i8* %[[V1]], i8** %[[BLOCK_CAPTURED]], align 8 +// CHECK-ARC: %[[V2:.*]] = load i8*, i8** %[[B_ADDR]], align 8 +// CHECK-ARC: %[[V3:.*]] = call i8* @objc_retain(i8* %[[V2]]) #3 +// CHECK-ARC: store i8* %[[V3]], i8** %[[BLOCK_CAPTURED]], align 8 +// CHECK: call void @noescapeFunc0( +// CHECK-ARC: call void @objc_storeStrong(i8** %[[V0]], i8* null) +// CHECK-ARC: call void @objc_storeStrong(i8** %[[B_ADDR]], i8* null) + +// Non-escaping blocks don't need copy/dispose helper functions. + +// CHECK-NOT: define internal void @__copy_helper_block_ +// CHECK-NOT: define internal void @__destroy_helper_block_ + +void func(id); + +void test6(id a, id b) { + noescapeFunc0(a, ^{ func(b); }); +} Index: cfe/trunk/lib/CodeGen/CGBlocks.h === --- cfe/trunk/lib/CodeGen/CGBlocks.h +++ cfe/trunk/lib/CodeGen/CGBlocks.h @@ -54,6 +54,7 @@ }; enum BlockLiteralFlags { + BLOCK_IS_NOESCAPE = (1 << 23),
[PATCH] D49594: [DebugInfo] Emit diagnostics when enabling -fdebug-types-section on non-linux target.
probinson accepted this revision. probinson added a comment. This revision is now accepted and ready to land. If the plan is for this to be relatively temporary then LGTM. https://reviews.llvm.org/D49594 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxxabi] r337582 - Merge changes to ItaniumDemangle over to libcxxabi.
Author: zturner Date: Fri Jul 20 10:16:49 2018 New Revision: 337582 URL: http://llvm.org/viewvc/llvm-project?rev=337582&view=rev Log: Merge changes to ItaniumDemangle over to libcxxabi. ItaniumDemangle had a small NFC refactor to make some of its code reusable by the newly added Microsoft demangler. To keep the libcxxabi demangler as close as possible to the master copy this refactor is being merged over. Differential Revision: https://reviews.llvm.org/D49575 Added: libcxxabi/trunk/src/demangle/ libcxxabi/trunk/src/demangle/Compiler.h libcxxabi/trunk/src/demangle/StringView.h libcxxabi/trunk/src/demangle/Utility.h Modified: libcxxabi/trunk/src/cxa_demangle.cpp Modified: libcxxabi/trunk/src/cxa_demangle.cpp URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=337582&r1=337581&r2=337582&view=diff == --- libcxxabi/trunk/src/cxa_demangle.cpp (original) +++ libcxxabi/trunk/src/cxa_demangle.cpp Fri Jul 20 10:16:49 2018 @@ -15,150 +15,27 @@ #include "__cxxabi_config.h" -#include -#include -#include +#include "demangle/Compiler.h" +#include "demangle/StringView.h" +#include "demangle/Utility.h" + #include +#include #include #include #include -#include +#include +#include -#ifdef _MSC_VER -// snprintf is implemented in VS 2015 -#if _MSC_VER < 1900 -#define snprintf _snprintf_s -#endif -#endif - -#ifndef NDEBUG -#if __has_attribute(noinline) && __has_attribute(used) -#define DUMP_METHOD __attribute__((noinline,used)) -#else -#define DUMP_METHOD -#endif -#endif namespace { -class StringView { - const char *First; - const char *Last; - -public: - template - StringView(const char (&Str)[N]) : First(Str), Last(Str + N - 1) {} - StringView(const char *First_, const char *Last_) : First(First_), Last(Last_) {} - StringView() : First(nullptr), Last(nullptr) {} - - StringView substr(size_t From, size_t To) { -if (To >= size()) - To = size() - 1; -if (From >= size()) - From = size() - 1; -return StringView(First + From, First + To); - } - - StringView dropFront(size_t N) const { -if (N >= size()) - N = size() - 1; -return StringView(First + N, Last); - } - - bool startsWith(StringView Str) const { -if (Str.size() > size()) - return false; -return std::equal(Str.begin(), Str.end(), begin()); - } - - const char &operator[](size_t Idx) const { return *(begin() + Idx); } - - const char *begin() const { return First; } - const char *end() const { return Last; } - size_t size() const { return static_cast(Last - First); } - bool empty() const { return First == Last; } -}; - -bool operator==(const StringView &LHS, const StringView &RHS) { - return LHS.size() == RHS.size() && - std::equal(LHS.begin(), LHS.end(), RHS.begin()); -} - -// Stream that AST nodes write their string representation into after the AST -// has been parsed. -class OutputStream { - char *Buffer; - size_t CurrentPosition; - size_t BufferCapacity; - - // Ensure there is at least n more positions in buffer. - void grow(size_t N) { -if (N + CurrentPosition >= BufferCapacity) { - BufferCapacity *= 2; - if (BufferCapacity < N + CurrentPosition) -BufferCapacity = N + CurrentPosition; - Buffer = static_cast(std::realloc(Buffer, BufferCapacity)); -} - } - -public: - OutputStream(char *StartBuf, size_t Size) - : Buffer(StartBuf), CurrentPosition(0), BufferCapacity(Size) {} - OutputStream() = default; - void reset(char *Buffer_, size_t BufferCapacity_) { -CurrentPosition = 0; -Buffer = Buffer_; -BufferCapacity = BufferCapacity_; - } - - /// If a ParameterPackExpansion (or similar type) is encountered, the offset - /// into the pack that we're currently printing. - unsigned CurrentPackIndex = std::numeric_limits::max(); - unsigned CurrentPackMax = std::numeric_limits::max(); - - OutputStream &operator+=(StringView R) { -size_t Size = R.size(); -if (Size == 0) - return *this; -grow(Size); -memmove(Buffer + CurrentPosition, R.begin(), Size); -CurrentPosition += Size; -return *this; - } - - OutputStream &operator+=(char C) { -grow(1); -Buffer[CurrentPosition++] = C; -return *this; - } - - size_t getCurrentPosition() const { return CurrentPosition; } - void setCurrentPosition(size_t NewPos) { CurrentPosition = NewPos; } - - char back() const { -return CurrentPosition ? Buffer[CurrentPosition - 1] : '\0'; - } - - bool empty() const { return CurrentPosition == 0; } - - char *getBuffer() { return Buffer; } - char *getBufferEnd() { return Buffer + CurrentPosition - 1; } - size_t getBufferCapacity() { return BufferCapacity; } -}; - -template -class SwapAndRestore { - T &Restore; - T OriginalValue; -public: - SwapAndRestore(T& Restore_, T NewVal) - : Restore(Restore_), OriginalValue(Restore) { -Restore = std::move(NewVal); -
r337585 - Prevent Scoped Enums from being Integral constant expressions:
Author: erichkeane Date: Fri Jul 20 10:42:09 2018 New Revision: 337585 URL: http://llvm.org/viewvc/llvm-project?rev=337585&view=rev Log: Prevent Scoped Enums from being Integral constant expressions: Discovered because of: https://bugs.llvm.org/show_bug.cgi?id=38235 It seems to me that a scoped enum should NOT be an integral constant expression without a cast, so this seems like a sensical change. Attributes that check for an integer parameter simply use this function to ensure that they have an integer, so it was previously allowing a scoped enum. Also added a test based on Richard's feedback to ensure that case labels still work. Differential Revision: https://reviews.llvm.org/D49599 Added: cfe/trunk/test/SemaCXX/PR38235.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=337585&r1=337584&r2=337585&view=diff == --- cfe/trunk/lib/AST/ExprConstant.cpp (original) +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Jul 20 10:42:09 2018 @@ -11142,7 +11142,7 @@ static bool EvaluateCPlusPlus11IntegralC const Expr *E, llvm::APSInt *Value, SourceLocation *Loc) { - if (!E->getType()->isIntegralOrEnumerationType()) { + if (!E->getType()->isIntegralOrUnscopedEnumerationType()) { if (Loc) *Loc = E->getExprLoc(); return false; } Added: cfe/trunk/test/SemaCXX/PR38235.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/PR38235.cpp?rev=337585&view=auto == --- cfe/trunk/test/SemaCXX/PR38235.cpp (added) +++ cfe/trunk/test/SemaCXX/PR38235.cpp Fri Jul 20 10:42:09 2018 @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +enum class E { Foo, Bar = 97119 }; + +void f() __attribute__((constructor(E::Foo))); // expected-error{{'constructor' attribute requires an integer constant}} +void f2() __attribute__((constructor(E::Bar)));// expected-error{{'constructor' attribute requires an integer constant}} + +void switch_me(E e) { + switch (e) { +case E::Foo: +case E::Bar: + break; + } +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r337587 - [CUDA] Provide integer SIMD functions for CUDA-9.2
Author: tra Date: Fri Jul 20 10:44:34 2018 New Revision: 337587 URL: http://llvm.org/viewvc/llvm-project?rev=337587&view=rev Log: [CUDA] Provide integer SIMD functions for CUDA-9.2 CUDA-9.2 made all integer SIMD functions into compiler builtins, so clang no longer has access to the implementation of these functions in either headers of libdevice and has to provide its own implementation. This is mostly a 1:1 mapping to a corresponding PTX instructions with an exception of vhadd2/vhadd4 that don't have an equivalent instruction and had to be implemented with a bit hack. Performance of this implementation will be suboptimal for SM_50 and newer GPUs where PTXAS generates noticeably worse code for the SIMD instructions compared to the code it generates for the inline assembly generated by nvcc (or used to come with CUDA headers). Differential Revision: https://reviews.llvm.org/D49274 Modified: cfe/trunk/lib/Headers/__clang_cuda_device_functions.h cfe/trunk/lib/Headers/__clang_cuda_libdevice_declares.h Modified: cfe/trunk/lib/Headers/__clang_cuda_device_functions.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_device_functions.h?rev=337587&r1=337586&r2=337587&view=diff == --- cfe/trunk/lib/Headers/__clang_cuda_device_functions.h (original) +++ cfe/trunk/lib/Headers/__clang_cuda_device_functions.h Fri Jul 20 10:44:34 2018 @@ -803,6 +803,8 @@ __DEVICE__ unsigned int __usad(unsigned unsigned int __c) { return __nv_usad(__a, __b, __c); } + +#if CUDA_VERSION >= 9000 && CUDA_VERSION < 9020 __DEVICE__ unsigned int __vabs2(unsigned int __a) { return __nv_vabs2(__a); } __DEVICE__ unsigned int __vabs4(unsigned int __a) { return __nv_vabs4(__a); } __DEVICE__ unsigned int __vabsdiffs2(unsigned int __a, unsigned int __b) { @@ -1041,6 +1043,431 @@ __DEVICE__ unsigned int __vsubus2(unsign __DEVICE__ unsigned int __vsubus4(unsigned int __a, unsigned int __b) { return __nv_vsubus4(__a, __b); } +#else // CUDA_VERSION >= 9020 +// CUDA no longer provides inline assembly (or bitcode) implementation of these +// functions, so we have to reimplment them. The implementation is naive and is +// not optimized for performance. + +// Helper function to convert N-bit boolean subfields into all-0 or all-1. +// E.g. __bool2mask(0x01000100,8) -> 0xff00ff00 +// __bool2mask(0x0001,16) -> 0x +__DEVICE__ unsigned int __bool2mask(unsigned int __a, int shift) { + return (__a << shift) - __a; +} +__DEVICE__ unsigned int __vabs2(unsigned int __a) { + unsigned int r; + asm("vabsdiff2.s32.s32.s32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(0), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vabs4(unsigned int __a) { + unsigned int r; + asm("vabsdiff4.s32.s32.s32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(0), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vabsdiffs2(unsigned int __a, unsigned int __b) { + unsigned int r; + asm("vabsdiff2.s32.s32.s32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} + +__DEVICE__ unsigned int __vabsdiffs4(unsigned int __a, unsigned int __b) { + unsigned int r; + asm("vabsdiff4.s32.s32.s32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vabsdiffu2(unsigned int __a, unsigned int __b) { + unsigned int r; + asm("vabsdiff2.u32.u32.u32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vabsdiffu4(unsigned int __a, unsigned int __b) { + unsigned int r; + asm("vabsdiff4.u32.u32.u32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vabsss2(unsigned int __a) { + unsigned int r; + asm("vabsdiff2.s32.s32.s32.sat %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(0), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vabsss4(unsigned int __a) { + unsigned int r; + asm("vabsdiff4.s32.s32.s32.sat %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(0), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vadd2(unsigned int __a, unsigned int __b) { + unsigned int r; + asm("vadd2.u32.u32.u32 %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vadd4(unsigned int __a, unsigned int __b) { + unsigned int r; + asm("vadd4.u32.u32.u32 %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vaddss2(unsigned int __a, unsigned int __b) { + unsigned int r; + asm("vadd2.s32.s32.s32.sat %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vaddss4(unsigned int __a, unsigned int __b) { + unsigned int r; + asm("vadd4.s32.s32.s32.sat %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vaddus2(un
[PATCH] D49274: [CUDA] Provide integer SIMD functions for CUDA-9.2
This revision was automatically updated to reflect the committed changes. tra marked 2 inline comments as done. Closed by commit rC337587: [CUDA] Provide integer SIMD functions for CUDA-9.2 (authored by tra, committed by ). Changed prior to commit: https://reviews.llvm.org/D49274?vs=156397&id=156542#toc Repository: rC Clang https://reviews.llvm.org/D49274 Files: lib/Headers/__clang_cuda_device_functions.h lib/Headers/__clang_cuda_libdevice_declares.h Index: lib/Headers/__clang_cuda_libdevice_declares.h === --- lib/Headers/__clang_cuda_libdevice_declares.h +++ lib/Headers/__clang_cuda_libdevice_declares.h @@ -372,6 +372,7 @@ __device__ unsigned int __nv_urhadd(unsigned int __a, unsigned int __b); __device__ unsigned int __nv_usad(unsigned int __a, unsigned int __b, unsigned int __c); +#if CUDA_VERSION >= 9000 && CUDA_VERSION < 9020 __device__ int __nv_vabs2(int __a); __device__ int __nv_vabs4(int __a); __device__ int __nv_vabsdiffs2(int __a, int __b); @@ -454,12 +455,12 @@ __device__ int __nv_vsubss4(int __a, int __b); __device__ int __nv_vsubus2(int __a, int __b); __device__ int __nv_vsubus4(int __a, int __b); +#endif // CUDA_VERSION __device__ double __nv_y0(double __a); __device__ float __nv_y0f(float __a); __device__ double __nv_y1(double __a); __device__ float __nv_y1f(float __a); __device__ float __nv_ynf(int __a, float __b); __device__ double __nv_yn(int __a, double __b); - } // extern "C" #endif // __CLANG_CUDA_LIBDEVICE_DECLARES_H__ Index: lib/Headers/__clang_cuda_device_functions.h === --- lib/Headers/__clang_cuda_device_functions.h +++ lib/Headers/__clang_cuda_device_functions.h @@ -803,6 +803,8 @@ unsigned int __c) { return __nv_usad(__a, __b, __c); } + +#if CUDA_VERSION >= 9000 && CUDA_VERSION < 9020 __DEVICE__ unsigned int __vabs2(unsigned int __a) { return __nv_vabs2(__a); } __DEVICE__ unsigned int __vabs4(unsigned int __a) { return __nv_vabs4(__a); } __DEVICE__ unsigned int __vabsdiffs2(unsigned int __a, unsigned int __b) { @@ -1041,6 +1043,431 @@ __DEVICE__ unsigned int __vsubus4(unsigned int __a, unsigned int __b) { return __nv_vsubus4(__a, __b); } +#else // CUDA_VERSION >= 9020 +// CUDA no longer provides inline assembly (or bitcode) implementation of these +// functions, so we have to reimplment them. The implementation is naive and is +// not optimized for performance. + +// Helper function to convert N-bit boolean subfields into all-0 or all-1. +// E.g. __bool2mask(0x01000100,8) -> 0xff00ff00 +// __bool2mask(0x0001,16) -> 0x +__DEVICE__ unsigned int __bool2mask(unsigned int __a, int shift) { + return (__a << shift) - __a; +} +__DEVICE__ unsigned int __vabs2(unsigned int __a) { + unsigned int r; + asm("vabsdiff2.s32.s32.s32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(0), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vabs4(unsigned int __a) { + unsigned int r; + asm("vabsdiff4.s32.s32.s32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(0), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vabsdiffs2(unsigned int __a, unsigned int __b) { + unsigned int r; + asm("vabsdiff2.s32.s32.s32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} + +__DEVICE__ unsigned int __vabsdiffs4(unsigned int __a, unsigned int __b) { + unsigned int r; + asm("vabsdiff4.s32.s32.s32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vabsdiffu2(unsigned int __a, unsigned int __b) { + unsigned int r; + asm("vabsdiff2.u32.u32.u32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vabsdiffu4(unsigned int __a, unsigned int __b) { + unsigned int r; + asm("vabsdiff4.u32.u32.u32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vabsss2(unsigned int __a) { + unsigned int r; + asm("vabsdiff2.s32.s32.s32.sat %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(0), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vabsss4(unsigned int __a) { + unsigned int r; + asm("vabsdiff4.s32.s32.s32.sat %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(0), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vadd2(unsigned int __a, unsigned int __b) { + unsigned int r; + asm("vadd2.u32.u32.u32 %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vadd4(unsigned int __a, unsigned int __b) { + unsigned int r; + asm("vadd4.u32.u32.u32 %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vaddss2(unsigned int __a, unsigned int __b) { + unsigned int r; + asm("vadd2.s32.s32.s32.sat %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "
[PATCH] D46845: [libcxx][c++17] P0083R5: Splicing Maps and Sets
erik.pilkington added a comment. Ping! https://reviews.llvm.org/D46845 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D15225: [Driver] Sanitizer support based on runtime library presence
george.karpenkov added a comment. @delcypher sorry i don't agree with the change requests. @mracek any comments? Comment at: clang/lib/Driver/ToolChains/Darwin.cpp:2298 SanitizerMask Res = ToolChain::getSupportedSanitizers(); - Res |= SanitizerKind::Address; - Res |= SanitizerKind::Leak; - Res |= SanitizerKind::Fuzzer; - Res |= SanitizerKind::FuzzerNoLink; + + if (sanitizerRuntimeExists("asan")) delcypher wrote: > I feel that we should assert that `Res` doesn't already contain the > SanitizerKind we are decided whether or not to set. > E.g. > > ``` > assert(!(Res & SanitizerKind::Address)); > if (sanitizerRuntimeExists("asan")) { > Res |= SanitizerKind::Address; > } > ``` I'm not sure it would be worth crashing the driver. Comment at: clang/lib/Driver/ToolChains/Darwin.h:134 + /// \return Directory to find the runtime library in. + SmallString<128> runtimeLibDir(bool IsEmbedded=false) const; + delcypher wrote: > Why is this a `SmallString<128>` but in other places we're just using > `std::string`? For driver it does not matter which datastructure to use. Here SmallString is used because that's what is more convenient to return. Comment at: clang/lib/Driver/ToolChains/Darwin.h:427 + /// containing the sanitizer {@code SanitizerName}. + std::string sanitizerToRelativeLibName(StringRef SanitizerName, + bool Shared = true) const; delcypher wrote: > I don't like this name very much. Given that the path is relative to the > directory containing the library, what this function really does is given the > **file name** for a sanitizer library. Mentioning "relative" is just > confusing. > > Wouldn't something like `getSanitizerLibName()` or `getNameForSanitizerLib()` > be much clearer? Then it's not clear whether the returned path is relative or absolute though. Comment at: clang/test/Driver/darwin-asan-nofortify.c:3 -// RUN: %clang -fsanitize=address %s -E -dM -target x86_64-darwin | FileCheck %s +// RUN: %clang -fsanitize=address %s -E -dM -target x86_64-darwin -resource-dir %S/Inputs/resource_dir | FileCheck %s delcypher wrote: > Are these `-resource-dir %S/Inputs/resource_dir` needed because compiler-rt > might not be present and now the driver checks for these? By default -resource-dir points to the resource dir in the "bin" directory. The contents of that is sort of random, and depends on what ninja commands have you ran before. https://reviews.llvm.org/D15225 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49508: [Sema] Mark implicitly-inserted ICE's as being part of explicit cast (PR38166)
rjmccall added inline comments. Comment at: include/clang/AST/Stmt.h:205 unsigned Kind : 6; -unsigned BasePathSize : 32 - 6 - NumExprBits; +bool PartOfExplicitCast : 1; +unsigned BasePathSize : 32 - 6 - 1 - NumExprBits; This needs to be `unsigned` to pack optimally on MSVC. Comment at: include/clang/AST/Stmt.h:206 +bool PartOfExplicitCast : 1; +unsigned BasePathSize : 32 - 6 - 1 - NumExprBits; }; This needs to be serialized. Repository: rC Clang https://reviews.llvm.org/D49508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49523: [clangd] Add support for per-file override compilation command
arphaman added a comment. In https://reviews.llvm.org/D49523#1169743, @jkorous wrote: > BTW it looks like we already had kind of support for compilation command > before (extra flags). > > commit 5ec1f7ca32eb85077a22ce81d41aa02a017d4852 > Author: Krasimir Georgiev > Date: Thu Jul 6 08:44:54 2017 + > > [clangd] Add support for per-file extra flags > > > There is even an LSP extension proposal: > > https://github.com/Microsoft/language-server-protocol/issues/255 > > But it seems as if we lost access to it here: > > commit aa49372548ff984ae9c48879a0d05833538a76b3 > Author: Sam McCall > Date: Mon Dec 4 10:08:45 2017 + > > [clangd] GlobalCompilationDatabase interface changes The extra-flags are still supported, see the test for example. They're not a full compilation command, just extra flags. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D49523 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49508: [Sema] Mark implicitly-inserted ICE's as being part of explicit cast (PR38166)
lebedev.ri added inline comments. Comment at: include/clang/AST/Stmt.h:206 +bool PartOfExplicitCast : 1; +unsigned BasePathSize : 32 - 6 - 1 - NumExprBits; }; rjmccall wrote: > This needs to be serialized. Uhm, could you please explain what do you mean by 'serialized'? Repository: rC Clang https://reviews.llvm.org/D49508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49508: [Sema] Mark implicitly-inserted ICE's as being part of explicit cast (PR38166)
rjmccall added inline comments. Comment at: include/clang/AST/Stmt.h:206 +bool PartOfExplicitCast : 1; +unsigned BasePathSize : 32 - 6 - 1 - NumExprBits; }; lebedev.ri wrote: > rjmccall wrote: > > This needs to be serialized. > Uhm, could you please explain what do you mean by 'serialized'? It needs to be preserved when writing an ICE into a PCH / module file. See the ASTWriter / ASTReader. Repository: rC Clang https://reviews.llvm.org/D49508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r337601 - [clangd] Fix racy use-after-scope in unittest
Author: d0k Date: Fri Jul 20 11:45:25 2018 New Revision: 337601 URL: http://llvm.org/viewvc/llvm-project?rev=337601&view=rev Log: [clangd] Fix racy use-after-scope in unittest This only shows up with asan when the stars align in a bad way. Modified: clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp Modified: clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp?rev=337601&r1=337600&r2=337601&view=diff == --- clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp Fri Jul 20 11:45:25 2018 @@ -251,6 +251,7 @@ TEST_F(TUSchedulerTests, ManyUpdates) { } TEST_F(TUSchedulerTests, EvictedAST) { + std::atomic BuiltASTCounter(0); ASTRetentionPolicy Policy; Policy.MaxRetainedASTs = 2; TUScheduler S( @@ -267,8 +268,6 @@ TEST_F(TUSchedulerTests, EvictedAST) { auto Bar = testPath("bar.cpp"); auto Baz = testPath("baz.cpp"); - std::atomic BuiltASTCounter; - BuiltASTCounter = false; // Build one file in advance. We will not access it later, so it will be the // one that the cache will evict. S.update(Foo, getInputs(Foo, SourceContents), WantDiagnostics::Yes, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r337602 - [clang-doc] Adding PublicOnly flag
Author: juliehockett Date: Fri Jul 20 11:49:55 2018 New Revision: 337602 URL: http://llvm.org/viewvc/llvm-project?rev=337602&view=rev Log: [clang-doc] Adding PublicOnly flag Submitted on behalf of Annie Cherkaev (@anniecherk) Added a flag which, when enabled, documents only those methods and fields which have a Public attribute. Differential Revision: https://reviews.llvm.org/D48395 Added: clang-tools-extra/trunk/test/clang-doc/module.cpp clang-tools-extra/trunk/test/clang-doc/public-module.cpp clang-tools-extra/trunk/test/clang-doc/public-records.cpp Modified: clang-tools-extra/trunk/clang-doc/ClangDoc.cpp clang-tools-extra/trunk/clang-doc/ClangDoc.h clang-tools-extra/trunk/clang-doc/Mapper.cpp clang-tools-extra/trunk/clang-doc/Mapper.h clang-tools-extra/trunk/clang-doc/Representation.cpp clang-tools-extra/trunk/clang-doc/Representation.h clang-tools-extra/trunk/clang-doc/Serialize.cpp clang-tools-extra/trunk/clang-doc/Serialize.h clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp Modified: clang-tools-extra/trunk/clang-doc/ClangDoc.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/ClangDoc.cpp?rev=337602&r1=337601&r2=337602&view=diff == --- clang-tools-extra/trunk/clang-doc/ClangDoc.cpp (original) +++ clang-tools-extra/trunk/clang-doc/ClangDoc.cpp Fri Jul 20 11:49:55 2018 @@ -15,6 +15,7 @@ #include "ClangDoc.h" #include "Mapper.h" +#include "Representation.h" #include "clang/AST/AST.h" #include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTContext.h" @@ -28,33 +29,33 @@ namespace doc { class MapperActionFactory : public tooling::FrontendActionFactory { public: - MapperActionFactory(tooling::ExecutionContext *ECtx) : ECtx(ECtx) {} + MapperActionFactory(ClangDocContext CDCtx) : CDCtx(CDCtx) {} clang::FrontendAction *create() override; private: - tooling::ExecutionContext *ECtx; + ClangDocContext CDCtx; }; clang::FrontendAction *MapperActionFactory::create() { class ClangDocAction : public clang::ASTFrontendAction { public: -ClangDocAction(ExecutionContext *ECtx) : ECtx(ECtx) {} +ClangDocAction(ClangDocContext CDCtx) : CDCtx(CDCtx) {} std::unique_ptr CreateASTConsumer(clang::CompilerInstance &Compiler, llvm::StringRef InFile) override { - return llvm::make_unique(&Compiler.getASTContext(), ECtx); + return llvm::make_unique(&Compiler.getASTContext(), CDCtx); } private: -ExecutionContext *ECtx; +ClangDocContext CDCtx; }; - return new ClangDocAction(ECtx); + return new ClangDocAction(CDCtx); } std::unique_ptr -newMapperActionFactory(tooling::ExecutionContext *ECtx) { - return llvm::make_unique(ECtx); +newMapperActionFactory(ClangDocContext CDCtx) { + return llvm::make_unique(CDCtx); } } // namespace doc Modified: clang-tools-extra/trunk/clang-doc/ClangDoc.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/ClangDoc.h?rev=337602&r1=337601&r2=337602&view=diff == --- clang-tools-extra/trunk/clang-doc/ClangDoc.h (original) +++ clang-tools-extra/trunk/clang-doc/ClangDoc.h Fri Jul 20 11:49:55 2018 @@ -17,6 +17,7 @@ #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_CLANGDOC_H #define LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_CLANGDOC_H +#include "Representation.h" #include "clang/Tooling/Execution.h" #include "clang/Tooling/StandaloneExecution.h" #include "clang/Tooling/Tooling.h" @@ -25,7 +26,7 @@ namespace clang { namespace doc { std::unique_ptr -newMapperActionFactory(tooling::ExecutionContext *ECtx); +newMapperActionFactory(ClangDocContext CDCtx); } // namespace doc } // namespace clang Modified: clang-tools-extra/trunk/clang-doc/Mapper.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/Mapper.cpp?rev=337602&r1=337601&r2=337602&view=diff == --- clang-tools-extra/trunk/clang-doc/Mapper.cpp (original) +++ clang-tools-extra/trunk/clang-doc/Mapper.cpp Fri Jul 20 11:49:55 2018 @@ -33,10 +33,14 @@ template bool MapASTVisitor if (index::generateUSRForDecl(D, USR)) return true; - ECtx->reportResult(llvm::toHex(llvm::toStringRef(serialize::hashUSR(USR))), - serialize::emitInfo(D, getComment(D, D->getASTContext()), - getLine(D, D->getASTContext()), - getFile(D, D->getASTContext(; + std::string info = serialize::emitInfo( + D, getComment(D, D->getASTContext()), getLine(D, D->getASTContext()), + getFile(D, D->getASTContext()), CDCtx.PublicOnly); + + if (info != "") +CDCtx.ECtx->reportResult( +llvm::toHex(llvm::toStringRef(serialize::hashUSR(USR))), info); + return true; } Modified: clang-tools-extr
[PATCH] D48395: Added PublicOnly flag
This revision was automatically updated to reflect the committed changes. Closed by commit rCTE337602: [clang-doc] Adding PublicOnly flag (authored by juliehockett, committed by ). Herald added a subscriber: arphaman. Changed prior to commit: https://reviews.llvm.org/D48395?vs=154470&id=156562#toc Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D48395 Files: clang-doc/ClangDoc.cpp clang-doc/ClangDoc.h clang-doc/Mapper.cpp clang-doc/Mapper.h clang-doc/Representation.cpp clang-doc/Representation.h clang-doc/Serialize.cpp clang-doc/Serialize.h clang-doc/tool/ClangDocMain.cpp test/clang-doc/module.cpp test/clang-doc/public-module.cpp test/clang-doc/public-records.cpp Index: clang-doc/Representation.cpp === --- clang-doc/Representation.cpp +++ clang-doc/Representation.cpp @@ -42,7 +42,7 @@ mergeInfos(std::vector> &Values) { if (Values.empty()) return llvm::make_error("No info values to merge.\n", - llvm::inconvertibleErrorCode()); + llvm::inconvertibleErrorCode()); switch (Values[0]->IT) { case InfoType::IT_namespace: Index: clang-doc/Serialize.h === --- clang-doc/Serialize.h +++ clang-doc/Serialize.h @@ -29,15 +29,15 @@ namespace serialize { std::string emitInfo(const NamespaceDecl *D, const FullComment *FC, - int LineNumber, StringRef File); + int LineNumber, StringRef File, bool PublicOnly); std::string emitInfo(const RecordDecl *D, const FullComment *FC, int LineNumber, - StringRef File); + StringRef File, bool PublicOnly); std::string emitInfo(const EnumDecl *D, const FullComment *FC, int LineNumber, - StringRef File); + StringRef File, bool PublicOnly); std::string emitInfo(const FunctionDecl *D, const FullComment *FC, - int LineNumber, StringRef File); + int LineNumber, StringRef File, bool PublicOnly); std::string emitInfo(const CXXMethodDecl *D, const FullComment *FC, - int LineNumber, StringRef File); + int LineNumber, StringRef File, bool PublicOnly); // Function to hash a given USR value for storage. // As USRs (Unified Symbol Resolution) could be large, especially for functions Index: clang-doc/tool/ClangDocMain.cpp === --- clang-doc/tool/ClangDocMain.cpp +++ clang-doc/tool/ClangDocMain.cpp @@ -64,6 +64,10 @@ llvm::cl::desc("Dump intermediate results to bitcode file."), llvm::cl::init(false), llvm::cl::cat(ClangDocCategory)); +static llvm::cl::opt +PublicOnly("public", llvm::cl::desc("Document only public declarations."), + llvm::cl::init(false), llvm::cl::cat(ClangDocCategory)); + enum OutputFormatTy { yaml, }; @@ -171,9 +175,10 @@ // Mapping phase llvm::outs() << "Mapping decls...\n"; - auto Err = Exec->get()->execute( - doc::newMapperActionFactory(Exec->get()->getExecutionContext()), - ArgAdjuster); + clang::doc::ClangDocContext CDCtx = {Exec->get()->getExecutionContext(), + PublicOnly}; + auto Err = + Exec->get()->execute(doc::newMapperActionFactory(CDCtx), ArgAdjuster); if (Err) { llvm::errs() << toString(std::move(Err)) << "\n"; return 1; Index: clang-doc/Mapper.h === --- clang-doc/Mapper.h +++ clang-doc/Mapper.h @@ -18,6 +18,7 @@ #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_MAPPER_H #define LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_MAPPER_H +#include "Representation.h" #include "clang/AST/RecursiveASTVisitor.h" #include "clang/Tooling/Execution.h" @@ -30,8 +31,8 @@ class MapASTVisitor : public clang::RecursiveASTVisitor, public ASTConsumer { public: - explicit MapASTVisitor(ASTContext *Ctx, ExecutionContext *ECtx) - : ECtx(ECtx) {} + explicit MapASTVisitor(ASTContext *Ctx, ClangDocContext CDCtx) + : CDCtx(CDCtx) {} void HandleTranslationUnit(ASTContext &Context) override; bool VisitNamespaceDecl(const NamespaceDecl *D); @@ -48,7 +49,7 @@ comments::FullComment *getComment(const NamedDecl *D, const ASTContext &Context) const; - ExecutionContext *ECtx; + ClangDocContext CDCtx; }; } // namespace doc Index: clang-doc/Serialize.cpp === --- clang-doc/Serialize.cpp +++ clang-doc/Serialize.cpp @@ -171,8 +171,20 @@ return Ty->getDecl()->getDefinition(); } -static void parseFields(RecordInfo &I, const RecordDecl *D) { +static bool isPublic(const clang::AccessSpecifier AS, + const clang::Linkage Link) { + if
Re: r337540 - Sema: Fix explicit address space cast in C++
On Fri, 20 Jul 2018 at 04:38, Yaxun Liu via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: yaxunl > Date: Fri Jul 20 04:32:51 2018 > New Revision: 337540 > > URL: http://llvm.org/viewvc/llvm-project?rev=337540&view=rev > Log: > Sema: Fix explicit address space cast in C++ > > Currently clang does not allow implicit cast of a pointer to a pointer type > in different address space but allows C-style cast of a pointer to a > pointer > type in different address space. However, there is a bug in Sema causing > incorrect Cast Expr in AST for the latter case, which in turn results in > invalid LLVM IR in codegen. > > This is because Sema::IsQualificationConversion returns true for a cast of > pointer to a pointer type in different address space, which in turn allows > a standard conversion and results in a cast expression with no op in AST. > > This patch fixes that by let Sema::IsQualificationConversion returns false > for a cast of pointer to a pointer type in different address space, which > in turn disallows standard conversion, implicit cast, and static cast. > Finally it results in an reinterpret cast and correct conversion kind is > set. > > Differential Revision: https://reviews.llvm.org/D49294 > > Added: > cfe/trunk/test/CodeGenCXX/address-space-cast.cpp > Modified: > cfe/trunk/lib/Sema/SemaCast.cpp > cfe/trunk/lib/Sema/SemaOverload.cpp > > Modified: cfe/trunk/lib/Sema/SemaCast.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=337540&r1=337539&r2=337540&view=diff > > == > --- cfe/trunk/lib/Sema/SemaCast.cpp (original) > +++ cfe/trunk/lib/Sema/SemaCast.cpp Fri Jul 20 04:32:51 2018 > @@ -1955,6 +1955,12 @@ static bool fixOverloadedReinterpretCast >return Result.isUsable(); > } > > +static bool IsAddressSpaceConversion(QualType SrcType, QualType DestType) > { > + return SrcType->isPointerType() && DestType->isPointerType() && > + > SrcType->getAs()->getPointeeType().getAddressSpace() != > + > DestType->getAs()->getPointeeType().getAddressSpace(); > +} > + > static TryCastResult TryReinterpretCast(Sema &Self, ExprResult &SrcExpr, > QualType DestType, bool CStyle, > SourceRange OpRange, > @@ -2198,6 +2204,8 @@ static TryCastResult TryReinterpretCast( > } else { >Kind = CK_BitCast; > } > + } else if (IsAddressSpaceConversion(SrcType, DestType)) { > +Kind = CK_AddressSpaceConversion; > This seems wrong to me. A reinterpret_cast from a pointer to one address space into a pointer to a different address space should be a bit cast, not an address space conversion. >} else { > Kind = CK_BitCast; >} > > Modified: cfe/trunk/lib/Sema/SemaOverload.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=337540&r1=337539&r2=337540&view=diff > > == > --- cfe/trunk/lib/Sema/SemaOverload.cpp (original) > +++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Jul 20 04:32:51 2018 > @@ -3150,6 +3150,15 @@ Sema::IsQualificationConversion(QualType >= PreviousToQualsIncludeConst && ToQuals.hasConst(); >} > > + // Allows address space promotion by language rules implemented in > + // Type::Qualifiers::isAddressSpaceSupersetOf. > + Qualifiers FromQuals = FromType.getQualifiers(); > + Qualifiers ToQuals = ToType.getQualifiers(); > + if (!ToQuals.isAddressSpaceSupersetOf(FromQuals) && > + !FromQuals.isAddressSpaceSupersetOf(ToQuals)) { > +return false; > + } > + >// We are left with FromType and ToType being the pointee types >// after unwrapping the original FromType and ToType the same number >// of types. If we unwrapped any pointers, and if FromType and > > Added: cfe/trunk/test/CodeGenCXX/address-space-cast.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/address-space-cast.cpp?rev=337540&view=auto > > == > --- cfe/trunk/test/CodeGenCXX/address-space-cast.cpp (added) > +++ cfe/trunk/test/CodeGenCXX/address-space-cast.cpp Fri Jul 20 04:32:51 > 2018 > @@ -0,0 +1,15 @@ > +// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -emit-llvm -o - | > FileCheck %s > + > +#define __private__ __attribute__((address_space(5))) > + > +void func_pchar(__private__ char *x); > + > +void test_cast(char *gen_ptr) { > + // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i8 addrspace(5)* > + // CHECK-NEXT: store i8 addrspace(5)* %[[cast]] > + __private__ char *priv_ptr = (__private__ char *)gen_ptr; > + > + // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i8 addrspace(5)* > + // CHECK-NEXT: call void @_Z10func_pcharPU3AS5c(i8 addrspace(5)* > %[[cast]]) > + func_pchar((__private__ char *)gen_ptr); > +} > > > ___
[PATCH] D49584: [CMake] Install C++ ABI headers into the right location
phosek added a subscriber: beanz. phosek added a comment. We currently support two different layouts: 1. The standard layout (for a lack of a better name) which is used when libc++ is built standalone as well as being built as part of LLVM without any other options which is `$DESTDIR/include/c++/v1` for headers and `$DESTDIR/lib` for libraries. Clang driver knows where to find those headers and libraries when libc++ is selected, the problem is that this only works for the default target since there's going to be just a single copy of `$DESTDIR/lib/libc++.so`, etc. 2. The mutliarch runtime layout where headers are installed to `$DESTDIR/lib/clang/$CLANG_VERSION/include/c++/v1` and libraries to `$DESTDIR/lib/clang/$CLANG_VERSION/$TARGET/lib` where `$TARGET` is the target passed to Clang, e.g. `--target=x86-linux-gnu`. This layout supports distributing libc++ (and other runtimes) for multiple different targets with your toolchain. The reason we cannot use the same prefix for both headers and libraries is the multiarch runtime layout since headers and libraries are installed to different paths. Fuchsia is currently the first toolchain that AFAIK uses the new layout for its toolchain, but @beanz is working on using this layout also for Darwin. Android team also expressed interest in using the new layout since they need to support multiple targets in their toolchain. Repository: rCXX libc++ https://reviews.llvm.org/D49584 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D15225: [Driver] Sanitizer support based on runtime library presence
delcypher added inline comments. Comment at: clang/lib/Driver/ToolChains/Darwin.cpp:2298 SanitizerMask Res = ToolChain::getSupportedSanitizers(); - Res |= SanitizerKind::Address; - Res |= SanitizerKind::Leak; - Res |= SanitizerKind::Fuzzer; - Res |= SanitizerKind::FuzzerNoLink; + + if (sanitizerRuntimeExists("asan")) george.karpenkov wrote: > delcypher wrote: > > I feel that we should assert that `Res` doesn't already contain the > > SanitizerKind we are decided whether or not to set. > > E.g. > > > > ``` > > assert(!(Res & SanitizerKind::Address)); > > if (sanitizerRuntimeExists("asan")) { > > Res |= SanitizerKind::Address; > > } > > ``` > I'm not sure it would be worth crashing the driver. Asserts are usually off in shipping compilers. If an assumption is being violated, as a developer it's better than you know about it during debugging. Comment at: clang/lib/Driver/ToolChains/Darwin.h:427 + /// containing the sanitizer {@code SanitizerName}. + std::string sanitizerToRelativeLibName(StringRef SanitizerName, + bool Shared = true) const; george.karpenkov wrote: > delcypher wrote: > > I don't like this name very much. Given that the path is relative to the > > directory containing the library, what this function really does is given > > the **file name** for a sanitizer library. Mentioning "relative" is just > > confusing. > > > > Wouldn't something like `getSanitizerLibName()` or > > `getNameForSanitizerLib()` be much clearer? > Then it's not clear whether the returned path is relative or absolute though. The name implies that it's a file name and not a path. It could be `getSanitizerLibFileName()` or `getFileNameForSanitizerLib()` but that seemed a little verbose. https://reviews.llvm.org/D15225 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46140: [coroutines] std::task type (WIP)
lewissbaker updated this revision to Diff 156565. lewissbaker added a comment. Herald added subscribers: cfe-commits, ldionne, mgorny. Many improvements: - Remove move-assignment operator - `task::operator co_await()` now returns by value when awaiting `task` rvalue. - Explicitly scope calls to std-library functions that live in `_VSTD`. - Make `__task_promise` ABI stable under exception/no-exception compilation modes. - Moved `__aligned_allocation_size` to - Make `task` have a default template parameter of void, allowing `task<>` to mean `task` - Allow `co_return { ... }` by adding overload of `return_value()` taking `T&&` and another taking `initializer_list`. - Implement optimisation that avoids storing the allocator in the coroutine frame if `allocator_traits::is_always_equal` is true and the allocator is default constructible. - Added unit-tests (currently failing some custom allocator tests under debug builds) Repository: rCXX libc++ https://reviews.llvm.org/D46140 Files: include/CMakeLists.txt include/experimental/__memory include/experimental/memory_resource include/experimental/task include/module.modulemap test/std/experimental/task/awaitable_traits.hpp test/std/experimental/task/counted.hpp test/std/experimental/task/lit.local.cfg test/std/experimental/task/manual_reset_event.hpp test/std/experimental/task/sync_wait.hpp test/std/experimental/task/task.basic/task_custom_allocator.pass.cpp test/std/experimental/task/task.basic/task_of_value.pass.cpp test/std/experimental/task/task.basic/task_of_void.pass.cpp test/std/experimental/task/task.lifetime/task_parameter_lifetime.pass.cpp test/std/experimental/task/task.lifetime/task_return_value_lifetime.pass.cpp Index: test/std/experimental/task/task.lifetime/task_return_value_lifetime.pass.cpp === --- /dev/null +++ test/std/experimental/task/task.lifetime/task_return_value_lifetime.pass.cpp @@ -0,0 +1,86 @@ +// -*- C++ -*- +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include +#include +#include + +#include "../counted.hpp" +#include "../sync_wait.hpp" + +DEFINE_COUNTED_VARIABLES(); + +void test_return_value_lifetime() +{ + counted::reset(); + + auto f = [](bool x) -> std::experimental::task + { +if (x) { + counted c; + co_return std::move(c); +} +co_return {}; + }; + + { +auto t = f(true); + +assert(counted::active_instance_count() == 0); +assert(counted::copy_constructor_count() == 0); +assert(counted::move_constructor_count() == 0); + +{ + auto c = sync_wait(std::move(t)); + assert(c.id() == 1); + + assert(counted::active_instance_count() == 2); + assert(counted::copy_constructor_count() == 0); + assert(counted::move_constructor_count() > 0); + assert(counted::default_constructor_count() == 1); +} + +// The result value in 't' is still alive until 't' destructs. +assert(counted::active_instance_count() == 1); + } + + assert(counted::active_instance_count() == 0); + + counted::reset(); + + { +auto t = f(false); + +assert(counted::active_instance_count() == 0); +assert(counted::copy_constructor_count() == 0); +assert(counted::move_constructor_count() == 0); + +{ + auto c = sync_wait(std::move(t)); + assert(c.id() == 1); + + assert(counted::active_instance_count() == 2); + assert(counted::copy_constructor_count() == 0); + assert(counted::move_constructor_count() > 0); + assert(counted::default_constructor_count() == 1); +} + +// The result value in 't' is still alive until 't' destructs. +assert(counted::active_instance_count() == 1); + } +} + +int main() +{ + test_return_value_lifetime(); + return 0; +} Index: test/std/experimental/task/task.lifetime/task_parameter_lifetime.pass.cpp === --- /dev/null +++ test/std/experimental/task/task.lifetime/task_parameter_lifetime.pass.cpp @@ -0,0 +1,57 @@ +// -*- C++ -*- +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +#include +#include + +#include "../counted.hpp" +#include "../sync_wait.hpp" + +DEFINE_COUNTED_VARIABLES(); + +void test_parameter_lifetime() +{ +
Re: r337540 - Sema: Fix explicit address space cast in C++
On Fri, 20 Jul 2018 at 12:00, Richard Smith wrote: > On Fri, 20 Jul 2018 at 04:38, Yaxun Liu via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: yaxunl >> Date: Fri Jul 20 04:32:51 2018 >> New Revision: 337540 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=337540&view=rev >> Log: >> Sema: Fix explicit address space cast in C++ >> >> Currently clang does not allow implicit cast of a pointer to a pointer >> type >> in different address space but allows C-style cast of a pointer to a >> pointer >> type in different address space. However, there is a bug in Sema causing >> incorrect Cast Expr in AST for the latter case, which in turn results in >> invalid LLVM IR in codegen. >> >> This is because Sema::IsQualificationConversion returns true for a cast of >> pointer to a pointer type in different address space, which in turn allows >> a standard conversion and results in a cast expression with no op in AST. >> >> This patch fixes that by let Sema::IsQualificationConversion returns false >> for a cast of pointer to a pointer type in different address space, which >> in turn disallows standard conversion, implicit cast, and static cast. >> Finally it results in an reinterpret cast and correct conversion kind is >> set. >> >> Differential Revision: https://reviews.llvm.org/D49294 >> >> Added: >> cfe/trunk/test/CodeGenCXX/address-space-cast.cpp >> Modified: >> cfe/trunk/lib/Sema/SemaCast.cpp >> cfe/trunk/lib/Sema/SemaOverload.cpp >> >> Modified: cfe/trunk/lib/Sema/SemaCast.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=337540&r1=337539&r2=337540&view=diff >> >> == >> --- cfe/trunk/lib/Sema/SemaCast.cpp (original) >> +++ cfe/trunk/lib/Sema/SemaCast.cpp Fri Jul 20 04:32:51 2018 >> @@ -1955,6 +1955,12 @@ static bool fixOverloadedReinterpretCast >>return Result.isUsable(); >> } >> >> +static bool IsAddressSpaceConversion(QualType SrcType, QualType >> DestType) { >> + return SrcType->isPointerType() && DestType->isPointerType() && >> + >> SrcType->getAs()->getPointeeType().getAddressSpace() != >> + >> DestType->getAs()->getPointeeType().getAddressSpace(); >> +} >> + >> static TryCastResult TryReinterpretCast(Sema &Self, ExprResult &SrcExpr, >> QualType DestType, bool CStyle, >> SourceRange OpRange, >> @@ -2198,6 +2204,8 @@ static TryCastResult TryReinterpretCast( >> } else { >>Kind = CK_BitCast; >> } >> + } else if (IsAddressSpaceConversion(SrcType, DestType)) { >> +Kind = CK_AddressSpaceConversion; >> > > This seems wrong to me. A reinterpret_cast from a pointer to one address > space into a pointer to a different address space should be a bit cast, not > an address space conversion. > Hmm. I suppose we have a choice: either reinterpret_cast always means 'reinterpret these bits as this other type' (and there are C-style casts that cannot be expressed in terms of named casts, violating the usual C++ rules for C-style casts) or reinterpret_cast between pointers always gives you a pointer to the same byte of storage and an address space bitcast requires casting via an integral type (violating the normal behavior that reinterpret_cast reinterprets the representation and doesn't change the value). These options both seem unsatisfying, but what you have here (reinterpret_cast attempts to form a pointer to the same byte) is definitely the more useful of those two options. Do any of our supported language extensions actually say what named casts in C++ do when attempting to cast between address spaces? The OpenCL 2.2 C++ extensions specification doesn't add address space qualifiers, so it doesn't have an answer for us. } else { >> Kind = CK_BitCast; >>} >> >> Modified: cfe/trunk/lib/Sema/SemaOverload.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=337540&r1=337539&r2=337540&view=diff >> >> == >> --- cfe/trunk/lib/Sema/SemaOverload.cpp (original) >> +++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Jul 20 04:32:51 2018 >> @@ -3150,6 +3150,15 @@ Sema::IsQualificationConversion(QualType >>= PreviousToQualsIncludeConst && ToQuals.hasConst(); >>} >> >> + // Allows address space promotion by language rules implemented in >> + // Type::Qualifiers::isAddressSpaceSupersetOf. >> + Qualifiers FromQuals = FromType.getQualifiers(); >> + Qualifiers ToQuals = ToType.getQualifiers(); >> + if (!ToQuals.isAddressSpaceSupersetOf(FromQuals) && >> + !FromQuals.isAddressSpaceSupersetOf(ToQuals)) { >> > Is this right? Qualification conversions are usually only permitted for "guaranteed-safe" conversions, which would be cases where the target address space is a superset of the source address space only. And OpenCL 2.2's C extensions specificati
[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics
craig.topper added a comment. Here are the IR patterns for this that work. Not sure if we can do this directly in C, we need a 128 bit type, but maybe we can emit it from CGBuiltin.cpp? define i64 @__shiftleft128(i64 %x, i64 %y, i8 %amt) { %a = zext i64 %x to i128 %b = zext i64 %y to i128 %c = shl i128 %b, 64 %d = or i128 %a, %c %amtmask = and i8 %amt, 63 %e = zext i8 %amtmask to i128 %f = shl i128 %d, %e %g = lshr i128 %f, 64 %h = trunc i128 %g to i64 ret i64 %h } define i64 @__shiftright128(i64 %x, i64 %y, i8 %amt) { %a = zext i64 %x to i128 %b = zext i64 %y to i128 %c = shl i128 %b, 64 %d = or i128 %a, %c %amtmask = and i8 %amt, 63 %e = zext i8 %amtmask to i128 %f = lshr i128 %d, %e %g = trunc i128 %f to i64 ret i64 %g } https://reviews.llvm.org/D49606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49508: [Sema] Mark implicitly-inserted ICE's as being part of explicit cast (PR38166)
lebedev.ri updated this revision to Diff 156568. lebedev.ri marked 4 inline comments as done. lebedev.ri added a comment. - Use `unsigned`, not bool. - Serialization, although without tests, and likely incompatible with previous versions. Repository: rC Clang https://reviews.llvm.org/D49508 Files: include/clang/AST/Expr.h include/clang/AST/Stmt.h lib/AST/ASTDumper.cpp lib/Sema/SemaCast.cpp lib/Serialization/ASTReaderStmt.cpp lib/Serialization/ASTWriterDecl.cpp lib/Serialization/ASTWriterStmt.cpp test/Sema/multistep-explicit-cast.c test/SemaCXX/multistep-explicit-cast.cpp Index: test/SemaCXX/multistep-explicit-cast.cpp === --- /dev/null +++ test/SemaCXX/multistep-explicit-cast.cpp @@ -0,0 +1,155 @@ +// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -ast-dump %s | FileCheck %s + +// We are checking that implicit casts don't get marked with 'PartOfExplicitCast', +// while in explicit casts, the implicitly-inserted implicit casts are marked with 'PartOfExplicitCast' + +unsigned char implicitcast_0(unsigned int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} implicitcast_0 'unsigned char (unsigned int)'{{$}} + // CHECK: ImplicitCastExpr {{.*}} 'unsigned char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' {{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int' lvalue ParmVar {{.*}} 'x' 'unsigned int'{{$}} + return x; +} + +signed char implicitcast_1(unsigned int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} implicitcast_1 'signed char (unsigned int)'{{$}} + // CHECK: ImplicitCastExpr {{.*}} 'signed char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' {{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int' lvalue ParmVar {{.*}} 'x' 'unsigned int'{{$}} + return x; +} + +unsigned char implicitcast_2(signed int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} implicitcast_2 'unsigned char (int)'{{$}} + // CHECK: ImplicitCastExpr {{.*}} 'unsigned char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'int' {{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} 'x' 'int'{{$}} + return x; +} + +signed char implicitcast_3(signed int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} implicitcast_3 'signed char (int)'{{$}} + // CHECK: ImplicitCastExpr {{.*}} 'signed char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'int' {{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} 'x' 'int'{{$}} + return x; +} + +//// + +unsigned char cstylecast_0(unsigned int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} cstylecast_0 'unsigned char (unsigned int)'{{$}} + // CHECK: CStyleCastExpr {{.*}} 'unsigned char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned char' PartOfExplicitCast{{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' PartOfExplicitCast{{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int' lvalue ParmVar {{.*}} 'x' 'unsigned int'{{$}} + return (unsigned char)x; +} + +signed char cstylecast_1(unsigned int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} cstylecast_1 'signed char (unsigned int)'{{$}} + // CHECK: CStyleCastExpr {{.*}} 'signed char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'signed char' PartOfExplicitCast{{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' PartOfExplicitCast{{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int' lvalue ParmVar {{.*}} 'x' 'unsigned int'{{$}} + return (signed char)x; +} + +unsigned char cstylecast_2(signed int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} cstylecast_2 'unsigned char (int)'{{$}} + // CHECK: CStyleCastExpr {{.*}} 'unsigned char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned char' PartOfExplicitCast{{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'int' PartOfExplicitCast{{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} 'x' 'int'{{$}} + return (unsigned char)x; +} + +signed char cstylecast_3(signed int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} cstylecast_3 'signed char (int)'{{$}} + // CHECK: CStyleCastExpr {{.*}} 'signed char' {{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'signed char' PartOfExplicitCast{{$}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} 'int' PartOfExplicitCast{{$}} + // CHECK-NEXT: DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} 'x' 'int'{{$}} + return (signed char)x; +} + +//// + +unsigned char cxxstaticcast_0(unsigned int x) { + // CHECK: FunctionDecl {{.*}} <{{.*}}, line:{{.*}}> line:{{.*}} cxxstaticcast_0 'unsigned char (unsigned int)'{{$}} + // CHECK: CXXStaticCastExpr {{.*}} 'unsigned char' static_cas
[PATCH] D49508: [Sema] Mark implicitly-inserted ICE's as being part of explicit cast (PR38166)
lebedev.ri added inline comments. Comment at: include/clang/AST/Stmt.h:206 +bool PartOfExplicitCast : 1; +unsigned BasePathSize : 32 - 6 - 1 - NumExprBits; }; rjmccall wrote: > lebedev.ri wrote: > > rjmccall wrote: > > > This needs to be serialized. > > Uhm, could you please explain what do you mean by 'serialized'? > It needs to be preserved when writing an ICE into a PCH / module file. See > the ASTWriter / ASTReader. Aha. I did add handling there but it raises questions: # This will silently break with different AST serialization versions. I'm not sure how to handle it, since `VERSION_MINOR` isn't even read back. # //Does// this need a test? How to write one? Like `./test/PCH/include-timestamp.cpp`, using `llvm-bcanalyzer`? Repository: rC Clang https://reviews.llvm.org/D49508 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49580: [clang-format] Adding style option for absolute formatting
acoomans updated this revision to Diff 156571. acoomans retitled this revision from "[WIP] Change clang-format to absolute indentation" to "[clang-format] Adding style option for absolute formatting". acoomans edited the summary of this revision. https://reviews.llvm.org/D49580 Files: docs/ClangFormatStyleOptions.rst include/clang/Format/Format.h lib/Format/Format.cpp lib/Format/UnwrappedLineFormatter.cpp test/Format/line-ranges-indent-abs.c test/Format/line-ranges-indent-abs.m test/Format/line-ranges-indent-rel.c Index: test/Format/line-ranges-indent-rel.c === --- /dev/null +++ test/Format/line-ranges-indent-rel.c @@ -0,0 +1,10 @@ +// RUN: grep -Ev "// *[A-Z-]+:" %s \ +// RUN: | clang-format -style=LLVM -lines=2:2 \ +// RUN: | FileCheck -strict-whitespace %s +// CHECK: {{^\ int f\(void\) \{$}} + int f(void) { +// CHECK: {{^\ \ \ int i = 0;$}} + int i = 0; +// CHECK: {{^\ \ \ return i;$}} + return i; +} Index: test/Format/line-ranges-indent-abs.m === --- /dev/null +++ test/Format/line-ranges-indent-abs.m @@ -0,0 +1,9 @@ +// RUN: grep -Ev "// *[A-Z-]+:" %s \ +// RUN: | clang-format -style="{BasedOnStyle: LLVM, IndentReference: Absolute}" -lines=2:2 \ +// RUN: | FileCheck -strict-whitespace %s +// CHECK: {{^\ \@protocol\ A$}} + @protocol A +// CHECK: {{^-\ \(void\)f;$}} +- (void)f; +// CHECK: {{^\@end$}} +@end Index: test/Format/line-ranges-indent-abs.c === --- /dev/null +++ test/Format/line-ranges-indent-abs.c @@ -0,0 +1,10 @@ +// RUN: grep -Ev "// *[A-Z-]+:" %s \ +// RUN: | clang-format -style="{BasedOnStyle: LLVM, IndentReference: Absolute}" -lines=2:2 \ +// RUN: | FileCheck -strict-whitespace %s +// CHECK: {{^\ int f\(void\) \{$}} + int f(void) { +// CHECK: {{^\ \ int i = 0;$}} + int i = 0; +// CHECK: {{^\ \ return i;$}} + return i; +} Index: lib/Format/UnwrappedLineFormatter.cpp === --- lib/Format/UnwrappedLineFormatter.cpp +++ lib/Format/UnwrappedLineFormatter.cpp @@ -1089,10 +1089,13 @@ format(Tok->Children, DryRun); // Adapt following lines on the current indent level to the same level - // unless the current \c AnnotatedLine is not at the beginning of a line. + // if indentation should be relative and unless the + // current \c AnnotatedLine is not at the beginning of a line. + bool RelativeIndentation = + Style.IndentReference != FormatStyle::IRS_Absolute; bool StartsNewLine = TheLine.First->NewlinesBefore > 0 || TheLine.First->IsFirst; - if (StartsNewLine) + if (RelativeIndentation && StartsNewLine) IndentTracker.adjustToUnmodifiedLine(TheLine); if (!DryRun) { bool ReformatLeadingWhitespace = Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -241,6 +241,13 @@ } }; +template <> struct ScalarEnumerationTraits { + static void enumeration(IO &IO, FormatStyle::IndentReferenceStyle &Value) { +IO.enumCase(Value, "Relative", FormatStyle::IRS_Relative); +IO.enumCase(Value, "Absolute", FormatStyle::IRS_Absolute); + } +}; + template <> struct ScalarEnumerationTraits { static void enumeration(IO &IO, FormatStyle::PointerAlignmentStyle &Value) { IO.enumCase(Value, "Middle", FormatStyle::PAS_Middle); @@ -411,6 +418,7 @@ IO.mapOptional("IncludeIsMainRegex", Style.IncludeStyle.IncludeIsMainRegex); IO.mapOptional("IndentCaseLabels", Style.IndentCaseLabels); IO.mapOptional("IndentPPDirectives", Style.IndentPPDirectives); +IO.mapOptional("IndentReference", Style.IndentReference); IO.mapOptional("IndentWidth", Style.IndentWidth); IO.mapOptional("IndentWrappedFunctionNames", Style.IndentWrappedFunctionNames); @@ -670,6 +678,7 @@ LLVMStyle.IncludeStyle.IncludeBlocks = tooling::IncludeStyle::IBS_Preserve; LLVMStyle.IndentCaseLabels = false; LLVMStyle.IndentPPDirectives = FormatStyle::PPDIS_None; + LLVMStyle.IndentReference = FormatStyle::IRS_Relative; LLVMStyle.IndentWrappedFunctionNames = false; LLVMStyle.IndentWidth = 2; LLVMStyle.JavaScriptQuotes = FormatStyle::JSQS_Leave; Index: include/clang/Format/Format.h === --- include/clang/Format/Format.h +++ include/clang/Format/Format.h @@ -1094,6 +1094,30 @@ /// The preprocessor directive indenting style to use. PPDirectiveIndentStyle IndentPPDirectives; + /// Different styles for indenting, used for partial formatting. + enum IndentReferenceStyle { +/// Indent relative to previous line, e.g.: +/// \code +/// int a = 0; +///int f(void) { // mis-indented by one space +/// int i = 0; <- those l
[PATCH] D49302: [AST] Various micro-optimizations in CXXInheritance
bricci added a comment. @bkramer Thanks for the review! Can you commit it for my since I can not do it myself? Repository: rC Clang https://reviews.llvm.org/D49302 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics
thakis added a comment. We have __int128. If you think hitting the pattern is preferable to inline asm, I can try to give that a try, either via C or via CGBuiltin.cpp. https://reviews.llvm.org/D49606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49148: [DEBUGINFO] Disable unsupported debug info options for NVPTX target.
ABataev updated this revision to Diff 156575. ABataev added a comment. Added checks for all possible debug options. Repository: rC Clang https://reviews.llvm.org/D49148 Files: include/clang/Basic/DiagnosticDriverKinds.td include/clang/Basic/DiagnosticGroups.td include/clang/Driver/ToolChain.h lib/Driver/ToolChains/Clang.cpp lib/Driver/ToolChains/Cuda.cpp lib/Driver/ToolChains/Cuda.h test/Driver/cuda-dwarf-2.cu test/Driver/cuda-unsupported-debug-options.cu test/Driver/openmp-offload-gpu.c test/Driver/openmp-unsupported-debug-options.c Index: test/Driver/openmp-unsupported-debug-options.c === --- /dev/null +++ test/Driver/openmp-unsupported-debug-options.c @@ -0,0 +1,21 @@ +// REQUIRES: clang-driver +// REQUIRES: x86-registered-target +// REQUIRES: nvptx-registered-target + +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -gz 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -gdwarf -fdebug-info-for-profiling 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -gdwarf-2 -gsplit-dwarf 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -gdwarf-3 -glldb 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -gdwarf-4 -gcodeview 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -gdwarf-5 -gmodules 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -ggdb -gembed-source -gdwarf-5 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -ggdb1 -fdebug-macro 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -ggdb2 -ggnu-pubnames 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -ggdb3 -gdwarf-aranges 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -c %s -g -gcolumn-info -fdebug-types-section 2>&1 | FileCheck %s +// CHECK: debug information option '{{-gz|-fdebug-info-for-profiling|-gsplit-dwarf|-glldb|-gcodeview|-gmodules|-gembed-source|-fdebug-macro|-ggnu-pubnames|-gdwarf-aranges|-fdebug-types-section}}' is not supported for target 'nvptx64-nvidia-cuda' [-Wunsupported-target-opt] +// CHECK-NOT: debug information option '{{.*}}' is not supported for target 'x86 +// CHECK: "-triple" "nvptx64-nvidia-cuda" +// CHECK-NOT: {{-compress-debug|-fdebug-info-for-profiling|split-dwarf|lldb|codeview|module-format|embed-source|debug-info-macro|gnu-pubnames|generate-arange-section|generate-type-units}} +// CHECK: "-triple" "x86_64 +// CHECK-SAME: {{-compress-debug|-fdebug-info-for-profiling|split-dwarf|lldb|codeview|module-format|embed-source|debug-info-macro|gnu-pubnames|generate-arange-section|generate-type-units}} Index: test/Driver/openmp-offload-gpu.c === --- test/Driver/openmp-offload-gpu.c +++ test/Driver/openmp-offload-gpu.c @@ -182,6 +182,8 @@ // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb1 -O2 --cuda-noopt-device-debug 2>&1 \ // RUN: | FileCheck -check-prefix=NO_DEBUG -check-prefix=LINE_TABLE %s +// LINE_TABLE-NOT: warning: debug +// NO_DEBUG-NOT: warning: debug // NO_DEBUG: ptxas // LINE_TABLE: "-lineinfo" // NO_DEBUG-NOT: "-g" @@ -203,6 +205,7 @@ // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb3 -O2 --cuda-noopt-device-debug 2>&1 \ // RUN: | FileCheck -check-prefix=HAS_DEBUG %s +// HAS_DEBUG-NOT: warning: debug // HAS_DEBUG: "-triple" "nvptx64-nvidia-cuda" // HAS_DEBUG-SAME: "-dwarf-version=2" // HAS_DEBUG-SAME: "-fopenmp-is-device" Index: test/Driver/cuda-unsupported-debug-options.cu === --- /dev/null +++ test/Driver/cuda-unsupported-debug-options.cu @@ -0,0 +1,21 @@ +// REQUIRES: clang-driver +// REQUIRES: x86-registered-target +// REQUIRES: nvptx-registered-target + +// RUN: %clang -### -target x86_64-linux-gnu -c %s -g -gz 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -c %s -gdwarf -fdebug-info-for-profiling 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -c %s -gdwarf-2 -gsplit-dwarf 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-linux-gnu -c %s -gdwarf-3 -glldb 2>&1 | FileCheck %s +// RU
r337607 - [AST] Various micro-optimizations in CXXInheritance
Author: d0k Date: Fri Jul 20 13:13:08 2018 New Revision: 337607 URL: http://llvm.org/viewvc/llvm-project?rev=337607&view=rev Log: [AST] Various micro-optimizations in CXXInheritance 1. Pack std::pair in CXXBasePaths::ClassSubobjects. 2. Use a SmallPtrSet instead of a SmallDenseSet for CXXBasePaths::VisitedDependentRecords. 3. Reorder some members of CXXBasePaths to save 8 bytes. 4. Use a SmallSetVector instead of a SetVector in CXXBasePaths::ComputeDeclsFound to avoid some allocations. This speeds up an -fsyntax-only on all of Boost by approx 0.15%, mainly by speeding up CXXBasePaths::lookupInBases by approx 10%. No functional changes. Patch by Bruno Ricci! Differential Revision: https://reviews.llvm.org/D49302 Modified: cfe/trunk/include/clang/AST/CXXInheritance.h cfe/trunk/lib/AST/CXXInheritance.cpp Modified: cfe/trunk/include/clang/AST/CXXInheritance.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CXXInheritance.h?rev=337607&r1=337606&r2=337607&view=diff == --- cfe/trunk/include/clang/AST/CXXInheritance.h (original) +++ cfe/trunk/include/clang/AST/CXXInheritance.h Fri Jul 20 13:13:08 2018 @@ -125,18 +125,36 @@ class CXXBasePaths { /// Paths - The actual set of paths that can be taken from the /// derived class to the same base class. std::list Paths; - + /// ClassSubobjects - Records the class subobjects for each class - /// type that we've seen. The first element in the pair says + /// type that we've seen. The first element IsVirtBase says /// whether we found a path to a virtual base for that class type, - /// while the element contains the number of non-virtual base + /// while NumberOfNonVirtBases contains the number of non-virtual base /// class subobjects for that class type. The key of the map is /// the cv-unqualified canonical type of the base class subobject. - llvm::SmallDenseMap, 8> ClassSubobjects; + struct IsVirtBaseAndNumberNonVirtBases { +unsigned IsVirtBase : 1; +unsigned NumberOfNonVirtBases : 31; + }; + llvm::SmallDenseMap + ClassSubobjects; /// VisitedDependentRecords - Records the dependent records that have been /// already visited. - llvm::SmallDenseSet VisitedDependentRecords; + llvm::SmallPtrSet VisitedDependentRecords; + + /// DetectedVirtual - The base class that is virtual. + const RecordType *DetectedVirtual = nullptr; + + /// ScratchPath - A BasePath that is used by Sema::lookupInBases + /// to help build the set of paths. + CXXBasePath ScratchPath; + + /// Array of the declarations that have been found. This + /// array is constructed only if needed, e.g., to iterate over the + /// results within LookupResult. + std::unique_ptr DeclsFound; + unsigned NumDeclsFound = 0; /// FindAmbiguities - Whether Sema::IsDerivedFrom should try find /// ambiguous paths while it is looking for a path from a derived @@ -152,20 +170,7 @@ class CXXBasePaths { /// if it finds a path that goes across a virtual base. The virtual class /// is also recorded. bool DetectVirtual; - - /// ScratchPath - A BasePath that is used by Sema::lookupInBases - /// to help build the set of paths. - CXXBasePath ScratchPath; - /// DetectedVirtual - The base class that is virtual. - const RecordType *DetectedVirtual = nullptr; - - /// Array of the declarations that have been found. This - /// array is constructed only if needed, e.g., to iterate over the - /// results within LookupResult. - std::unique_ptr DeclsFound; - unsigned NumDeclsFound = 0; - void ComputeDeclsFound(); bool lookupInBases(ASTContext &Context, const CXXRecordDecl *Record, Modified: cfe/trunk/lib/AST/CXXInheritance.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CXXInheritance.cpp?rev=337607&r1=337606&r2=337607&view=diff == --- cfe/trunk/lib/AST/CXXInheritance.cpp (original) +++ cfe/trunk/lib/AST/CXXInheritance.cpp Fri Jul 20 13:13:08 2018 @@ -40,7 +40,7 @@ void CXXBasePaths::ComputeDeclsFound() { assert(NumDeclsFound == 0 && !DeclsFound && "Already computed the set of declarations"); - llvm::SetVector> Decls; + llvm::SmallSetVector Decls; for (paths_iterator Path = begin(), PathEnd = end(); Path != PathEnd; ++Path) Decls.insert(Path->Decls.front()); @@ -63,8 +63,8 @@ CXXBasePaths::decl_range CXXBasePaths::f /// an unqualified, canonical class type. bool CXXBasePaths::isAmbiguous(CanQualType BaseType) { BaseType = BaseType.getUnqualifiedType(); - std::pair& Subobjects = ClassSubobjects[BaseType]; - return Subobjects.second + (Subobjects.first? 1 : 0) > 1; + IsVirtBaseAndNumberNonVirtBases Subobjects = ClassSubobjects[BaseType]; + return Subobjects.NumberOfNonVirtBases + (Subobjects.IsVirtBase ? 1 : 0) > 1; } /// clear - Clear out all prior path information. @@ -217,21 +217,21 @@ bool CXXBasePa
[PATCH] D49302: [AST] Various micro-optimizations in CXXInheritance
This revision was automatically updated to reflect the committed changes. Closed by commit rL337607: [AST] Various micro-optimizations in CXXInheritance (authored by d0k, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D49302?vs=155392&id=156582#toc Repository: rL LLVM https://reviews.llvm.org/D49302 Files: cfe/trunk/include/clang/AST/CXXInheritance.h cfe/trunk/lib/AST/CXXInheritance.cpp Index: cfe/trunk/include/clang/AST/CXXInheritance.h === --- cfe/trunk/include/clang/AST/CXXInheritance.h +++ cfe/trunk/include/clang/AST/CXXInheritance.h @@ -125,18 +125,36 @@ /// Paths - The actual set of paths that can be taken from the /// derived class to the same base class. std::list Paths; - + /// ClassSubobjects - Records the class subobjects for each class - /// type that we've seen. The first element in the pair says + /// type that we've seen. The first element IsVirtBase says /// whether we found a path to a virtual base for that class type, - /// while the element contains the number of non-virtual base + /// while NumberOfNonVirtBases contains the number of non-virtual base /// class subobjects for that class type. The key of the map is /// the cv-unqualified canonical type of the base class subobject. - llvm::SmallDenseMap, 8> ClassSubobjects; + struct IsVirtBaseAndNumberNonVirtBases { +unsigned IsVirtBase : 1; +unsigned NumberOfNonVirtBases : 31; + }; + llvm::SmallDenseMap + ClassSubobjects; /// VisitedDependentRecords - Records the dependent records that have been /// already visited. - llvm::SmallDenseSet VisitedDependentRecords; + llvm::SmallPtrSet VisitedDependentRecords; + + /// DetectedVirtual - The base class that is virtual. + const RecordType *DetectedVirtual = nullptr; + + /// ScratchPath - A BasePath that is used by Sema::lookupInBases + /// to help build the set of paths. + CXXBasePath ScratchPath; + + /// Array of the declarations that have been found. This + /// array is constructed only if needed, e.g., to iterate over the + /// results within LookupResult. + std::unique_ptr DeclsFound; + unsigned NumDeclsFound = 0; /// FindAmbiguities - Whether Sema::IsDerivedFrom should try find /// ambiguous paths while it is looking for a path from a derived @@ -152,20 +170,7 @@ /// if it finds a path that goes across a virtual base. The virtual class /// is also recorded. bool DetectVirtual; - - /// ScratchPath - A BasePath that is used by Sema::lookupInBases - /// to help build the set of paths. - CXXBasePath ScratchPath; - /// DetectedVirtual - The base class that is virtual. - const RecordType *DetectedVirtual = nullptr; - - /// Array of the declarations that have been found. This - /// array is constructed only if needed, e.g., to iterate over the - /// results within LookupResult. - std::unique_ptr DeclsFound; - unsigned NumDeclsFound = 0; - void ComputeDeclsFound(); bool lookupInBases(ASTContext &Context, const CXXRecordDecl *Record, Index: cfe/trunk/lib/AST/CXXInheritance.cpp === --- cfe/trunk/lib/AST/CXXInheritance.cpp +++ cfe/trunk/lib/AST/CXXInheritance.cpp @@ -40,7 +40,7 @@ assert(NumDeclsFound == 0 && !DeclsFound && "Already computed the set of declarations"); - llvm::SetVector> Decls; + llvm::SmallSetVector Decls; for (paths_iterator Path = begin(), PathEnd = end(); Path != PathEnd; ++Path) Decls.insert(Path->Decls.front()); @@ -63,8 +63,8 @@ /// an unqualified, canonical class type. bool CXXBasePaths::isAmbiguous(CanQualType BaseType) { BaseType = BaseType.getUnqualifiedType(); - std::pair& Subobjects = ClassSubobjects[BaseType]; - return Subobjects.second + (Subobjects.first? 1 : 0) > 1; + IsVirtBaseAndNumberNonVirtBases Subobjects = ClassSubobjects[BaseType]; + return Subobjects.NumberOfNonVirtBases + (Subobjects.IsVirtBase ? 1 : 0) > 1; } /// clear - Clear out all prior path information. @@ -217,30 +217,30 @@ // Determine whether we need to visit this base class at all, // updating the count of subobjects appropriately. -std::pair& Subobjects = ClassSubobjects[BaseType]; +IsVirtBaseAndNumberNonVirtBases &Subobjects = ClassSubobjects[BaseType]; bool VisitBase = true; bool SetVirtual = false; if (BaseSpec.isVirtual()) { - VisitBase = !Subobjects.first; - Subobjects.first = true; + VisitBase = !Subobjects.IsVirtBase; + Subobjects.IsVirtBase = true; if (isDetectingVirtual() && DetectedVirtual == nullptr) { // If this is the first virtual we find, remember it. If it turns out // there is no base path here, we'll reset it later. DetectedVirtual = BaseType->getAs(); SetVirtual = true; } -} else - ++Subobjects.second; - +} else {
[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics
craig.topper added a comment. I'd prefer the pattern over inline assembly. It'll give us more flexibility in the backend if we should be using some other instruction on different targets. https://reviews.llvm.org/D49606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics
spatel added a comment. In https://reviews.llvm.org/D49606#1170278, @craig.topper wrote: > Here are the IR patterns for this that work. Not sure if we can do this > directly in C, we need a 128 bit type, but maybe we can emit it from > CGBuiltin.cpp? > > define i64 @__shiftleft128(i64 %x, i64 %y, i8 %amt) { > %a = zext i64 %x to i128 > %b = zext i64 %y to i128 > %c = shl i128 %b, 64 > %d = or i128 %a, %c > %amtmask = and i8 %amt, 63 > %e = zext i8 %amtmask to i128 > %f = shl i128 %d, %e > %g = lshr i128 %f, 64 > %h = trunc i128 %g to i64 > ret i64 %h > } > > define i64 @__shiftright128(i64 %x, i64 %y, i8 %amt) { > %a = zext i64 %x to i128 > %b = zext i64 %y to i128 > %c = shl i128 %b, 64 > %d = or i128 %a, %c > %amtmask = and i8 %amt, 63 > %e = zext i8 %amtmask to i128 > %f = lshr i128 %d, %e > %g = trunc i128 %f to i64 > ret i64 %g > } > I’m not at my dev machine, but this is exactly the definition of funnel shift, no? Unless that got reverted, adding/modifying clang builtins was the next step in the plan for those intrinsics. We probably need some backend work to match the variable shift version, but shift-by constant should already work. https://reviews.llvm.org/D49606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics
thakis updated this revision to Diff 156596. thakis edited the summary of this revision. https://reviews.llvm.org/D49606 Files: clang/lib/Headers/intrin.h clang/test/Headers/ms-intrin.cpp Index: clang/test/Headers/ms-intrin.cpp === --- clang/test/Headers/ms-intrin.cpp +++ clang/test/Headers/ms-intrin.cpp @@ -42,6 +42,8 @@ __stosw(0, 0, 0); #ifdef _M_X64 + __shiftleft128(1, 2, 3); + __shiftright128(1, 2, 3); __movsq(0, 0, 0); __stosq(0, 0, 0); #endif Index: clang/lib/Headers/intrin.h === --- clang/lib/Headers/intrin.h +++ clang/lib/Headers/intrin.h @@ -853,6 +853,20 @@ __asm__ volatile ("nop"); } #endif +#if defined(__x86_64__) +static __inline__ unsigned __int64 __DEFAULT_FN_ATTRS +__shiftleft128(unsigned __int64 __l, unsigned __int64 __h, unsigned char __d) { + unsigned __int128 __val = ((unsigned __int128)__h << 64) | __l; + unsigned __int128 __res = __val << (__d & 63); + return (unsigned __int64)(__res >> 64); +} +static __inline__ unsigned __int64 __DEFAULT_FN_ATTRS +__shiftright128(unsigned __int64 __l, unsigned __int64 __h, unsigned char __d) { + unsigned __int128 __val = ((unsigned __int128)__h << 64) | __l; + unsigned __int128 __res = __val >> (__d & 63); + return (unsigned __int64)__res; +} +#endif /**\ |* Privileged intrinsics Index: clang/test/Headers/ms-intrin.cpp === --- clang/test/Headers/ms-intrin.cpp +++ clang/test/Headers/ms-intrin.cpp @@ -42,6 +42,8 @@ __stosw(0, 0, 0); #ifdef _M_X64 + __shiftleft128(1, 2, 3); + __shiftright128(1, 2, 3); __movsq(0, 0, 0); __stosq(0, 0, 0); #endif Index: clang/lib/Headers/intrin.h === --- clang/lib/Headers/intrin.h +++ clang/lib/Headers/intrin.h @@ -853,6 +853,20 @@ __asm__ volatile ("nop"); } #endif +#if defined(__x86_64__) +static __inline__ unsigned __int64 __DEFAULT_FN_ATTRS +__shiftleft128(unsigned __int64 __l, unsigned __int64 __h, unsigned char __d) { + unsigned __int128 __val = ((unsigned __int128)__h << 64) | __l; + unsigned __int128 __res = __val << (__d & 63); + return (unsigned __int64)(__res >> 64); +} +static __inline__ unsigned __int64 __DEFAULT_FN_ATTRS +__shiftright128(unsigned __int64 __l, unsigned __int64 __h, unsigned char __d) { + unsigned __int128 __val = ((unsigned __int128)__h << 64) | __l; + unsigned __int128 __res = __val >> (__d & 63); + return (unsigned __int64)__res; +} +#endif /**\ |* Privileged intrinsics ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics
thakis added a comment. Now with C builtins which get nicely optimized. https://reviews.llvm.org/D49606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r337611 - [CStringSyntaxChecker] Fix build bot builds != x86 archs
Author: devnexen Date: Fri Jul 20 13:39:49 2018 New Revision: 337611 URL: http://llvm.org/viewvc/llvm-project?rev=337611&view=rev Log: [CStringSyntaxChecker] Fix build bot builds != x86 archs Reviewers: NoQ,george.karpenkov Reviewed By: NoQ Differential Revision: https://reviews.llvm.org/D49588 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp cfe/trunk/test/Analysis/cstring-syntax.c Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp?rev=337611&r1=337610&r2=337611&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp Fri Jul 20 13:39:49 2018 @@ -147,7 +147,7 @@ bool WalkAST::containsBadStrlcpyPattern( const Expr *DstArg = CE->getArg(0); const Expr *LenArg = CE->getArg(2); - const auto *DstArgDecl = dyn_cast(DstArg->IgnoreParenCasts()); + const auto *DstArgDecl = dyn_cast(DstArg->IgnoreParenImpCasts()); const auto *LenArgDecl = dyn_cast(LenArg->IgnoreParenLValueCasts()); // - size_t dstlen = sizeof(dst) if (LenArgDecl) { @@ -159,14 +159,15 @@ bool WalkAST::containsBadStrlcpyPattern( // - integral value // We try to figure out if the last argument is possibly longer // than the destination can possibly handle if its size can be defined - if (const auto *IL = dyn_cast(LenArg->IgnoreParenCasts())) { + if (const auto *IL = dyn_cast(LenArg->IgnoreParenImpCasts())) { uint64_t ILRawVal = IL->getValue().getZExtValue(); -if (const auto *Buffer = dyn_cast(DstArgDecl->getType())) { - ASTContext &C = BR.getContext(); - uint64_t Usize = C.getTypeSizeInChars(DstArg->getType()).getQuantity(); - uint64_t BufferLen = BR.getContext().getTypeSize(Buffer) / Usize; - if (BufferLen < ILRawVal) -return true; +if (DstArgDecl) { + if (const auto *Buffer = dyn_cast(DstArgDecl->getType())) { +ASTContext &C = BR.getContext(); +uint64_t BufferLen = C.getTypeSize(Buffer) / 8; +if (BufferLen < ILRawVal) + return true; + } } } Modified: cfe/trunk/test/Analysis/cstring-syntax.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cstring-syntax.c?rev=337611&r1=337610&r2=337611&view=diff == --- cfe/trunk/test/Analysis/cstring-syntax.c (original) +++ cfe/trunk/test/Analysis/cstring-syntax.c Fri Jul 20 13:39:49 2018 @@ -1,4 +1,7 @@ // RUN: %clang_analyze_cc1 -analyzer-checker=unix.cstring.BadSizeArg -analyzer-store=region -Wno-strncat-size -Wno-strlcpy-strlcat-size -Wno-sizeof-array-argument -Wno-sizeof-pointer-memaccess -verify %s +// RUN: %clang_analyze_cc1 -triple armv7-a15-linux -analyzer-checker=unix.cstring.BadSizeArg -analyzer-store=region -Wno-strncat-size -Wno-strlcpy-strlcat-size -Wno-sizeof-array-argument -Wno-sizeof-pointer-memaccess -verify %s +// RUN: %clang_analyze_cc1 -triple aarch64_be-none-linux-gnu -analyzer-checker=unix.cstring.BadSizeArg -analyzer-store=region -Wno-strncat-size -Wno-strlcpy-strlcat-size -Wno-sizeof-array-argument -Wno-sizeof-pointer-memaccess -verify %s +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -analyzer-checker=unix.cstring.BadSizeArg -analyzer-store=region -Wno-strncat-size -Wno-strlcpy-strlcat-size -Wno-sizeof-array-argument -Wno-sizeof-pointer-memaccess -verify %s typedef __SIZE_TYPE__ size_t; char *strncat(char *, const char *, size_t); @@ -27,4 +30,5 @@ void testStrlcpy(const char *src) { strlcpy(dest, src, 20); // expected-warning {{The third argument is larger than the size of the input buffer. Replace with the value 'sizeof(dest)` or lower}} strlcpy(dest, src, badlen); // expected-warning {{The third argument is larger than the size of the input buffer. Replace with the value 'sizeof(dest)` or lower}} strlcpy(dest, src, ulen); + strlcpy(dest + 5, src, 5); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r337612 - AMDGPU: Switch default dwarf version to 2
Author: kzhuravl Date: Fri Jul 20 13:46:25 2018 New Revision: 337612 URL: http://llvm.org/viewvc/llvm-project?rev=337612&view=rev Log: AMDGPU: Switch default dwarf version to 2 There were some problems unearthed with version 5, which I am going to look at. Differential Revision: https://reviews.llvm.org/D49613 Modified: cfe/trunk/lib/Driver/ToolChains/AMDGPU.h cfe/trunk/test/Driver/amdgpu-toolchain.c Modified: cfe/trunk/lib/Driver/ToolChains/AMDGPU.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/AMDGPU.h?rev=337612&r1=337611&r2=337612&view=diff == --- cfe/trunk/lib/Driver/ToolChains/AMDGPU.h (original) +++ cfe/trunk/lib/Driver/ToolChains/AMDGPU.h Fri Jul 20 13:46:25 2018 @@ -56,7 +56,7 @@ protected: public: AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args); - unsigned GetDefaultDwarfVersion() const override { return 5; } + unsigned GetDefaultDwarfVersion() const override { return 2; } bool IsIntegratedAssemblerDefault() const override { return true; } llvm::opt::DerivedArgList * TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch, Modified: cfe/trunk/test/Driver/amdgpu-toolchain.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/amdgpu-toolchain.c?rev=337612&r1=337611&r2=337612&view=diff == --- cfe/trunk/test/Driver/amdgpu-toolchain.c (original) +++ cfe/trunk/test/Driver/amdgpu-toolchain.c Fri Jul 20 13:46:25 2018 @@ -3,4 +3,4 @@ // AS_LINK: ld.lld{{.*}} "-shared" // RUN: %clang -### -g -target amdgcn--amdhsa -mcpu=kaveri %s 2>&1 | FileCheck -check-prefix=DWARF_VER %s -// DWARF_VER: "-dwarf-version=5" +// DWARF_VER: "-dwarf-version=2" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics
craig.topper added a comment. @spatel, yes its exactly funnel shift. I wasn't sure if we were ready for clang to create it yet or not. Can we let this go as is and change it to funnel shift once we have the variable case fixed in the backend? https://reviews.llvm.org/D49606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics
thakis added a comment. Isn't implementing this in plain old C the nicest approach anyhow, even once funnel shift exists? https://reviews.llvm.org/D49606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D15225: [Driver] Sanitizer support based on runtime library presence
george.karpenkov updated this revision to Diff 156603. https://reviews.llvm.org/D15225 Files: clang/lib/Driver/ToolChains/Darwin.cpp clang/lib/Driver/ToolChains/Darwin.h clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_ios_dynamic.dylib clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_iossim_dynamic.dylib clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_osx_dynamic.dylib clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_tvos_dynamic.dylib clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_tvossim_dynamic.dylib clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_watchos_dynamic.dylib clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.asan_watchossim_dynamic.dylib clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.fuzzer_osx.a clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.lsan_ios_dynamic.dylib clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.lsan_iossim_dynamic.dylib clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.lsan_osx_dynamic.dylib clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.lsan_tvossim_dynamic.dylib clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.tsan_iossim_dynamic.dylib clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.tsan_osx_dynamic.dylib clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.tsan_tvossim_dynamic.dylib clang/test/Driver/darwin-asan-nofortify.c clang/test/Driver/darwin-sanitizer-ld.c clang/test/Driver/fsanitize.c clang/test/Driver/fuzzer.c clang/test/Driver/sanitizer-ld.c Index: clang/test/Driver/sanitizer-ld.c === --- clang/test/Driver/sanitizer-ld.c +++ clang/test/Driver/sanitizer-ld.c @@ -530,6 +530,7 @@ // RUN: %clangxx -fsanitize=address %s -### -o %t.o 2>&1 \ // RUN: -mmacosx-version-min=10.6 \ +// RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -target x86_64-apple-darwin13.4.0 -fuse-ld=ld -stdlib=platform \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-ASAN-DARWIN106-CXX %s @@ -539,6 +540,7 @@ // RUN: %clangxx -fsanitize=leak %s -### -o %t.o 2>&1 \ // RUN: -mmacosx-version-min=10.6 \ +// RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -target x86_64-apple-darwin13.4.0 -fuse-ld=ld -stdlib=platform \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-LSAN-DARWIN106-CXX %s @@ -598,6 +600,7 @@ // RUN: %clang -fsanitize=cfi -fsanitize-stats %s -### -o %t.o 2>&1 \ // RUN: -target x86_64-apple-darwin -fuse-ld=ld \ +// RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-CFI-STATS-DARWIN %s // CHECK-CFI-STATS-DARWIN: "{{.*}}ld{{(.exe)?}}" Index: clang/test/Driver/fuzzer.c === --- clang/test/Driver/fuzzer.c +++ clang/test/Driver/fuzzer.c @@ -1,28 +1,28 @@ // Test flags inserted by -fsanitize=fuzzer. -// RUN: %clang -fsanitize=fuzzer %s -target x86_64-apple-darwin14 -### 2>&1 | FileCheck --check-prefixes=CHECK-FUZZER-LIB,CHECK-COVERAGE-FLAGS %s +// RUN: %clang -fsanitize=fuzzer %s -target x86_64-apple-darwin14 -resource-dir %S/Inputs/resource_dir -### 2>&1 | FileCheck --check-prefixes=CHECK-FUZZER-LIB,CHECK-COVERAGE-FLAGS %s // // CHECK-FUZZER-LIB: libclang_rt.fuzzer // CHECK-COVERAGE: -fsanitize-coverage-inline-8bit-counters // CHECK-COVERAGE-SAME: -fsanitize-coverage-indirect-calls // CHECK-COVERAGE-SAME: -fsanitize-coverage-trace-cmp // CHECK-COVERAGE-SAME: -fsanitize-coverage-pc-table -// RUN: %clang -fsanitize=fuzzer -target i386-unknown-linux -stdlib=platform %s -### 2>&1 | FileCheck --check-prefixes=CHECK-LIBCXX-LINUX %s +// RUN: %clang -fsanitize=fuzzer -target i386-unknown-linux -stdlib=platform -resource-dir %S/Inputs/resource_dir %s -### 2>&1 | FileCheck --check-prefixes=CHECK-LIBCXX-LINUX %s // // CHECK-LIBCXX-LINUX: -lstdc++ -// RUN: %clang -target x86_64-apple-darwin14 -fsanitize=fuzzer %s -### 2>&1 | FileCheck --check-prefixes=CHECK-LIBCXX-DARWIN %s +// RUN: %clang -target x86_64-apple-darwin14 -fsanitize=fuzzer -resource-dir %S/Inputs/resource_dir %s -### 2>&1 | FileCheck --check-prefixes=CHECK-LIBCXX-DARWIN %s // // CHECK-LIBCXX-DARWIN: -lc++ // Check that we don't link in libFuzzer.a when producing a shared object. -// RUN: %clang -fsanitize=fuzzer %s -shared -o %t.so -### 2>&1 | FileCheck --check-prefixes=CHECK-NOLIB-SO %s +// RUN: %clang -fsanitize=fuzzer %s -shared -o %t.so -resource-dir %S/Inputs/resource_dir -### 2>&1 | FileCheck --check-prefixes=CHECK-NOLIB-SO %s // CHECK-NOLIB-SO-NOT: libclang_rt.libfuzzer // Check that we don't link in libFuzzer when compiling with -fsanitize=fuzzer-no-link. -// RUN: %clang -fsani
[PATCH] D49508: [Sema] Mark implicitly-inserted ICE's as being part of explicit cast (PR38166)
rsmith added inline comments. Comment at: include/clang/AST/Stmt.h:206 +bool PartOfExplicitCast : 1; +unsigned BasePathSize : 32 - 6 - 1 - NumExprBits; }; lebedev.ri wrote: > rjmccall wrote: > > lebedev.ri wrote: > > > rjmccall wrote: > > > > This needs to be serialized. > > > Uhm, could you please explain what do you mean by 'serialized'? > > It needs to be preserved when writing an ICE into a PCH / module file. See > > the ASTWriter / ASTReader. > Aha. I did add handling there but it raises questions: > # This will silently break with different AST serialization versions. > I'm not sure how to handle it, since `VERSION_MINOR` isn't even read > back. > # //Does// this need a test? How to write one? > Like `./test/PCH/include-timestamp.cpp`, using `llvm-bcanalyzer`? Don't worry about breaking the serialization format. We do not maintain AST file format compatibility in general (neither between major releases nor between any two arbitrary SVN revisions). [We should probably maintain file format compatibility between patch releases, but I don't think that works right now because we check the full version number including the patch level when reading a file.] Please do add a test: what you need to do is create a PCH containing an implicit cast expression and then import that AST file and do anything to check that the value is preserved (such as inspecting the output of `-ast-dump`). Maybe you could add this to the existing `test/PCH/cxx_exprs.cpp` test, which already does most of what you want, but doesn't have any `FileCheck` tests on the `-ast-dump` output yet. Comment at: lib/AST/ASTDumper.cpp:2122 + if (Node->getIsPartOfExplicitCast()) +OS << " PartOfExplicitCast"; } Our predominant convention is to use lower_snake_case for such things in `-ast-dump` (though we're not exactly consistent on this...) Comment at: lib/Sema/SemaCast.cpp:94-101 +void updatePartOfExplicitCastFlags(CastExpr *CE) { + // Walk down from the CE to the OrigSrcExpr, and mark all immediate + // ImplicitCastExpr's as being part of ExplicitCastExpr. The original CE + // (which is a ExplicitCastExpr), and the OrigSrcExpr are not touched. + while (OrigSrcExpr.get() != CE->getSubExpr() && + (CE = dyn_cast(CE->getSubExpr( +CE->setIsPartOfExplicitCast(true); You don't need to track the `OrigSrcExpr` here. You can just recurse down through all the `ImplicitCastExpr`s (they're always all notionally part of the explicit cast). Repository: rC Clang https://reviews.llvm.org/D49508 ___ 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
[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics
craig.topper added a comment. The only weird thing that I can really think of with the C version is that the 'and' on the shift amount might get hoisted out of a loop and not get dropped during isel. https://reviews.llvm.org/D49606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49523: [clangd] Add support for per-file override compilation command
arphaman added a comment. In https://reviews.llvm.org/D49523#1169728, @malaperle wrote: > In https://reviews.llvm.org/D49523#1169000, @arphaman wrote: > > > In https://reviews.llvm.org/D49523#1167553, @malaperle wrote: > > > > > Interesting! We also have a need for passing compilation commands in a > > > context where there is no compile_commands.json, but we were thinking of > > > putting this in a "didChangeConfiguration" message so that all the > > > commands would be available even before files are opened. This would be > > > allow Clangd to have the necessary information for background indexing > > > which would include unopened files. Subsequent changes to compilation > > > commands would probably go through a similar didChangeConfiguration and > > > the appropriate (opened) files would get reparsed (not unlike > > > https://reviews.llvm.org/D49267). I'm making a few guesses here: I assume > > > that in the context of XCode, you would not do background indexing in > > > Clangd but let XCode do it as it can also coordinate (and not overlap) > > > with build tasks. Is that correct? In any case, I think the approach in > > > the patch is not incompatible with what we had in mind, i.e. we could > > > also reuse "overrideCompilationCommandForFile" for each file specified in > > > didChangeConfiguration. I'm point this out because if you *do* end up > > > needing all the compilation commands beforehand like I mentioned, then > > > maybe we can skip the approach of specifying them with didOpen and send > > > them all with didChangeConfiguration from start. > > > > > > Thanks for your response, > > As it stands right now we will not run the indexer in Clangd for our use > > case, and it's unclear if we can even assemble a set of compile commands, > > so we would like to provide the commands when a file is open. We might be > > interested in a "didChangeConfiguration" message extension in the future > > (ideally it would be possible to change the subset of the constructed > > compilation database). > > > Sounds good, I think sending it in didOpen makes sense then. And yes, I agree > that we would need to support changing a subset of commands through > didChangeConfiguration, eventually! > > In https://reviews.llvm.org/D49523#1169620, @jkorous wrote: > > > Hi Marc-Andre, what is a structure of data you are passing as parameter of > > didChangeConfiguration message? > > > We don't yet :) But we will need to send the information per-file through it > instead of using the compile_commands.json. Right now, what is supported in > the didChangeConfiguration is pointing to a different compile_commands.json, > in order to support multiple configuration (actually pointing to the folder > containing the json file). > > > All we need is to pass per-file compilation command to clangd. Maybe we > > could send didChangeConfiguration message right after didOpen. > > > > EDIT: Well, provided we would find a way how not to parse the file twice. > > The idea would be to send the per-file commands to clangd *before* anything > is opened. So the didOpen would just read the latest command in memory. And > subsequent changes to commands would be communicated with > didChangeConfiguration and then files would get reparsed. I'm actually > thinking we might want to send the commands in the "initialize" request for > all the initial commands and then update them with didChangeConfiguration > whenever they change. That way, there is no risk for reparsing as we should > not do anything (indexing!) before the initialize. > But it doesn't sounds like you need this right now :) I reconsidered our needs. We would actually want to use the 'didChangeConfiguration' extension right now as well. I will work on a patch for it that is based on top of this one :) Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D49523 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics
craig.topper accepted this revision. craig.topper added a comment. This revision is now accepted and ready to land. LGTM. I'm inclined to let this go in now since we have a requested use for it. We can change it to funnel shift once we're confident in the backend. https://reviews.llvm.org/D49606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49606: [ms] Add __shiftleft128 / __shiftright128 intrinsics
spatel added a comment. In https://reviews.llvm.org/D49606#1170448, @thakis wrote: > Isn't implementing this in plain old C the nicest approach anyhow, even once > funnel shift exists? No, the primary reason for creating the intrinsic is that we can’t guarantee that we’ll recognize the pattern as ‘shld’ or ‘rotate’ in this C/IR form. That’s because the pattern can get split across basic blocks, so the backend can’t easily recognize it. Also, IIUC this patch only deals with the specific case of 64-bit values, so we still don’t have the functionality for other widths? I don’t object if this helps that one case, but we have made the investment in the IR intrinsics, so using them should be the general direction/goal. https://reviews.llvm.org/D49606 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r337619 - [ms] Add __shiftleft128 / __shiftright128 intrinsics
Author: nico Date: Fri Jul 20 14:02:09 2018 New Revision: 337619 URL: http://llvm.org/viewvc/llvm-project?rev=337619&view=rev Log: [ms] Add __shiftleft128 / __shiftright128 intrinsics Carefully match the pattern matched by ISel so that this produces shld / shrd (unless Subtarget->isSHLDSlow() is true). Thanks to Craig Topper for providing the LLVM IR pattern that gets successfully matched. Fixes PR37755. Modified: cfe/trunk/lib/Headers/intrin.h cfe/trunk/test/Headers/ms-intrin.cpp Modified: cfe/trunk/lib/Headers/intrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=337619&r1=337618&r2=337619&view=diff == --- cfe/trunk/lib/Headers/intrin.h (original) +++ cfe/trunk/lib/Headers/intrin.h Fri Jul 20 14:02:09 2018 @@ -863,6 +863,20 @@ __nop(void) { __asm__ volatile ("nop"); } #endif +#if defined(__x86_64__) +static __inline__ unsigned __int64 __DEFAULT_FN_ATTRS +__shiftleft128(unsigned __int64 __l, unsigned __int64 __h, unsigned char __d) { + unsigned __int128 __val = ((unsigned __int128)__h << 64) | __l; + unsigned __int128 __res = __val << (__d & 63); + return (unsigned __int64)(__res >> 64); +} +static __inline__ unsigned __int64 __DEFAULT_FN_ATTRS +__shiftright128(unsigned __int64 __l, unsigned __int64 __h, unsigned char __d) { + unsigned __int128 __val = ((unsigned __int128)__h << 64) | __l; + unsigned __int128 __res = __val >> (__d & 63); + return (unsigned __int64)__res; +} +#endif /**\ |* Privileged intrinsics Modified: cfe/trunk/test/Headers/ms-intrin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/ms-intrin.cpp?rev=337619&r1=337618&r2=337619&view=diff == --- cfe/trunk/test/Headers/ms-intrin.cpp (original) +++ cfe/trunk/test/Headers/ms-intrin.cpp Fri Jul 20 14:02:09 2018 @@ -42,6 +42,8 @@ void f() { __stosw(0, 0, 0); #ifdef _M_X64 + __shiftleft128(1, 2, 3); + __shiftright128(1, 2, 3); __movsq(0, 0, 0); __stosq(0, 0, 0); #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits