[PATCH] D151190: [clangd] Do not end inactiveRegions range at position 0 of line
nridge updated this revision to Diff 528189. nridge marked 3 inline comments as done. nridge added a comment. Herald added a subscriber: mgrang. Address review comments Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151190/new/ https://reviews.llvm.org/D151190 Files: clang-tools-extra/clangd/ClangdServer.cpp clang-tools-extra/clangd/SemanticHighlighting.cpp clang-tools-extra/clangd/SemanticHighlighting.h clang-tools-extra/clangd/SourceCode.cpp clang-tools-extra/clangd/SourceCode.h clang-tools-extra/clangd/unittests/ClangdTests.cpp clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp === --- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp +++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp @@ -450,11 +450,11 @@ #define $Macro_decl[[test]] #undef $Macro[[test]] -$InactiveCode[[#ifdef test]] -$InactiveCode[[#endif]] + #ifdef $Macro[[test]] + #endif -$InactiveCode[[#if defined(test)]] -$InactiveCode[[#endif]] + #if defined($Macro[[test]]) + #endif )cpp", R"cpp( struct $Class_def[[S]] { @@ -561,8 +561,9 @@ R"cpp( // Code in the preamble. // Inactive lines get an empty InactiveCode token at the beginning. -$InactiveCode[[#ifdef test]] -$InactiveCode[[#endif]] + #ifdef $Macro[[test]] +$InactiveCode[[int Inactive1;]] + #endif // A declaration to cause the preamble to end. int $Variable_def[[EndPreamble]]; @@ -571,21 +572,21 @@ // Code inside inactive blocks does not get regular highlightings // because it's not part of the AST. #define $Macro_decl[[test2]] -$InactiveCode[[#if defined(test)]] + #if defined($Macro[[test]]) $InactiveCode[[int Inactive2;]] -$InactiveCode[[#elif defined(test2)]] + #elif defined($Macro[[test2]]) int $Variable_def[[Active1]]; -$InactiveCode[[#else]] + #else $InactiveCode[[int Inactive3;]] -$InactiveCode[[#endif]] + #endif #ifndef $Macro[[test]] int $Variable_def[[Active2]]; #endif -$InactiveCode[[#ifdef test]] + #ifdef $Macro[[test]] $InactiveCode[[int Inactive4;]] -$InactiveCode[[#else]] + #else int $Variable_def[[Active3]]; #endif )cpp", Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp === --- clang-tools-extra/clangd/unittests/ClangdTests.cpp +++ clang-tools-extra/clangd/unittests/ClangdTests.cpp @@ -1332,26 +1332,31 @@ #define PREAMBLEMACRO 42 #if PREAMBLEMACRO > 40 #define ACTIVE -$inactive1[[#else - #define INACTIVE -#endif]] +#else +$inactive1[[ #define INACTIVE]] +#endif int endPreamble; -$inactive2[[#ifndef CMDMACRO -int inactiveInt; -#endif]] +#ifndef CMDMACRO +$inactive2[[int inactiveInt;]] +#endif #undef CMDMACRO -$inactive3[[#ifdef CMDMACRO - int inactiveInt2; -#else]] - int activeInt; +#ifdef CMDMACRO +$inactive3[[ int inactiveInt2;]] +#elif PREAMBLEMACRO > 0 + int activeInt1; + int activeInt2; +#else +$inactive4[[ int inactiveInt3;]] #endif +#ifdef CMDMACRO +#endif // empty inactive range, gets dropped )cpp"); Server.addDocument(testPath("foo.cpp"), Source.code()); ASSERT_TRUE(Server.blockUntilIdleForTest()); EXPECT_THAT(Callback.FoundInactiveRegions, - ElementsAre(ElementsAre(Source.range("inactive1"), - Source.range("inactive2"), - Source.range("inactive3"; + ElementsAre(ElementsAre( + Source.range("inactive1"), Source.range("inactive2"), + Source.range("inactive3"), Source.range("inactive4"; } } // namespace Index: clang-tools-extra/clangd/SourceCode.h === --- clang-tools-extra/clangd/SourceCode.h +++ clang-tools-extra/clangd/SourceCode.h @@ -72,6 +72,9 @@ /// FIXME: This should return an error if the location is invalid. Position sourceLocToPosition(const SourceManager &SM, SourceLocation Loc); +/// Get the last Position on a given line. +llvm::Expected endOfLine(llvm::StringRef Code, int Line); + /// Return the file location, corresponding to \p P. Note that one should take /// care to avoid comparing the result with expansion locations. llvm::Expected sourceLocationInMainFile(const SourceManager &SM, Index: clang-tools-extra/clangd/SourceCode.cpp === --- clang-tools-extra/clangd/SourceCode.cpp +++ clang-tools-extra/clangd/SourceCode.cpp @@ -228,6 +228,16 @@ return P; } +llvm::Expected endOfLine(llvm::StringRef Code, int Line) { + auto StartOfLine = positionToOffset(Code, Position{Line, 0}); + if (!StartOfLine) +return Start
[PATCH] D151190: [clangd] Do not end inactiveRegions range at position 0 of line
nridge updated this revision to Diff 528190. nridge added a comment. Add comment Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151190/new/ https://reviews.llvm.org/D151190 Files: clang-tools-extra/clangd/ClangdServer.cpp clang-tools-extra/clangd/SemanticHighlighting.cpp clang-tools-extra/clangd/SemanticHighlighting.h clang-tools-extra/clangd/SourceCode.cpp clang-tools-extra/clangd/SourceCode.h clang-tools-extra/clangd/unittests/ClangdTests.cpp clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp === --- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp +++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp @@ -450,11 +450,11 @@ #define $Macro_decl[[test]] #undef $Macro[[test]] -$InactiveCode[[#ifdef test]] -$InactiveCode[[#endif]] + #ifdef $Macro[[test]] + #endif -$InactiveCode[[#if defined(test)]] -$InactiveCode[[#endif]] + #if defined($Macro[[test]]) + #endif )cpp", R"cpp( struct $Class_def[[S]] { @@ -561,8 +561,9 @@ R"cpp( // Code in the preamble. // Inactive lines get an empty InactiveCode token at the beginning. -$InactiveCode[[#ifdef test]] -$InactiveCode[[#endif]] + #ifdef $Macro[[test]] +$InactiveCode[[int Inactive1;]] + #endif // A declaration to cause the preamble to end. int $Variable_def[[EndPreamble]]; @@ -571,21 +572,21 @@ // Code inside inactive blocks does not get regular highlightings // because it's not part of the AST. #define $Macro_decl[[test2]] -$InactiveCode[[#if defined(test)]] + #if defined($Macro[[test]]) $InactiveCode[[int Inactive2;]] -$InactiveCode[[#elif defined(test2)]] + #elif defined($Macro[[test2]]) int $Variable_def[[Active1]]; -$InactiveCode[[#else]] + #else $InactiveCode[[int Inactive3;]] -$InactiveCode[[#endif]] + #endif #ifndef $Macro[[test]] int $Variable_def[[Active2]]; #endif -$InactiveCode[[#ifdef test]] + #ifdef $Macro[[test]] $InactiveCode[[int Inactive4;]] -$InactiveCode[[#else]] + #else int $Variable_def[[Active3]]; #endif )cpp", Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp === --- clang-tools-extra/clangd/unittests/ClangdTests.cpp +++ clang-tools-extra/clangd/unittests/ClangdTests.cpp @@ -1332,26 +1332,31 @@ #define PREAMBLEMACRO 42 #if PREAMBLEMACRO > 40 #define ACTIVE -$inactive1[[#else - #define INACTIVE -#endif]] +#else +$inactive1[[ #define INACTIVE]] +#endif int endPreamble; -$inactive2[[#ifndef CMDMACRO -int inactiveInt; -#endif]] +#ifndef CMDMACRO +$inactive2[[int inactiveInt;]] +#endif #undef CMDMACRO -$inactive3[[#ifdef CMDMACRO - int inactiveInt2; -#else]] - int activeInt; +#ifdef CMDMACRO +$inactive3[[ int inactiveInt2;]] +#elif PREAMBLEMACRO > 0 + int activeInt1; + int activeInt2; +#else +$inactive4[[ int inactiveInt3;]] #endif +#ifdef CMDMACRO +#endif // empty inactive range, gets dropped )cpp"); Server.addDocument(testPath("foo.cpp"), Source.code()); ASSERT_TRUE(Server.blockUntilIdleForTest()); EXPECT_THAT(Callback.FoundInactiveRegions, - ElementsAre(ElementsAre(Source.range("inactive1"), - Source.range("inactive2"), - Source.range("inactive3"; + ElementsAre(ElementsAre( + Source.range("inactive1"), Source.range("inactive2"), + Source.range("inactive3"), Source.range("inactive4"; } } // namespace Index: clang-tools-extra/clangd/SourceCode.h === --- clang-tools-extra/clangd/SourceCode.h +++ clang-tools-extra/clangd/SourceCode.h @@ -72,6 +72,9 @@ /// FIXME: This should return an error if the location is invalid. Position sourceLocToPosition(const SourceManager &SM, SourceLocation Loc); +/// Get the last Position on a given line. +llvm::Expected endOfLine(llvm::StringRef Code, int Line); + /// Return the file location, corresponding to \p P. Note that one should take /// care to avoid comparing the result with expansion locations. llvm::Expected sourceLocationInMainFile(const SourceManager &SM, Index: clang-tools-extra/clangd/SourceCode.cpp === --- clang-tools-extra/clangd/SourceCode.cpp +++ clang-tools-extra/clangd/SourceCode.cpp @@ -228,6 +228,16 @@ return P; } +llvm::Expected endOfLine(llvm::StringRef Code, int Line) { + auto StartOfLine = positionToOffset(Code, Position{Line, 0}); + if (!StartOfLine) +return StartOfLine.takeError(); + StringRef LineText = Code.drop_front(*StartOfLine).take_until([](
[PATCH] D119711: Add asan support for MSVC debug runtimes
DanWillans added a comment. Herald added a subscriber: MaskRay. Herald added a project: All. Hi all, Has there been any progress on this? I want to run clang-tidy on some code being compiled in debug with MSVC but I hit the clang-diagnostic-error note 'D.Diag(clang::diag::note_drv_address_sanitizer_debug_runtime)'. Later versions of MSVC support ASan with debug runtime now Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D119711/new/ https://reviews.llvm.org/D119711 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D152093: [clang][Analysis] Handle && and || against variable and its negation as tautology
hazohelet created this revision. hazohelet added reviewers: aaron.ballman, tbaeder, erichkeane. Herald added a reviewer: NoQ. Herald added a project: All. hazohelet requested review of this revision. Herald added a project: clang. This patch introduces a new warning flag `-Wtautological-negation-compare` grouped in `-Wtautological-compare` that warns on the use of `&&` or `||` operators against a variable and its negation. e.g. `x || !x` and `!x && x` This also makes the `-Winfinite-recursion` diagnose more cases. Fixes https://github.com/llvm/llvm-project/issues/56035 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D152093 Files: clang/docs/ReleaseNotes.rst clang/include/clang/Analysis/CFG.h clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/Analysis/CFG.cpp clang/lib/Sema/AnalysisBasedWarnings.cpp clang/test/Analysis/temp-obj-dtors-cfg-output.cpp clang/test/Misc/warning-wall.c clang/test/SemaCXX/tautological-negation-compare.cpp clang/test/SemaCXX/warn-infinite-recursion.cpp Index: clang/test/SemaCXX/warn-infinite-recursion.cpp === --- clang/test/SemaCXX/warn-infinite-recursion.cpp +++ clang/test/SemaCXX/warn-infinite-recursion.cpp @@ -203,3 +203,13 @@ (void)typeid(unevaluated_recursive_function()); return 0; } + +void func1(int i) { // expected-warning {{call itself}} + if (i || !i) +func1(i); +} +void func2(int i) { // expected-warning {{call itself}} + if (!i && i) {} + else +func2(i); +} Index: clang/test/SemaCXX/tautological-negation-compare.cpp === --- /dev/null +++ clang/test/SemaCXX/tautological-negation-compare.cpp @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wtautological-negation-compare -Wno-constant-logical-operand %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wtautological-compare -Wno-constant-logical-operand %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wall -Wno-unused -Wno-loop-analysis -Wno-constant-logical-operand %s + +#define COPY(x) x + +void test_int(int x) { + if (x || !x) {} // expected-warning {{'||' against a variable and its negation always evaluates to true}} + if (!x || x) {} // expected-warning {{'||' against a variable and its negation always evaluates to true}} + if (x && !x) {} // expected-warning {{'&&' against a variable and its negation always evaluates to false}} + if (!x && x) {} // expected-warning {{'&&' against a variable and its negation always evaluates to false}} + + // parentheses are ignored + if (x || (!x)) {} // expected-warning {{'||' against a variable and its negation always evaluates to true}} + if (!(x) || x) {} // expected-warning {{'||' against a variable and its negation always evaluates to true}} + + // don't warn on macros + if (COPY(x) || !x) {} + if (!x || COPY(x)) {} + if (x && COPY(!x)) {} + if (COPY(!x && x)) {} + + // dont' warn on literals + if (1 || !1) {} + if (!42 && 42) {} + + + // don't warn on overloads + struct Foo{ +int val; +Foo operator!() const { return Foo{!val}; } +bool operator||(const Foo other) const { return val || other.val; } +bool operator&&(const Foo other) const { return val && other.val; } + }; + + Foo f{3}; + if (f || !f) {} + if (!f || f) {} + if (f.val || !f.val) {} // expected-warning {{'||' against a variable and its negation always evaluates to true}} + if (!f.val && f.val) {} // expected-warning {{'&&' against a variable and its negation always evaluates to false}} +} Index: clang/test/Misc/warning-wall.c === --- clang/test/Misc/warning-wall.c +++ clang/test/Misc/warning-wall.c @@ -55,6 +55,7 @@ CHECK-NEXT: -Wtautological-bitwise-compare CHECK-NEXT: -Wtautological-undefined-compare CHECK-NEXT: -Wtautological-objc-bool-compare +CHECK-NEXT: -Wtautological-negation-compare CHECK-NEXT:-Wtrigraphs CHECK-NEXT:-Wuninitialized CHECK-NEXT: -Wsometimes-uninitialized Index: clang/test/Analysis/temp-obj-dtors-cfg-output.cpp === --- clang/test/Analysis/temp-obj-dtors-cfg-output.cpp +++ clang/test/Analysis/temp-obj-dtors-cfg-output.cpp @@ -1393,13 +1393,13 @@ // CHECK: Succs (2): B2 B1 // CHECK: [B4 (NORETURN)] // CHECK: 1: ~NoReturn() (Temporary object destructor) -// CHECK: Preds (1): B5 +// CHECK: Preds (1): B5(Unreachable) // CHECK: Succs (1): B0 // CHECK: [B5] // CHECK: 1: [B8.3] || [B7.2] || [B6.7] // CHECK: T: (Temp Dtor) [B6.4] // CHECK: Preds (3): B6 B7 B8 -// CHECK: Succs (2): B4 B3 +// CHECK: Succs (2): B4(Unreachable) B3 // CHECK: [B6] // CHECK: 1: check // CHECK: 2: [B6.1] (ImplicitCastExpr, FunctionToPointerDecay, _Bool (*)(const NoReturn &)) Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
[PATCH] D151094: [clang] Implement P2564 "consteval must propagate up"
cor3ntin updated this revision to Diff 528205. cor3ntin added a comment. Remove missed and useless llvm:: specifier Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151094/new/ https://reviews.llvm.org/D151094 Files: clang/docs/ReleaseNotes.rst clang/include/clang/AST/Decl.h clang/include/clang/AST/DeclBase.h clang/include/clang/AST/Expr.h clang/include/clang/AST/Stmt.h clang/include/clang/Basic/DiagnosticSemaKinds.td clang/include/clang/Sema/ScopeInfo.h clang/include/clang/Sema/Sema.h clang/lib/AST/ASTImporter.cpp clang/lib/AST/Decl.cpp clang/lib/AST/DeclPrinter.cpp clang/lib/AST/Expr.cpp clang/lib/AST/ExprConstant.cpp clang/lib/AST/TextNodeDumper.cpp clang/lib/AST/VTableBuilder.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/Frontend/InitPreprocessor.cpp clang/lib/Parse/ParseDeclCXX.cpp clang/lib/Sema/ScopeInfo.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaLambda.cpp clang/lib/Sema/SemaStmt.cpp clang/lib/Sema/SemaTemplateDeduction.cpp clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterDecl.cpp clang/lib/Serialization/ASTWriterStmt.cpp clang/test/CodeGenCXX/cxx20-consteval-crash.cpp clang/test/SemaCXX/cxx2a-consteval-default-params.cpp clang/test/SemaCXX/cxx2a-consteval.cpp clang/test/SemaCXX/cxx2b-consteval-propagate.cpp clang/www/cxx_status.html Index: clang/www/cxx_status.html === --- clang/www/cxx_status.html +++ clang/www/cxx_status.html @@ -363,7 +363,7 @@ consteval needs to propagate up https://wg21.link/P2564R3";>P2564R3 (DR) - No + Clang 17 Lifetime extension in range-based for loops Index: clang/test/SemaCXX/cxx2b-consteval-propagate.cpp === --- /dev/null +++ clang/test/SemaCXX/cxx2b-consteval-propagate.cpp @@ -0,0 +1,152 @@ +// RUN: %clang_cc1 -std=c++2a -emit-llvm-only -Wno-unused-value %s -verify +// RUN: %clang_cc1 -std=c++2b -emit-llvm-only -Wno-unused-value %s -verify + +consteval int id(int i) { return i; } +constexpr char id(char c) { return c; } + +template +constexpr int f(T t) { // expected-note {{declared here}} +return t + id(t); // expected-note 2{{'f' is an immediate function because its body contains a call to a consteval function 'id' and that call is not a constant expression}} +} + +namespace examples { + +auto a = &f; // ok, f is not an immediate function +auto b = &f; // expected-error {{cannot take address of immediate function 'f' outside of an immediate invocation}} + +static_assert(f(3) == 6); // ok + +template +constexpr int g(T t) {// g is not an immediate function +return t + id(42);// because id(42) is already a constant +} + +template +constexpr bool is_not(T t, F f) { +return not f(t); +} + +consteval bool is_even(int i) { return i % 2 == 0; } + +static_assert(is_not(5, is_even)); + +int x = 0; // expected-note {{declared here}} + +template +constexpr T h(T t = id(x)) { // expected-note {{read of non-const variable 'x' is not allowed in a constant expression}} \ + // expected-note {{'hh' is an immediate function because its body contains a call to a consteval function 'id' and that call is not a constant expression}} +return t; +} + +template +constexpr T hh() { // hh is an immediate function +return h(); +} + +int i = hh(); // expected-error {{call to immediate function 'examples::hh' is not a constant expression}} \ + // expected-note {{in call to 'hh()'}} + +struct A { + int x; + int y = id(x); +}; + +template +constexpr int k(int) { + return A(42).y; +} + +} + +namespace nested { + +template +constexpr int fdupe(T t) { +return id(t); +} + +struct a { + constexpr a(int) { } +}; + +a aa(fdupe((f(7; + +template +constexpr int foo(T t); // expected-note {{declared here}} + +a bb(f(foo(7))); // expected-error{{call to immediate function 'f' is not a constant expression}} \ + // expected-note{{undefined function 'foo' cannot be used in a constant expression}} + +} + +namespace e2{ +template +constexpr int f(T t); +auto a = &f; +auto b = &f; +} + +namespace forward_declare_constexpr{ +template +constexpr int f(T t); + +auto a = &f; +auto b = &f; + +template +constexpr int f(T t) { +return id(0); +} +} + +namespace forward_declare_consteval{ +template +constexpr int f(T t); // expected-note {{'f' defined here}} + +auto a = &f; +auto b = &f; // expected-error {{immediate function 'f' used before it is defined}} \ + // expected-note {{in instantiation of function template specialization}} + +template +constexpr int f(T t) { +return id(t); // expected-note {{'f' is an immediate function because its body contains a call to a consteva
[clang] e8bd2a5 - [clang][CodeGen] Break up TargetInfo.cpp [6/8]
Author: Sergei Barannikov Date: 2023-06-04T14:35:32+03:00 New Revision: e8bd2a57849e1c193341db99186abb903eb9579d URL: https://github.com/llvm/llvm-project/commit/e8bd2a57849e1c193341db99186abb903eb9579d DIFF: https://github.com/llvm/llvm-project/commit/e8bd2a57849e1c193341db99186abb903eb9579d.diff LOG: [clang][CodeGen] Break up TargetInfo.cpp [6/8] Make `qualifyWindowsLibrary` and `addStackProbeTargetAttributes` protected members of `TargetCodeGenInfo`. These are helper functions used by `getDependentLibraryOption` and `setTargetAttributes` methods when targeting Windows. The change will allow these functions to be reused after splitting `TargetInfo.cpp`. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D150178 Added: Modified: clang/lib/CodeGen/TargetInfo.cpp clang/lib/CodeGen/TargetInfo.h Removed: diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 3d56d0e0b0128..fb0a7158d1a39 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -2543,6 +2543,7 @@ class X86_64TargetCodeGenInfo : public TargetCodeGenInfo { const FunctionDecl *Callee, const CallArgList &Args) const override; }; +} // namespace static void initFeatureMaps(const ASTContext &Ctx, llvm::StringMap &CallerMap, @@ -2641,7 +2642,7 @@ void X86_64TargetCodeGenInfo::checkFunctionCallABI( } } -static std::string qualifyWindowsLibrary(llvm::StringRef Lib) { +std::string TargetCodeGenInfo::qualifyWindowsLibrary(StringRef Lib) { // If the argument does not end in .lib, automatically add the suffix. // If the argument contains a space, enclose it in quotes. // This matches the behavior of MSVC. @@ -2654,6 +2655,7 @@ static std::string qualifyWindowsLibrary(llvm::StringRef Lib) { return ArgStr; } +namespace { class WinX86_32TargetCodeGenInfo : public X86_32TargetCodeGenInfo { public: WinX86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, @@ -2677,11 +2679,11 @@ class WinX86_32TargetCodeGenInfo : public X86_32TargetCodeGenInfo { Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\""; } }; +} // namespace -static void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV, - CodeGen::CodeGenModule &CGM) { +void TargetCodeGenInfo::addStackProbeTargetAttributes( +const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const { if (llvm::Function *Fn = dyn_cast_or_null(GV)) { - if (CGM.getCodeGenOpts().StackProbeSize != 4096) Fn->addFnAttr("stack-probe-size", llvm::utostr(CGM.getCodeGenOpts().StackProbeSize)); @@ -2698,6 +2700,7 @@ void WinX86_32TargetCodeGenInfo::setTargetAttributes( addStackProbeTargetAttributes(D, GV, CGM); } +namespace { class WinX86_64TargetCodeGenInfo : public TargetCodeGenInfo { public: WinX86_64TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, @@ -2736,6 +2739,7 @@ class WinX86_64TargetCodeGenInfo : public TargetCodeGenInfo { Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\""; } }; +} // namespace void WinX86_64TargetCodeGenInfo::setTargetAttributes( const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const { @@ -2753,7 +2757,6 @@ void WinX86_64TargetCodeGenInfo::setTargetAttributes( addStackProbeTargetAttributes(D, GV, CGM); } -} void X86_64ABIInfo::postMerge(unsigned AggregateSize, Class &Lo, Class &Hi) const { diff --git a/clang/lib/CodeGen/TargetInfo.h b/clang/lib/CodeGen/TargetInfo.h index 7637e55ccf410..933a352595120 100644 --- a/clang/lib/CodeGen/TargetInfo.h +++ b/clang/lib/CodeGen/TargetInfo.h @@ -398,6 +398,12 @@ class TargetCodeGenInfo { virtual llvm::Type *getOpenCLType(CodeGenModule &CGM, const Type *T) const { return nullptr; } + +protected: + static std::string qualifyWindowsLibrary(StringRef Lib); + + void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV, + CodeGen::CodeGenModule &CGM) const; }; } // namespace CodeGen ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D150178: [clang][CodeGen] Break up TargetInfo.cpp [6/8]
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGe8bd2a57849e: [clang][CodeGen] Break up TargetInfo.cpp [6/8] (authored by barannikov88). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D150178/new/ https://reviews.llvm.org/D150178 Files: clang/lib/CodeGen/TargetInfo.cpp clang/lib/CodeGen/TargetInfo.h Index: clang/lib/CodeGen/TargetInfo.h === --- clang/lib/CodeGen/TargetInfo.h +++ clang/lib/CodeGen/TargetInfo.h @@ -398,6 +398,12 @@ virtual llvm::Type *getOpenCLType(CodeGenModule &CGM, const Type *T) const { return nullptr; } + +protected: + static std::string qualifyWindowsLibrary(StringRef Lib); + + void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV, + CodeGen::CodeGenModule &CGM) const; }; } // namespace CodeGen Index: clang/lib/CodeGen/TargetInfo.cpp === --- clang/lib/CodeGen/TargetInfo.cpp +++ clang/lib/CodeGen/TargetInfo.cpp @@ -2543,6 +2543,7 @@ const FunctionDecl *Callee, const CallArgList &Args) const override; }; +} // namespace static void initFeatureMaps(const ASTContext &Ctx, llvm::StringMap &CallerMap, @@ -2641,7 +2642,7 @@ } } -static std::string qualifyWindowsLibrary(llvm::StringRef Lib) { +std::string TargetCodeGenInfo::qualifyWindowsLibrary(StringRef Lib) { // If the argument does not end in .lib, automatically add the suffix. // If the argument contains a space, enclose it in quotes. // This matches the behavior of MSVC. @@ -2654,6 +2655,7 @@ return ArgStr; } +namespace { class WinX86_32TargetCodeGenInfo : public X86_32TargetCodeGenInfo { public: WinX86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, @@ -2677,11 +2679,11 @@ Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\""; } }; +} // namespace -static void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV, - CodeGen::CodeGenModule &CGM) { +void TargetCodeGenInfo::addStackProbeTargetAttributes( +const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const { if (llvm::Function *Fn = dyn_cast_or_null(GV)) { - if (CGM.getCodeGenOpts().StackProbeSize != 4096) Fn->addFnAttr("stack-probe-size", llvm::utostr(CGM.getCodeGenOpts().StackProbeSize)); @@ -2698,6 +2700,7 @@ addStackProbeTargetAttributes(D, GV, CGM); } +namespace { class WinX86_64TargetCodeGenInfo : public TargetCodeGenInfo { public: WinX86_64TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, @@ -2736,6 +2739,7 @@ Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\""; } }; +} // namespace void WinX86_64TargetCodeGenInfo::setTargetAttributes( const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const { @@ -2753,7 +2757,6 @@ addStackProbeTargetAttributes(D, GV, CGM); } -} void X86_64ABIInfo::postMerge(unsigned AggregateSize, Class &Lo, Class &Hi) const { Index: clang/lib/CodeGen/TargetInfo.h === --- clang/lib/CodeGen/TargetInfo.h +++ clang/lib/CodeGen/TargetInfo.h @@ -398,6 +398,12 @@ virtual llvm::Type *getOpenCLType(CodeGenModule &CGM, const Type *T) const { return nullptr; } + +protected: + static std::string qualifyWindowsLibrary(StringRef Lib); + + void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV, + CodeGen::CodeGenModule &CGM) const; }; } // namespace CodeGen Index: clang/lib/CodeGen/TargetInfo.cpp === --- clang/lib/CodeGen/TargetInfo.cpp +++ clang/lib/CodeGen/TargetInfo.cpp @@ -2543,6 +2543,7 @@ const FunctionDecl *Callee, const CallArgList &Args) const override; }; +} // namespace static void initFeatureMaps(const ASTContext &Ctx, llvm::StringMap &CallerMap, @@ -2641,7 +2642,7 @@ } } -static std::string qualifyWindowsLibrary(llvm::StringRef Lib) { +std::string TargetCodeGenInfo::qualifyWindowsLibrary(StringRef Lib) { // If the argument does not end in .lib, automatically add the suffix. // If the argument contains a space, enclose it in quotes. // This matches the behavior of MSVC. @@ -2654,6 +2655,7 @@ return ArgStr; } +namespace { class WinX86_32TargetCodeGenInfo : public X86_32TargetCodeGenInfo { public: WinX86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, @@ -2677,11 +2679,11 @@ Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\""; } }; +} // name
[PATCH] D150215: [clang][CodeGen] Break up TargetInfo.cpp [7/8]
barannikov88 updated this revision to Diff 528208. barannikov88 added a comment. Rebase Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D150215/new/ https://reviews.llvm.org/D150215 Files: clang/lib/CodeGen/TargetInfo.cpp clang/lib/CodeGen/TargetInfo.h Index: clang/lib/CodeGen/TargetInfo.h === --- clang/lib/CodeGen/TargetInfo.h +++ clang/lib/CodeGen/TargetInfo.h @@ -406,6 +406,150 @@ CodeGen::CodeGenModule &CGM) const; }; +std::unique_ptr +createDefaultTargetCodeGenInfo(CodeGenModule &CGM); + +enum class AArch64ABIKind { + AAPCS = 0, + DarwinPCS, + Win64, +}; + +std::unique_ptr +createAArch64TargetCodeGenInfo(CodeGenModule &CGM, AArch64ABIKind Kind); + +std::unique_ptr +createWindowsAArch64TargetCodeGenInfo(CodeGenModule &CGM, AArch64ABIKind K); + +std::unique_ptr +createAMDGPUTargetCodeGenInfo(CodeGenModule &CGM); + +std::unique_ptr +createARCTargetCodeGenInfo(CodeGenModule &CGM); + +enum class ARMABIKind { + APCS = 0, + AAPCS = 1, + AAPCS_VFP = 2, + AAPCS16_VFP = 3, +}; + +std::unique_ptr +createARMTargetCodeGenInfo(CodeGenModule &CGM, ARMABIKind Kind); + +std::unique_ptr +createWindowsARMTargetCodeGenInfo(CodeGenModule &CGM, ARMABIKind K); + +std::unique_ptr +createAVRTargetCodeGenInfo(CodeGenModule &CGM, unsigned NPR, unsigned NRR); + +std::unique_ptr +createBPFTargetCodeGenInfo(CodeGenModule &CGM); + +std::unique_ptr +createCSKYTargetCodeGenInfo(CodeGenModule &CGM, unsigned FLen); + +std::unique_ptr +createHexagonTargetCodeGenInfo(CodeGenModule &CGM); + +std::unique_ptr +createLanaiTargetCodeGenInfo(CodeGenModule &CGM); + +std::unique_ptr +createLoongArchTargetCodeGenInfo(CodeGenModule &CGM, unsigned GRLen, + unsigned FLen); + +std::unique_ptr +createM68kTargetCodeGenInfo(CodeGenModule &CGM); + +std::unique_ptr +createMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32); + +std::unique_ptr +createMSP430TargetCodeGenInfo(CodeGenModule &CGM); + +std::unique_ptr +createNVPTXTargetCodeGenInfo(CodeGenModule &CGM); + +std::unique_ptr +createPNaClTargetCodeGenInfo(CodeGenModule &CGM); + +enum class PPC64_SVR4_ABIKind { + ELFv1 = 0, + ELFv2, +}; + +std::unique_ptr +createAIXTargetCodeGenInfo(CodeGenModule &CGM, bool Is64Bit); + +std::unique_ptr +createPPC32TargetCodeGenInfo(CodeGenModule &CGM, bool SoftFloatABI); + +std::unique_ptr +createPPC64TargetCodeGenInfo(CodeGenModule &CGM); + +std::unique_ptr +createPPC64_SVR4_TargetCodeGenInfo(CodeGenModule &CGM, PPC64_SVR4_ABIKind Kind, + bool SoftFloatABI); + +std::unique_ptr +createRISCVTargetCodeGenInfo(CodeGenModule &CGM, unsigned XLen, unsigned FLen); + +std::unique_ptr +createCommonSPIRTargetCodeGenInfo(CodeGenModule &CGM); + +std::unique_ptr +createSPIRVTargetCodeGenInfo(CodeGenModule &CGM); + +std::unique_ptr +createSparcV8TargetCodeGenInfo(CodeGenModule &CGM); + +std::unique_ptr +createSparcV9TargetCodeGenInfo(CodeGenModule &CGM); + +std::unique_ptr +createSystemZTargetCodeGenInfo(CodeGenModule &CGM, bool HasVector, + bool SoftFloatABI); + +std::unique_ptr +createTCETargetCodeGenInfo(CodeGenModule &CGM); + +std::unique_ptr +createVETargetCodeGenInfo(CodeGenModule &CGM); + +enum class WebAssemblyABIKind { + MVP = 0, + ExperimentalMV = 1, +}; + +std::unique_ptr +createWebAssemblyTargetCodeGenInfo(CodeGenModule &CGM, WebAssemblyABIKind K); + +/// The AVX ABI level for X86 targets. +enum class X86AVXABILevel { + None, + AVX, + AVX512, +}; + +std::unique_ptr createX86_32TargetCodeGenInfo( +CodeGenModule &CGM, bool DarwinVectorABI, bool Win32StructABI, +unsigned NumRegisterParameters, bool SoftFloatABI); + +std::unique_ptr +createWinX86_32TargetCodeGenInfo(CodeGenModule &CGM, bool DarwinVectorABI, + bool Win32StructABI, + unsigned NumRegisterParameters); + +std::unique_ptr +createX86_64TargetCodeGenInfo(CodeGenModule &CGM, X86AVXABILevel AVXLevel); + +std::unique_ptr +createWinX86_64TargetCodeGenInfo(CodeGenModule &CGM, X86AVXABILevel AVXLevel); + +std::unique_ptr +createXCoreTargetCodeGenInfo(CodeGenModule &CGM); + } // namespace CodeGen } // namespace clang Index: clang/lib/CodeGen/TargetInfo.cpp === --- clang/lib/CodeGen/TargetInfo.cpp +++ clang/lib/CodeGen/TargetInfo.cpp @@ -829,11 +829,6 @@ // This is a very simple ABI that relies a lot on DefaultABIInfo. //===--===// -enum class WebAssemblyABIKind { - MVP = 0, - ExperimentalMV = 1, -}; - class WebAssemblyABIInfo final : public ABIInfo { DefaultABIInfo defaultInfo; WebAssemblyABIKind Kind; @@ -2239,12 +2234,6 @@ namespace { -/// The AVX ABI level for X86 targets. -enum class X86AVXABILevel { - None, - AVX, - AVX512 -}
[PATCH] D148094: [clang][CodeGen] Break up TargetInfo.cpp [8/8]
barannikov88 updated this revision to Diff 528209. barannikov88 added a comment. Rebase Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148094/new/ https://reviews.llvm.org/D148094 Files: clang/docs/UsersManual.rst clang/docs/tools/clang-formatted-files.txt clang/lib/CodeGen/ABIInfo.cpp clang/lib/CodeGen/ABIInfo.h clang/lib/CodeGen/ABIInfoImpl.cpp clang/lib/CodeGen/ABIInfoImpl.h clang/lib/CodeGen/CMakeLists.txt clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/TargetInfo.cpp clang/lib/CodeGen/Targets/AArch64.cpp clang/lib/CodeGen/Targets/AMDGPU.cpp clang/lib/CodeGen/Targets/ARC.cpp clang/lib/CodeGen/Targets/ARM.cpp clang/lib/CodeGen/Targets/AVR.cpp clang/lib/CodeGen/Targets/BPF.cpp clang/lib/CodeGen/Targets/CSKY.cpp clang/lib/CodeGen/Targets/Hexagon.cpp clang/lib/CodeGen/Targets/Lanai.cpp clang/lib/CodeGen/Targets/LoongArch.cpp clang/lib/CodeGen/Targets/M68k.cpp clang/lib/CodeGen/Targets/MSP430.cpp clang/lib/CodeGen/Targets/Mips.cpp clang/lib/CodeGen/Targets/NVPTX.cpp clang/lib/CodeGen/Targets/PNaCl.cpp clang/lib/CodeGen/Targets/PPC.cpp clang/lib/CodeGen/Targets/RISCV.cpp clang/lib/CodeGen/Targets/SPIR.cpp clang/lib/CodeGen/Targets/Sparc.cpp clang/lib/CodeGen/Targets/SystemZ.cpp clang/lib/CodeGen/Targets/TCE.cpp clang/lib/CodeGen/Targets/VE.cpp clang/lib/CodeGen/Targets/WebAssembly.cpp clang/lib/CodeGen/Targets/X86.cpp clang/lib/CodeGen/Targets/XCore.cpp clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp llvm/utils/gn/secondary/clang/lib/CodeGen/BUILD.gn ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D151785: [clangd] Desugar dependent type aliases for auto type hints
zyounan added inline comments. Comment at: clang-tools-extra/clangd/InlayHints.cpp:267 StructuredBindingPolicy = TypeHintPolicy; StructuredBindingPolicy.PrintCanonicalTypes = true; } `PrintCanonicalTypes` turns on printing default template arguments, which would prevent the patch from printing, e.g., `std::basic_string`, within the default length limitation. ``` std::map Map; for (auto &[Key, Value] : Map) // Key: basic_string, allocator>, whose length exceeds the default threshold. ``` Is it safe to drop it now? I believe this patch can handle the case the comment mentioned. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151785/new/ https://reviews.llvm.org/D151785 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D152096: [Clang] Check for abstract parameters only when functions are defined.
cor3ntin created this revision. Herald added a project: All. cor3ntin requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. The C++ standard allows abstract parameters in deleted functions and in function declarations > The type of a parameter or the return type for a function definition > shall not be a (possibly cv-qualified) class type that is > incomplete or abstract within the function body > unless the function is deleted. Fixes https://github.com/llvm/llvm-project/issues/63012 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D152096 Files: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaChecking.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/test/CXX/class.derived/class.abstract/p3.cpp clang/test/CXX/drs/dr6xx.cpp clang/test/SemaCXX/abstract.cpp clang/test/SemaCXX/auto-type-from-cxx.cpp clang/test/SemaObjCXX/parameters.mm Index: clang/test/SemaObjCXX/parameters.mm === --- clang/test/SemaObjCXX/parameters.mm +++ clang/test/SemaObjCXX/parameters.mm @@ -11,9 +11,9 @@ X0 x0a; // expected-note{{instantiation}} -struct test2 { virtual void foo() = 0; }; // expected-note {{unimplemented}} +struct test2 { virtual void foo() = 0; }; @interface Test2 -- (void) foo: (test2) foo; // expected-error {{parameter type 'test2' is an abstract class}} +- (void) foo: (test2) foo ; @end template void r1(__restrict T); Index: clang/test/SemaCXX/auto-type-from-cxx.cpp === --- clang/test/SemaCXX/auto-type-from-cxx.cpp +++ clang/test/SemaCXX/auto-type-from-cxx.cpp @@ -21,18 +21,18 @@ namespace TestDeductionFail { template -void caller(T x) {x.fun();} // expected-note {{candidate template ignored: substitution failure [with T = TestDeductionFail::Abstract]: parameter type 'TestDeductionFail::Abstract' is an abstract class}} +void caller(T x) {x.fun();} // expected-error {{parameter type 'TestDeductionFail::Abstract' is an abstract class}} template auto getCaller(){ - return caller; // expected-error {{cannot deduce return type 'auto' from returned value of type ''}} + return caller; // expected-note {{in instantiation of function template specialization 'TestDeductionFail::caller' requested here}} } class Abstract{ public: void fun(); -virtual void vfun()=0; -void call(){getCaller()(*this);} // expected-note {{in instantiation of function template specialization 'TestDeductionFail::getCaller' requested here}} +virtual void vfun()=0; // expected-note {{unimplemented pure virtual method 'vfun' in 'Abstract'}} +void call(){getCaller()(*this);} // expected-error {{allocating an object of abstract class type 'TestDeductionFail::Abstract'}} }; } Index: clang/test/SemaCXX/abstract.cpp === --- clang/test/SemaCXX/abstract.cpp +++ clang/test/SemaCXX/abstract.cpp @@ -32,42 +32,48 @@ C *d = new C; // expected-error {{allocating an object of abstract class type 'C'}} C c; // expected-error {{variable type 'C' is an abstract class}} -void t1(C c); // expected-error {{parameter type 'C' is an abstract class}} -void t2(C); // expected-error {{parameter type 'C' is an abstract class}} +void t1(C c); +void t2(C); +void t3(C c){}; // expected-error {{parameter type 'C' is an abstract class}} +void t4(C){}; // expected-error {{parameter type 'C' is an abstract class}} struct S { C c; // expected-error {{field type 'C' is an abstract class}} }; -void t3(const C&); +void t5(const C&); void f() { C(); // expected-error {{allocating an object of abstract class type 'C'}} - t3(C()); // expected-error {{allocating an object of abstract class type 'C'}} + t5(C()); // expected-error {{allocating an object of abstract class type 'C'}} } C e1[2]; // expected-error {{array of abstract class type 'C'}} C (*e2)[2]; // expected-error {{array of abstract class type 'C'}} C (**e3)[2]; // expected-error {{array of abstract class type 'C'}} -void t4(C c[2]); // expected-error {{array of abstract class type 'C'}} +void t6(C c[2]); // expected-error {{array of abstract class type 'C'}} -void t5(void (*)(C)); // expected-error {{parameter type 'C' is an abstract class}} +void t7(void (*)(C)); -typedef void (*Func)(C); // expected-error {{parameter type 'C' is an abstract class}} -void t6(Func); +typedef void (*Func)(C); +void t8(Func); class F { F a() { while (1) {} } // expected-error {{return type 'F' is an abstract class}} - + class D { -void f(F c); // expected-error {{parameter type 'F' is an abstract class}} +void f(F c){}; // expected-error {{parameter type 'F' is an abstract class}} +void g(F c); +void h(F c) = delete; }; union U { -void u(F c); // expected-error {{parameter type 'F' is an abstract class}} +void u(F c){}; // expe
[PATCH] D151833: Respect "-fdiagnostics-absolute-paths" on emit include location
charmitro updated this revision to Diff 528219. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151833/new/ https://reviews.llvm.org/D151833 Files: clang/lib/Frontend/TextDiagnostic.cpp clang/test/Frontend/absolute-paths-import.h clang/test/Frontend/absolute-paths.c Index: clang/test/Frontend/absolute-paths.c === --- clang/test/Frontend/absolute-paths.c +++ clang/test/Frontend/absolute-paths.c @@ -1,5 +1,10 @@ -// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. %s 2>&1 | FileCheck -check-prefix=NORMAL -check-prefix=CHECK %s -// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. -fdiagnostics-absolute-paths %s 2>&1 | FileCheck -check-prefix=ABSOLUTE -check-prefix=CHECK %s +// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. %s 2>&1 | FileCheck -DROOT_ABSOLUTE=%s -check-prefix=NORMAL -check-prefix=CHECK %s +// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. -fdiagnostics-absolute-paths %s 2>&1 | FileCheck -DROOT_ABSOLUTE=%s -check-prefix=ABSOLUTE -check-prefix=CHECK %s + +#include "absolute-paths-import.h" +// NORMAL: In file included from {{.*}}absolute-paths.c:4: +// NORMAL-NOT: In file included from [[ROOT_ABSOLUTE]]:4: +// ABSOLUTE: In file included from [[ROOT_ABSOLUTE]]:4: #include "absolute-paths.h" Index: clang/test/Frontend/absolute-paths-import.h === --- /dev/null +++ clang/test/Frontend/absolute-paths-import.h @@ -0,0 +1 @@ +#warning abc Index: clang/lib/Frontend/TextDiagnostic.cpp === --- clang/lib/Frontend/TextDiagnostic.cpp +++ clang/lib/Frontend/TextDiagnostic.cpp @@ -868,10 +868,11 @@ } void TextDiagnostic::emitIncludeLocation(FullSourceLoc Loc, PresumedLoc PLoc) { - if (DiagOpts->ShowLocation && PLoc.isValid()) -OS << "In file included from " << PLoc.getFilename() << ':' - << PLoc.getLine() << ":\n"; - else + if (DiagOpts->ShowLocation && PLoc.isValid()) { +OS << "In file included from "; +emitFilename(PLoc.getFilename(), Loc.getManager()); +OS << ':' << PLoc.getLine() << ":\n"; + } else OS << "In included file:\n"; } Index: clang/test/Frontend/absolute-paths.c === --- clang/test/Frontend/absolute-paths.c +++ clang/test/Frontend/absolute-paths.c @@ -1,5 +1,10 @@ -// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. %s 2>&1 | FileCheck -check-prefix=NORMAL -check-prefix=CHECK %s -// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. -fdiagnostics-absolute-paths %s 2>&1 | FileCheck -check-prefix=ABSOLUTE -check-prefix=CHECK %s +// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. %s 2>&1 | FileCheck -DROOT_ABSOLUTE=%s -check-prefix=NORMAL -check-prefix=CHECK %s +// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SystemHeaderPrefix/.. -fdiagnostics-absolute-paths %s 2>&1 | FileCheck -DROOT_ABSOLUTE=%s -check-prefix=ABSOLUTE -check-prefix=CHECK %s + +#include "absolute-paths-import.h" +// NORMAL: In file included from {{.*}}absolute-paths.c:4: +// NORMAL-NOT: In file included from [[ROOT_ABSOLUTE]]:4: +// ABSOLUTE: In file included from [[ROOT_ABSOLUTE]]:4: #include "absolute-paths.h" Index: clang/test/Frontend/absolute-paths-import.h === --- /dev/null +++ clang/test/Frontend/absolute-paths-import.h @@ -0,0 +1 @@ +#warning abc Index: clang/lib/Frontend/TextDiagnostic.cpp === --- clang/lib/Frontend/TextDiagnostic.cpp +++ clang/lib/Frontend/TextDiagnostic.cpp @@ -868,10 +868,11 @@ } void TextDiagnostic::emitIncludeLocation(FullSourceLoc Loc, PresumedLoc PLoc) { - if (DiagOpts->ShowLocation && PLoc.isValid()) -OS << "In file included from " << PLoc.getFilename() << ':' - << PLoc.getLine() << ":\n"; - else + if (DiagOpts->ShowLocation && PLoc.isValid()) { +OS << "In file included from "; +emitFilename(PLoc.getFilename(), Loc.getManager()); +OS << ':' << PLoc.getLine() << ":\n"; + } else OS << "In included file:\n"; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] c755031 - [NFC][CLANG] Fix Static Code Analyzer Concerns
Author: Manna, Soumi Date: 2023-06-04T09:09:59-07:00 New Revision: c7550310738b27aec440e5d20cec7f0209d45721 URL: https://github.com/llvm/llvm-project/commit/c7550310738b27aec440e5d20cec7f0209d45721 DIFF: https://github.com/llvm/llvm-project/commit/c7550310738b27aec440e5d20cec7f0209d45721.diff LOG: [NFC][CLANG] Fix Static Code Analyzer Concerns This patch uses castAs instead of getAs which will assert if the type doesn't match to resolve dereference issue with nullptr FPT when calling getThisType() in clang::CodeGen::CGDebugInfo::CreateType(clang::MemberPointerType const *, llvm::DIFile *). Reviewed By: erichkeane Differential Revision: https://reviews.llvm.org/D151947 Added: Modified: clang/lib/CodeGen/CGDebugInfo.cpp Removed: diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 2857ea20ba1d8..edef27bdf377c 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -3307,7 +3307,7 @@ llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty, Flags); const FunctionProtoType *FPT = - Ty->getPointeeType()->getAs(); + Ty->getPointeeType()->castAs(); return DBuilder.createMemberPointerType( getOrCreateInstanceMethodType( CXXMethodDecl::getThisType(FPT, Ty->getMostRecentCXXRecordDecl()), ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D151947: [NFC][CLANG] Fix Static Code Analyzer Concerns
This revision was automatically updated to reflect the committed changes. Closed by commit rGc7550310738b: [NFC][CLANG] Fix Static Code Analyzer Concerns (authored by Manna). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151947/new/ https://reviews.llvm.org/D151947 Files: clang/lib/CodeGen/CGDebugInfo.cpp Index: clang/lib/CodeGen/CGDebugInfo.cpp === --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -3307,7 +3307,7 @@ Flags); const FunctionProtoType *FPT = - Ty->getPointeeType()->getAs(); + Ty->getPointeeType()->castAs(); return DBuilder.createMemberPointerType( getOrCreateInstanceMethodType( CXXMethodDecl::getThisType(FPT, Ty->getMostRecentCXXRecordDecl()), Index: clang/lib/CodeGen/CGDebugInfo.cpp === --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -3307,7 +3307,7 @@ Flags); const FunctionProtoType *FPT = - Ty->getPointeeType()->getAs(); + Ty->getPointeeType()->castAs(); return DBuilder.createMemberPointerType( getOrCreateInstanceMethodType( CXXMethodDecl::getThisType(FPT, Ty->getMostRecentCXXRecordDecl()), ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] b0525f6 - [NFC][CLANG] [NFC][CLANG] Fix nullptr dereference issue in ConvertQualTypeToKind()
Author: Manna, Soumi Date: 2023-06-04T09:35:44-07:00 New Revision: b0525f66988eac69138ba4ca30f5f07ff5218093 URL: https://github.com/llvm/llvm-project/commit/b0525f66988eac69138ba4ca30f5f07ff5218093 DIFF: https://github.com/llvm/llvm-project/commit/b0525f66988eac69138ba4ca30f5f07ff5218093.diff LOG: [NFC][CLANG] [NFC][CLANG] Fix nullptr dereference issue in ConvertQualTypeToKind() This patch uses castAs instead of getAs which will assert if the type doesn't match in ConvertQualTypeToKind(clang::ASTContext const &, clang::QualType). Reviewed By: erichkeane Differential Revision: https://reviews.llvm.org/D151928 Added: Modified: clang/lib/Interpreter/Value.cpp Removed: diff --git a/clang/lib/Interpreter/Value.cpp b/clang/lib/Interpreter/Value.cpp index fe37eebac5257..6d0eaf1b82e10 100644 --- a/clang/lib/Interpreter/Value.cpp +++ b/clang/lib/Interpreter/Value.cpp @@ -108,7 +108,7 @@ static Value::Kind ConvertQualTypeToKind(const ASTContext &Ctx, QualType QT) { if (!BT || BT->isNullPtrType()) return Value::K_PtrOrObj; - switch (QT->getAs()->getKind()) { + switch (QT->castAs()->getKind()) { default: assert(false && "Type not supported"); return Value::K_Unspecified; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D151928: [NFC][CLANG] Fix nullptr dereference issue in ConvertQualTypeToKind()
This revision was automatically updated to reflect the committed changes. Closed by commit rGb0525f66988e: [NFC][CLANG] [NFC][CLANG] Fix nullptr dereference issue in… (authored by Manna). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151928/new/ https://reviews.llvm.org/D151928 Files: clang/lib/Interpreter/Value.cpp Index: clang/lib/Interpreter/Value.cpp === --- clang/lib/Interpreter/Value.cpp +++ clang/lib/Interpreter/Value.cpp @@ -108,7 +108,7 @@ if (!BT || BT->isNullPtrType()) return Value::K_PtrOrObj; - switch (QT->getAs()->getKind()) { + switch (QT->castAs()->getKind()) { default: assert(false && "Type not supported"); return Value::K_Unspecified; Index: clang/lib/Interpreter/Value.cpp === --- clang/lib/Interpreter/Value.cpp +++ clang/lib/Interpreter/Value.cpp @@ -108,7 +108,7 @@ if (!BT || BT->isNullPtrType()) return Value::K_PtrOrObj; - switch (QT->getAs()->getKind()) { + switch (QT->castAs()->getKind()) { default: assert(false && "Type not supported"); return Value::K_Unspecified; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D151010: [NFC][CLANG] Fix bug with dereference null return value found by static analyzer tool
Manna abandoned this revision. Manna added a comment. This is False Positive. Closing the PR. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151010/new/ https://reviews.llvm.org/D151010 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D152107: [NFC][CLANG] Fix nullptr dereference issue in checkSizelessVectorShift()
Manna created this revision. Manna added a reviewer: erichkeane. Herald added subscribers: ctetreau, tschuett. Herald added a project: All. Manna requested review of this revision. Herald added a project: clang. This patch uses castAs instead of getAs which will assert if the type doesn't match in checkSizelessVectorShift(clang::​Sema &, clang::​ActionResult &, clang::​ActionResult &, clang::​SourceLocation, bool). Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D152107 Files: clang/lib/Sema/SemaExpr.cpp Index: clang/lib/Sema/SemaExpr.cpp === --- clang/lib/Sema/SemaExpr.cpp +++ clang/lib/Sema/SemaExpr.cpp @@ -12039,14 +12039,14 @@ return QualType(); QualType LHSType = LHS.get()->getType(); - const BuiltinType *LHSBuiltinTy = LHSType->getAs(); + const BuiltinType *LHSBuiltinTy = LHSType->castAs(); QualType LHSEleType = LHSType->isVLSTBuiltinType() ? LHSBuiltinTy->getSveEltType(S.getASTContext()) : LHSType; // Note that RHS might not be a vector QualType RHSType = RHS.get()->getType(); - const BuiltinType *RHSBuiltinTy = RHSType->getAs(); + const BuiltinType *RHSBuiltinTy = RHSType->castAs(); QualType RHSEleType = RHSType->isVLSTBuiltinType() ? RHSBuiltinTy->getSveEltType(S.getASTContext()) : RHSType; Index: clang/lib/Sema/SemaExpr.cpp === --- clang/lib/Sema/SemaExpr.cpp +++ clang/lib/Sema/SemaExpr.cpp @@ -12039,14 +12039,14 @@ return QualType(); QualType LHSType = LHS.get()->getType(); - const BuiltinType *LHSBuiltinTy = LHSType->getAs(); + const BuiltinType *LHSBuiltinTy = LHSType->castAs(); QualType LHSEleType = LHSType->isVLSTBuiltinType() ? LHSBuiltinTy->getSveEltType(S.getASTContext()) : LHSType; // Note that RHS might not be a vector QualType RHSType = RHS.get()->getType(); - const BuiltinType *RHSBuiltinTy = RHSType->getAs(); + const BuiltinType *RHSBuiltinTy = RHSType->castAs(); QualType RHSEleType = RHSType->isVLSTBuiltinType() ? RHSBuiltinTy->getSveEltType(S.getASTContext()) : RHSType; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D152109: Update clang-repl documentation
Krishna-13-cyber created this revision. Krishna-13-cyber added reviewers: v.g.vassilev, QuillPusher, davidlange6. Herald added a project: All. Krishna-13-cyber requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Update Clang-repl documentation with:- - Add usage and build instructions - Add examples depicting their usage in clang-repl. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D152109 Files: clang/docs/ClangRepl.rst Index: clang/docs/ClangRepl.rst === --- clang/docs/ClangRepl.rst +++ clang/docs/ClangRepl.rst @@ -16,22 +16,6 @@ of Cling upstream, making them useful and available to a broader audience. - -Clang-Repl Usage - - - -.. code-block:: text - - clang-repl> #include - clang-repl> int f() { std::cout << "Hello Interpreted World!\n"; return 0; } - clang-repl> auto r = f(); - // Prints Hello Interpreted World! - -Note that the implementation is not complete and highly experimental. We do -not yet support statements on the global scope, for example. - - Clang-Repl Basic Data Flow == @@ -64,6 +48,133 @@ 8. The machine code is then executed. +Just like Clang, Clang-Repl can be integrated in existing applications as a +library (via using the clangInterpreter library). This turning your C++ compiler +into a service which incrementally can consume and execute code. The +**Compiler as A Service** (**CaaS**) concept helps supporting move advanced use +cases such as template instantiations on demand and automatic language +interoperability. It also helps static languages such as C/C++ become apt for +data science. + + +Clang-Repl-Usage + + +**Clang-Repl** is an interactive C++ interpreter that allows for incremental +compilation. It supports interactive programming for C++ in a +read-evaluate-print-loop (REPL) style. It uses Clang as a library to compile the +high level programming language into LLVM IR. Then the LLVM IR is executed by +the LLVM just-in-time (JIT) infrastructure. + +Build Instructions: +=== + + +.. code-block:: console + + $ cd llvm-project + $ mkdir build + $ cd build + $ cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_ENABLE_PROJECTS=clang -G "Unix Makefiles" ../llvm + +**Note here**, above RelWithDebInfo - Debug / Release + +.. code-block:: console + + cmake --build . --target clang clang-repl -j n + OR + cmake --build . --target clang clang-repl + +**Clang-repl** is built under llvm-project/build/bin.roceeding into the directory **llvm-project/build/bin** + +.. code-block:: console + + ./clang-repl + clang-repl> + + +Basic: +== +.. code-block:: text + + clang-repl> #include + clang-repl> int f() { std::cout << "Hello Interpreted World!\n"; return 0; } + clang-repl> auto r = f(); + // Prints Hello Interpreted World! + +.. code-block:: text + + clang-repl> #include + clang-repl> using namespace std; + clang-repl> std::cout << "Welcome to CLANG-REPL" << std::endl; + Welcome to CLANG-REPL + // Prints Welcome to CLANG-REPL + + +Function Definitions and Calls: +=== + + +.. code-block:: text + + clang-repl> #include + clang-repl> int sum(int a, int b){ return a+b; }; + clang-repl> int c = sum(9,10); + clang-repl> std::cout << c; + 19clang-repl> + +Iterative Structures: += + + +.. code-block:: text + + clang-repl> #include + clang-repl> for (int i = 0;i < 3;i++){ std::cout << i << std::endl;} + 0 + 1 + 2 + clang-repl> while(i < 7){ i++; std::cout << i << std::endl;} + 4 + 5 + 6 + 7 + +Classes and Structures: +=== + + +.. code-block:: text + + clang-repl> #include + clang-repl> class Rectangle {int width, height; public: void set_values (int,int);int area() {return width*height;}}; + clang-repl> void Rectangle::set_values (int x, int y) { width = x;height = y;} + clang-repl> int main () { Rectangle rect;rect.set_values (3,4); std::cout << "area: " << rect.area();return 0;} + clang-repl> main(); + area: 12clang-repl> + +Lamdas: +=== + + +.. code-block:: text + + clang-repl> #include + clang-repl> using namespace std; + clang-repl> auto welcome = []() { std::cout << "Welcome to REPL" << std::endl;}; + clang-repl> welcome(); + Welcome to REPL + +Closure or Termination: +=== + + +.. code-block:: text + + clang-repl>%quit + + + Just like Clang, Clang-Repl can be integrated in existing applications as a library (via using the clangInterpreter library). This turning your C++ compiler into a service which incrementally can consume and execute code. The ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D151339: [OpenCL] Add cl_ext_image_raw10_raw12 extension
Anastasia accepted this revision. Anastasia added a comment. This revision is now accepted and ready to land. LGTM! Thanks Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151339/new/ https://reviews.llvm.org/D151339 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D152083: [clang] Warning for uninitialized elements in fixed-size arrays
Sinitax updated this revision to Diff 528256. Sinitax added a comment. Add new warning to its own group. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D152083/new/ https://reviews.llvm.org/D152083 Files: clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/Sema/SemaInit.cpp Index: clang/lib/Sema/SemaInit.cpp === --- clang/lib/Sema/SemaInit.cpp +++ clang/lib/Sema/SemaInit.cpp @@ -980,6 +980,22 @@ if (RequiresSecondPass && !hadError) FillInEmptyInitializations(Entity, FullyStructuredList, RequiresSecondPass, nullptr, 0); + +if (const ConstantArrayType *CAType = dyn_cast(T)) { + if (FullyStructuredList->getNumInits() < CAType->getSize().getZExtValue()) { +S.Diag(IL->getBeginLoc(), diag::warn_uninit_fixed_size_array) + << IL->getSourceRange(); + } else { +Expr **inits = FullyStructuredList->getInits(); +for (unsigned i = 0, e = FullyStructuredList->getNumInits(); i != e; ++i) { + if (inits[i] == nullptr) { +S.Diag(IL->getBeginLoc(), diag::warn_uninit_fixed_size_array) + << IL->getSourceRange(); +break; + } +} + } +} } if (hadError && FullyStructuredList) FullyStructuredList->markError(); Index: clang/include/clang/Basic/DiagnosticSemaKinds.td === --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2214,6 +2214,9 @@ "reference %0 is not yet bound to a value when used within its own" " initialization">, InGroup; +def warn_uninit_fixed_size_array : Warning< + "fixed-size array contains uninitialized elements">, + InGroup, DefaultIgnore; def warn_uninit_var : Warning< "variable %0 is uninitialized when %select{used here|captured by block}1">, InGroup, DefaultIgnore; Index: clang/include/clang/Basic/DiagnosticGroups.td === --- clang/include/clang/Basic/DiagnosticGroups.td +++ clang/include/clang/Basic/DiagnosticGroups.td @@ -729,6 +729,7 @@ def UninitializedSometimes : DiagGroup<"sometimes-uninitialized">; def UninitializedStaticSelfInit : DiagGroup<"static-self-init">; def UninitializedConstReference : DiagGroup<"uninitialized-const-reference">; +def UninitializedArrayElements : DiagGroup<"uninitialized-array-elements">; def Uninitialized : DiagGroup<"uninitialized", [UninitializedSometimes, UninitializedStaticSelfInit, UninitializedConstReference]>; Index: clang/lib/Sema/SemaInit.cpp === --- clang/lib/Sema/SemaInit.cpp +++ clang/lib/Sema/SemaInit.cpp @@ -980,6 +980,22 @@ if (RequiresSecondPass && !hadError) FillInEmptyInitializations(Entity, FullyStructuredList, RequiresSecondPass, nullptr, 0); + +if (const ConstantArrayType *CAType = dyn_cast(T)) { + if (FullyStructuredList->getNumInits() < CAType->getSize().getZExtValue()) { +S.Diag(IL->getBeginLoc(), diag::warn_uninit_fixed_size_array) + << IL->getSourceRange(); + } else { +Expr **inits = FullyStructuredList->getInits(); +for (unsigned i = 0, e = FullyStructuredList->getNumInits(); i != e; ++i) { + if (inits[i] == nullptr) { +S.Diag(IL->getBeginLoc(), diag::warn_uninit_fixed_size_array) + << IL->getSourceRange(); +break; + } +} + } +} } if (hadError && FullyStructuredList) FullyStructuredList->markError(); Index: clang/include/clang/Basic/DiagnosticSemaKinds.td === --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2214,6 +2214,9 @@ "reference %0 is not yet bound to a value when used within its own" " initialization">, InGroup; +def warn_uninit_fixed_size_array : Warning< + "fixed-size array contains uninitialized elements">, + InGroup, DefaultIgnore; def warn_uninit_var : Warning< "variable %0 is uninitialized when %select{used here|captured by block}1">, InGroup, DefaultIgnore; Index: clang/include/clang/Basic/DiagnosticGroups.td === --- clang/include/clang/Basic/DiagnosticGroups.td +++ clang/include/clang/Basic/DiagnosticGroups.td @@ -729,6 +729,7 @@ def UninitializedSometimes : DiagGroup<"sometimes-uninitialized">; def UninitializedStaticSelfInit : DiagGroup<"static-self-init">; def UninitializedConstReference : DiagGroup<"uninitialized-const-reference">; +def UninitializedArrayElements : DiagGroup<"unin
[PATCH] D148490: [AIX] use system assembler for assembly files
This revision was automatically updated to reflect the committed changes. Closed by commit rG4b27ad735c8d: [AIX] use system assembler for assembly files (authored by shchenz). Changed prior to commit: https://reviews.llvm.org/D148490?vs=521233&id=528257#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148490/new/ https://reviews.llvm.org/D148490 Files: clang/lib/Driver/ToolChain.cpp clang/test/Driver/aix-as.c Index: clang/test/Driver/aix-as.c === --- clang/test/Driver/aix-as.c +++ clang/test/Driver/aix-as.c @@ -1,22 +1,40 @@ // General tests that as(1) invocations on AIX targets are sane. Note that we // only test assembler functionalities in this suite. +// Check powerpc-ibm-aix7.1.0.0, system assembler is used for assembly files, 32-bit. +// RUN: %clang -x assembler %s -### -c -fintegrated-as 2>&1 \ +// RUN: --target=powerpc-ibm-aix7.1.0.0 \ +// RUN: | FileCheck --check-prefix=CHECK-AS32 %s +// +// RUN: %clang -x assembler %s -### -c 2>&1 -fno-integrated-as \ +// RUN: --target=powerpc-ibm-aix7.1.0.0 \ +// RUN: | FileCheck --check-prefix=CHECK-AS32 %s + // Check powerpc-ibm-aix7.1.0.0, 32-bit. // RUN: %clang %s -### -c 2>&1 \ // RUN: --target=powerpc-ibm-aix7.1.0.0 \ -// RUN: | FileCheck --check-prefix=CHECK-AS32 %s +// RUN: | FileCheck --check-prefixes=CHECK-AS32,CHECK-AS32-CC1 %s // CHECK-AS32-NOT: warning: -// CHECK-AS32: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" +// CHECK-AS32-CC1: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" // CHECK-AS32: "{{.*}}as{{(.exe)?}}" // CHECK-AS32: "-a32" // CHECK-AS32: "-many" +// Check powerpc64-ibm-aix7.1.0.0, system assembler is used for assembly files, 64-bit. +// RUN: %clang -x assembler %s -### -c -fintegrated-as 2>&1 \ +// RUN: --target=powerpc64-ibm-aix7.1.0.0 \ +// RUN: | FileCheck --check-prefix=CHECK-AS64 %s +// +// RUN: %clang -x assembler %s -### -c -fno-integrated-as 2>&1 \ +// RUN: --target=powerpc64-ibm-aix7.1.0.0 \ +// RUN: | FileCheck --check-prefix=CHECK-AS64 %s + // Check powerpc64-ibm-aix7.1.0.0, 64-bit. // RUN: %clang %s -### -c 2>&1 \ // RUN: --target=powerpc64-ibm-aix7.1.0.0 \ -// RUN: | FileCheck --check-prefix=CHECK-AS64 %s +// RUN: | FileCheck --check-prefixes=CHECK-AS64,CHECK-AS64-CC1 %s // CHECK-AS64-NOT: warning: -// CHECK-AS64: "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" +// CHECK-AS64-CC1: "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" // CHECK-AS64: "{{.*}}as{{(.exe)?}}" // CHECK-AS64: "-a64" // CHECK-AS64: "-many" Index: clang/lib/Driver/ToolChain.cpp === --- clang/lib/Driver/ToolChain.cpp +++ clang/lib/Driver/ToolChain.cpp @@ -662,7 +662,8 @@ if (D.IsFlangMode() && getDriver().ShouldUseFlangCompiler(JA)) return getFlang(); if (getDriver().ShouldUseClangCompiler(JA)) return getClang(); Action::ActionClass AC = JA.getKind(); - if (AC == Action::AssembleJobClass && useIntegratedAs()) + if (AC == Action::AssembleJobClass && useIntegratedAs() && + !getTriple().isOSAIX()) return getClangAs(); return getTool(AC); } Index: clang/test/Driver/aix-as.c === --- clang/test/Driver/aix-as.c +++ clang/test/Driver/aix-as.c @@ -1,22 +1,40 @@ // General tests that as(1) invocations on AIX targets are sane. Note that we // only test assembler functionalities in this suite. +// Check powerpc-ibm-aix7.1.0.0, system assembler is used for assembly files, 32-bit. +// RUN: %clang -x assembler %s -### -c -fintegrated-as 2>&1 \ +// RUN: --target=powerpc-ibm-aix7.1.0.0 \ +// RUN: | FileCheck --check-prefix=CHECK-AS32 %s +// +// RUN: %clang -x assembler %s -### -c 2>&1 -fno-integrated-as \ +// RUN: --target=powerpc-ibm-aix7.1.0.0 \ +// RUN: | FileCheck --check-prefix=CHECK-AS32 %s + // Check powerpc-ibm-aix7.1.0.0, 32-bit. // RUN: %clang %s -### -c 2>&1 \ // RUN: --target=powerpc-ibm-aix7.1.0.0 \ -// RUN: | FileCheck --check-prefix=CHECK-AS32 %s +// RUN: | FileCheck --check-prefixes=CHECK-AS32,CHECK-AS32-CC1 %s // CHECK-AS32-NOT: warning: -// CHECK-AS32: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" +// CHECK-AS32-CC1: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" // CHECK-AS32: "{{.*}}as{{(.exe)?}}" // CHECK-AS32: "-a32" // CHECK-AS32: "-many" +// Check powerpc64-ibm-aix7.1.0.0, system assembler is used for assembly files, 64-bit. +// RUN: %clang -x assembler %s -### -c -fintegrated-as 2>&1 \ +// RUN: --target=powerpc64-ibm-aix7.1.0.0 \ +// RUN: | FileCheck --check-prefix=CHECK-AS64 %s +// +// RUN: %clang -x assembler %s -### -c -fno-integrated-as 2>&1 \ +// RUN: --target=powerpc64-ibm-aix7.1.0.0 \ +// RUN: | FileCheck --check-prefix=CHECK-AS64 %s + // Check powerpc64-ibm-aix7.1.0.0, 64-bit. // RUN: %clang %s -### -c 2>&1 \ // RUN: --tar
[clang] 4b27ad7 - [AIX] use system assembler for assembly files
Author: Chen Zheng Date: 2023-06-04T21:37:48-04:00 New Revision: 4b27ad735c8da7cd21a7ea58614ebd4d3c940a89 URL: https://github.com/llvm/llvm-project/commit/4b27ad735c8da7cd21a7ea58614ebd4d3c940a89 DIFF: https://github.com/llvm/llvm-project/commit/4b27ad735c8da7cd21a7ea58614ebd4d3c940a89.diff LOG: [AIX] use system assembler for assembly files Change to system assembler to compile assembly files even -fintegrated-as is specified. We don't have a good Clang as for now for assembly files on AIX. Reviewed By: qiucf Differential Revision: https://reviews.llvm.org/D148490 Added: Modified: clang/lib/Driver/ToolChain.cpp clang/test/Driver/aix-as.c Removed: diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 8bfa5baf92ff7..ccaebb384d4dc 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -662,7 +662,8 @@ Tool *ToolChain::SelectTool(const JobAction &JA) const { if (D.IsFlangMode() && getDriver().ShouldUseFlangCompiler(JA)) return getFlang(); if (getDriver().ShouldUseClangCompiler(JA)) return getClang(); Action::ActionClass AC = JA.getKind(); - if (AC == Action::AssembleJobClass && useIntegratedAs()) + if (AC == Action::AssembleJobClass && useIntegratedAs() && + !getTriple().isOSAIX()) return getClangAs(); return getTool(AC); } diff --git a/clang/test/Driver/aix-as.c b/clang/test/Driver/aix-as.c index 9412604c2e84f..c6aeae4c10183 100644 --- a/clang/test/Driver/aix-as.c +++ b/clang/test/Driver/aix-as.c @@ -1,22 +1,40 @@ // General tests that as(1) invocations on AIX targets are sane. Note that we // only test assembler functionalities in this suite. +// Check powerpc-ibm-aix7.1.0.0, system assembler is used for assembly files, 32-bit. +// RUN: %clang -x assembler %s -### -c -fintegrated-as 2>&1 \ +// RUN: --target=powerpc-ibm-aix7.1.0.0 \ +// RUN: | FileCheck --check-prefix=CHECK-AS32 %s +// +// RUN: %clang -x assembler %s -### -c 2>&1 -fno-integrated-as \ +// RUN: --target=powerpc-ibm-aix7.1.0.0 \ +// RUN: | FileCheck --check-prefix=CHECK-AS32 %s + // Check powerpc-ibm-aix7.1.0.0, 32-bit. // RUN: %clang %s -### -c 2>&1 \ // RUN: --target=powerpc-ibm-aix7.1.0.0 \ -// RUN: | FileCheck --check-prefix=CHECK-AS32 %s +// RUN: | FileCheck --check-prefixes=CHECK-AS32,CHECK-AS32-CC1 %s // CHECK-AS32-NOT: warning: -// CHECK-AS32: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" +// CHECK-AS32-CC1: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" // CHECK-AS32: "{{.*}}as{{(.exe)?}}" // CHECK-AS32: "-a32" // CHECK-AS32: "-many" +// Check powerpc64-ibm-aix7.1.0.0, system assembler is used for assembly files, 64-bit. +// RUN: %clang -x assembler %s -### -c -fintegrated-as 2>&1 \ +// RUN: --target=powerpc64-ibm-aix7.1.0.0 \ +// RUN: | FileCheck --check-prefix=CHECK-AS64 %s +// +// RUN: %clang -x assembler %s -### -c -fno-integrated-as 2>&1 \ +// RUN: --target=powerpc64-ibm-aix7.1.0.0 \ +// RUN: | FileCheck --check-prefix=CHECK-AS64 %s + // Check powerpc64-ibm-aix7.1.0.0, 64-bit. // RUN: %clang %s -### -c 2>&1 \ // RUN: --target=powerpc64-ibm-aix7.1.0.0 \ -// RUN: | FileCheck --check-prefix=CHECK-AS64 %s +// RUN: | FileCheck --check-prefixes=CHECK-AS64,CHECK-AS64-CC1 %s // CHECK-AS64-NOT: warning: -// CHECK-AS64: "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" +// CHECK-AS64-CC1: "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" // CHECK-AS64: "{{.*}}as{{(.exe)?}}" // CHECK-AS64: "-a64" // CHECK-AS64: "-many" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D150746: [CodeGen]Translating pointer arguments can require an address space cast
This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rG29663e2b8c4e: [clang][CodeGen] Account for VTT address space (authored by AlexVlx). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D150746/new/ https://reviews.llvm.org/D150746 Files: clang/lib/CodeGen/ItaniumCXXABI.cpp clang/test/CodeGenCXX/vtt-address-space.cpp Index: clang/test/CodeGenCXX/vtt-address-space.cpp === --- /dev/null +++ clang/test/CodeGenCXX/vtt-address-space.cpp @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -std=c++11 -emit-llvm -o - | FileCheck %s +// This is temporarily disabled as it requires fixing typeinfo & vptr handling +// as well; it will be enabled once those fixes are in. +// XFAIL: * + +// This is the sample from the C++ Itanium ABI, p2.6.2. +namespace Test { + class A1 { int i; }; + class A2 { int i; virtual void f(); }; + class V1 : public A1, public A2 { int i; }; + class B1 { int i; }; + class B2 { int i; }; + class V2 : public B1, public B2, public virtual V1 { int i; }; + class V3 { virtual void g(); }; + class C1 : public virtual V1 { int i; }; + class C2 : public virtual V3, virtual V2 { int i; }; + class X1 { int i; }; + class C3 : public X1 { int i; }; + class D : public C1, public C2, public C3 { int i; }; + + D d; +} + +// CHECK: @_ZTTN4Test1DE = linkonce_odr unnamed_addr addrspace(1) constant [13 x ptr] [ptr addrspacecast (ptr addrspace(1) getelementptr inbounds ({ [5 x ptr], [7 x ptr], [4 x ptr], [3 x ptr] }, ptr addrspace(1) @_ZTVN4Test1DE, i32 0, inrange i32 0, i32 5) to ptr), ptr addrspacecast (ptr addrspace(1) getelementptr inbounds ({ [3 x ptr], [4 x ptr] }, ptr addrspace(1) @_ZTCN4Test1DE0_NS_2C1E, i32 0, inrange i32 0, i32 3) to ptr), ptr addrspacecast (ptr addrspace(1) getelementptr inbounds ({ [3 x ptr], [4 x ptr] }, ptr addrspace(1) @_ZTCN4Test1DE0_NS_2C1E, i32 0, inrange i32 1, i32 3) to ptr), ptr addrspacecast (ptr addrspace(1) getelementptr inbounds ({ [7 x ptr], [3 x ptr], [4 x ptr] }, ptr addrspace(1) @_ZTCN4Test1DE16_NS_2C2E, i32 0, inrange i32 0, i32 6) to ptr), ptr addrspacecast (ptr addrspace(1) getelementptr inbounds ({ [7 x ptr], [3 x ptr], [4 x ptr] }, ptr addrspace(1) @_ZTCN4Test1DE16_NS_2C2E, i32 0, inrange i32 0, i32 6) to ptr), ptr addrspacecast (ptr addrspace(1) getelementptr inbounds ({ [7 x ptr], [3 x ptr], [4 x ptr] }, ptr addrspace(1) @_ZTCN4Test1DE16_NS_2C2E, i32 0, inrange i32 1, i32 3) to ptr), ptr addrspacecast (ptr addrspace(1) getelementptr inbounds ({ [7 x ptr], [3 x ptr], [4 x ptr] }, ptr addrspace(1) @_ZTCN4Test1DE16_NS_2C2E, i32 0, inrange i32 2, i32 3) to ptr), ptr addrspacecast (ptr addrspace(1) getelementptr inbounds ({ [5 x ptr], [7 x ptr], [4 x ptr], [3 x ptr] }, ptr addrspace(1) @_ZTVN4Test1DE, i32 0, inrange i32 2, i32 3) to ptr), ptr addrspacecast (ptr addrspace(1) getelementptr inbounds ({ [5 x ptr], [7 x ptr], [4 x ptr], [3 x ptr] }, ptr addrspace(1) @_ZTVN4Test1DE, i32 0, inrange i32 1, i32 6) to ptr), ptr addrspacecast (ptr addrspace(1) getelementptr inbounds ({ [5 x ptr], [7 x ptr], [4 x ptr], [3 x ptr] }, ptr addrspace(1) @_ZTVN4Test1DE, i32 0, inrange i32 1, i32 6) to ptr), ptr addrspacecast (ptr addrspace(1) getelementptr inbounds ({ [5 x ptr], [7 x ptr], [4 x ptr], [3 x ptr] }, ptr addrspace(1) @_ZTVN4Test1DE, i32 0, inrange i32 3, i32 3) to ptr), ptr addrspacecast (ptr addrspace(1) getelementptr inbounds ({ [3 x ptr], [4 x ptr] }, ptr addrspace(1) @_ZTCN4Test1DE64_NS_2V2E, i32 0, inrange i32 0, i32 3) to ptr), ptr addrspacecast (ptr addrspace(1) getelementptr inbounds ({ [3 x ptr], [4 x ptr] }, ptr addrspace(1) @_ZTCN4Test1DE64_NS_2V2E, i32 0, inrange i32 1, i32 3) to ptr)], comdat, align 8 +// CHECK: call void @_ZN4Test2V2C2Ev(ptr noundef nonnull align 8 dereferenceable(20) %2, ptr addrspace(1) noundef getelementptr inbounds ([13 x ptr], ptr addrspace(1) @_ZTTN4Test1DE, i64 0, i64 11)) +// CHECK: call void @_ZN4Test2C1C2Ev(ptr noundef nonnull align 8 dereferenceable(12) %this1, ptr addrspace(1) noundef getelementptr inbounds ([13 x ptr], ptr addrspace(1) @_ZTTN4Test1DE, i64 0, i64 1)) +// CHECK: call void @_ZN4Test2C2C2Ev(ptr noundef nonnull align 8 dereferenceable(12) %3, ptr addrspace(1) noundef getelementptr inbounds ([13 x ptr], ptr addrspace(1) @_ZTTN4Test1DE, i64 0, i64 3)) +// CHECK-NEXT: define linkonce_odr void @_ZN4Test2V2C2Ev(ptr noundef nonnull align 8 dereferenceable(20) %this, ptr addrspace(1) noundef %vtt) +// CHECK-NEXT: define linkonce_odr void @_ZN4Test2C1C2Ev(ptr noundef nonnull align 8 dereferenceable(12) %this, ptr addrspace(1) noundef %vtt) +// CHECK-NEXT: define linkonce_odr void @_ZN4Test2C2C2Ev(ptr noundef nonnull align 8 dereferenceable(12) %this, ptr addrspace(1) noundef %vtt) Index: clang/lib/CodeGen/ItaniumCXXABI.c
[clang] 29663e2 - [clang][CodeGen] Account for VTT address space
Author: Alex Voicu Date: 2023-06-05T03:06:25+01:00 New Revision: 29663e2b8c4edcd850a4245b1f9509f974220906 URL: https://github.com/llvm/llvm-project/commit/29663e2b8c4edcd850a4245b1f9509f974220906 DIFF: https://github.com/llvm/llvm-project/commit/29663e2b8c4edcd850a4245b1f9509f974220906.diff LOG: [clang][CodeGen] Account for VTT address space Correctly account for the fact that certain targets do not use the generic address space for the implicit VTT argument. This entails adjusting `ItaniumCXXABI::buildStructorSignature`, `ItaniumCXXABI::addImplicitStructorParams` and `ItaniumCXXABI::getImplicitConstructorArgs` to use the target's global variable address space. The associated test is temporarily marked `XFAIL` as additional fixes are needed. Reviewed By: rjmccall Differential Revision: https://reviews.llvm.org/D150746 Added: clang/test/CodeGenCXX/vtt-address-space.cpp Modified: clang/lib/CodeGen/ItaniumCXXABI.cpp Removed: diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 5dc21dd31e0ae..73137ea27222f 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -1587,12 +1587,14 @@ ItaniumCXXABI::buildStructorSignature(GlobalDecl GD, // All parameters are already in place except VTT, which goes after 'this'. // These are Clang types, so we don't need to worry about sret yet. - // Check if we need to add a VTT parameter (which has type void **). + // Check if we need to add a VTT parameter (which has type global void **). if ((isa(GD.getDecl()) ? GD.getCtorType() == Ctor_Base : GD.getDtorType() == Dtor_Base) && cast(GD.getDecl())->getParent()->getNumVBases() != 0) { +LangAS AS = CGM.GetGlobalVarAddressSpace(nullptr); +QualType Q = Context.getAddrSpaceQualType(Context.VoidPtrTy, AS); ArgTys.insert(ArgTys.begin() + 1, - Context.getPointerType(Context.VoidPtrTy)); + Context.getPointerType(CanQualType::CreateUnsafe(Q))); return AddedStructorArgCounts::prefix(1); } return AddedStructorArgCounts{}; @@ -1625,7 +1627,9 @@ void ItaniumCXXABI::addImplicitStructorParams(CodeGenFunction &CGF, ASTContext &Context = getContext(); // FIXME: avoid the fake decl -QualType T = Context.getPointerType(Context.VoidPtrTy); +LangAS AS = CGM.GetGlobalVarAddressSpace(nullptr); +QualType Q = Context.getAddrSpaceQualType(Context.VoidPtrTy, AS); +QualType T = Context.getPointerType(Q); auto *VTTDecl = ImplicitParamDecl::Create( Context, /*DC=*/nullptr, MD->getLocation(), &Context.Idents.get("vtt"), T, ImplicitParamDecl::CXXVTT); @@ -1667,10 +1671,14 @@ CGCXXABI::AddedStructorArgs ItaniumCXXABI::getImplicitConstructorArgs( if (!NeedsVTTParameter(GlobalDecl(D, Type))) return AddedStructorArgs{}; - // Insert the implicit 'vtt' argument as the second argument. + // Insert the implicit 'vtt' argument as the second argument. Make sure to + // correctly reflect its address space, which can diff er from generic on + // some targets. llvm::Value *VTT = CGF.GetVTTParameter(GlobalDecl(D, Type), ForVirtualBase, Delegating); - QualType VTTTy = getContext().getPointerType(getContext().VoidPtrTy); + LangAS AS = CGM.GetGlobalVarAddressSpace(nullptr); + QualType Q = getContext().getAddrSpaceQualType(getContext().VoidPtrTy, AS); + QualType VTTTy = getContext().getPointerType(Q); return AddedStructorArgs::prefix({{VTT, VTTTy}}); } diff --git a/clang/test/CodeGenCXX/vtt-address-space.cpp b/clang/test/CodeGenCXX/vtt-address-space.cpp new file mode 100644 index 0..595587923d5f6 --- /dev/null +++ b/clang/test/CodeGenCXX/vtt-address-space.cpp @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -std=c++11 -emit-llvm -o - | FileCheck %s +// This is temporarily disabled as it requires fixing typeinfo & vptr handling +// as well; it will be enabled once those fixes are in. +// XFAIL: * + +// This is the sample from the C++ Itanium ABI, p2.6.2. +namespace Test { + class A1 { int i; }; + class A2 { int i; virtual void f(); }; + class V1 : public A1, public A2 { int i; }; + class B1 { int i; }; + class B2 { int i; }; + class V2 : public B1, public B2, public virtual V1 { int i; }; + class V3 { virtual void g(); }; + class C1 : public virtual V1 { int i; }; + class C2 : public virtual V3, virtual V2 { int i; }; + class X1 { int i; }; + class C3 : public X1 { int i; }; + class D : public C1, public C2, public C3 { int i; }; + + D d; +} + +// CHECK: @_ZTTN4Test1DE = linkonce_odr unnamed_addr addrspace(1) constant [13 x ptr] [ptr addrspacecast (ptr addrspace(1) getelementptr inbounds ({ [5 x ptr], [7 x ptr], [4 x ptr], [3 x ptr] }, ptr addrspace(1) @_ZTVN4Test1DE, i32 0, inrange i32 0, i32 5) to ptr), ptr addrspacecast (ptr a
[PATCH] D151863: [x86][MC] Fix movdir64b addressing
akshaykhadse added a comment. @craig.topper, @skan: Does this look good? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151863/new/ https://reviews.llvm.org/D151863 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D142388: [clang] Add builtin_nondeterministic_value
zixuan-wu added inline comments. Comment at: clang/test/CodeGen/builtins-nondeterministic-value.c:26 +// CHECK-LABEL: entry +// CHECK: [[A:%.*]] = alloca double, align 8 +// CHECK: store double [[X:%.*]], ptr [[A]], align 8 hi, @ManuelJBrito , because double is 4 alignment in CSKY target, could you please update this with capture match pattern which makes it more adaptable? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D142388/new/ https://reviews.llvm.org/D142388 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1
ychen updated this revision to Diff 528268. ychen marked 14 inline comments as done. ychen added a comment. - address existing comments Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D139837/new/ https://reviews.llvm.org/D139837 Files: clang/docs/ReleaseNotes.rst clang/include/clang/AST/DeclBase.h clang/include/clang/AST/DeclCXX.h clang/include/clang/Sema/Sema.h clang/include/clang/Sema/TemplateDeduction.h clang/lib/AST/ASTImporter.cpp clang/lib/AST/Decl.cpp clang/lib/Frontend/FrontendActions.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaInit.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Sema/SemaTemplate.cpp clang/lib/Sema/SemaTemplateDeduction.cpp clang/lib/Sema/SemaTemplateInstantiate.cpp clang/lib/Sema/SemaTemplateInstantiateDecl.cpp clang/lib/Serialization/ASTReaderDecl.cpp clang/lib/Serialization/ASTWriterDecl.cpp clang/test/SemaTemplate/aggregate-deduction-candidate.cpp clang/www/cxx_status.html Index: clang/www/cxx_status.html === --- clang/www/cxx_status.html +++ clang/www/cxx_status.html @@ -1246,7 +1246,7 @@ Class template argument deduction for aggregates https://wg21.link/p1816r0";>P1816R0 - No + Clang 17 https://wg21.link/p2082r1";>P2082R1 Index: clang/test/SemaTemplate/aggregate-deduction-candidate.cpp === --- /dev/null +++ clang/test/SemaTemplate/aggregate-deduction-candidate.cpp @@ -0,0 +1,333 @@ +// RUN: %clang_cc1 -std=c++20 -verify -ast-dump -ast-dump-decl-types -ast-dump-filter "deduction guide" %s | FileCheck %s --strict-whitespace + +namespace Basic { + template struct A { +T x; +T y; + }; + + A a1 = {3.0, 4.0}; + A a2 = {.x = 3.0, .y = 4.0}; + + A a3(3.0, 4.0); + + // CHECK-LABEL: Dumping Basic::: + // CHECK: FunctionTemplateDecl {{.*}} implicit + // CHECK: |-TemplateTypeParmDecl {{.*}} referenced class depth 0 index 0 T + // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit 'auto (T, T) -> A' + // CHECK: | |-ParmVarDecl {{.*}} 'T' + // CHECK: | `-ParmVarDecl {{.*}} 'T' + // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used 'auto (double, double) -> Basic::A' + // CHECK: |-TemplateArgument type 'double' + // CHECK: | `-BuiltinType {{.*}} 'double' + // CHECK: |-ParmVarDecl {{.*}} 'double':'double' + // CHECK: `-ParmVarDecl {{.*}} 'double':'double' + // CHECK: FunctionProtoType {{.*}} 'auto (T, T) -> A' dependent trailing_return cdecl + // CHECK: |-InjectedClassNameType {{.*}} 'A' dependent + // CHECK: | `-CXXRecord {{.*}} 'A' + // CHECK: |-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0 + // CHECK: | `-TemplateTypeParm {{.*}} 'T' + // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0 + // CHECK: `-TemplateTypeParm {{.*}} 'T' + + template struct S { // expected-note 2 {{candidate}} +T x; +T y; + }; + + template struct C { // expected-note 10 {{candidate}} +S s; +T t; + }; + + template struct D { // expected-note 6 {{candidate}} +S s; +T t; + }; + + C c1 = {1, 2}; // expected-error {{no viable}} + C c2 = {1, 2, 3}; // expected-error {{no viable}} + C c3 = {{1u, 2u}, 3}; + + C c4(1, 2);// expected-error {{no viable}} + C c5(1, 2, 3); // expected-error {{no viable}} + C c6({1u, 2u}, 3); + + D d1 = {1, 2}; // expected-error {{no viable}} + D d2 = {1, 2, 3}; + + D d3(1, 2); // expected-error {{no viable}} + // CTAD succeed but brace elision is not allowed for parenthesized aggregate init. + D d4(1, 2, 3); // expected-error {{no viable}} + + // CHECK-LABEL: Dumping Basic::: + // CHECK: FunctionTemplateDecl {{.*}} implicit + // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 T + // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit 'auto (S, T) -> C' + // CHECK: | |-ParmVarDecl {{.*}} 'S':'S' + // CHECK: | `-ParmVarDecl {{.*}} 'T' + // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used 'auto (S, int) -> Basic::C' + // CHECK: |-TemplateArgument type 'int' + // CHECK: | `-BuiltinType {{.*}} 'int' + // CHECK: |-ParmVarDecl {{.*}} 'S':'Basic::S' + // CHECK: `-ParmVarDecl {{.*}} 'int':'int' + // CHECK: FunctionProtoType {{.*}} 'auto (S, T) -> C' dependent trailing_return cdecl + // CHECK: |-InjectedClassNameType {{.*}} 'C' dependent + // CHECK: | `-CXXRecord {{.*}} 'C' + // CHECK: |-ElaboratedType {{.*}} 'S' sugar dependent + // CHECK: | `-TemplateSpecializationType {{.*}} 'S' dependent S + // CHECK: | `-TemplateArgument type 'T' + // CHECK: | `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0 + // CHECK: | `-TemplateTypeParm {{.*}} 'T' + // CHECK: `-TemplateTypeParmType {{.*}} 'T' dependent depth 0 index 0 + // CHECK: `-TemplateTypeParm {{.*}} 'T' + + // CHECK-LABEL: Dumping Basic::: + // CHECK: FunctionTemplateDecl {{.*}} implici
[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1
ychen added inline comments. Comment at: clang/include/clang/AST/DeclBase.h:1689 +/// (used during overload resolution). +uint64_t DeductionCandidateKind : 2; aaron.ballman wrote: > Best not to give this the same name as a type (I don't care which one changes > names). I've changed the type name and kept this as is. Comment at: clang/include/clang/Sema/Sema.h:3992 + OverloadCandidateParamOrder PO = {}, + bool AggregateCandidateDeduction = false); void AddFunctionCandidates(const UnresolvedSetImpl &Functions, aaron.ballman wrote: > We're up to 12 parameters for this function, five of which are `bool` > parameters... at some point, this probably needs to be refactored. Agreed. I will keep my eye on it. Comment at: clang/lib/Sema/SemaInit.cpp:504-510 InitListChecker(Sema &S, const InitializedEntity &Entity, InitListExpr *IL, QualType &T, bool VerifyOnly, bool TreatUnavailableAsInvalid, - bool InOverloadResolution = false); + bool InOverloadResolution = false, + SmallVector *AggrDeductionCandidateParamTypes = nullptr); + InitListChecker(Sema &S, const InitializedEntity &Entity, InitListExpr *IL, + QualType &T, + SmallVector &AggrDeductionCandidateParamTypes) aaron.ballman wrote: > We shouldn't force the caller to use the same-sized SmallVector, right? That's right. Comment at: clang/lib/Sema/SemaInit.cpp:1036 +RecordDecl *InitListChecker::getRecordDecl(QualType DeclType) { + if (DeclType->isRecordType()) aaron.ballman wrote: > Can we make this return a `const RecordDecl *` or does that run into viral > const issues? "viral const issues". Deep somewhere else needs it non-const. Comment at: clang/lib/Sema/SemaInit.cpp:1445-1447 + // brace elision is not considered for any aggregate element that has a + // dependent non-array type or an array type with a value-dependent + // bound aaron.ballman wrote: > Be sure to add test coverage for use of VLAs in C++ (we support it as an > extension). `Array::a2` test case covers this. Comment at: clang/lib/Sema/SemaTemplate.cpp:2576 +SourceLocation Loc) { + if (CXXRecordDecl *DefRecord = + cast(Template->getTemplatedDecl())->getDefinition()) { aaron.ballman wrote: > Something is amiss here. Either this should be using `dyn_cast` or it should > not be in an `if` statement (`cast` cannot fail; it asserts if it does). It's the `getDefinition()` that may be null. I've hoist the cast out to make it obvious. Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:1059-1062 +case CodeSynthesisContext::BuildingDeductionGuides: + assert( + false && + "failed building deduction guides, add meaningful diagnostics here"); aaron.ballman wrote: > cor3ntin wrote: > > This seems unfinished > +1 I meant to keep this a future work since this path is dead until some errors could be thrown out of this context. In the future, if errors happen during building deduction guides, this assertion failure could trigger at build time. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D139837/new/ https://reviews.llvm.org/D139837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D151863: [x86][MC] Fix movdir64b addressing
skan added a comment. Replace the url of the picture in the summary with the plain text? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151863/new/ https://reviews.llvm.org/D151863 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D151863: [x86][MC] Fix movdir64b addressing
skan added inline comments. Comment at: llvm/test/MC/X86/x86-64-movdir64b-intel.s:1 +// RUN: llvm-mc -triple x86_64-unknown-unknown -x86-asm-syntax=intel -output-asm-variant=1 --show-encoding %s | FileCheck %s +// CHECK: movdir64b rax, zmmword ptr [rax - 4096] The test can pass w/o this patch. I think we should replace it with IR test (llc) here, the input should be the diff in ms-inline-asm-64.c. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151863/new/ https://reviews.llvm.org/D151863 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1
cor3ntin added inline comments. Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:1059-1062 +case CodeSynthesisContext::BuildingDeductionGuides: + assert( + false && + "failed building deduction guides, add meaningful diagnostics here"); ychen wrote: > aaron.ballman wrote: > > cor3ntin wrote: > > > This seems unfinished > > +1 > I meant to keep this a future work since this path is dead until some errors > could be thrown out of this context. In the future, if errors happen during > building deduction guides, this assertion failure could trigger at build time. In this case, maybe change the message assert(false && "unexpected deduction guide in instantiation stack") or something along those lines. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D139837/new/ https://reviews.llvm.org/D139837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D151863: [x86][MC] Fix movdir64b addressing
akshaykhadse added inline comments. Comment at: llvm/test/MC/X86/x86-64-movdir64b-intel.s:1 +// RUN: llvm-mc -triple x86_64-unknown-unknown -x86-asm-syntax=intel -output-asm-variant=1 --show-encoding %s | FileCheck %s +// CHECK: movdir64b rax, zmmword ptr [rax - 4096] skan wrote: > The test can pass w/o this patch. I think we should replace it with IR test > (llc) here, the input should be the diff in ms-inline-asm-64.c. It is better to remove this as it does not add any value. We cannot write a llc test for this because: - If input IR is `call ... "movdir64b eax, ZMMWORD PTR arr ..."`, the generated assembly will be `movdir64b arr, %rax" - If input IR is `call ... "movdir64b eax, ZMMWORD PTR $0 ..."`, the generated assembly will be `movdir64b -4016(%rbp), %rax" In other words, it's responsibility of front-end to generate the correct IR. If the IR is not correct, the back-end will not fix it and incorrect assembly will be generated. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151863/new/ https://reviews.llvm.org/D151863 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D134681: [Clang][AArch64][SME] Add outer product intrinsics
bryanpkc updated this revision to Diff 528291. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D134681/new/ https://reviews.llvm.org/D134681 Files: clang/include/clang/Basic/arm_sme.td clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_mopa-za32.c clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_mopa-za64.c clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_mops-za32.c clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_mops-za64.c clang/test/Sema/aarch64-sme-intrinsics/acle_sme_imm.cpp Index: clang/test/Sema/aarch64-sme-intrinsics/acle_sme_imm.cpp === --- clang/test/Sema/aarch64-sme-intrinsics/acle_sme_imm.cpp +++ clang/test/Sema/aarch64-sme-intrinsics/acle_sme_imm.cpp @@ -132,6 +132,19 @@ SVE_ACLE_FUNC(svaddha_za32, _s32, _m,)(4, pg, pg, svundef_s32()); // expected-error@+1 {{argument value 18446744073709551615 is outside the valid range [0, 3]}} SVE_ACLE_FUNC(svaddva_za32, _s32, _m,)(-1, pg, pg, svundef_s32()); + + // expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}} + SVE_ACLE_FUNC(svmopa_za32, _s8, _m,)(4, pg, pg, svundef_s8(), svundef_s8()); + // expected-error@+1 {{argument value 18446744073709551615 is outside the valid range [0, 3]}} + SVE_ACLE_FUNC(svmops_za32, _s8, _m,)(-1, pg, pg, svundef_s8(), svundef_s8()); + // expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}} + SVE_ACLE_FUNC(svsumopa_za32, _s8, _m,)(4, pg, pg, svundef_s8(), svundef_u8()); + // expected-error@+1 {{argument value 18446744073709551615 is outside the valid range [0, 3]}} + SVE_ACLE_FUNC(svsumops_za32, _s8, _m,)(-1, pg, pg, svundef_s8(), svundef_u8()); + // expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}} + SVE_ACLE_FUNC(svusmopa_za32, _u8, _m,)(4, pg, pg, svundef_u8(), svundef_s8()); + // expected-error@+1 {{argument value 18446744073709551615 is outside the valid range [0, 3]}} + SVE_ACLE_FUNC(svusmops_za32, _u8, _m,)(-1, pg, pg, svundef_u8(), svundef_s8()); } ARM_STREAMING_ATTR @@ -174,6 +187,19 @@ SVE_ACLE_FUNC(svaddha_za64, _s64, _m,)(8, pg, pg, svundef_s64()); // expected-error@+1 {{argument value 18446744073709551615 is outside the valid range [0, 7]}} SVE_ACLE_FUNC(svaddva_za64, _s64, _m,)(-1, pg, pg, svundef_s64()); + + // expected-error@+1 {{argument value 8 is outside the valid range [0, 7]}} + SVE_ACLE_FUNC(svmopa_za64, _s16, _m,)(8, pg, pg, svundef_s16(), svundef_s16()); + // expected-error@+1 {{argument value 18446744073709551615 is outside the valid range [0, 7]}} + SVE_ACLE_FUNC(svmops_za64, _s16, _m,)(-1, pg, pg, svundef_s16(), svundef_s16()); + // expected-error@+1 {{argument value 8 is outside the valid range [0, 7]}} + SVE_ACLE_FUNC(svsumopa_za64, _s16, _m,)(8, pg, pg, svundef_s16(), svundef_u16()); + // expected-error@+1 {{argument value 18446744073709551615 is outside the valid range [0, 7]}} + SVE_ACLE_FUNC(svsumops_za64, _s16, _m,)(-1, pg, pg, svundef_s16(), svundef_u16()); + // expected-error@+1 {{argument value 8 is outside the valid range [0, 7]}} + SVE_ACLE_FUNC(svusmopa_za64, _u16, _m,)(8, pg, pg, svundef_u16(), svundef_s16()); + // expected-error@+1 {{argument value 18446744073709551615 is outside the valid range [0, 7]}} + SVE_ACLE_FUNC(svusmops_za64, _u16, _m,)(-1, pg, pg, svundef_u16(), svundef_s16()); } ARM_STREAMING_ATTR Index: clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_mops-za64.c === --- /dev/null +++ clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_mops-za64.c @@ -0,0 +1,80 @@ +// REQUIRES: aarch64-registered-target +// RUN: %clang_cc1 -DDISABLE_SME_ATTRIBUTES -triple aarch64-none-linux-gnu -target-feature +sme-f64f64 -target-feature +sme-i16i64 -target-feature +sve -target-feature +bf16 -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s -check-prefixes=CHECK,CHECK-C +// RUN: %clang_cc1 -DDISABLE_SME_ATTRIBUTES -triple aarch64-none-linux-gnu -target-feature +sme-f64f64 -target-feature +sme-i16i64 -target-feature +sve -target-feature +bf16 -S -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,CHECK-CXX +// RUN: %clang_cc1 -DDISABLE_SME_ATTRIBUTES -DSME_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sme-f64f64 -target-feature +sme-i16i64 -target-feature +sve -target-feature +bf16 -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s -check-prefixes=CHECK,CHECK-C +// RUN: %clang_cc1 -DDISABLE_SME_ATTRIBUTES -DSME_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sme-f64f64 -target-feature +sme-i16i64 -target-feature +sve -target-feature +bf16 -S -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,CHECK-CXX +// RUN: %clang_cc1 -DDISABLE_SME_ATTRIBUTES -triple aarch64-none-linux-gnu -target-feature +sme-f64f64 -target-feature +sme-i16i64 -target-feature +sve -target-feature +bf16 -S -O1 -Werror -o /dev/null %s +
[PATCH] D142702: [Clang][AArch64][SME] Generate target features from +(no)sme.* options
bryanpkc updated this revision to Diff 528293. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D142702/new/ https://reviews.llvm.org/D142702 Files: clang/lib/Driver/ToolChains/Arch/AArch64.cpp clang/test/Driver/aarch64-implied-sme-features.c clang/test/Driver/aarch64-implied-sve-features.c Index: clang/test/Driver/aarch64-implied-sve-features.c === --- clang/test/Driver/aarch64-implied-sve-features.c +++ clang/test/Driver/aarch64-implied-sve-features.c @@ -57,7 +57,7 @@ // SVE2-SUBFEATURE-MIX: "-target-feature" "+sve2-bitperm" "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "-sve2-aes" // RUN: %clang --target=aarch64-linux-gnu -march=armv8-a+sve2-sm4+nosve2 %s -### 2>&1 | FileCheck %s --check-prefix=SVE2-SUBFEATURE-CONFLICT -// SVE2-SUBFEATURE-CONFLICT: "-target-feature" "+sve" "-target-feature" "-sve2" "-target-feature" "-sve2-bitperm" "-target-feature" "-sve2-sha3" "-target-feature" "-sve2-aes" "-target-feature" "-sve2-sm4" +// SVE2-SUBFEATURE-CONFLICT: "-target-feature" "+sve" "-target-feature" "-sve2" "-target-feature" "-sve2-bitperm" "-target-feature" "-sve2-sha3" "-target-feature" "-sve2-aes" "-target-feature" "-sve2-sm4" "-target-feature" "-sme" "-target-feature" "-sme-f64f64" "-target-feature" "-sme-i16i64" // RUN: %clang --target=aarch64-linux-gnu -march=armv8-a+sve2-aes+nosve %s -### 2>&1 | FileCheck %s --check-prefix=SVE-SUBFEATURE-CONFLICT // SVE-SUBFEATURE-CONFLICT-NOT: "-target-feature" "+sve2-aes" @@ -65,7 +65,7 @@ // SVE-SUBFEATURE-CONFLICT-NOT: "-target-feature" "+sve" // RUN: %clang --target=aarch64-linux-gnu -march=armv8-a+nosve+sve2-aes %s -### 2>&1 | FileCheck %s --check-prefix=SVE-SUBFEATURE-CONFLICT-REV -// SVE-SUBFEATURE-CONFLICT-REV: "-target-feature" "-sve2-bitperm" "-target-feature" "-sve2-sha3" "-target-feature" "-sve2-sm4" "-target-feature" "+sve2-aes" "-target-feature" "+sve" "-target-feature" "+sve2" +// SVE-SUBFEATURE-CONFLICT-REV: "-target-feature" "-sve2-bitperm" "-target-feature" "-sve2-sha3" "-target-feature" "-sve2-sm4" "-target-feature" "-sme" "-target-feature" "-sme-f64f64" "-target-feature" "-sme-i16i64" "-target-feature" "+sve2-aes" "-target-feature" "+sve" "-target-feature" "+sve2" // RUN: %clang --target=aarch64-linux-gnu -mcpu=neoverse-n2+nosve2 %s -### 2>&1 | FileCheck %s --check-prefix=SVE-MCPU-FEATURES // SVE-MCPU-FEATURES-NOT: "-target-feature" "+sve2-bitperm" Index: clang/test/Driver/aarch64-implied-sme-features.c === --- /dev/null +++ clang/test/Driver/aarch64-implied-sme-features.c @@ -0,0 +1,55 @@ +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme %s -### 2>&1 | FileCheck %s --check-prefix=SME-IMPLY +// SME-IMPLY: "-target-feature" "+sme" "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+bf16" + +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+nosme %s -### 2>&1 | FileCheck %s --check-prefix=NOSME +// NOSME: "-target-feature" "-sme" + +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme+nosme %s -### 2>&1 | FileCheck %s --check-prefix=SME-REVERT +// SME-REVERT-NOT: "-target-feature" "+sme" +// SME-REVERT: "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+bf16" "-target-feature" "-sme" "-target-feature" "-sme-f64f64" "-target-feature" "-sme-i16i64" + +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme+nosve %s -### 2>&1 | FileCheck %s --check-prefix=SME-CONFLICT +// SME-CONFLICT: "-target-feature" "-sve" "-target-feature" "-sve2" "-target-feature" "-sve2-bitperm" "-target-feature" "-sve2-sha3" "-target-feature" "-sve2-aes" "-target-feature" "-sve2-sm4" "-target-feature" "-sme" + +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme+sve %s -### 2>&1 | FileCheck %s --check-prefix=SME-SVE +// SME-SVE: "-target-feature" "+sme" "-target-feature" "+sve2" "-target-feature" "+bf16" "-target-feature" "+sve" + +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme-i16i64 %s -### 2>&1 | FileCheck %s --check-prefix=SME-I16I64 +// SME-I16I64: "-target-feature" "+sme-i16i64" "-target-feature" "+sme" "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+bf16" + +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+nosme-i16i64 %s -### 2>&1 | FileCheck %s --check-prefix=NOSME-I16I64 +// NOSME-I16I64-NOT: "-target-feature" "+sme-i16i64" +// NOSME-I16I64-NOT: "-target-feature" "+sme" +// NOSME-I16I64-NOT: "-target-feature" "+sve" +// NOSME-I16I64-NOT: "-target-feature" "+sve2" +// NOSME-I16I64-NOT: "-target-feature" "+bf16" +// NOSME-I16I64: "-target-feature" "-sme-i16i64" + +// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme-i16i64+nosme-i16i64 %s -### 2>&1 | FileCheck %s --check-prefix=SME-I16I64-REVERT +// SME-I16I64-REVERT: "-target-feature" "+sme" "-target-feature" "+sve" "-target-feature" "+sve2" "-target-feature" "+bf16" "-target-f
[PATCH] D128648: [Clang][AArch64][SME] Add vector read/write (mova) intrinsics
bryanpkc added a comment. @sdesmalen Could you review this and the rest of the patch stack? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D128648/new/ https://reviews.llvm.org/D128648 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D151863: [x86][MC] Fix movdir64b addressing
skan added inline comments. Comment at: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1780 // Otherwise, we set the base register to a non-zero value - // if we don't know the actual value at this time. This is necessary to + // if we don't know the actual value at this time. This is necessary to // get the matching correct in some cases. This logic was firstly added by 7ca135b25ff408fda31f3b01d5e9303054e8267f. I am not sure whether it's out of date now. But if removing it can make your test pass and not introduce LIT regression, removing should be a better fix. We shouldn't turn a logic we don't understand into another logic we don't understand, which would confuse later developers Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151863/new/ https://reviews.llvm.org/D151863 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D151863: [x86][MC] Fix movdir64b addressing
akshaykhadse added inline comments. Comment at: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:1780 // Otherwise, we set the base register to a non-zero value - // if we don't know the actual value at this time. This is necessary to + // if we don't know the actual value at this time. This is necessary to // get the matching correct in some cases. skan wrote: > This logic was firstly added by 7ca135b25ff408fda31f3b01d5e9303054e8267f. > > I am not sure whether it's out of date now. But if removing it can make your > test pass and not introduce LIT regression, removing should be a better fix. > > We shouldn't turn a logic we don't understand into another logic we don't > understand, which would confuse later developers Ok, let me change this. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151863/new/ https://reviews.llvm.org/D151863 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D151863: [x86][MC] Fix movdir64b addressing
skan added inline comments. Comment at: llvm/test/MC/X86/x86-64-movdir64b-intel.s:1 +// RUN: llvm-mc -triple x86_64-unknown-unknown -x86-asm-syntax=intel -output-asm-variant=1 --show-encoding %s | FileCheck %s +// CHECK: movdir64b rax, zmmword ptr [rax - 4096] akshaykhadse wrote: > skan wrote: > > The test can pass w/o this patch. I think we should replace it with IR test > > (llc) here, the input should be the diff in ms-inline-asm-64.c. > It is better to remove this as it does not add any value. > > We cannot write a llc test for this because: > - If input IR is `call ... "movdir64b eax, ZMMWORD PTR arr ..."`, the > generated assembly will be `movdir64b arr, %rax" > - If input IR is `call ... "movdir64b eax, ZMMWORD PTR $0 ..."`, the > generated assembly will be `movdir64b -4016(%rbp), %rax" > > In other words, it's responsibility of front-end to generate the correct IR. > If the IR is not correct, the back-end will not fix it and incorrect assembly > will be generated. > The backend will parse the inline asm in IR too. As I mentioned, you split the end-to-end test to C->IR and IR->AS. So you need to check the inline asm in IR can be parsed correctly. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D151863/new/ https://reviews.llvm.org/D151863 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 6f57d8d - Revert "[XCOFF][DWARF] XCOFF64 should be able to select the dwarf format in intergrated-as mode."
Author: esmeyi Date: 2023-06-05T02:50:47-04:00 New Revision: 6f57d8df2d5f81fa8efe1020aaa5f6017fba10c6 URL: https://github.com/llvm/llvm-project/commit/6f57d8df2d5f81fa8efe1020aaa5f6017fba10c6 DIFF: https://github.com/llvm/llvm-project/commit/6f57d8df2d5f81fa8efe1020aaa5f6017fba10c6.diff LOG: Revert "[XCOFF][DWARF] XCOFF64 should be able to select the dwarf format in intergrated-as mode." This reverts commit 4054c68644dfebbb584bca698a25d18d1d312bae. Due to AIX system linker requires DWARF64 for XCOFF64. Added: Modified: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/debug-options-as.c clang/test/Driver/debug-options.c llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/test/CodeGen/PowerPC/aix-dwarf.ll llvm/test/CodeGen/PowerPC/aix-xcoff-exception-section-debug.ll Removed: llvm/test/DebugInfo/XCOFF/dwarf-format.ll diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 02eec4d59b620..5a7dbe1debc65 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4156,9 +4156,9 @@ static void renderDwarfFormat(const Driver &D, const llvm::Triple &T, else if (!T.isArch64Bit()) D.Diag(diag::err_drv_argument_only_allowed_with) << DwarfFormatArg->getAsString(Args) << "64 bit architecture"; -else if (!(T.isOSBinFormatELF() || T.isOSBinFormatXCOFF())) +else if (!T.isOSBinFormatELF()) D.Diag(diag::err_drv_argument_only_allowed_with) - << DwarfFormatArg->getAsString(Args) << "ELF/XCOFF platforms"; + << DwarfFormatArg->getAsString(Args) << "ELF platforms"; } DwarfFormatArg->render(Args, CmdArgs); diff --git a/clang/test/Driver/debug-options-as.c b/clang/test/Driver/debug-options-as.c index baa6bf1e70f1a..87268e8c5deaf 100644 --- a/clang/test/Driver/debug-options-as.c +++ b/clang/test/Driver/debug-options-as.c @@ -59,7 +59,7 @@ // // GDWARF64_VER: error: invalid argument '-gdwarf64' only allowed with 'DWARFv3 or greater' // GDWARF64_32ARCH: error: invalid argument '-gdwarf64' only allowed with '64 bit architecture' -// GDWARF64_ELF: error: invalid argument '-gdwarf64' only allowed with 'ELF/XCOFF platforms' +// GDWARF64_ELF: error: invalid argument '-gdwarf64' only allowed with 'ELF platforms' // Check that -gdwarf-N can be placed before other options of the "-g" group. // RUN: %clang -### -c -g -gdwarf-3 -target %itanium_abi_triple -fintegrated-as -x assembler %s 2>&1 \ diff --git a/clang/test/Driver/debug-options.c b/clang/test/Driver/debug-options.c index 1799f2cc1492b..8617949cea1c8 100644 --- a/clang/test/Driver/debug-options.c +++ b/clang/test/Driver/debug-options.c @@ -462,7 +462,7 @@ // GDWARF64_ON: "-gdwarf64" // GDWARF64_VER: error: invalid argument '-gdwarf64' only allowed with 'DWARFv3 or greater' // GDWARF64_32ARCH: error: invalid argument '-gdwarf64' only allowed with '64 bit architecture' -// GDWARF64_ELF: error: invalid argument '-gdwarf64' only allowed with 'ELF/XCOFF platforms' +// GDWARF64_ELF: error: invalid argument '-gdwarf64' only allowed with 'ELF platforms' /// Default to -fno-dwarf-directory-asm for -fno-integrated-as before DWARF v5. // RUN: %clang -### -target x86_64 -c -gdwarf-2 %s 2>&1 | FileCheck --check-prefix=DIRECTORY %s diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index e0814c0f61af6..ea9a2d7e5e397 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -397,17 +397,14 @@ DwarfDebug::DwarfDebug(AsmPrinter *A) // 1: For ELF when requested. // 2: For XCOFF64: the AIX assembler will fill in debug section lengths //according to the DWARF64 format for 64-bit assembly, so we must use - //DWARF64 in the compiler for 64-bit mode on non-integrated-as mode. - bool IsXcoff = TT.isOSBinFormatXCOFF(); - bool UseIntegratedAs = Asm->OutStreamer->isIntegratedAssemblerRequired(); + //DWARF64 in the compiler too for 64-bit mode. Dwarf64 &= - ((TT.isOSBinFormatELF() || (IsXcoff && UseIntegratedAs)) && - (Asm->TM.Options.MCOptions.Dwarf64 || MMI->getModule()->isDwarf64())) || - (IsXcoff && !UseIntegratedAs); + ((Asm->TM.Options.MCOptions.Dwarf64 || MMI->getModule()->isDwarf64()) && + TT.isOSBinFormatELF()) || + TT.isOSBinFormatXCOFF(); - if (!Dwarf64 && TT.isArch64Bit() && IsXcoff && !UseIntegratedAs) -report_fatal_error( -"XCOFF requires DWARF64 for 64-bit mode on non-integrated-as mode!"); + if (!Dwarf64 && TT.isArch64Bit() && TT.isOSBinFormatXCOFF()) +report_fatal_error("XCOFF requires DWARF64 for 64-bit mode!"); UseRangesSection = !NoDwarfRangesSection && !TT.isNVPTX(); diff --git a/llvm/test/CodeGen/PowerPC/aix-dwarf.ll b/llvm/test/CodeGen/PowerPC/aix-dwarf.ll index 4535d01210b16..0a4032f2acecd 100