Re: [PATCH] D16586: Make clang AAPCS compliant w.r.t volatile bitfield accesses
rmaprath added inline comments. Comment at: test/CodeGen/aapcs-bitfield.c:312-317 @@ +311,8 @@ + + // BE: %[[PTR3:.*]] = bitcast %struct.st5a* %[[PTR2]] to i32* + // BE-NEXT: %[[LD:.*]] = load volatile i32, i32* %[[PTR3]], align 4 + // BE-NEXT: %[[CLR:.*]] = and i32 %[[LD]], -16252929 + // BE-NEXT: %[[SET:.*]] = or i32 %[[CLR]], 1572864 + // BE-NEXT: store volatile i32 %[[SET]], i32* %[[PTR3]], align 4 + m->y.b = 3; +} rsmith wrote: > This violates the C and C++ object models by creating a data race on `m->y.a` > that was not present in the source code. A store to a bit-field cannot write > to bytes that are not part of the same sequence of bit-field members. If this > ABI really requires that (and supports multi-threaded systems), it is not a > correct ABI for C11 nor C++11. (This leaves open the question of which > standard we should follow...) Hi Richard, Thank you for this, I didn't know about this restriction in the C11/C++11 standards. The AAPCS is indeed at odds with the standards in this case, for a simpler example, consider: struct foo { char a; volatile short b : 8; }; void foo(struct foo *p) { p->b = 0xFF; } This store will cause 'a' to be written as well according to the AAPCS. The conflicting sections of the standards are: - AAPCS: 7.1.7.4 Combining bit-field and non-bit-field members (+ 7.1.7.5 - volatile bitfield access) - C++11: 1.7 The C++ memory model - C11: 3.14 memory location I will take this up with the AAPCS authors. http://reviews.llvm.org/D16586 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16686: [OpenCL] Generate metadata for opencl_unroll_hint attribute
pxli168 added inline comments. Comment at: lib/Sema/SemaStmtAttr.cpp:208 @@ +207,3 @@ +SourceRange Range) { + assert(A.getKind() == AttributeList::AT_OpenCLUnrollHint); + This is also not necessary because this function can be called only if it is an OpenCLUnrollHint Comment at: lib/Sema/SemaStmtAttr.cpp:210 @@ +209,3 @@ + + // opencl_unroll_hint can have 0 arguments (compiler determines unrolling + // factor) or 1 argument (the unroll factor provided by the user). You may put the reference at the begin and make a summary after that, I don't think see ... for details is need. Just like what other OpenCL references. Comment at: lib/Sema/SemaStmtAttr.cpp:217 @@ +216,3 @@ + if (NumArgs > 1) { +S.Diag(A.getLoc(), diag::err_attribute_too_many_arguments) << 1; +return 0; > def err_attribute_too_many_arguments : Error<"%0 attribute takes no more than > %1 argument%s1">; you should give this two arguments, one is name and another is the number you expected. Comment at: lib/Sema/SemaStmtAttr.cpp:218 @@ +217,3 @@ +S.Diag(A.getLoc(), diag::err_attribute_too_many_arguments) << 1; +return 0; + } please use nullptr should not use 0 in C++11. Comment at: lib/Sema/SemaStmtAttr.cpp:225 @@ +224,3 @@ +Expr *E = A.getArgAsExpr(0); +assert(E != nullptr && "Invalid opencl_unroll_hint argument"); +llvm::APSInt ArgVal(32); Is this necessary as you have checked there is only one arg in this attr? Comment at: lib/Sema/SemaStmtAttr.cpp:230 @@ +229,3 @@ + S.Diag(A.getLoc(), diag::err_attribute_argument_type) + << A.getName()->getName() << AANT_ArgumentIntegerConstant + << E->getSourceRange(); Why there is two getName? Comment at: test/SemaOpenCL/unroll-hint.cl:17 @@ +16,3 @@ +kernel void E() { + __attribute__((opencl_unroll_hint(2,4))) // expected-error {{1 attribute takes no more than 1 argument}} + for(int i=0; i<100; i++); I think > expected-error {{**1 attribute **takes no more than 1 argument}} should be opencl_unroll_hint http://reviews.llvm.org/D16686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16717: [clang-tidy] Add non-constant references in function parameters check.
hokein updated this revision to Diff 46628. hokein added a comment. Address comments. http://reviews.llvm.org/D16717 Files: clang-tidy/google/CMakeLists.txt clang-tidy/google/GoogleTidyModule.cpp clang-tidy/google/NonConstReferences.cpp clang-tidy/google/NonConstReferences.h docs/clang-tidy/checks/google-runtime-references.rst docs/clang-tidy/checks/list.rst test/clang-tidy/google-runtime-references.cpp Index: test/clang-tidy/google-runtime-references.cpp === --- /dev/null +++ test/clang-tidy/google-runtime-references.cpp @@ -0,0 +1,139 @@ +// RUN: %check_clang_tidy %s google-runtime-references %t -- -- -std=c++11 + +int a; +int &b = a; +int *c; +void f1(int a); +void f2(int *b); +void f3(const int &c); +void f4(int const &d); + +// Don't warn on implicit operator= in c++11 mode. +class A { + virtual void f() {} +}; +// Don't warn on rvalue-references. +struct A2 { + A2(A2&&) = default; + void f(A2&&) {} +}; + +// Don't warn on iostream parameters. +namespace xxx { +class istream { }; +class ostringstream { }; +} +void g1(xxx::istream &istr); +void g1(xxx::ostringstream &istr); + +void g1(int &a); +// CHECK-MESSAGES: [[@LINE-1]]:14: warning: non-const reference parameter 'a', make it const or use a pointer [google-runtime-references] + +struct s {}; +void g2(int a, int b, s c, s &d); +// CHECK-MESSAGES: [[@LINE-1]]:31: warning: non-const reference parameter 'd', {{.*}} + +typedef int &ref; +void g3(ref a); +// CHECK-MESSAGES: [[@LINE-1]]:13: warning: non-const reference {{.*}} + +void g4(int &a, int &b, int &); +// CHECK-MESSAGES: [[@LINE-1]]:14: warning: non-const reference parameter 'a', {{.*}} +// CHECK-MESSAGES: [[@LINE-2]]:22: warning: non-const reference parameter 'b', {{.*}} +// CHECK-MESSAGES: [[@LINE-3]]:30: warning: non-const reference parameter '', {{.*}} + +class B { + B(B& a) {} +// CHECK-MESSAGES: [[@LINE-1]]:8: warning: non-const reference {{.*}} + virtual void f(int &a) {} +// CHECK-MESSAGES: [[@LINE-1]]:23: warning: non-const reference {{.*}} + void g(int &b); +// CHECK-MESSAGES: [[@LINE-1]]:15: warning: non-const reference {{.*}} + + // Don't warn on the parameter of stream extractors defined as members. + B& operator>>(int& val) { return *this; } +}; + +// Only warn on the first declaration of each function to reduce duplicate +// warnings. +void B::g(int &b) {} + +// Don't warn on the first parameter of stream inserters. +A& operator<<(A& s, int&) { return s; } +// CHECK-MESSAGES: [[@LINE-1]]:25: warning: non-const reference parameter '', {{.*}} + +// Don't warn on either parameter of stream extractors. Both need to be +// non-const references by convention. +A& operator>>(A& input, int& val) { return input; } + +// Don't warn on lambdas. +auto lambda = [] (int&) {}; + +// Don't warn on typedefs, as we'll warn on the function itself. +typedef int (*fp)(int &); + +// Don't warn on function references. +typedef void F(); +void g5(const F& func) {} +void g6(F& func) {} + +template +void g7(const T& t) {} + +template +void g8(T t) {} + +void f5() { + g5(f5); + g6(f5); + g7(f5); + g7(f5); + g8(f5); + g8(f5); +} + +// Don't warn on dependent types. +template +void g9(T& t) {} +template +void g10(T t) {} + +void f6() { + int i; + float f; + g9(i); + g9(i); + g9(i); + g10(i); + g10(f); +} + +// Warn only on the overridden methods from the base class, as the child class +// only implements the interface. +class C : public B { + C(); + virtual void f(int &a) {} +}; + +// Don't warn on operator<< with streams-like interface. +A& operator<<(A& s, int) { return s; } + +// Don't warn on swap(). +void swap(C& c1, C& c2) {} + +// Don't warn on standalone operator++, operator--, operator+=, operator-=, +// operator*=, etc. that all need non-const references to be functional. +A& operator++(A& a) { return a; } +A operator++(A& a, int) { return a; } +A& operator--(A& a) { return a; } +A operator--(A& a, int) { return a; } +A& operator+=(A& a, const A& b) { return a; } +A& operator-=(A& a, const A& b) { return a; } +A& operator*=(A& a, const A& b) { return a; } +A& operator/=(A& a, const A& b) { return a; } +A& operator%=(A& a, const A& b) { return a; } +A& operator<<=(A& a, const A& b) { return a; } +A& operator>>=(A& a, const A& b) { return a; } +A& operator|=(A& a, const A& b) { return a; } +A& operator^=(A& a, const A& b) { return a; } +A& operator&=(A& a, const A& b) { return a; } Index: docs/clang-tidy/checks/list.rst === --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -38,6 +38,7 @@ google-runtime-member-string-references google-runtime-memset google-runtime-operator + google-runtime-references llvm-header-guard llvm-include-order llvm-namespace-comment Index: docs/clang-tidy/checks/google-runtime-references.rst === -
Re: [PATCH] D16717: [clang-tidy] Add non-constant references in function parameters check.
hokein marked 4 inline comments as done. hokein added a comment. http://reviews.llvm.org/D16717 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15283: [ARMv8-M] Add Clang targeting for ARMv8-M Baseline/Mainline
bsmith added a comment. Ping. Repository: rL LLVM http://reviews.llvm.org/D15283 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16630: PR23057: Fix assertion `Val && "isa<> used on a null pointer"' on invalid for-range expression
d.zobnin.bugzilla added inline comments. Comment at: lib/Parse/ParseStmt.cpp:1719-1724 @@ -1718,6 +1718,8 @@ if (ForRange) { +ExprResult CorrectedRange = +Actions.CorrectDelayedTyposInExpr(ForRangeInit.RangeExpr.get()); ForRangeStmt = Actions.ActOnCXXForRangeStmt( getCurScope(), ForLoc, CoawaitLoc, FirstPart.get(), -ForRangeInit.ColonLoc, ForRangeInit.RangeExpr.get(), +ForRangeInit.ColonLoc, CorrectedRange.get(), T.getCloseLocation(), Sema::BFRK_Build); majnemer wrote: > Does this change effect all of the test cases you've added? If not, I think > it would make sense to split this change out. Yes, this change is needed in all added test cases. Without this we will have an assertion failure in ~Sema(): ``` assert(DelayedTypos.empty() && "Uncorrected typos!"); ``` http://reviews.llvm.org/D16630 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r259487 - clang-format: Make AlignAfterOpenBracket also affect angle brackets.
Author: djasper Date: Tue Feb 2 04:28:11 2016 New Revision: 259487 URL: http://llvm.org/viewvc/llvm-project?rev=259487&view=rev Log: clang-format: Make AlignAfterOpenBracket also affect angle brackets. Patch by Matthew Whitehead, thank you. Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp cfe/trunk/unittests/Format/FormatTest.cpp Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=259487&r1=259486&r2=259487&view=diff == --- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original) +++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Tue Feb 2 04:28:11 2016 @@ -353,7 +353,8 @@ void ContinuationIndenter::addTokenOnCur // disallowing any further line breaks if there is no line break after the // opening parenthesis. Don't break if it doesn't conserve columns. if (Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak && - Previous.is(tok::l_paren) && State.Column > getNewLineColumn(State) && + Previous.isOneOf(tok::l_paren, TT_TemplateOpener, tok::l_square) && + State.Column > getNewLineColumn(State) && (!Previous.Previous || !Previous.Previous->isOneOf(tok::kw_for, tok::kw_while, tok::kw_switch))) State.Stack.back().NoLineBreak = true; Modified: cfe/trunk/unittests/Format/FormatTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=259487&r1=259486&r2=259487&view=diff == --- cfe/trunk/unittests/Format/FormatTest.cpp (original) +++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Feb 2 04:28:11 2016 @@ -10325,6 +10325,15 @@ TEST_F(FormatTest, ConstructorInitialize ": a(aa), a(aa),\n" " a(aa) {}", Style); + Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak; + verifyFormat( + "SomeLongTemplateVariableName<\n" + "aa, aa>", + Style); + verifyFormat( + "bool smaller = 1 < (\n" + " a);", + Style); } TEST_F(FormatTest, BreakConstructorInitializersBeforeComma) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r259489 - Move DebugInfoKind into its own header to cut the cyclic dependency edge from Driver to Frontend.
Author: d0k Date: Tue Feb 2 05:06:51 2016 New Revision: 259489 URL: http://llvm.org/viewvc/llvm-project?rev=259489&view=rev Log: Move DebugInfoKind into its own header to cut the cyclic dependency edge from Driver to Frontend. Added: cfe/trunk/include/clang/Driver/DebugInfoKind.h Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def cfe/trunk/include/clang/Frontend/CodeGenOptions.h cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/lib/CodeGen/CGBlocks.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.h cfe/trunk/lib/CodeGen/CGDecl.cpp cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/lib/Driver/Tools.h cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp Added: cfe/trunk/include/clang/Driver/DebugInfoKind.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/DebugInfoKind.h?rev=259489&view=auto == --- cfe/trunk/include/clang/Driver/DebugInfoKind.h (added) +++ cfe/trunk/include/clang/Driver/DebugInfoKind.h Tue Feb 2 05:06:51 2016 @@ -0,0 +1,39 @@ +//===--- DebugInfoKind.h - Debug Info Emission Types *- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef LLVM_CLANG_DRIVER_DEBUGINFOKIND_H +#define LLVM_CLANG_DRIVER_DEBUGINFOKIND_H + +namespace clang { +namespace codegenoptions { + +enum DebugInfoKind { + NoDebugInfo, /// Don't generate debug info. + LocTrackingOnly, /// Emit location information but do not generate + /// debug info in the output. This is useful in + /// cases where the backend wants to track source + /// locations for instructions without actually + /// emitting debug info for them (e.g., when -Rpass + /// is used). + DebugLineTablesOnly, /// Emit only debug info necessary for generating + /// line number tables (-gline-tables-only). + LimitedDebugInfo,/// Limit generated debug info to reduce size + /// (-fno-standalone-debug). This emits + /// forward decls for types that could be + /// replaced with forward decls in the source + /// code. For dynamic C++ classes type info + /// is only emitted int the module that + /// contains the classe's vtable. + FullDebugInfo/// Generate complete debug info. +}; + +} // end namespace codegenoptions +} // end namespace clang + +#endif Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=259489&r1=259488&r2=259489&view=diff == --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original) +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Tue Feb 2 05:06:51 2016 @@ -185,7 +185,7 @@ VALUE_CODEGENOPT(NumRegisterParameters, VALUE_CODEGENOPT(SSPBufferSize, 32, 0) /// The kind of generated debug info. -ENUM_CODEGENOPT(DebugInfo, DebugInfoKind, 3, NoDebugInfo) +ENUM_CODEGENOPT(DebugInfo, codegenoptions::DebugInfoKind, 3, codegenoptions::NoDebugInfo) /// Tune the debug info for this debugger. ENUM_CODEGENOPT(DebuggerTuning, DebuggerKind, 2, DebuggerKindDefault) Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=259489&r1=259488&r2=259489&view=diff == --- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original) +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h Tue Feb 2 05:06:51 2016 @@ -15,6 +15,7 @@ #define LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H #include "clang/Basic/Sanitizers.h" +#include "clang/Driver/DebugInfoKind.h" #include "llvm/Support/Regex.h" #include #include @@ -58,30 +59,6 @@ public: Mixed = 2 }; - enum DebugInfoKind { -NoDebugInfo, /// Don't generate debug info. - -LocTrackingOnly, /// Emit location information but do not generate - /// debug info in the output. This is useful in - /// cases where the backend wants to track source - /// locations for instructions without actually -
r259490 - Make headers self-contained.
Author: d0k Date: Tue Feb 2 05:06:57 2016 New Revision: 259490 URL: http://llvm.org/viewvc/llvm-project?rev=259490&view=rev Log: Make headers self-contained. Modified: cfe/trunk/include/clang/Lex/HeaderMap.h cfe/trunk/include/clang/Lex/MacroArgs.h cfe/trunk/lib/Analysis/BodyFarm.h Modified: cfe/trunk/include/clang/Lex/HeaderMap.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderMap.h?rev=259490&r1=259489&r2=259490&view=diff == --- cfe/trunk/include/clang/Lex/HeaderMap.h (original) +++ cfe/trunk/include/clang/Lex/HeaderMap.h Tue Feb 2 05:06:57 2016 @@ -16,11 +16,9 @@ #include "clang/Basic/LLVM.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/MemoryBuffer.h" #include -namespace llvm { - class MemoryBuffer; -} namespace clang { class FileEntry; class FileManager; Modified: cfe/trunk/include/clang/Lex/MacroArgs.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/MacroArgs.h?rev=259490&r1=259489&r2=259490&view=diff == --- cfe/trunk/include/clang/Lex/MacroArgs.h (original) +++ cfe/trunk/include/clang/Lex/MacroArgs.h Tue Feb 2 05:06:57 2016 @@ -15,13 +15,13 @@ #define LLVM_CLANG_LEX_MACROARGS_H #include "clang/Basic/LLVM.h" +#include "clang/Lex/Token.h" #include "llvm/ADT/ArrayRef.h" #include namespace clang { class MacroInfo; class Preprocessor; - class Token; class SourceLocation; /// MacroArgs - An instance of this class captures information about Modified: cfe/trunk/lib/Analysis/BodyFarm.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BodyFarm.h?rev=259490&r1=259489&r2=259490&view=diff == --- cfe/trunk/lib/Analysis/BodyFarm.h (original) +++ cfe/trunk/lib/Analysis/BodyFarm.h Tue Feb 2 05:06:57 2016 @@ -15,6 +15,7 @@ #ifndef LLVM_CLANG_LIB_ANALYSIS_BODYFARM_H #define LLVM_CLANG_LIB_ANALYSIS_BODYFARM_H +#include "clang/AST/DeclBase.h" #include "clang/Basic/LLVM.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/Optional.h" @@ -22,7 +23,6 @@ namespace clang { class ASTContext; -class Decl; class FunctionDecl; class ObjCMethodDecl; class ObjCPropertyDecl; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r259491 - [OpenCL] Eliminate warning when declaring OpenCL builtin functions.
Author: stulova Date: Tue Feb 2 05:29:43 2016 New Revision: 259491 URL: http://llvm.org/viewvc/llvm-project?rev=259491&view=rev Log: [OpenCL] Eliminate warning when declaring OpenCL builtin functions. OpenCL builtin functions are usually declared in header files. Currently clang emits warning for OpenCL builtin functions which have the same name as standard C library functions. This commit eliminates such warnings by not adding the C standard includes following the restriction from OpenCL v1.2 s6.9.f. Patch by Liu Yaxun (Sam)! Review: http://reviews.llvm.org/D16692 Added: cfe/trunk/test/SemaOpenCL/builtin.cl Modified: cfe/trunk/lib/Sema/SemaLookup.cpp Modified: cfe/trunk/lib/Sema/SemaLookup.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=259491&r1=259490&r2=259491&view=diff == --- cfe/trunk/lib/Sema/SemaLookup.cpp (original) +++ cfe/trunk/lib/Sema/SemaLookup.cpp Tue Feb 2 05:29:43 2016 @@ -684,9 +684,9 @@ static bool LookupBuiltin(Sema &S, Looku // If this is a builtin on this (or all) targets, create the decl. if (unsigned BuiltinID = II->getBuiltinID()) { -// In C++, we don't have any predefined library functions like -// 'malloc'. Instead, we'll just error. -if (S.getLangOpts().CPlusPlus && +// In C++ and OpenCL (spec v1.2 s6.9.f), we don't have any predefined +// library functions like 'malloc'. Instead, we'll just error. +if ((S.getLangOpts().CPlusPlus || S.getLangOpts().OpenCL) && S.Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID)) return false; Added: cfe/trunk/test/SemaOpenCL/builtin.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/builtin.cl?rev=259491&view=auto == --- cfe/trunk/test/SemaOpenCL/builtin.cl (added) +++ cfe/trunk/test/SemaOpenCL/builtin.cl Tue Feb 2 05:29:43 2016 @@ -0,0 +1,3 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only + +float __attribute__((overloadable)) acos(float); // expected-no-diagnostics ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16351: [FIX] Bug 25404 - Crash on typedef in OpenCL 2.0
ichesnokov removed rL LLVM as the repository for this revision. ichesnokov updated this revision to Diff 46634. ichesnokov added a comment. Warnings added to the case. Turned off by default: Original bahavior: "// If we have a redefinition of a typedef in C, emit a warning. This warning // is normally mapped to an error, but can be controlled with // -Wtypedef-redefinition. If either the original or the redefinition is // in a system header, don't emit this for compatibility with GCC. " The similar is applied to implicit/builtin typedefs. It needs to define -Wsystem-headers to see the warning. http://reviews.llvm.org/D16351 Files: lib/Sema/SemaDecl.cpp test/SemaOpenCL/implicit-typedef.cl Index: test/SemaOpenCL/implicit-typedef.cl === --- test/SemaOpenCL/implicit-typedef.cl +++ test/SemaOpenCL/implicit-typedef.cl @@ -0,0 +1,2 @@ +// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only -Wsystem-headers +typedef atomic_int atomic_flag; // expected-warning {{redefinition of typedef 'atomic_flag' is a C11 feature}} Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -2033,6 +2033,22 @@ if (getLangOpts().Modules || getLangOpts().C11) return; + // Added isImplicit() check, because implicit TypeDecl::getLocation() + // returns 0. The're many implicit typedefs in OpenCL, e.g. atomic_flag. + if (Old->isImplicit() || New->isImplicit()) { +// Since we don't emit system header warnings for compatibility with GCC, +// don't do this for implicit type redifinition warnings the same way. +if (!getDiagnostics().getSuppressSystemWarnings()) { + if (New->getLocation().isValid()) { +Diag(New->getLocation(), diag::ext_redefinition_of_typedef) + << New->getDeclName(); +if (Old->getLocation().isValid()) + Diag(Old->getLocation(), diag::note_previous_definition); + } +} +return; + } + // If we have a redefinition of a typedef in C, emit a warning. This warning // is normally mapped to an error, but can be controlled with // -Wtypedef-redefinition. If either the original or the redefinition is Index: test/SemaOpenCL/implicit-typedef.cl === --- test/SemaOpenCL/implicit-typedef.cl +++ test/SemaOpenCL/implicit-typedef.cl @@ -0,0 +1,2 @@ +// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only -Wsystem-headers +typedef atomic_int atomic_flag; // expected-warning {{redefinition of typedef 'atomic_flag' is a C11 feature}} Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -2033,6 +2033,22 @@ if (getLangOpts().Modules || getLangOpts().C11) return; + // Added isImplicit() check, because implicit TypeDecl::getLocation() + // returns 0. The're many implicit typedefs in OpenCL, e.g. atomic_flag. + if (Old->isImplicit() || New->isImplicit()) { +// Since we don't emit system header warnings for compatibility with GCC, +// don't do this for implicit type redifinition warnings the same way. +if (!getDiagnostics().getSuppressSystemWarnings()) { + if (New->getLocation().isValid()) { +Diag(New->getLocation(), diag::ext_redefinition_of_typedef) + << New->getDeclName(); +if (Old->getLocation().isValid()) + Diag(Old->getLocation(), diag::note_previous_definition); + } +} +return; + } + // If we have a redefinition of a typedef in C, emit a warning. This warning // is normally mapped to an error, but can be controlled with // -Wtypedef-redefinition. If either the original or the redefinition is ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16351: [FIX] Bug 25404 - Crash on typedef in OpenCL 2.0
ichesnokov marked 3 inline comments as done. Comment at: test/SemaOpenCL/implicit-typedef.cl:2 @@ +1,2 @@ +// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only -Wsystem-headers +typedef atomic_int atomic_flag; // expected-warning {{redefinition of typedef 'atomic_flag' is a C11 feature}} Test case command line fixed. Comment at: test/SemaOpenCL/implicit-typedef.cl:2 @@ +1,2 @@ +// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only -Wsystem-headers +typedef atomic_int atomic_flag; // expected-warning {{redefinition of typedef 'atomic_flag' is a C11 feature}} ichesnokov wrote: > Test case command line fixed. Added a warning (reused existing C/C++). Warning is checked in test case. http://reviews.llvm.org/D16351 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D16801: [OpenMP] Change in initial size of DSAStackTy::StackTy
esakella created this revision. esakella added a subscriber: ABataev. Hello, I have made a small change in the initial size of the StackTy SmallVector of class DSAStackTy. I reduced the initial size of this SmallVector from 64 elements to 4 elements, in order to improve the memory consumption during the creation of the Sema, whose constructor calls the Sema::InitDataSharingAttributesStack() function, which in turn creates a DSAStackTy. After profiling Clang (I just gave it a simple source file to compile) before and after this change, the difference in memory consumption is up to almost 400 KB. Would that change be acceptable? Thank you, Sakellari Elisavet http://reviews.llvm.org/D16801 Files: lib/Sema/SemaOpenMP.cpp Index: lib/Sema/SemaOpenMP.cpp === --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -123,7 +123,7 @@ CancelRegion(false), AssociatedLoops(1), InnerTeamsRegionLoc() {} }; - typedef SmallVector StackTy; + typedef SmallVector StackTy; /// \brief Stack of used declaration and their data-sharing attributes. StackTy Stack; Index: lib/Sema/SemaOpenMP.cpp === --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -123,7 +123,7 @@ CancelRegion(false), AssociatedLoops(1), InnerTeamsRegionLoc() {} }; - typedef SmallVector StackTy; + typedef SmallVector StackTy; /// \brief Stack of used declaration and their data-sharing attributes. StackTy Stack; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16686: [OpenCL] Generate metadata for opencl_unroll_hint attribute
Anastasia added inline comments. Comment at: lib/Sema/SemaStmtAttr.cpp:225 @@ +224,3 @@ +Expr *E = A.getArgAsExpr(0); +assert(E != nullptr && "Invalid opencl_unroll_hint argument"); +llvm::APSInt ArgVal(32); pxli168 wrote: > Is this necessary as you have checked there is only one arg in this attr? I guess this might be the case if it's not an Expr, but not sure what else it could be. I think we probably don't need it. Comment at: lib/Sema/SemaStmtAttr.cpp:230 @@ +229,3 @@ + S.Diag(A.getLoc(), diag::err_attribute_argument_type) + << A.getName()->getName() << AANT_ArgumentIntegerConstant + << E->getSourceRange(); pxli168 wrote: > Why there is two getName? 1st returns IdentifierInfo and 2nd actual StringRef. http://reviews.llvm.org/D16686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16794: [Clang-tidy] Make readability-simplify-boolean-expr working with included files
aaron.ballman added a comment. Missing a test case for this functionality. The isExpansionInMainFile() was used to silence the diagnostic in macros, but it was pointed out during review that this should be fixed and it seems to have fallen through the cracks. Can you also add tests for macros to ensure the behavior is acceptable there still? See http://reviews.llvm.org/D8996 for more context. Repository: rL LLVM http://reviews.llvm.org/D16794 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16786: [Clang-tidy] Make modernize-redundant-void-arg working with included files
aaron.ballman added a comment. Missing testcases for this; I suspect that isExpansionInMainFile was being used to filter out results in macro expansions, so some tests to ensure the behavior is correct there would also be appreciated. Repository: rL LLVM http://reviews.llvm.org/D16786 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r259492 - Test commit (NFC).
Author: dzobnin Date: Tue Feb 2 06:39:08 2016 New Revision: 259492 URL: http://llvm.org/viewvc/llvm-project?rev=259492&view=rev Log: Test commit (NFC). Modified: cfe/trunk/test/CodeGenCXX/alignment.cpp Modified: cfe/trunk/test/CodeGenCXX/alignment.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/alignment.cpp?rev=259492&r1=259491&r2=259492&view=diff == --- cfe/trunk/test/CodeGenCXX/alignment.cpp (original) +++ cfe/trunk/test/CodeGenCXX/alignment.cpp Tue Feb 2 06:39:08 2016 @@ -32,7 +32,7 @@ namespace test0 { // CHECK: [[T2:%.*]] = or i8 [[T1]], [[T0]] // CHECK: store i8 [[T2]], i8* [[FIELD_P]], align 4 b.onebit = int_source(); - + // CHECK: [[B_P:%.*]] = load [[B]]*, [[B]]** // CHECK: [[FIELD_P:%.*]] = bitcast [[B]]* [[B_P]] to i8* // CHECK: [[VALUE:%.*]] = load i8, i8* [[FIELD_P]], align 4 @@ -60,7 +60,7 @@ namespace test0 { // CHECK: [[T2:%.*]] = or i8 [[T1]], [[T0]] // CHECK: store i8 [[T2]], i8* [[FIELD_P]], align 2 c.onebit = int_source(); - + // CHECK: [[C_P:%.*]] = load [[C]]*, [[C]]** // CHECK: [[T0:%.*]] = bitcast [[C]]* [[C_P]] to i8* // CHECK: [[T1:%.*]] = getelementptr inbounds i8, i8* [[T0]], i64 8 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM! Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.cpp:366 @@ +365,3 @@ + binaryOperator( + isExpansionInMainFile(), hasOperatorName(OperatorName), + hasLHS(allOf( Sorry for not noticing this earlier, but since we have two other in-flight patches I reviewed this morning, it caught my attention: we should not be using isExpansionInMainFile, but instead testing the source location of the matches to see if they're in a macro expansion. This is usually done with something like `Result.SourceManager->isMacroBodyExpansion(SomeLoc)`. I realize this is existing code and not your problem, but it should be fixed in a follow-on patch (by someone) and include some macro test cases. http://reviews.llvm.org/D16308 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D16804: [analyzer] AnalysisConsumer: print fully-qualified function name while displaying progress
a.sidorin created this revision. a.sidorin added reviewers: xazax.hun, zaks.anna, dcoughlin. a.sidorin added a subscriber: cfe-commits. -analyzer-display progress option prints only function names which may be suspicious. This patch forces AnalysisConsumer to print fully-qualified function names. http://reviews.llvm.org/D16804 Files: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp test/Analysis/analyze_display_progress.c test/Analysis/analyze_display_progress.cpp Index: test/Analysis/analyze_display_progress.cpp === --- /dev/null +++ test/Analysis/analyze_display_progress.cpp @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -analyze -analyzer-display-progress %s 2>&1 | FileCheck %s + +void f() {}; +void g() {}; +void h() {} + +struct SomeStruct { + void f() {} +}; + +struct SomeOtherStruct { + void f() {} +}; + +namespace ns { + struct SomeStruct { +void f() {} + }; +} + +// CHECK: analyze_display_progress.cpp f +// CHECK: analyze_display_progress.cpp g +// CHECK: analyze_display_progress.cpp h +// CHECK: analyze_display_progress.cpp SomeStruct::f +// CHECK: analyze_display_progress.cpp SomeOtherStruct::f +// CHECK: analyze_display_progress.cpp ns::SomeStruct::f Index: test/Analysis/analyze_display_progress.c === --- test/Analysis/analyze_display_progress.c +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 -analyze -analyzer-display-progress %s 2>&1 | FileCheck %s - -void f() {}; -void g() {}; -void h() {} - -// CHECK: analyze_display_progress.c f -// CHECK: analyze_display_progress.c g -// CHECK: analyze_display_progress.c h \ No newline at end of file Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp === --- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -286,7 +286,7 @@ llvm::errs() << ": " << Loc.getFilename(); if (isa(D) || isa(D)) { const NamedDecl *ND = cast(D); -llvm::errs() << ' ' << *ND << '\n'; +llvm::errs() << ' ' << ND->getQualifiedNameAsString() << '\n'; } else if (isa(D)) { llvm::errs() << ' ' << "block(line:" << Loc.getLine() << ",col:" Index: test/Analysis/analyze_display_progress.cpp === --- /dev/null +++ test/Analysis/analyze_display_progress.cpp @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -analyze -analyzer-display-progress %s 2>&1 | FileCheck %s + +void f() {}; +void g() {}; +void h() {} + +struct SomeStruct { + void f() {} +}; + +struct SomeOtherStruct { + void f() {} +}; + +namespace ns { + struct SomeStruct { +void f() {} + }; +} + +// CHECK: analyze_display_progress.cpp f +// CHECK: analyze_display_progress.cpp g +// CHECK: analyze_display_progress.cpp h +// CHECK: analyze_display_progress.cpp SomeStruct::f +// CHECK: analyze_display_progress.cpp SomeOtherStruct::f +// CHECK: analyze_display_progress.cpp ns::SomeStruct::f Index: test/Analysis/analyze_display_progress.c === --- test/Analysis/analyze_display_progress.c +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 -analyze -analyzer-display-progress %s 2>&1 | FileCheck %s - -void f() {}; -void g() {}; -void h() {} - -// CHECK: analyze_display_progress.c f -// CHECK: analyze_display_progress.c g -// CHECK: analyze_display_progress.c h \ No newline at end of file Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp === --- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -286,7 +286,7 @@ llvm::errs() << ": " << Loc.getFilename(); if (isa(D) || isa(D)) { const NamedDecl *ND = cast(D); -llvm::errs() << ' ' << *ND << '\n'; +llvm::errs() << ' ' << ND->getQualifiedNameAsString() << '\n'; } else if (isa(D)) { llvm::errs() << ' ' << "block(line:" << Loc.getLine() << ",col:" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16376: clang-tidy check: Assignment and Construction
aaron.ballman added inline comments. Comment at: clang-tidy/misc/AssignmentAndConstructionCheck.cpp:91 @@ +90,3 @@ + case AssignmentAndConstructionCheck::SpecialFunctionKind::CopyConstructor: +return "class '%0' defines a copy-constructor but not a copy-assignment " + "operator"; Should elide the single quotes in these diagnostics and pass in the NamedDecl to the diagnostic instead of a string -- the diagnostic formatter handles quoting properly from NamedDecl objects. Also, the diagnostics should remove the hyphens -- it's a copy constructor, not a copy-constructor (same for assignment , etc). Comment at: clang-tidy/misc/AssignmentAndConstructionCheck.cpp:108 @@ +107,3 @@ + switch (S) { +case AssignmentAndConstructionCheck::SpecialFunctionKind::CopyConstructor: +return (llvm::Twine("\n") + ClassName + " &operator=(const " + ClassName + This line is not indented properly. Comment at: clang-tidy/misc/AssignmentAndConstructionCheck.cpp:133 @@ +132,3 @@ + DiagnosticBuilder Diag = diag(MatchedDecl.getLocation(), diagnosticFormat(S)) + << ClassName; + You can pass in `&MatchedDecl` instead of a StringRef to get the proper quoting in the diagnostic. Comment at: clang-tidy/misc/AssignmentAndConstructionCheck.cpp:142 @@ +141,3 @@ + + std::string FixIt = buildFixIt(MatchedDecl, ClassName, S); (llvm::Twine("\n") + ClassName + " &operator=(const " + +ClassName + " &) = " + deleteOrDefault(MatchedDecl) + ";") The extra statement after the call to buildFixIt() looks amiss. ;-) Comment at: clang-tidy/misc/AssignmentAndConstructionCheck.cpp:152 @@ +151,3 @@ + if (const auto *MatchedDecl = + Result.Nodes.getNodeAs("copy-ctor")) { +diagnosticAndFixIt(Result, *MatchedDecl, Elide braces when the compound body is only one statement (here and elsewhere). Comment at: clang-tidy/misc/AssignmentAndConstructionCheck.cpp:160 @@ +159,3 @@ + } + + else if (const auto *MatchedDecl = Extra newline here. Comment at: clang-tidy/misc/AssignmentAndConstructionCheck.h:31 @@ +30,3 @@ + + enum class SpecialFunctionKind { +CopyConstructor, Since this is an implementation detail, perhaps it can be moved into the source file instead of made a public member of the check? Comment at: clang-tidy/misc/AssignmentAndConstructionCheck.h:39 @@ +38,3 @@ +private: + void diagnosticAndFixIt( + const ast_matchers::MatchFinder::MatchResult &Result, const CXXMethodDecl &MatchedDecl, s/diagnostic/diagnose (to make it a verb)? Comment at: clang-tidy/misc/MiscTidyModule.cpp:93 @@ -91,1 +92,3 @@ +CheckFactories.registerCheck( +"misc-assignment-and-construction"); CheckFactories.registerCheck( I don't have a better idea for a name, but this doesn't seem to tell the user much about what the check will do, either. Would it make sense to expand this check into a rule of (2)/3/(4)/5 check (http://en.cppreference.com/w/cpp/language/rule_of_three) with config options as to which rule to enforce, so that it optionally includes the destructor? I'm thinking of config options like: RuleOf=3|5, IncludeDestructors=true|false with the defaults being 3 and true, respectively? The check could be named misc-cpp-special-member-rule (or something more clear than that). As it stands, the check currently handles the rule of 2 and 4, but I think a lot of people may want the rule of 3 or 5 instead and it would be good to cover them all under the same check name. Note, this could be done in a follow-up patch, I am mostly interested in getting the name correct for the check. Comment at: docs/clang-tidy/checks/misc-assignment-and-construction.rst:8 @@ +7,3 @@ +constructor. This behaviour is deprecated by the standard (C++ 14 draft +standard [class.construction paragraph 18]). + No need to mention draft standard; C++14 is an IS. Also, the citation should be: [class.copy] paragraph 18. Comment at: docs/clang-tidy/checks/misc-assignment-and-construction.rst:18 @@ +17,3 @@ +This check finds classes where only one of the copy/move constructor and +copy/move assignment operator is user-defined. The fix is defensive. Incorrect +compiler-generated assignment/construction can cause unexpected behaviour. An May want to expound on what you mean by the fix being defensive. Comment at: test/clang-tidy/misc-assignment-and-construction.cpp:161 @@ +160,2 @@ + E4 &operator=(E4 &&); +}; Can we also have a test that shows a deleted operation generates a deleted companion? e.g., ``` struct S { S(const S&) = delete; // check that it adds S& operator=(cons
Re: [PATCH] D16700: [Clang-tidy] Make null pointer literals for fixes configurable for two checks
aaron.ballman added a comment. Missing test cases. As for a global option, once http://reviews.llvm.org/D16113 lands, you can use `getLocalOrGlobal()` if you want to use a global option for this functionality. Comment at: clang-tidy/readability/ImplicitBoolCastCheck.cpp:69 @@ -68,2 +68,3 @@ StringRef -getZeroLiteralToCompareWithForGivenType(CastKind CastExpressionKind, +getZeroLiteralToCompareWithForGivenType(ImplicitBoolCastCheck *Check, +CastKind CastExpressionKind, Check can be a const pointer. Comment at: clang-tidy/readability/ImplicitBoolCastCheck.cpp:126 @@ -124,3 +125,3 @@ void addFixItHintsForGenericExpressionCastToBool( -DiagnosticBuilder &Diagnostic, const ImplicitCastExpr *CastExpression, -const Stmt *ParentStatement, ASTContext &Context) { +ImplicitBoolCastCheck *Check, DiagnosticBuilder &Diagnostic, +const ImplicitCastExpr *CastExpression, const Stmt *ParentStatement, Same here. Comment at: clang-tidy/readability/ImplicitBoolCastCheck.h:32 @@ -30,1 +31,3 @@ +Options.get("NullPointerLiteral", +Context->getLangOpts().CPlusPlus11 ? "nullptr" : "0")) {} void registerMatchers(ast_matchers::MatchFinder *Finder) override; I know you are following the pattern used in the code here, but I think this class needs a storeOptions() function as well. See AssertSideEffectCheck as an example. Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.cpp:175 @@ -174,2 +174,3 @@ -std::string replacementExpression(const MatchFinder::MatchResult &Result, +std::string replacementExpression(SimplifyBooleanExprCheck *Check, + const MatchFinder::MatchResult &Result, Check can be a const pointer. Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.cpp:276 @@ +275,3 @@ + NullPointerLiteral( + Options.get("NullPointerLiteral", + Context->getLangOpts().CPlusPlus11 ? "nullptr" : "0")) {} I think this also needs a storeOptions() method. Repository: rL LLVM http://reviews.llvm.org/D16700 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r259497 - Fix for PR8901: attribute "mode" rejected for enums and dependent types.
Author: dzobnin Date: Tue Feb 2 07:50:39 2016 New Revision: 259497 URL: http://llvm.org/viewvc/llvm-project?rev=259497&view=rev Log: Fix for PR8901: attribute "mode" rejected for enums and dependent types. Allow "mode" attribute for enum types, except for vector modes, for compatibility with GCC. Support "mode" attribute with dependent types. Differential Revision: http://reviews.llvm.org/D16219 Added: cfe/trunk/test/CodeGen/attr-mode-enums.c cfe/trunk/test/CodeGenCXX/attr-mode-vector-types-tmpl.cpp cfe/trunk/test/Sema/attr-mode-enums.c cfe/trunk/test/SemaCXX/attr-mode-tmpl.cpp Modified: cfe/trunk/include/clang/Basic/Attr.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Sema/AttributeList.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp cfe/trunk/test/Sema/attr-mode.c Modified: cfe/trunk/include/clang/Basic/Attr.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=259497&r1=259496&r2=259497&view=diff == --- cfe/trunk/include/clang/Basic/Attr.td (original) +++ cfe/trunk/include/clang/Basic/Attr.td Tue Feb 2 07:50:39 2016 @@ -879,8 +879,8 @@ def MipsInterrupt : InheritableAttr, Tar def Mode : Attr { let Spellings = [GCC<"mode">]; - let Subjects = SubjectList<[Var, TypedefName, Field], ErrorDiag, - "ExpectedVariableFieldOrTypedef">; + let Subjects = SubjectList<[Var, Enum, TypedefName, Field], ErrorDiag, + "ExpectedVariableEnumFieldOrTypedef">; let Args = [IdentifierArgument<"Mode">]; let Documentation = [Undocumented]; } Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=259497&r1=259496&r2=259497&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Feb 2 07:50:39 2016 @@ -2448,7 +2448,7 @@ def warn_attribute_wrong_decl_type : War "variables, functions and classes|Objective-C protocols|" "functions and global variables|structs, unions, and typedefs|structs and typedefs|" "interface or protocol declarations|kernel functions|non-K&R-style functions|" - "variables, fields and typedefs}1">, + "variables, enums, fields and typedefs}1">, InGroup; def err_attribute_wrong_decl_type : Error; def warn_type_attribute_wrong_type : Warning< @@ -2858,6 +2858,8 @@ def warn_vector_mode_deprecated : Warnin InGroup; def err_complex_mode_vector_type : Error< "type of machine mode does not support base vector types">; +def err_enum_mode_vector_type : Error< + "mode %0 is not supported for enumeration types">; def warn_attribute_nonnull_no_pointers : Warning< "'nonnull' attribute applied to function with no pointer arguments">, InGroup; Modified: cfe/trunk/include/clang/Sema/AttributeList.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=259497&r1=259496&r2=259497&view=diff == --- cfe/trunk/include/clang/Sema/AttributeList.h (original) +++ cfe/trunk/include/clang/Sema/AttributeList.h Tue Feb 2 07:50:39 2016 @@ -856,7 +856,7 @@ enum AttributeDeclKind { ExpectedObjectiveCInterfaceOrProtocol, ExpectedKernelFunction, ExpectedFunctionWithProtoType, - ExpectedVariableFieldOrTypedef + ExpectedVariableEnumFieldOrTypedef }; } // end namespace clang Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=259497&r1=259496&r2=259497&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Tue Feb 2 07:50:39 2016 @@ -7750,6 +7750,10 @@ public: void AddLaunchBoundsAttr(SourceRange AttrRange, Decl *D, Expr *MaxThreads, Expr *MinBlocks, unsigned SpellingListIndex); + /// AddModeAttr - Adds a mode attribute to a particular declaration. + void AddModeAttr(SourceRange AttrRange, Decl *D, IdentifierInfo *Name, + unsigned SpellingListIndex, bool InInstantiation = false); + //======// // C++ Coroutines TS // Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=259497&r1=259496&r2=259497&view=diff == --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Feb 2 07:50:
Re: [PATCH] D16219: PR8901: attribute "mode" rejected for enums and dependent types
This revision was automatically updated to reflect the committed changes. Closed by commit rL259497: Fix for PR8901: attribute "mode" rejected for enums and dependent types. (authored by dzobnin). Changed prior to commit: http://reviews.llvm.org/D16219?vs=46521&id=46643#toc Repository: rL LLVM http://reviews.llvm.org/D16219 Files: cfe/trunk/include/clang/Basic/Attr.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Sema/AttributeList.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp cfe/trunk/test/CodeGen/attr-mode-enums.c cfe/trunk/test/CodeGenCXX/attr-mode-vector-types-tmpl.cpp cfe/trunk/test/Sema/attr-mode-enums.c cfe/trunk/test/Sema/attr-mode.c cfe/trunk/test/SemaCXX/attr-mode-tmpl.cpp Index: cfe/trunk/include/clang/Sema/Sema.h === --- cfe/trunk/include/clang/Sema/Sema.h +++ cfe/trunk/include/clang/Sema/Sema.h @@ -7750,6 +7750,10 @@ void AddLaunchBoundsAttr(SourceRange AttrRange, Decl *D, Expr *MaxThreads, Expr *MinBlocks, unsigned SpellingListIndex); + /// AddModeAttr - Adds a mode attribute to a particular declaration. + void AddModeAttr(SourceRange AttrRange, Decl *D, IdentifierInfo *Name, + unsigned SpellingListIndex, bool InInstantiation = false); + //======// // C++ Coroutines TS // Index: cfe/trunk/include/clang/Sema/AttributeList.h === --- cfe/trunk/include/clang/Sema/AttributeList.h +++ cfe/trunk/include/clang/Sema/AttributeList.h @@ -856,7 +856,7 @@ ExpectedObjectiveCInterfaceOrProtocol, ExpectedKernelFunction, ExpectedFunctionWithProtoType, - ExpectedVariableFieldOrTypedef + ExpectedVariableEnumFieldOrTypedef }; } // end namespace clang Index: cfe/trunk/include/clang/Basic/Attr.td === --- cfe/trunk/include/clang/Basic/Attr.td +++ cfe/trunk/include/clang/Basic/Attr.td @@ -879,8 +879,8 @@ def Mode : Attr { let Spellings = [GCC<"mode">]; - let Subjects = SubjectList<[Var, TypedefName, Field], ErrorDiag, - "ExpectedVariableFieldOrTypedef">; + let Subjects = SubjectList<[Var, Enum, TypedefName, Field], ErrorDiag, + "ExpectedVariableEnumFieldOrTypedef">; let Args = [IdentifierArgument<"Mode">]; let Documentation = [Undocumented]; } Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td === --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td @@ -2448,7 +2448,7 @@ "variables, functions and classes|Objective-C protocols|" "functions and global variables|structs, unions, and typedefs|structs and typedefs|" "interface or protocol declarations|kernel functions|non-K&R-style functions|" - "variables, fields and typedefs}1">, + "variables, enums, fields and typedefs}1">, InGroup; def err_attribute_wrong_decl_type : Error; def warn_type_attribute_wrong_type : Warning< @@ -2858,6 +2858,8 @@ InGroup; def err_complex_mode_vector_type : Error< "type of machine mode does not support base vector types">; +def err_enum_mode_vector_type : Error< + "mode %0 is not supported for enumeration types">; def warn_attribute_nonnull_no_pointers : Warning< "'nonnull' attribute applied to function with no pointer arguments">, InGroup; Index: cfe/trunk/test/SemaCXX/attr-mode-tmpl.cpp === --- cfe/trunk/test/SemaCXX/attr-mode-tmpl.cpp +++ cfe/trunk/test/SemaCXX/attr-mode-tmpl.cpp @@ -0,0 +1,104 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +typedef enum { XX } EnumType; +struct S { int x; }; + +// Check enumerations. Vector modes on enum types must cause an error. +template +void CheckEnumerations() { + // Check that non-vector 'mode' attribute is OK with enumeration types. + typedef T __attribute__((mode(QI))) T1; + typedef T T2 __attribute__((mode(HI))); + typedef T __attribute__((mode(V8SI))) T3; // expected-error{{mode 'V8SI' is not supported for enumeration types}} + // expected-warning@-1{{specifying vector types with the 'mode' attribute is deprecated}} + + typedef enum __attribute__((mode(HI))) { A4, B4 } T4; + typedef enum { A5, B5 } __attribute__((mode(SI))) T5; + typedef enum __attribute__((mode(V2SI))) { A6, B6 } T6; // expected-error{{mode 'V2SI' is not supported for enumeration types}} + // expected-warning@-1{{deprecated}} + typedef enum { A7, B7 } __attribute__((mode(V2QI))) T7; // expected-error{{mode 'V2QI' is not supported for enumeration types}} +
r259499 - Add backend dignostic printer for unsupported features
Author: olista01 Date: Tue Feb 2 07:52:52 2016 New Revision: 259499 URL: http://llvm.org/viewvc/llvm-project?rev=259499&view=rev Log: Add backend dignostic printer for unsupported features Re-commit of r258950 after fixing layering violation. The related LLVM patch adds a backend diagnostic type for reporting unsupported features, this adds a printer for them to clang. In the case where debug location information is not available, I've changed the printer to report the location as the first line of the function, rather than the closing brace, as the latter does not give the user any information. This also affects optimisation remarks. Added: cfe/trunk/test/CodeGen/backend-unsupported-error.ll Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td cfe/trunk/lib/CodeGen/CodeGenAction.cpp cfe/trunk/test/Frontend/optimization-remark-analysis.c cfe/trunk/test/Misc/backend-optimization-failure-nodbg.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=259499&r1=259498&r2=259499&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Tue Feb 2 07:52:52 2016 @@ -58,8 +58,10 @@ def remark_fe_backend_optimization_remar BackendInfo, InGroup; def warn_fe_backend_optimization_failure : Warning<"%0">, BackendInfo, InGroup, DefaultWarn; -def note_fe_backend_optimization_remark_invalid_loc : Note<"could " - "not determine the original source location for %0:%1:%2">; +def note_fe_backend_invalid_loc : Note<"could " + "not determine the original source location for %0:%1:%2">, BackendInfo; + +def err_fe_backend_unsupported : Error<"%0">, BackendInfo; def remark_sanitize_address_insert_extra_padding_accepted : Remark< "-fsanitize-address-field-padding applied to %0">, ShowInSystemHeader, Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=259499&r1=259498&r2=259499&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Tue Feb 2 07:52:52 2016 @@ -242,6 +242,13 @@ namespace clang { ((BackendConsumer *)Context)->DiagnosticHandlerImpl(DI); } +/// Get the best possible source location to represent a diagnostic that +/// may have associated debug info. +const FullSourceLoc +getBestLocationFromDebugLoc(const llvm::DiagnosticInfoWithDebugLocBase &D, +bool &BadDebugInfo, StringRef &Filename, +unsigned &Line, unsigned &Column) const; + void InlineAsmDiagHandler2(const llvm::SMDiagnostic &, SourceLocation LocCookie); @@ -254,6 +261,8 @@ namespace clang { /// \return True if the diagnostic has been successfully reported, false /// otherwise. bool StackSizeDiagHandler(const llvm::DiagnosticInfoStackSize &D); +/// \brief Specialized handler for unsupported backend feature diagnostic. +void UnsupportedDiagHandler(const llvm::DiagnosticInfoUnsupported &D); /// \brief Specialized handlers for optimization remarks. /// Note that these handlers only accept remarks and they always handle /// them. @@ -439,16 +448,11 @@ BackendConsumer::StackSizeDiagHandler(co return false; } -void BackendConsumer::EmitOptimizationMessage( -const llvm::DiagnosticInfoOptimizationBase &D, unsigned DiagID) { - // We only support warnings and remarks. - assert(D.getSeverity() == llvm::DS_Remark || - D.getSeverity() == llvm::DS_Warning); - +const FullSourceLoc BackendConsumer::getBestLocationFromDebugLoc( +const llvm::DiagnosticInfoWithDebugLocBase &D, bool &BadDebugInfo, StringRef &Filename, +unsigned &Line, unsigned &Column) const { SourceManager &SourceMgr = Context->getSourceManager(); FileManager &FileMgr = SourceMgr.getFileManager(); - StringRef Filename; - unsigned Line, Column; SourceLocation DILoc; if (D.isLocationAvailable()) { @@ -459,6 +463,7 @@ void BackendConsumer::EmitOptimizationMe // source manager, so pass 1 if Column is not set. DILoc = SourceMgr.translateFileLineCol(FE, Line, Column ? Column : 1); } +BadDebugInfo = DILoc.isInvalid(); } // If a location isn't available, try to approximate it using the associated @@ -467,18 +472,63 @@ void BackendConsumer::EmitOptimizationMe FullSourceLoc Loc(DILoc, SourceMgr); if (Loc.isInvalid()) if (const Decl *FD = Gen->GetDeclForMangledName(D.getFunction().getName())) - Loc = FD->getASTContext().getFullLoc(FD->getBodyRBrace()); + Loc = FD->getASTContext().getFul
Re: [PATCH] D16572: PR23057: fix use-after-free due to local token buffer in ParseCXXAmbiguousParenExpression
DmitryPolukhin updated this revision to Diff 46644. DmitryPolukhin added a comment. Use EOF token instead of copy buffer. This approach looks a bit more fragile but definitely more efficient, PTAL. http://reviews.llvm.org/D16572 Files: lib/Parse/ParseExprCXX.cpp test/Parser/cxx-ambig-paren-expr-asan.cpp Index: test/Parser/cxx-ambig-paren-expr-asan.cpp === --- /dev/null +++ test/Parser/cxx-ambig-paren-expr-asan.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s + +// This syntax error used to cause use-after free due to token local buffer +// in ParseCXXAmbiguousParenExpression. +int H((int()[)]); +// expected-error@-1 {{expected expression}} +// expected-error@-2 {{expected ']'}} +// expected-note@-3 {{to match this '['}} +// expected-error@-4 {{expected ';' after top level declarator}} Index: lib/Parse/ParseExprCXX.cpp === --- lib/Parse/ParseExprCXX.cpp +++ lib/Parse/ParseExprCXX.cpp @@ -3081,6 +3081,14 @@ ParseAs = NotCastExpr ? SimpleExpr : CastExpr; } + // Create a fake EOF to mark end of Toks buffer. + Token AttrEnd; + AttrEnd.startToken(); + AttrEnd.setKind(tok::eof); + AttrEnd.setLocation(Tok.getLocation()); + AttrEnd.setEofData(Toks.data()); + Toks.push_back(AttrEnd); + // The current token should go after the cached tokens. Toks.push_back(Tok); // Re-enter the stored parenthesized tokens into the token stream, so we may @@ -3105,6 +3113,10 @@ Tracker.consumeClose(); ColonProt.restore(); +// Consume EOF marker for Toks buffer. +assert(Tok.is(tok::eof) && Tok.getEofData() == AttrEnd.getEofData()); +ConsumeAnyToken(); + if (ParseAs == CompoundLiteral) { ExprType = CompoundLiteral; if (DeclaratorInfo.isInvalidType()) @@ -3141,10 +3153,16 @@ // Match the ')'. if (Result.isInvalid()) { -SkipUntil(tok::r_paren, StopAtSemi); +while (Tok.isNot(tok::eof)) + ConsumeAnyToken(); +assert(Tok.getEofData() == AttrEnd.getEofData()); +ConsumeAnyToken(); return ExprError(); } Tracker.consumeClose(); + // Consume EOF marker for Toks buffer. + assert(Tok.is(tok::eof) && Tok.getEofData() == AttrEnd.getEofData()); + ConsumeAnyToken(); return Result; } Index: test/Parser/cxx-ambig-paren-expr-asan.cpp === --- /dev/null +++ test/Parser/cxx-ambig-paren-expr-asan.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s + +// This syntax error used to cause use-after free due to token local buffer +// in ParseCXXAmbiguousParenExpression. +int H((int()[)]); +// expected-error@-1 {{expected expression}} +// expected-error@-2 {{expected ']'}} +// expected-note@-3 {{to match this '['}} +// expected-error@-4 {{expected ';' after top level declarator}} Index: lib/Parse/ParseExprCXX.cpp === --- lib/Parse/ParseExprCXX.cpp +++ lib/Parse/ParseExprCXX.cpp @@ -3081,6 +3081,14 @@ ParseAs = NotCastExpr ? SimpleExpr : CastExpr; } + // Create a fake EOF to mark end of Toks buffer. + Token AttrEnd; + AttrEnd.startToken(); + AttrEnd.setKind(tok::eof); + AttrEnd.setLocation(Tok.getLocation()); + AttrEnd.setEofData(Toks.data()); + Toks.push_back(AttrEnd); + // The current token should go after the cached tokens. Toks.push_back(Tok); // Re-enter the stored parenthesized tokens into the token stream, so we may @@ -3105,6 +3113,10 @@ Tracker.consumeClose(); ColonProt.restore(); +// Consume EOF marker for Toks buffer. +assert(Tok.is(tok::eof) && Tok.getEofData() == AttrEnd.getEofData()); +ConsumeAnyToken(); + if (ParseAs == CompoundLiteral) { ExprType = CompoundLiteral; if (DeclaratorInfo.isInvalidType()) @@ -3141,10 +3153,16 @@ // Match the ')'. if (Result.isInvalid()) { -SkipUntil(tok::r_paren, StopAtSemi); +while (Tok.isNot(tok::eof)) + ConsumeAnyToken(); +assert(Tok.getEofData() == AttrEnd.getEofData()); +ConsumeAnyToken(); return ExprError(); } Tracker.consumeClose(); + // Consume EOF marker for Toks buffer. + assert(Tok.is(tok::eof) && Tok.getEofData() == AttrEnd.getEofData()); + ConsumeAnyToken(); return Result; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14274: Add alloc_size attribute to clang
aaron.ballman added a comment. The attribute part looks mostly good (a few small nits), but the rest should be reviewed by @rsmith. Comment at: lib/Sema/SemaDeclAttr.cpp:737 @@ +736,3 @@ +unsigned FuncParamNo, unsigned AttrArgNo) { + assert(Attr.getArg(AttrArgNo).is()); + // FuncParamNo is base-1 Can be replaced with assert(Attr.isArgExpr(AttrArgNo) && "expected expression argument"); Comment at: lib/Sema/SemaDeclAttr.cpp:739 @@ +738,3 @@ + // FuncParamNo is base-1 + if (FuncParamNo < 1 || FuncParamNo > FD->getNumParams()) { +SourceLocation SrcLoc = Attr.getArgAsExpr(AttrArgNo)->getLocStart(); This whole if should be replaced by a call to checkFunctionOrMethodParameterIndex(), which will return the correct function parameter number as an output parameter. http://reviews.llvm.org/D14274 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r259506 - [StaticAnalyzer] Pull SymExpr and SymbolData into its own header to avoid cyclic includes.
Author: d0k Date: Tue Feb 2 08:24:11 2016 New Revision: 259506 URL: http://llvm.org/viewvc/llvm-project?rev=259506&view=rev Log: [StaticAnalyzer] Pull SymExpr and SymbolData into its own header to avoid cyclic includes. Added: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h?rev=259506&r1=259505&r2=259506&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h Tue Feb 2 08:24:11 2016 @@ -19,6 +19,7 @@ #include "llvm/ADT/FoldingSet.h" namespace clang { +class CFGBlock; namespace ento { Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h?rev=259506&r1=259505&r2=259506&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h Tue Feb 2 08:24:11 2016 @@ -26,6 +26,7 @@ namespace ento { class EnvironmentManager; class SValBuilder; +class SymbolReaper; /// An entry in the environment consists of a Stmt and an LocationContext. /// This allows the environment to manage context-sensitive bindings, Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=259506&r1=259505&r2=259506&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Tue Feb 2 08:24:11 2016 @@ -21,6 +21,7 @@ #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/ExprObjC.h" +#include "clang/Analysis/AnalysisContext.h" #include "clang/Basic/LLVM.h" #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h" #include "llvm/ADT/FoldingSet.h" Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h?rev=259506&r1=259505&r2=259506&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h Tue Feb 2 08:24:11 2016 @@ -21,6 +21,7 @@ #include "clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h" #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h" #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h" namespace clang { Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h?rev=259506&r1=259505&r2=259506&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h Tue Feb 2 08:24:11 2016 @@ -15,9 +15,11 @@ #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALS_H #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALS_H +#include "clang/AST/Expr.h" #include "clang/Basic/LLVM.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h" -#include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h" +#include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/ImmutableList.h" //====// Added: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h?rev
r259507 - Make the remaining headers self-contained.
Author: d0k Date: Tue Feb 2 08:24:21 2016 New Revision: 259507 URL: http://llvm.org/viewvc/llvm-project?rev=259507&view=rev Log: Make the remaining headers self-contained. Modified: cfe/trunk/include/clang/AST/BaseSubobject.h cfe/trunk/include/clang/AST/DeclOpenMP.h cfe/trunk/include/clang/AST/Mangle.h cfe/trunk/include/clang/AST/TemplateName.h cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h cfe/trunk/include/clang/Sema/ObjCMethodList.h cfe/trunk/include/clang/Sema/Ownership.h cfe/trunk/include/clang/Sema/Scope.h cfe/trunk/include/clang/Sema/SemaLambda.h cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h cfe/trunk/lib/CodeGen/CodeGenTBAA.h Modified: cfe/trunk/include/clang/AST/BaseSubobject.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/BaseSubobject.h?rev=259507&r1=259506&r2=259507&view=diff == --- cfe/trunk/include/clang/AST/BaseSubobject.h (original) +++ cfe/trunk/include/clang/AST/BaseSubobject.h Tue Feb 2 08:24:21 2016 @@ -15,13 +15,12 @@ #define LLVM_CLANG_AST_BASESUBOBJECT_H #include "clang/AST/CharUnits.h" +#include "clang/AST/DeclCXX.h" #include "llvm/ADT/DenseMap.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/type_traits.h" namespace clang { - class CXXRecordDecl; - // BaseSubobject - Uniquely identifies a direct or indirect base class. // Stores both the base class decl and the offset from the most derived class to // the base class. Used for vtable and VTT generation. Modified: cfe/trunk/include/clang/AST/DeclOpenMP.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclOpenMP.h?rev=259507&r1=259506&r2=259507&view=diff == --- cfe/trunk/include/clang/AST/DeclOpenMP.h (original) +++ cfe/trunk/include/clang/AST/DeclOpenMP.h Tue Feb 2 08:24:21 2016 @@ -17,6 +17,7 @@ #include "clang/AST/DeclBase.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/Support/TrailingObjects.h" namespace clang { class Expr; Modified: cfe/trunk/include/clang/AST/Mangle.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Mangle.h?rev=259507&r1=259506&r2=259507&view=diff == --- cfe/trunk/include/clang/AST/Mangle.h (original) +++ cfe/trunk/include/clang/AST/Mangle.h Tue Feb 2 08:24:21 2016 @@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_AST_MANGLE_H #define LLVM_CLANG_AST_MANGLE_H +#include "clang/AST/Decl.h" #include "clang/AST/Type.h" #include "clang/Basic/ABI.h" #include "llvm/ADT/DenseMap.h" Modified: cfe/trunk/include/clang/AST/TemplateName.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TemplateName.h?rev=259507&r1=259506&r2=259507&view=diff == --- cfe/trunk/include/clang/AST/TemplateName.h (original) +++ cfe/trunk/include/clang/AST/TemplateName.h Tue Feb 2 08:24:21 2016 @@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_AST_TEMPLATENAME_H #define LLVM_CLANG_AST_TEMPLATENAME_H +#include "clang/AST/NestedNameSpecifier.h" #include "clang/Basic/LLVM.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/PointerUnion.h" Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h?rev=259507&r1=259506&r2=259507&view=diff == --- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h (original) +++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Tue Feb 2 08:24:21 2016 @@ -15,6 +15,7 @@ #include "clang-c/Index.h" #include "clang/AST/CanonicalType.h" +#include "clang/AST/DeclBase.h" #include "clang/AST/Type.h" #include "clang/Sema/CodeCompleteOptions.h" #include "llvm/ADT/DenseMap.h" Modified: cfe/trunk/include/clang/Sema/ObjCMethodList.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ObjCMethodList.h?rev=259507&r1=259506&r2=259507&view=diff == --- cfe/trunk/include/clang/Sema/ObjCMethodList.h (original) +++ cfe/trunk/include/clang/Sema/ObjCMethodList.h Tue Feb 2 08:24:21 2016 @@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_SEMA_OBJCMETHODLIST_H #define LLVM_CLANG_SEMA_OBJCMETHODLIST_H +#include "clang/AST/DeclObjC.h" #include "llvm/ADT/PointerIntPair.h" namespace clang { Modified: cfe/trunk/include/clang/Sema/Ownership.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Ownership.h?rev=259507&r1=259506&r2=259507&view=diff == --- cfe/trunk/include/clang/Sema/Ownership.h (original) +++ cfe/trunk/include/clang/Sema/Ownership.h Tue Feb 2 08:24:21 2016 @@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_SEMA_OWNER
Re: [PATCH] D12834: add gcc abi_tag support
aaron.ballman added a subscriber: cfe-commits. aaron.ballman added reviewers: rsmith, majnemer. aaron.ballman added a comment. I don't have the expertise to review the semantics of the attribute, but here are some cursory thoughts on the attribute itself. Comment at: include/clang/Basic/Attr.td:355 @@ +354,3 @@ + let Args = [VariadicStringArgument<"Tags">]; + let Subjects = SubjectList<[Struct, Var, Function, Namespace], ErrorDiag, + "ExpectedStructClassVariableFunctionMethodOrInlineNamespace">; The diagnostic doesn't match the subject -- "methods" refers to Objective-C methods, which should either be listed in the SubjectList or removed from the diagnostic. Comment at: include/clang/Basic/Attr.td:357 @@ +356,3 @@ + "ExpectedStructClassVariableFunctionMethodOrInlineNamespace">; + let Documentation = [Undocumented]; +} No new undocumented attributes, please -- you should add documentation to AttrDocs.td and link to it from here. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:4149 @@ +4148,3 @@ +def err_attr_abi_tag_only_on_inline_namespace : + Error<"abi_tag attribute only allowed on inline namespaces">; +def err_attr_abi_tag_only_on_named_namespace : Should quote 'abi_tag' in the diagnostic (here and below as well). Also, why an error instead of a warning and dropping the attribute from the declaration? Perhaps: 'abi_tag' attribute on %select{inline|anonymous}0 namespace ignored" as a warning, and remove the below diagnostic entirely? Comment at: lib/Sema/SemaDeclAttr.cpp:4456 @@ +4455,3 @@ + + SmallVector Tags; + Why a vector of std::string instead of StringRef? Comment at: lib/Sema/SemaDeclAttr.cpp:4476 @@ +4475,3 @@ + if (NS && Attr.getNumArgs() == 0) { + Tags.push_back(NS->getName()); + } Indentation is incorrect; also, elide braces for single statement ifs. Comment at: lib/Sema/SemaDeclAttr.cpp:4479 @@ +4478,3 @@ + + // store tags sorted and without duplicates + std::sort(Tags.begin(), Tags.end()); Comments should be complete sentences (with capitalization and punctuation); here and elsewhere. Repository: rL LLVM http://reviews.llvm.org/D12834 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16686: [OpenCL] Generate metadata for opencl_unroll_hint attribute
yaxunl updated this revision to Diff 46651. yaxunl marked 9 inline comments as done. yaxunl added a comment. Revised as Xiuli and Anastasia suggested. http://reviews.llvm.org/D16686 Files: include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td include/clang/Basic/DiagnosticParseKinds.td include/clang/Basic/DiagnosticSemaKinds.td include/clang/Parse/Parser.h lib/CodeGen/CGLoopInfo.cpp lib/Parse/ParseDecl.cpp lib/Parse/ParseStmt.cpp lib/Sema/SemaStmtAttr.cpp test/CodeGenOpenCL/unroll-hint.cl test/Parser/opencl-unroll-hint.cl test/SemaOpenCL/unroll-hint.cl Index: test/SemaOpenCL/unroll-hint.cl === --- /dev/null +++ test/SemaOpenCL/unroll-hint.cl @@ -0,0 +1,24 @@ +//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s + +kernel void C (global int *x) { + int I = 3; + __attribute__((opencl_unroll_hint(I))) // expected-error {{opencl_unroll_hint attribute requires an integer constant}} + while (I--); +} + +kernel void D (global int *x) { + int i = 10; + __attribute__((opencl_unroll_hint)) + do { + } while(i--); +} + +kernel void E() { + __attribute__((opencl_unroll_hint(2,4))) // expected-error {{opencl_unroll_hint attribute takes no more than 1 argument}} + for(int i=0; i<100; i++); +} + +kernel void F() { + __attribute__((opencl_unroll_hint(-1))) // expected-error {{opencl_unroll_hint attribute requires a positive integral compile time constant expression}} + for(int i=0; i<100; i++); +} Index: test/Parser/opencl-unroll-hint.cl === --- /dev/null +++ test/Parser/opencl-unroll-hint.cl @@ -0,0 +1,8 @@ +//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s + +kernel void B (global int *x) { + __attribute__((opencl_unroll_hint(42))) + if (x[0]) // expected-error {{OpenCL only supports opencl_unroll_hint attribute on for, while, and do statements}} +x[0] = 15; +} + Index: test/CodeGenOpenCL/unroll-hint.cl === --- /dev/null +++ test/CodeGenOpenCL/unroll-hint.cl @@ -0,0 +1,96 @@ +// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s + +/*** for ***/ +void for_count() +{ +// CHECK-LABEL: for_count +__attribute__((opencl_unroll_hint(8))) +for( int i = 0; i < 1000; ++i); +// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_COUNT:.*]] +} + +void for_disable() +{ +// CHECK-LABEL: for_disable +__attribute__((opencl_unroll_hint(1))) +for( int i = 0; i < 1000; ++i); +// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_DISABLE:.*]] +} + +void for_full() +{ +// CHECK-LABEL: for_full +__attribute__((opencl_unroll_hint)) +for( int i = 0; i < 1000; ++i); +// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_FULL:.*]] +} + +/*** while ***/ +void while_count() +{ +// CHECK-LABEL: while_count +int i = 1000; +__attribute__((opencl_unroll_hint(8))) +while(i-->0); +// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_COUNT:.*]] +} + +void while_disable() +{ +// CHECK-LABEL: while_disable +int i = 1000; +__attribute__((opencl_unroll_hint(1))) +while(i-->0); +// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_DISABLE:.*]] +} + +void while_full() +{ +// CHECK-LABEL: while_full +int i = 1000; +__attribute__((opencl_unroll_hint)) +while(i-->0); +// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_FULL:.*]] +} + +/*** do ***/ +void do_count() +{ +// CHECK-LABEL: do_count +int i = 1000; +__attribute__((opencl_unroll_hint(8))) +do {} while(i--> 0); +// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_COUNT:.*]] +} + +void do_disable() +{ +// CHECK-LABEL: do_disable +int i = 1000; +__attribute__((opencl_unroll_hint(1))) +do {} while(i--> 0); +// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_DISABLE:.*]] +} + +void do_full() +{ +// CHECK-LABEL: do_full +int i = 1000; +__attribute__((opencl_unroll_hint)) +do {} while(i--> 0); +// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_FULL:.*]] +} + + +// CHECK: ![[FOR_COUNT]] = distinct !{![[FOR_COUNT]], ![[COUNT:.*]]} +// CHECK: ![[COUNT]] = !{!"llvm.loop.unroll.count", i32 8} +// CHECK: ![[FOR_DISABLE]] = distinct !{![[FOR_DISABLE]], ![[DISABLE:.*]]} +// CHECK: ![[DISABLE]] = !{!"llvm.loop.unroll.disable"} +// CHECK: ![[FOR_FULL]] = distinct !{![[FOR_FULL]], ![[FULL:.*]]} +// CHECK: ![[FULL]] = !{!"llvm.loop.unroll.full"} +// CHECK: ![[WHILE_COUNT]] = distinct !{![[WHILE_COUNT]],![[COUNT]]} +// CHECK: ![[WHILE_DISABLE]] = distinct !{![[WHILE_DISABLE]], ![[DISABLE]]} +// CHECK: ![[WHILE_FULL]]= distinct !{![[WHILE_FULL]], ![[FULL]]} +// CHECK: ![[DO_COUNT]] = distinct !{![[DO_COUNT]], ![[COUNT]]} +// CHECK: ![[DO_DISABLE]]= distinct !{![[DO_DISABLE]], ![[DISABLE]]} +// CHECK: ![[DO_FULL]] = dis
Re: [PATCH] D16682: 19957 - OpenCL incorrectly accepts implicit address space conversion with ternary operator
ichesnokov removed rL LLVM as the repository for this revision. ichesnokov updated this revision to Diff 46655. ichesnokov added a comment. Test cases moved to single file. Please review and accept. http://reviews.llvm.org/D16682 Files: test/SemaOpenCL/ternary-implicit-casts.cl Index: test/SemaOpenCL/ternary-implicit-casts.cl === --- test/SemaOpenCL/ternary-implicit-casts.cl +++ test/SemaOpenCL/ternary-implicit-casts.cl @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only + +kernel void implicit_cast_local(global int* gint, local int* lint, int cond) +{ + // will not compile, ptr is not generic but local + local int *ptr = cond ? gint : lint; // expected-warning {{pointer type mismatch ('__global int *' and '__local int *')}} expected-error {{initializing '__local int *' with an expression of type 'void *' changes address space of pointer}} +} + +kernel void implicit_cast_generic(global int* gint, local int* lint, int cond) { + // will compile, ptr is generic and can accept global and local + int* ptr = cond ? gint : lint; // expected-warning {{pointer type mismatch ('__global int *' and '__local int *')}} +} Index: test/SemaOpenCL/ternary-implicit-casts.cl === --- test/SemaOpenCL/ternary-implicit-casts.cl +++ test/SemaOpenCL/ternary-implicit-casts.cl @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only + +kernel void implicit_cast_local(global int* gint, local int* lint, int cond) +{ + // will not compile, ptr is not generic but local + local int *ptr = cond ? gint : lint; // expected-warning {{pointer type mismatch ('__global int *' and '__local int *')}} expected-error {{initializing '__local int *' with an expression of type 'void *' changes address space of pointer}} +} + +kernel void implicit_cast_generic(global int* gint, local int* lint, int cond) { + // will compile, ptr is generic and can accept global and local + int* ptr = cond ? gint : lint; // expected-warning {{pointer type mismatch ('__global int *' and '__local int *')}} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
RE: r259489 - Move DebugInfoKind into its own header to cut the cyclic dependency edge from Driver to Frontend.
Maybe Basic would be a better home for the new header? Having CodeGen pull in something from Driver seems weird and unprecedented. Thanks, --paulr > -Original Message- > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of > Benjamin Kramer via cfe-commits > Sent: Tuesday, February 02, 2016 3:07 AM > To: cfe-commits@lists.llvm.org > Subject: r259489 - Move DebugInfoKind into its own header to cut the > cyclic dependency edge from Driver to Frontend. > > Author: d0k > Date: Tue Feb 2 05:06:51 2016 > New Revision: 259489 > > URL: http://llvm.org/viewvc/llvm-project?rev=259489&view=rev > Log: > Move DebugInfoKind into its own header to cut the cyclic dependency edge > from Driver to Frontend. > > Added: > cfe/trunk/include/clang/Driver/DebugInfoKind.h > Modified: > cfe/trunk/include/clang/Frontend/CodeGenOptions.def > cfe/trunk/include/clang/Frontend/CodeGenOptions.h > cfe/trunk/lib/CodeGen/BackendUtil.cpp > cfe/trunk/lib/CodeGen/CGBlocks.cpp > cfe/trunk/lib/CodeGen/CGDebugInfo.cpp > cfe/trunk/lib/CodeGen/CGDebugInfo.h > cfe/trunk/lib/CodeGen/CGDecl.cpp > cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp > cfe/trunk/lib/CodeGen/CodeGenFunction.cpp > cfe/trunk/lib/CodeGen/CodeGenModule.cpp > cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp > cfe/trunk/lib/Driver/Tools.cpp > cfe/trunk/lib/Driver/Tools.h > cfe/trunk/lib/Frontend/CompilerInvocation.cpp > cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp > > Added: cfe/trunk/include/clang/Driver/DebugInfoKind.h > URL: http://llvm.org/viewvc/llvm- > project/cfe/trunk/include/clang/Driver/DebugInfoKind.h?rev=259489&view=aut > o > == > > --- cfe/trunk/include/clang/Driver/DebugInfoKind.h (added) > +++ cfe/trunk/include/clang/Driver/DebugInfoKind.h Tue Feb 2 05:06:51 > 2016 > @@ -0,0 +1,39 @@ > +//===--- DebugInfoKind.h - Debug Info Emission Types *- C++ - > *-===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//=== > --===// > + > +#ifndef LLVM_CLANG_DRIVER_DEBUGINFOKIND_H > +#define LLVM_CLANG_DRIVER_DEBUGINFOKIND_H > + > +namespace clang { > +namespace codegenoptions { > + > +enum DebugInfoKind { > + NoDebugInfo, /// Don't generate debug info. > + LocTrackingOnly, /// Emit location information but do not generate > + /// debug info in the output. This is useful in > + /// cases where the backend wants to track source > + /// locations for instructions without actually > + /// emitting debug info for them (e.g., when - > Rpass > + /// is used). > + DebugLineTablesOnly, /// Emit only debug info necessary for generating > + /// line number tables (-gline-tables-only). > + LimitedDebugInfo,/// Limit generated debug info to reduce size > + /// (-fno-standalone-debug). This emits > + /// forward decls for types that could be > + /// replaced with forward decls in the source > + /// code. For dynamic C++ classes type info > + /// is only emitted int the module that > + /// contains the classe's vtable. > + FullDebugInfo/// Generate complete debug info. > +}; > + > +} // end namespace codegenoptions > +} // end namespace clang > + > +#endif > > Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def > URL: http://llvm.org/viewvc/llvm- > project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=259489&r1= > 259488&r2=259489&view=diff > == > > --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original) > +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Tue Feb 2 > 05:06:51 2016 > @@ -185,7 +185,7 @@ VALUE_CODEGENOPT(NumRegisterParameters, > VALUE_CODEGENOPT(SSPBufferSize, 32, 0) > > /// The kind of generated debug info. > -ENUM_CODEGENOPT(DebugInfo, DebugInfoKind, 3, NoDebugInfo) > +ENUM_CODEGENOPT(DebugInfo, codegenoptions::DebugInfoKind, 3, > codegenoptions::NoDebugInfo) > > /// Tune the debug info for this debugger. > ENUM_CODEGENOPT(DebuggerTuning, DebuggerKind, 2, DebuggerKindDefault) > > Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h > URL: http://llvm.org/viewvc/llvm- > project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=259489&r1=25 > 9488&r2=259489&view=diff > == > > --- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original) > +++ cfe/trunk/include/clang/Fr
Re: [PATCH] D16682: 19957 - OpenCL incorrectly accepts implicit address space conversion with ternary operator
ichesnokov added inline comments. Comment at: test/CodeGenOpenCL/ternary-implicit-casts-fail.cl:2 @@ +1,3 @@ +// RUN: %clang_cc1 %s +// XFAIL: * + ichesnokov wrote: > asl wrote: > > ichesnokov wrote: > > > asl wrote: > > > > Don't do XFAIL tests - they will be "ok" regardless of the failure > > > > type. Make sure you're checking the exact error message, etc. > > > Unable to use // expected-error {{}}. > > > Compiler gives error: initializing '__local int *' with an expression of > > > type 'void *' changes address space of pointer > > > Using // expected-error {{initializing '__local int *' with an expression > > > of type 'void *' changes address space of pointer}} does not work. > > > Thus I used XFAIL. > > This is either bug in expected-error stuff (which I honestly doubt) or you > > did something wrong. > I'll send the patch to llvm-dev to find out what's the reason of > expected-error fail. It was my error: I forgot add -verify parameter. http://reviews.llvm.org/D16682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16788: PS4 ABI Round 2. Actual PS4 code.
probinson added inline comments. Comment at: include/clang/Basic/TargetCXXABI.h:118 @@ -115,1 +117,3 @@ +/// in LLVM 3.2. +PS4 }; rjmccall wrote: > I'm not sure why you added a new C++ ABI kind here. The bug fix you're > opting out of is not at all specific to C++, and there are more > straightforward ways to check the target than checking the C++ ABI kind. > > I mean, I have no doubt that eventually there will be some significant C++ > ABI bug fix that you don't want to pick up, so I'm not opposed to adding a > new C++ ABI kind. It just seems inappropriate to do that in this patch. The alignment attribute is affecting layout, and layout would seem to be an ABI thing. http://reviews.llvm.org/D16788 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r259518 - Make CodeGen headers self-contained.
Author: d0k Date: Tue Feb 2 10:05:18 2016 New Revision: 259518 URL: http://llvm.org/viewvc/llvm-project?rev=259518&view=rev Log: Make CodeGen headers self-contained. Modified: cfe/trunk/lib/CodeGen/CGRecordLayout.h Modified: cfe/trunk/lib/CodeGen/CGRecordLayout.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayout.h?rev=259518&r1=259517&r2=259518&view=diff == --- cfe/trunk/lib/CodeGen/CGRecordLayout.h (original) +++ cfe/trunk/lib/CodeGen/CGRecordLayout.h Tue Feb 2 10:05:18 2016 @@ -11,7 +11,7 @@ #define LLVM_CLANG_LIB_CODEGEN_CGRECORDLAYOUT_H #include "clang/AST/CharUnits.h" -#include "clang/AST/Decl.h" +#include "clang/AST/DeclCXX.h" #include "clang/Basic/LLVM.h" #include "llvm/ADT/DenseMap.h" #include "llvm/IR/DerivedTypes.h" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16572: PR23057: fix use-after-free due to local token buffer in ParseCXXAmbiguousParenExpression
majnemer accepted this revision. majnemer added a reviewer: majnemer. majnemer added a comment. This revision is now accepted and ready to land. LGTM http://reviews.llvm.org/D16572 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16630: PR23057: Fix assertion `Val && "isa<> used on a null pointer"' on invalid for-range expression
majnemer accepted this revision. majnemer added a reviewer: majnemer. majnemer added a comment. This revision is now accepted and ready to land. LGTM http://reviews.llvm.org/D16630 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D16808: [MCU] PR26438: Fix assertion failure on function returning an empty struct or union
d.zobnin.bugzilla created this revision. d.zobnin.bugzilla added reviewers: mkuper, rnk, DavidKreitzer. d.zobnin.bugzilla added a subscriber: cfe-commits. Add missing check for zero-sized type for MCU ABI in order to return zero-sized types (empty structs and unions) via memory. http://reviews.llvm.org/D16808 Files: lib/CodeGen/TargetInfo.cpp test/CodeGen/mcu-struct-return.c Index: lib/CodeGen/TargetInfo.cpp === --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -1010,8 +1010,9 @@ uint64_t Size = Context.getTypeSize(Ty); // For i386, type must be register sized. - // For the MCU ABI, it only needs to be <= 8-byte - if ((IsMCUABI && Size > 64) || (!IsMCUABI && !isRegisterSize(Size))) + // For the MCU ABI, it only needs to be positive <= 8-byte. + if ((IsMCUABI && (Size == 0 || Size > 64)) || + (!IsMCUABI && !isRegisterSize(Size))) return false; if (Ty->isVectorType()) { Index: test/CodeGen/mcu-struct-return.c === --- test/CodeGen/mcu-struct-return.c +++ test/CodeGen/mcu-struct-return.c @@ -0,0 +1,66 @@ +// RUN: %clang_cc1 -triple i386-pc-elfiamcu -emit-llvm %s -o - | FileCheck %s + +// Structure that is more than 8 byte. +struct Big { + double a[10]; +}; + +// Empty union with zero size must be returned via memory. +union U1 { +} u1; + +// Too large union (80 bytes) must be returned via memory. +union U2 { + struct Big b; +} u2; + +// Aggregate union, must be returned in register. +union U3 { + int x; +} u3; + +// Empty struct with zero size, must be returned via memory. +struct S1 { +} s1; + +// Aggregate struct, must be returend in register. +struct S2 { + int x; +} s2; + +// CHECK: [[UNION1_TYPE:%.+]] = type {} +// CHECK: [[UNION2_TYPE:%.+]] = type { [[STRUCT_TYPE:%.+]] } +// CHECK: [[STRUCT_TYPE]] = type { [10 x double] } +// CHECK: [[UNION3_TYPE:%.+]] = type { i32 } +// CHECK: [[STRUCT1_TYPE:%.+]] = type {} +// CHECK: [[STRUCT2_TYPE:%.+]] = type { i32 } + +union U1 foo1() { return u1; } +union U2 foo2() { return u2; } +union U3 foo3() { return u3; } +struct S1 bar1() { return s1; } +struct S2 bar2() { return s2; } +// CHECK: define void @foo1([[UNION1_TYPE]]* noalias sret %{{.+}}) +// CHECK: define void @foo2([[UNION2_TYPE]]* noalias sret %{{.+}}) +// CHECK: define i32 @foo3() +// CHECK: define void @bar1([[STRUCT1_TYPE]]* noalias sret %{{.+}}) +// CHECK: define i32 @bar2() + +void run() { + union U1 x1 = foo1(); + union U2 x2 = foo2(); + union U3 x3 = foo3(); + struct S1 y1 = bar1(); + struct S2 y2 = bar2(); + + // CHECK: [[X1:%.+]] = alloca [[UNION1_TYPE]] + // CHECK: [[X2:%.+]] = alloca [[UNION2_TYPE]] + // CHECK: [[X3:%.+]] = alloca [[UNION3_TYPE]] + // CHECK: [[Y1:%.+]] = alloca [[STRUCT1_TYPE]] + // CHECK: [[Y2:%.+]] = alloca [[STRUCT2_TYPE]] + // CHECK: call void @foo1([[UNION1_TYPE]]* sret [[X1]]) + // CHECK: call void @foo2([[UNION2_TYPE]]* sret [[X2]]) + // CHECK: {{.+}} = call i32 @foo3() + // CHECK: call void @bar1([[STRUCT1_TYPE]]* sret [[Y1]]) + // CHECK: {{.+}} = call i32 @bar2() +} Index: lib/CodeGen/TargetInfo.cpp === --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -1010,8 +1010,9 @@ uint64_t Size = Context.getTypeSize(Ty); // For i386, type must be register sized. - // For the MCU ABI, it only needs to be <= 8-byte - if ((IsMCUABI && Size > 64) || (!IsMCUABI && !isRegisterSize(Size))) + // For the MCU ABI, it only needs to be positive <= 8-byte. + if ((IsMCUABI && (Size == 0 || Size > 64)) || + (!IsMCUABI && !isRegisterSize(Size))) return false; if (Ty->isVectorType()) { Index: test/CodeGen/mcu-struct-return.c === --- test/CodeGen/mcu-struct-return.c +++ test/CodeGen/mcu-struct-return.c @@ -0,0 +1,66 @@ +// RUN: %clang_cc1 -triple i386-pc-elfiamcu -emit-llvm %s -o - | FileCheck %s + +// Structure that is more than 8 byte. +struct Big { + double a[10]; +}; + +// Empty union with zero size must be returned via memory. +union U1 { +} u1; + +// Too large union (80 bytes) must be returned via memory. +union U2 { + struct Big b; +} u2; + +// Aggregate union, must be returned in register. +union U3 { + int x; +} u3; + +// Empty struct with zero size, must be returned via memory. +struct S1 { +} s1; + +// Aggregate struct, must be returend in register. +struct S2 { + int x; +} s2; + +// CHECK: [[UNION1_TYPE:%.+]] = type {} +// CHECK: [[UNION2_TYPE:%.+]] = type { [[STRUCT_TYPE:%.+]] } +// CHECK: [[STRUCT_TYPE]] = type { [10 x double] } +// CHECK: [[UNION3_TYPE:%.+]] = type { i32 } +// CHECK: [[STRUCT1_TYPE:%.+]] = type {} +// CHECK: [[STRUCT2_TYPE:%.+]] = type { i32 } + +union U1 foo1() { return u1; } +union U2 foo2() { return u2; } +union U3 foo3() { return u3; } +struct S1 bar1() { return s1; } +struct S2 bar2() { return s2;
Re: [PATCH] D16539: [FIX] 26194 - LLVM crash in CXXNameMangler::mangleType
ichesnokov added a comment. Please support discussion about MicrosoftMangle+CL at https://llvm.org/bugs/show_bug.cgi?id=26194 Comment at: tools/driver/driver.cpp:367 @@ -367,1 +366,3 @@ +int Result = ExecuteCC1Tool(argv, argv[1] + 4); +return Result; // Useful for debugging to set breakpoint here } pxli168 wrote: > I think this dubug use shuold not be in the patch. Yes, this is enough to work with MicrosoftMangler. However I am in doubt about this implentation. Please forward discussion at https://llvm.org/bugs/show_bug.cgi?id=26194 http://reviews.llvm.org/D16539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16808: [MCU] PR26438: Fix assertion failure on function returning an empty struct or union
hjl.tools added a subscriber: hjl.tools. hjl.tools added a comment. Why should empty structs and unions) be return in memory? I don't remember I called for it in MCU psABI. http://reviews.llvm.org/D16808 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16717: [clang-tidy] Add non-constant references in function parameters check.
alexfh accepted this revision. alexfh added a comment. This revision is now accepted and ready to land. Looks good with one nit. Thank you! Comment at: test/clang-tidy/google-runtime-references.cpp:1 @@ +1,2 @@ +// RUN: %check_clang_tidy %s google-runtime-references %t -- -- -std=c++11 + `-std=c++11` is added by default. Please remove everything after the `%t`. http://reviews.llvm.org/D16717 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers
LegalizeAdulthood added inline comments. Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.cpp:366 @@ +365,3 @@ + binaryOperator( + isExpansionInMainFile(), hasOperatorName(OperatorName), + hasLHS(allOf( aaron.ballman wrote: > Sorry for not noticing this earlier, but since we have two other in-flight > patches I reviewed this morning, it caught my attention: we should not be > using isExpansionInMainFile, but instead testing the source location of the > matches to see if they're in a macro expansion. This is usually done with > something like `Result.SourceManager->isMacroBodyExpansion(SomeLoc)`. > > I realize this is existing code and not your problem, but it should be fixed > in a follow-on patch (by someone) and include some macro test cases. There is an open bug on this that I will address. And while this is existing code, I am the author of the original check :). I also experienced a problem when running this check on some code that did something like: ``` #define FOO (par[1] > 4) // ... bool f() { if (!FOO) { return true; } else { return false; } } ``` So it needs improvement w.r.t. macros and that is also on my to-do list. I'm trying to do things in incremental steps and not giant changes. http://reviews.llvm.org/D16308 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers
LegalizeAdulthood added a comment. I do not have commit access. If someone could commit this for me, I would appreciate it. Patch by Richard Thomson. Thanks. http://reviews.llvm.org/D16308 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r259530 - [clang-tidy] Add non-constant references in function parameters check.
Author: alexfh Date: Tue Feb 2 11:27:01 2016 New Revision: 259530 URL: http://llvm.org/viewvc/llvm-project?rev=259530&view=rev Log: [clang-tidy] Add non-constant references in function parameters check. Summary: This is implemented originally by Alexander Kornienko. Reviewers: alexfh Subscribers: cfe-commits Patch by Haojian Wu! Differential Revision: http://reviews.llvm.org/D16717 Added: clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.cpp clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.h clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-references.rst clang-tools-extra/trunk/test/clang-tidy/google-runtime-references.cpp Modified: clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Modified: clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt?rev=259530&r1=259529&r2=259530&view=diff == --- clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt (original) +++ clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt Tue Feb 2 11:27:01 2016 @@ -8,6 +8,7 @@ add_clang_library(clangTidyGoogleModule GoogleTidyModule.cpp IntegerTypesCheck.cpp MemsetZeroLengthCheck.cpp + NonConstReferences.cpp OverloadedUnaryAndCheck.cpp StringReferenceMemberCheck.cpp TodoCommentCheck.cpp Modified: clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp?rev=259530&r1=259529&r2=259530&view=diff == --- clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp Tue Feb 2 11:27:01 2016 @@ -21,6 +21,7 @@ #include "IntegerTypesCheck.h" #include "MemsetZeroLengthCheck.h" #include "OverloadedUnaryAndCheck.h" +#include "NonConstReferences.h" #include "StringReferenceMemberCheck.h" #include "TodoCommentCheck.h" #include "UnnamedNamespaceInHeaderCheck.h" @@ -47,6 +48,8 @@ public: "google-runtime-int"); CheckFactories.registerCheck( "google-runtime-operator"); +CheckFactories.registerCheck( +"google-runtime-references"); CheckFactories.registerCheck( "google-runtime-member-string-references"); CheckFactories.registerCheck( Added: clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.cpp?rev=259530&view=auto == --- clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.cpp (added) +++ clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.cpp Tue Feb 2 11:27:01 2016 @@ -0,0 +1,119 @@ +//===--- NonConstReferences.cpp - clang-tidy *- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "NonConstReferences.h" +#include "clang/AST/DeclBase.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/ASTMatchers/ASTMatchers.h" + +using namespace clang::ast_matchers; + +namespace clang { +namespace tidy { +namespace google { +namespace runtime { + +void NonConstReferences::registerMatchers(MatchFinder *Finder) { + Finder->addMatcher( + parmVarDecl( + unless(isInstantiated()), + hasType(references( + qualType(unless(isConstQualified())).bind("referenced_type"))), + unless(hasType(rValueReferenceType( + .bind("param"), + this); +} + +void NonConstReferences::check(const MatchFinder::MatchResult &Result) { + const auto *Parameter = Result.Nodes.getNodeAs("param"); + const auto *Function = + dyn_cast_or_null(Parameter->getParentFunctionOrMethod()); + + if (Function == nullptr || Function->isImplicit()) +return; + + if (!Function->isCanonicalDecl()) +return; + + if (const CXXMethodDecl *Method = dyn_cast(Function)) { +// Don't warn on implementations of an interface using references. +if (Method->begin_overridden_methods() != Method->end_overridden_methods()) + return; +// Don't warn on lambdas, as they frequently have to conform to the +// interface defined elsewhere. +if (Method->getParent()->isLambda()) + return; + } + + auto ReferencedType = *Result.Nodes.getNodeAs("referenced_type"); + // Don't warn on function references, they shouldn't be constant. +
[clang-tools-extra] r259531 - [clang-tidy] Removed unnecessary parameters in the test
Author: alexfh Date: Tue Feb 2 11:27:08 2016 New Revision: 259531 URL: http://llvm.org/viewvc/llvm-project?rev=259531&view=rev Log: [clang-tidy] Removed unnecessary parameters in the test Modified: clang-tools-extra/trunk/test/clang-tidy/google-runtime-references.cpp Modified: clang-tools-extra/trunk/test/clang-tidy/google-runtime-references.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-runtime-references.cpp?rev=259531&r1=259530&r2=259531&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/google-runtime-references.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/google-runtime-references.cpp Tue Feb 2 11:27:08 2016 @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s google-runtime-references %t -- -- -std=c++11 +// RUN: %check_clang_tidy %s google-runtime-references %t int a; int &b = a; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16717: [clang-tidy] Add non-constant references in function parameters check.
This revision was automatically updated to reflect the committed changes. Closed by commit rL259530: [clang-tidy] Add non-constant references in function parameters check. (authored by alexfh). Changed prior to commit: http://reviews.llvm.org/D16717?vs=46628&id=4#toc Repository: rL LLVM http://reviews.llvm.org/D16717 Files: clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.cpp clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.h clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-references.rst clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst clang-tools-extra/trunk/test/clang-tidy/google-runtime-references.cpp Index: clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp === --- clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp +++ clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp @@ -21,6 +21,7 @@ #include "IntegerTypesCheck.h" #include "MemsetZeroLengthCheck.h" #include "OverloadedUnaryAndCheck.h" +#include "NonConstReferences.h" #include "StringReferenceMemberCheck.h" #include "TodoCommentCheck.h" #include "UnnamedNamespaceInHeaderCheck.h" @@ -47,6 +48,8 @@ "google-runtime-int"); CheckFactories.registerCheck( "google-runtime-operator"); +CheckFactories.registerCheck( +"google-runtime-references"); CheckFactories.registerCheck( "google-runtime-member-string-references"); CheckFactories.registerCheck( Index: clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.h === --- clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.h +++ clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.h @@ -0,0 +1,36 @@ +//===--- NonConstReferences.h - clang-tidy --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_NON_CONST_REFERENCES_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_NON_CONST_REFERENCES_H + +#include "../ClangTidy.h" + +namespace clang { +namespace tidy { +namespace google { +namespace runtime { + +/// \brief Checks the usage of non-constant references in function parameters. +/// +/// https://google.github.io/styleguide/cppguide.html#Reference_Arguments +class NonConstReferences : public ClangTidyCheck { +public: + NonConstReferences(StringRef Name, ClangTidyContext *Context) + : ClangTidyCheck(Name, Context) {} + void registerMatchers(ast_matchers::MatchFinder *Finder) override; + void check(const ast_matchers::MatchFinder::MatchResult &Result) override; +}; + +} // namespace runtime +} // namespace google +} // namespace tidy +} // namespace clang + +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_NON_CONST_REFERENCES_H Index: clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.cpp === --- clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.cpp +++ clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.cpp @@ -0,0 +1,119 @@ +//===--- NonConstReferences.cpp - clang-tidy *- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "NonConstReferences.h" +#include "clang/AST/DeclBase.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/ASTMatchers/ASTMatchers.h" + +using namespace clang::ast_matchers; + +namespace clang { +namespace tidy { +namespace google { +namespace runtime { + +void NonConstReferences::registerMatchers(MatchFinder *Finder) { + Finder->addMatcher( + parmVarDecl( + unless(isInstantiated()), + hasType(references( + qualType(unless(isConstQualified())).bind("referenced_type"))), + unless(hasType(rValueReferenceType( + .bind("param"), + this); +} + +void NonConstReferences::check(const MatchFinder::MatchResult &Result) { + const auto *Parameter = Result.Nodes.getNodeAs("param"); + const auto *Function = + dyn_cast_or_null(Parameter->getParentFunctionOrMethod()); + + if (Function == nullptr || Function->isImplicit()) +return; + + if (!Function->isCanonicalDecl()) +return; + + if (const CXXMethodDecl *Method = dyn_cast(Function)) { +// Don't warn on implementations of an interface using references. +if (Method->begin_ove
Re: [PATCH] D16788: PS4 ABI Round 2. Actual PS4 code.
rjmccall added inline comments. Comment at: include/clang/Basic/TargetCXXABI.h:118 @@ -115,1 +117,3 @@ +/// in LLVM 3.2. +PS4 }; probinson wrote: > rjmccall wrote: > > I'm not sure why you added a new C++ ABI kind here. The bug fix you're > > opting out of is not at all specific to C++, and there are more > > straightforward ways to check the target than checking the C++ ABI kind. > > > > I mean, I have no doubt that eventually there will be some significant C++ > > ABI bug fix that you don't want to pick up, so I'm not opposed to adding a > > new C++ ABI kind. It just seems inappropriate to do that in this patch. > The alignment attribute is affecting layout, and layout would seem to be an > ABI thing. The CXXABI types dictate C++-specific ABI details, e.g. the layout of v-tables. Generic C-level ABI details like type sizes and alignments and struct layout quirks are provided by TargetInfo. In particular, TargetInfo already have 3 or 4 target-specific methods controlling various details of bit-field alignment; adding another for this will be very natural. http://reviews.llvm.org/D16788 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r259532 - PR23057: Fix assertion `Val && "isa<> used on a null pointer"' on invalid for-range expression.
Author: dzobnin Date: Tue Feb 2 11:33:09 2016 New Revision: 259532 URL: http://llvm.org/viewvc/llvm-project?rev=259532&view=rev Log: PR23057: Fix assertion `Val && "isa<> used on a null pointer"' on invalid for-range expression. Fix the issue discovered by fuzzing (PR23057, comment 18) by handling nullptr in Sema::ActOnCXXForRangeDecl and correct delayed typos in for-range expression before calling Sema::ActOnCXXForRangeStmt. Also fixes PR26288. Differential Revision: http://reviews.llvm.org/D16630 Added: cfe/trunk/test/Parser/cxx-invalid-for-range.cpp Modified: cfe/trunk/lib/Parse/ParseStmt.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp Modified: cfe/trunk/lib/Parse/ParseStmt.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=259532&r1=259531&r2=259532&view=diff == --- cfe/trunk/lib/Parse/ParseStmt.cpp (original) +++ cfe/trunk/lib/Parse/ParseStmt.cpp Tue Feb 2 11:33:09 2016 @@ -1716,9 +1716,11 @@ StmtResult Parser::ParseForStatement(Sou StmtResult ForEachStmt; if (ForRange) { +ExprResult CorrectedRange = +Actions.CorrectDelayedTyposInExpr(ForRangeInit.RangeExpr.get()); ForRangeStmt = Actions.ActOnCXXForRangeStmt( getCurScope(), ForLoc, CoawaitLoc, FirstPart.get(), -ForRangeInit.ColonLoc, ForRangeInit.RangeExpr.get(), +ForRangeInit.ColonLoc, CorrectedRange.get(), T.getCloseLocation(), Sema::BFRK_Build); // Similarly, we need to do the semantic analysis for a for-range Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=259532&r1=259531&r2=259532&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Feb 2 11:33:09 2016 @@ -9928,6 +9928,10 @@ void Sema::ActOnUninitializedDecl(Decl * } void Sema::ActOnCXXForRangeDecl(Decl *D) { + // If there is no declaration, there was an error parsing it. Ignore it. + if (!D) +return; + VarDecl *VD = dyn_cast(D); if (!VD) { Diag(D->getLocation(), diag::err_for_range_decl_must_be_var); Modified: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp?rev=259532&r1=259531&r2=259532&view=diff == --- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp (original) +++ cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp Tue Feb 2 11:33:09 2016 @@ -18,6 +18,9 @@ void f() { for (struct S { S(int) {} } s : arr) { // expected-error {{types may not be defined in a for range declaration}} } + for (struct S { S(int) {} } s : Undeclared); // expected-error{{types may not be defined in a for range declaration}} + // expected-error@-1{{use of undeclared identifier 'Undeclared'}} + new struct T {}; // expected-error {{'T' cannot be defined in a type specifier}} new struct A {}; // expected-error {{'A' cannot be defined in a type specifier}} Added: cfe/trunk/test/Parser/cxx-invalid-for-range.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-invalid-for-range.cpp?rev=259532&view=auto == --- cfe/trunk/test/Parser/cxx-invalid-for-range.cpp (added) +++ cfe/trunk/test/Parser/cxx-invalid-for-range.cpp Tue Feb 2 11:33:09 2016 @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + +// From PR23057 comment #18 (https://llvm.org/bugs/show_bug.cgi?id=23057#c18). + +namespace N { + int X[10]; // expected-note{{declared here +} + +void f1() { + for (auto operator new : X); // expected-error{{'operator new' cannot be the name of a variable or data member}} + // expected-error@-1{{use of undeclared identifier 'X'; did you mean 'N::X'?}} +} + +void f2() { + for (a operator== :) // expected-error{{'operator==' cannot be the name of a variable or data member}} + // expected-error@-1{{expected expression}} + // expected-error@-2{{unknown type name 'a'}} +} // expected-error{{expected statement}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16630: PR23057: Fix assertion `Val && "isa<> used on a null pointer"' on invalid for-range expression
This revision was automatically updated to reflect the committed changes. Closed by commit rL259532: PR23057: Fix assertion `Val && "isa<> used on a null pointer"' on invalid for… (authored by dzobnin). Changed prior to commit: http://reviews.llvm.org/D16630?vs=46131&id=46669#toc Repository: rL LLVM http://reviews.llvm.org/D16630 Files: cfe/trunk/lib/Parse/ParseStmt.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp cfe/trunk/test/Parser/cxx-invalid-for-range.cpp Index: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp === --- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp +++ cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp @@ -18,6 +18,9 @@ for (struct S { S(int) {} } s : arr) { // expected-error {{types may not be defined in a for range declaration}} } + for (struct S { S(int) {} } s : Undeclared); // expected-error{{types may not be defined in a for range declaration}} + // expected-error@-1{{use of undeclared identifier 'Undeclared'}} + new struct T {}; // expected-error {{'T' cannot be defined in a type specifier}} new struct A {}; // expected-error {{'A' cannot be defined in a type specifier}} Index: cfe/trunk/test/Parser/cxx-invalid-for-range.cpp === --- cfe/trunk/test/Parser/cxx-invalid-for-range.cpp +++ cfe/trunk/test/Parser/cxx-invalid-for-range.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + +// From PR23057 comment #18 (https://llvm.org/bugs/show_bug.cgi?id=23057#c18). + +namespace N { + int X[10]; // expected-note{{declared here +} + +void f1() { + for (auto operator new : X); // expected-error{{'operator new' cannot be the name of a variable or data member}} + // expected-error@-1{{use of undeclared identifier 'X'; did you mean 'N::X'?}} +} + +void f2() { + for (a operator== :) // expected-error{{'operator==' cannot be the name of a variable or data member}} + // expected-error@-1{{expected expression}} + // expected-error@-2{{unknown type name 'a'}} +} // expected-error{{expected statement}} Index: cfe/trunk/lib/Sema/SemaDecl.cpp === --- cfe/trunk/lib/Sema/SemaDecl.cpp +++ cfe/trunk/lib/Sema/SemaDecl.cpp @@ -9928,6 +9928,10 @@ } void Sema::ActOnCXXForRangeDecl(Decl *D) { + // If there is no declaration, there was an error parsing it. Ignore it. + if (!D) +return; + VarDecl *VD = dyn_cast(D); if (!VD) { Diag(D->getLocation(), diag::err_for_range_decl_must_be_var); Index: cfe/trunk/lib/Parse/ParseStmt.cpp === --- cfe/trunk/lib/Parse/ParseStmt.cpp +++ cfe/trunk/lib/Parse/ParseStmt.cpp @@ -1716,9 +1716,11 @@ StmtResult ForEachStmt; if (ForRange) { +ExprResult CorrectedRange = +Actions.CorrectDelayedTyposInExpr(ForRangeInit.RangeExpr.get()); ForRangeStmt = Actions.ActOnCXXForRangeStmt( getCurScope(), ForLoc, CoawaitLoc, FirstPart.get(), -ForRangeInit.ColonLoc, ForRangeInit.RangeExpr.get(), +ForRangeInit.ColonLoc, CorrectedRange.get(), T.getCloseLocation(), Sema::BFRK_Build); // Similarly, we need to do the semantic analysis for a for-range Index: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp === --- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp +++ cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp @@ -18,6 +18,9 @@ for (struct S { S(int) {} } s : arr) { // expected-error {{types may not be defined in a for range declaration}} } + for (struct S { S(int) {} } s : Undeclared); // expected-error{{types may not be defined in a for range declaration}} + // expected-error@-1{{use of undeclared identifier 'Undeclared'}} + new struct T {}; // expected-error {{'T' cannot be defined in a type specifier}} new struct A {}; // expected-error {{'A' cannot be defined in a type specifier}} Index: cfe/trunk/test/Parser/cxx-invalid-for-range.cpp === --- cfe/trunk/test/Parser/cxx-invalid-for-range.cpp +++ cfe/trunk/test/Parser/cxx-invalid-for-range.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + +// From PR23057 comment #18 (https://llvm.org/bugs/show_bug.cgi?id=23057#c18). + +namespace N { + int X[10]; // expected-note{{declared here +} + +void f1() { + for (auto operator new : X); // expected-error{{'operator new' cannot be the name of a variable or data member}} + // expected-error@-1{{use of undeclared identifier 'X'; did you mean 'N::X'?}} +}
r259537 - ARM: allow both vfma and vfms intrinsics on v7.
Author: tnorthover Date: Tue Feb 2 12:02:10 2016 New Revision: 259537 URL: http://llvm.org/viewvc/llvm-project?rev=259537&view=rev Log: ARM: allow both vfma and vfms intrinsics on v7. The main purpose here is that vfma/vfms should be symmetric, and they are supported on most v7 cores. The new ArchGuard is suggested by ACLE but prophylactic for us. Almost all CPUs with NEON *will* have vfma, and the few exceptions I know of (e.g. Cortex-A8) are incorrectly modelled by Clang so can't trigger a test. Fortunately, they're getting rarer. But if we ever do support them properly arm_neon.h should now do the right thing. Added: cfe/trunk/test/Sema/arm_vfma.c Modified: cfe/trunk/include/clang/Basic/arm_neon.td Modified: cfe/trunk/include/clang/Basic/arm_neon.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=259537&r1=259536&r2=259537&view=diff == --- cfe/trunk/include/clang/Basic/arm_neon.td (original) +++ cfe/trunk/include/clang/Basic/arm_neon.td Tue Feb 2 12:02:10 2016 @@ -824,7 +824,10 @@ def VREINTERPRET // Vector fused multiply-add operations -def VFMA : SInst<"vfma", "", "fQf">; +let ArchGuard = "defined(__ARM_FEATURE_FMA)" in { + def VFMA : SInst<"vfma", "", "fQf">; + def VFMS : SInst<"vfms", "", "fQf">; +} // fp16 vector operations @@ -908,7 +911,7 @@ def FDIV : IOpInst<"vdiv", "ddd", "fdQf // Vector fused multiply-add operations def FMLA : SInst<"vfma", "", "dQd">; -def FMLS : SInst<"vfms", "", "fdQfQd">; +def FMLS : SInst<"vfms", "", "dQd">; // MUL, MLA, MLS, FMA, FMS definitions with scalar argument Added: cfe/trunk/test/Sema/arm_vfma.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/arm_vfma.c?rev=259537&view=auto == --- cfe/trunk/test/Sema/arm_vfma.c (added) +++ cfe/trunk/test/Sema/arm_vfma.c Tue Feb 2 12:02:10 2016 @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-feature +neon -fsyntax-only -verify %s +#include + +// expected-no-diagnostics + +void func(float32x2_t v2f32, float32x4_t v4f32) { + vfma_f32(v2f32, v2f32, v2f32); + vfmaq_f32(v4f32, v4f32, v4f32); + + vfms_f32(v2f32, v2f32, v2f32); + vfmsq_f32(v4f32, v4f32, v4f32); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16808: [MCU] PR26438: Fix assertion failure on function returning an empty struct or union
rnk added a comment. If the ABI is still open to small changes and clarifications, can we make sure that C and C++ empty structs are passed the same way? Unfortunately, on normal x86_64 SysV GCC doesn't pass them the same way and Clang has to follow suit. http://reviews.llvm.org/D16808 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16700: [Clang-tidy] Make null pointer literals for fixes configurable for two checks
Eugene.Zelenko abandoned this revision. Eugene.Zelenko added a comment. I'll wait for global options implementation. Repository: rL LLVM http://reviews.llvm.org/D16700 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16786: [Clang-tidy] Make modernize-redundant-void-arg working with included files
Eugene.Zelenko added a comment. I didn't notice test cases for included files for other checkers. So it's hard to tell for should special test case introduced for this specific problem or not. Repository: rL LLVM http://reviews.llvm.org/D16786 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16794: [Clang-tidy] Make readability-simplify-boolean-expr working with included files
Eugene.Zelenko added a comment. I didn't notice test cases for included files for other checkers. So it's hard to tell for should special test case introduced for this specific problem or not. Repository: rL LLVM http://reviews.llvm.org/D16794 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r259507 - Make the remaining headers self-contained.
Out of curiosity, what technique were you using to find out if the headers were self-contained? Just "clang -c foo.h"? Cheers, Rafael On 2 February 2016 at 09:24, Benjamin Kramer via cfe-commits wrote: > Author: d0k > Date: Tue Feb 2 08:24:21 2016 > New Revision: 259507 > > URL: http://llvm.org/viewvc/llvm-project?rev=259507&view=rev > Log: > Make the remaining headers self-contained. > > Modified: > cfe/trunk/include/clang/AST/BaseSubobject.h > cfe/trunk/include/clang/AST/DeclOpenMP.h > cfe/trunk/include/clang/AST/Mangle.h > cfe/trunk/include/clang/AST/TemplateName.h > cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h > cfe/trunk/include/clang/Sema/ObjCMethodList.h > cfe/trunk/include/clang/Sema/Ownership.h > cfe/trunk/include/clang/Sema/Scope.h > cfe/trunk/include/clang/Sema/SemaLambda.h > cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h > cfe/trunk/lib/CodeGen/CodeGenTBAA.h > > Modified: cfe/trunk/include/clang/AST/BaseSubobject.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/BaseSubobject.h?rev=259507&r1=259506&r2=259507&view=diff > == > --- cfe/trunk/include/clang/AST/BaseSubobject.h (original) > +++ cfe/trunk/include/clang/AST/BaseSubobject.h Tue Feb 2 08:24:21 2016 > @@ -15,13 +15,12 @@ > #define LLVM_CLANG_AST_BASESUBOBJECT_H > > #include "clang/AST/CharUnits.h" > +#include "clang/AST/DeclCXX.h" > #include "llvm/ADT/DenseMap.h" > #include "llvm/Support/DataTypes.h" > #include "llvm/Support/type_traits.h" > > namespace clang { > - class CXXRecordDecl; > - > // BaseSubobject - Uniquely identifies a direct or indirect base class. > // Stores both the base class decl and the offset from the most derived > class to > // the base class. Used for vtable and VTT generation. > > Modified: cfe/trunk/include/clang/AST/DeclOpenMP.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclOpenMP.h?rev=259507&r1=259506&r2=259507&view=diff > == > --- cfe/trunk/include/clang/AST/DeclOpenMP.h (original) > +++ cfe/trunk/include/clang/AST/DeclOpenMP.h Tue Feb 2 08:24:21 2016 > @@ -17,6 +17,7 @@ > > #include "clang/AST/DeclBase.h" > #include "llvm/ADT/ArrayRef.h" > +#include "llvm/Support/TrailingObjects.h" > > namespace clang { > class Expr; > > Modified: cfe/trunk/include/clang/AST/Mangle.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Mangle.h?rev=259507&r1=259506&r2=259507&view=diff > == > --- cfe/trunk/include/clang/AST/Mangle.h (original) > +++ cfe/trunk/include/clang/AST/Mangle.h Tue Feb 2 08:24:21 2016 > @@ -14,6 +14,7 @@ > #ifndef LLVM_CLANG_AST_MANGLE_H > #define LLVM_CLANG_AST_MANGLE_H > > +#include "clang/AST/Decl.h" > #include "clang/AST/Type.h" > #include "clang/Basic/ABI.h" > #include "llvm/ADT/DenseMap.h" > > Modified: cfe/trunk/include/clang/AST/TemplateName.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TemplateName.h?rev=259507&r1=259506&r2=259507&view=diff > == > --- cfe/trunk/include/clang/AST/TemplateName.h (original) > +++ cfe/trunk/include/clang/AST/TemplateName.h Tue Feb 2 08:24:21 2016 > @@ -14,6 +14,7 @@ > #ifndef LLVM_CLANG_AST_TEMPLATENAME_H > #define LLVM_CLANG_AST_TEMPLATENAME_H > > +#include "clang/AST/NestedNameSpecifier.h" > #include "clang/Basic/LLVM.h" > #include "llvm/ADT/FoldingSet.h" > #include "llvm/ADT/PointerUnion.h" > > Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h?rev=259507&r1=259506&r2=259507&view=diff > == > --- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h (original) > +++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Tue Feb 2 08:24:21 > 2016 > @@ -15,6 +15,7 @@ > > #include "clang-c/Index.h" > #include "clang/AST/CanonicalType.h" > +#include "clang/AST/DeclBase.h" > #include "clang/AST/Type.h" > #include "clang/Sema/CodeCompleteOptions.h" > #include "llvm/ADT/DenseMap.h" > > Modified: cfe/trunk/include/clang/Sema/ObjCMethodList.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ObjCMethodList.h?rev=259507&r1=259506&r2=259507&view=diff > == > --- cfe/trunk/include/clang/Sema/ObjCMethodList.h (original) > +++ cfe/trunk/include/clang/Sema/ObjCMethodList.h Tue Feb 2 08:24:21 2016 > @@ -14,6 +14,7 @@ > #ifndef LLVM_CLANG_SEMA_OBJCMETHODLIST_H > #define LLVM_CLANG_SEMA_OBJCMETHODLIST_H > > +#include "clang/AST/DeclObjC.h" > #include "llvm/ADT/PointerIntPair.h" > > namespace clang { > > Modifie
Re: [PATCH] D15861: Support fully-qualified names for all QualTypes
saugustine updated this revision to Diff 46680. saugustine marked 19 inline comments as done. saugustine added a comment. - Update docs. Handle keywords and anonymous namespaces. - Address code review issues. Cleanup many http://reviews.llvm.org/D15861 Files: include/clang/Tooling/Core/QualTypeNames.h lib/Tooling/Core/CMakeLists.txt lib/Tooling/Core/QualTypeNames.cpp unittests/Tooling/CMakeLists.txt unittests/Tooling/QualTypeNamesTest.cpp Index: unittests/Tooling/QualTypeNamesTest.cpp === --- /dev/null +++ unittests/Tooling/QualTypeNamesTest.cpp @@ -0,0 +1,166 @@ +//===- unittest/Tooling/QualTypeNameTest.cpp --===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "clang/Tooling/Core/QualTypeNames.h" +#include "TestVisitor.h" +using namespace clang; + +namespace { +struct TypeNameVisitor : TestVisitor { + llvm::StringMap ExpectedQualTypeNames; + + // ValueDecls are the least-derived decl with both a qualtype and a + // name. + bool traverseDecl(Decl *D) { +return true; // Always continue + } + + bool VisitValueDecl(const ValueDecl *VD) { +std::string ExpectedName = +ExpectedQualTypeNames.lookup(VD->getNameAsString()); +if (ExpectedName != "") { + std::string ActualName = + TypeName::getFullyQualifiedName(VD->getType(), *Context); + if (ExpectedName != ActualName) { +// A custom message makes it much easier to see what declaration +// failed compared to EXPECT_EQ. +EXPECT_TRUE(false) << "Typename::getFullyQualifiedName failed for " + << VD->getQualifiedNameAsString() << std::endl + << " Actual: " << ActualName << std::endl + << " Exepcted: " << ExpectedName; + } +} +return true; + } +}; + +// named namespaces inside anonymous namespaces + +TEST(QualTypeNameTest, getFullyQualifiedName) { + TypeNameVisitor Visitor; + // Simple case to test the test framework itself. + Visitor.ExpectedQualTypeNames["CheckInt"] = "int"; + + // Keeping the names of the variables whose types we check unique + // within the entire test--regardless of their own scope--makes it + // easier to diagnose test failures. + + // Simple namespace qualifier + Visitor.ExpectedQualTypeNames["CheckA"] = "A::B::Class0"; + // Lookup up the enclosing scopes, then down another one. (These + // appear as elaborated type in the AST. In that case--even if + // policy.SuppressScope = 0--qual_type.getAsString(policy) only + // gives the name as it appears in the source, not the full name. + Visitor.ExpectedQualTypeNames["CheckB"] = "A::B::C::Class1"; + // Template parameter expansion. + Visitor.ExpectedQualTypeNames["CheckC"] = + "A::B::Template0"; + // Recursive template parameter expansion. + Visitor.ExpectedQualTypeNames["CheckD"] = + "A::B::Template0, " + "A::B::Template0 >"; + // Variadic Template expansion. + Visitor.ExpectedQualTypeNames["CheckE"] = + "A::Variadic, " + "A::B::Template1, A::B::C::MyInt>"; + // Using declarations should be fully expanded. + Visitor.ExpectedQualTypeNames["CheckF"] = "A::B::Class0"; + // Elements found within "using namespace foo;" should be fully + // expanded. + Visitor.ExpectedQualTypeNames["CheckG"] = "A::B::C::MyInt"; + // Type inside function + Visitor.ExpectedQualTypeNames["CheckH"] = "struct X"; + // Anonymous Namespaces + Visitor.ExpectedQualTypeNames["CheckI"] = "aClass"; + // Keyword inclusion with namespaces + Visitor.ExpectedQualTypeNames["CheckJ"] = "struct A::aStruct"; + // Anonymous Namespaces nested in named namespaces and vice-versa. + Visitor.ExpectedQualTypeNames["CheckK"] = "D::aStruct"; + // Namespace alias + Visitor.ExpectedQualTypeNames["CheckL"] = "A::B::C::MyInt"; + Visitor.ExpectedQualTypeNames["non_dependent_type_var"] = + "template Foo::non_dependent_type"; + Visitor.runOver( + "int CheckInt;\n" + "namespace A {\n" + " namespace B {\n" + " class Class0 { };\n" + " namespace C {\n" + " typedef int MyInt;" + " }\n" + " template class Template0;" + " template class Template1;" + " typedef B::Class0 AnotherClass;\n" + " void Function1(Template0 CheckC);\n" + " void Function2(Template0,\n" + "Template0 > CheckD);\n" + " }\n" + "template class Variadic {};\n" + "Variadic, " + " B::Template1, " + " B::C::MyInt > CheckE;\n" + " namespace BC = B::C;\n" + " BC::MyInt CheckL;\n" + "}\n" + "using A::B::Class0;\n" + "void Function(Class0 CheckF);\n" + "using name
Re: r259507 - Make the remaining headers self-contained.
On Tue, Feb 2, 2016 at 11:11 AM, Rafael Espíndola < cfe-commits@lists.llvm.org> wrote: > Out of curiosity, what technique were you using to find out if the > headers were self-contained? Just "clang -c foo.h"? > Building LLVM & Clang with C++ modules enabled > > Cheers, > Rafael > > > On 2 February 2016 at 09:24, Benjamin Kramer via cfe-commits > wrote: > > Author: d0k > > Date: Tue Feb 2 08:24:21 2016 > > New Revision: 259507 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=259507&view=rev > > Log: > > Make the remaining headers self-contained. > > > > Modified: > > cfe/trunk/include/clang/AST/BaseSubobject.h > > cfe/trunk/include/clang/AST/DeclOpenMP.h > > cfe/trunk/include/clang/AST/Mangle.h > > cfe/trunk/include/clang/AST/TemplateName.h > > cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h > > cfe/trunk/include/clang/Sema/ObjCMethodList.h > > cfe/trunk/include/clang/Sema/Ownership.h > > cfe/trunk/include/clang/Sema/Scope.h > > cfe/trunk/include/clang/Sema/SemaLambda.h > > cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h > > cfe/trunk/lib/CodeGen/CodeGenTBAA.h > > > > Modified: cfe/trunk/include/clang/AST/BaseSubobject.h > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/BaseSubobject.h?rev=259507&r1=259506&r2=259507&view=diff > > > == > > --- cfe/trunk/include/clang/AST/BaseSubobject.h (original) > > +++ cfe/trunk/include/clang/AST/BaseSubobject.h Tue Feb 2 08:24:21 2016 > > @@ -15,13 +15,12 @@ > > #define LLVM_CLANG_AST_BASESUBOBJECT_H > > > > #include "clang/AST/CharUnits.h" > > +#include "clang/AST/DeclCXX.h" > > #include "llvm/ADT/DenseMap.h" > > #include "llvm/Support/DataTypes.h" > > #include "llvm/Support/type_traits.h" > > > > namespace clang { > > - class CXXRecordDecl; > > - > > // BaseSubobject - Uniquely identifies a direct or indirect base class. > > // Stores both the base class decl and the offset from the most derived > class to > > // the base class. Used for vtable and VTT generation. > > > > Modified: cfe/trunk/include/clang/AST/DeclOpenMP.h > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclOpenMP.h?rev=259507&r1=259506&r2=259507&view=diff > > > == > > --- cfe/trunk/include/clang/AST/DeclOpenMP.h (original) > > +++ cfe/trunk/include/clang/AST/DeclOpenMP.h Tue Feb 2 08:24:21 2016 > > @@ -17,6 +17,7 @@ > > > > #include "clang/AST/DeclBase.h" > > #include "llvm/ADT/ArrayRef.h" > > +#include "llvm/Support/TrailingObjects.h" > > > > namespace clang { > > class Expr; > > > > Modified: cfe/trunk/include/clang/AST/Mangle.h > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Mangle.h?rev=259507&r1=259506&r2=259507&view=diff > > > == > > --- cfe/trunk/include/clang/AST/Mangle.h (original) > > +++ cfe/trunk/include/clang/AST/Mangle.h Tue Feb 2 08:24:21 2016 > > @@ -14,6 +14,7 @@ > > #ifndef LLVM_CLANG_AST_MANGLE_H > > #define LLVM_CLANG_AST_MANGLE_H > > > > +#include "clang/AST/Decl.h" > > #include "clang/AST/Type.h" > > #include "clang/Basic/ABI.h" > > #include "llvm/ADT/DenseMap.h" > > > > Modified: cfe/trunk/include/clang/AST/TemplateName.h > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TemplateName.h?rev=259507&r1=259506&r2=259507&view=diff > > > == > > --- cfe/trunk/include/clang/AST/TemplateName.h (original) > > +++ cfe/trunk/include/clang/AST/TemplateName.h Tue Feb 2 08:24:21 2016 > > @@ -14,6 +14,7 @@ > > #ifndef LLVM_CLANG_AST_TEMPLATENAME_H > > #define LLVM_CLANG_AST_TEMPLATENAME_H > > > > +#include "clang/AST/NestedNameSpecifier.h" > > #include "clang/Basic/LLVM.h" > > #include "llvm/ADT/FoldingSet.h" > > #include "llvm/ADT/PointerUnion.h" > > > > Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h?rev=259507&r1=259506&r2=259507&view=diff > > > == > > --- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h (original) > > +++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Tue Feb 2 > 08:24:21 2016 > > @@ -15,6 +15,7 @@ > > > > #include "clang-c/Index.h" > > #include "clang/AST/CanonicalType.h" > > +#include "clang/AST/DeclBase.h" > > #include "clang/AST/Type.h" > > #include "clang/Sema/CodeCompleteOptions.h" > > #include "llvm/ADT/DenseMap.h" > > > > Modified: cfe/trunk/include/clang/Sema/ObjCMethodList.h > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ObjCMethodList.h?rev=259507&r1=259506&r2=259507&view=diff > > > =
Re: [PATCH] D16759: [OpenMP] Parsing + sema for target parallel for directive.
ABataev accepted this revision. ABataev added a comment. This revision is now accepted and ready to land. LG with small comment Comment at: lib/Parse/ParseOpenMP.cpp:185 @@ -182,3 +184,3 @@ /// 'distribute' | 'target enter data' | 'target exit data' | -/// 'target parallel' +/// 'target parallel' | 'target parallel for' /// annot_pragma_openmp_end move '{clause}' string from line 183 after 'target parallel for' http://reviews.llvm.org/D16759 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15861: Support fully-qualified names for all QualTypes
Richard, Please take another look when you get a chance. Thanks. On Tue, Feb 2, 2016 at 11:14 AM, Sterling Augustine wrote: > saugustine updated this revision to Diff 46680. > saugustine marked 19 inline comments as done. > saugustine added a comment. > > - Update docs. Handle keywords and anonymous namespaces. > - Address code review issues. Cleanup many > > > http://reviews.llvm.org/D15861 > > Files: > include/clang/Tooling/Core/QualTypeNames.h > lib/Tooling/Core/CMakeLists.txt > lib/Tooling/Core/QualTypeNames.cpp > unittests/Tooling/CMakeLists.txt > unittests/Tooling/QualTypeNamesTest.cpp > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16804: [analyzer] AnalysisConsumer: print fully-qualified function name while displaying progress
zaks.anna accepted this revision. zaks.anna added a comment. This revision is now accepted and ready to land. Thank you! http://reviews.llvm.org/D16804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16786: [Clang-tidy] Make modernize-redundant-void-arg working with included files
Eugene.Zelenko added a comment. I think proper solution will be to create tests for included files ot the fly, bu renaming main test to .h and creating dummy source file. But this is task for scripts wizards :-) Repository: rL LLVM http://reviews.llvm.org/D16786 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16786: [Clang-tidy] Make modernize-redundant-void-arg working with included files
aaron.ballman added a comment. In http://reviews.llvm.org/D16786#341938, @Eugene.Zelenko wrote: > I didn't notice test cases for included files for other checkers. So it's > hard to tell for should special test case introduced for this specific > problem or not. Generally speaking, all changes should have a test case accompanying them unless the change is NFC. It helps ensure we don't regress behavior the we want with the fix. Repository: rL LLVM http://reviews.llvm.org/D16786 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16794: [Clang-tidy] Make readability-simplify-boolean-expr working with included files
Eugene.Zelenko added a comment. I think proper solution will be to create tests for included files ot the fly, bu renaming main test to .h and creating dummy source file. But this is task for scripts wizards :-) Repository: rL LLVM http://reviews.llvm.org/D16794 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16786: [Clang-tidy] Make modernize-redundant-void-arg working with included files
aaron.ballman added a comment. In http://reviews.llvm.org/D16786#342072, @Eugene.Zelenko wrote: > I think proper solution will be to create tests for included files ot the > fly, bu renaming main test to .h and creating dummy source file. But this is > task for scripts wizards :-) I'm not certain if that's the proper solution or not, but I'm also not comfortable with committing nontrivial changes without an accompanying test case. either. I would recommend writing a simple test include that would fail before applying your patch (and succeeds after) and go that route, unless you want to try your hand at the scripting approach. Repository: rL LLVM http://reviews.llvm.org/D16786 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16786: [Clang-tidy] Make modernize-redundant-void-arg working with included files
Eugene.Zelenko added a comment. In http://reviews.llvm.org/D16786#342074, @aaron.ballman wrote: > In http://reviews.llvm.org/D16786#342072, @Eugene.Zelenko wrote: > > > I think proper solution will be to create tests for included files ot the > > fly, bu renaming main test to .h and creating dummy source file. But this > > is task for scripts wizards :-) > > > I'm not certain if that's the proper solution or not, but I'm also not > comfortable with committing nontrivial changes without an accompanying test > case. either. I would recommend writing a simple test include that would fail > before applying your patch (and succeeds after) and go that route, unless you > want to try your hand at the scripting approach. My point is that all checks should be test in similar situations. It's not reasonable to introduce special checks only for selected ones. Repository: rL LLVM http://reviews.llvm.org/D16786 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16786: [Clang-tidy] Make modernize-redundant-void-arg working with included files
aaron.ballman added a comment. In http://reviews.llvm.org/D16786#342075, @Eugene.Zelenko wrote: > In http://reviews.llvm.org/D16786#342074, @aaron.ballman wrote: > > > In http://reviews.llvm.org/D16786#342072, @Eugene.Zelenko wrote: > > > > > I think proper solution will be to create tests for included files ot the > > > fly, bu renaming main test to .h and creating dummy source file. But this > > > is task for scripts wizards :-) > > > > > > I'm not certain if that's the proper solution or not, but I'm also not > > comfortable with committing nontrivial changes without an accompanying test > > case. either. I would recommend writing a simple test include that would > > fail before applying your patch (and succeeds after) and go that route, > > unless you want to try your hand at the scripting approach. > > > My point is that all checks should be test in similar situations. It's not > reasonable to introduce special checks only for selected ones. Agreed; however, not all checks have the same behavior regarding macro expansion and header files. Some checks have special behaviors regarding macros, others may require the check to not be run outside of the main file, etc. I'm not certain how well such a test harness can be generalized for this, but if you have ideas in mind, they would be great to explore! Repository: rL LLVM http://reviews.llvm.org/D16786 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D16819: Remove llvm::(cast|isa) from lib/CodeGen/Address.h to fix build with gcc-4.8.1
sugak created this revision. sugak added reviewers: rsmith, rjmccall. sugak added subscribers: hans, cfe-commits. gcc-4.8.1 fails to build clang because of a regression in that version of gcc (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58022). See details about the generated error in https://llvm.org/bugs/show_bug.cgi?id=26362. To work around the build error, this diff moves definitions `cast(clang::CodeGen::Address)` and `isa(clang::CodeGen::Address)` from llvm to clang namespace. No build errors are introduced with this change. I've tested this with gcc-4.8.1 and gcc-4.9.0 both on master and release_38. http://reviews.llvm.org/D16819 Files: lib/CodeGen/Address.h Index: lib/CodeGen/Address.h === --- lib/CodeGen/Address.h +++ lib/CodeGen/Address.h @@ -104,23 +104,15 @@ }; } -} -namespace llvm { - // Present a minimal LLVM-like casting interface. - template inline U cast(clang::CodeGen::Address addr) { -return U::castImpl(addr); - } - template inline bool isa(clang::CodeGen::Address addr) { -return U::isaImpl(addr); - } +// Present a minimal LLVM-like casting interface. +template inline U cast(CodeGen::Address addr) { + return U::castImpl(addr); +} +template inline bool isa(CodeGen::Address addr) { + return U::isaImpl(addr); } -namespace clang { - // Make our custom isa and cast available in namespace clang, to mirror - // what we do for LLVM's versions in Basic/LLVM.h. - using llvm::isa; - using llvm::cast; } #endif Index: lib/CodeGen/Address.h === --- lib/CodeGen/Address.h +++ lib/CodeGen/Address.h @@ -104,23 +104,15 @@ }; } -} -namespace llvm { - // Present a minimal LLVM-like casting interface. - template inline U cast(clang::CodeGen::Address addr) { -return U::castImpl(addr); - } - template inline bool isa(clang::CodeGen::Address addr) { -return U::isaImpl(addr); - } +// Present a minimal LLVM-like casting interface. +template inline U cast(CodeGen::Address addr) { + return U::castImpl(addr); +} +template inline bool isa(CodeGen::Address addr) { + return U::isaImpl(addr); } -namespace clang { - // Make our custom isa and cast available in namespace clang, to mirror - // what we do for LLVM's versions in Basic/LLVM.h. - using llvm::isa; - using llvm::cast; } #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16503: [MSVC Compat] Warn when suppressing a trailing comma in macro args
thakis added a comment. Sorry for the slow response. I was reading http://reviews.llvm.org/D15670 to understand this patch, and I couldn't find anything in that patch that enables this extension only in Microsoft mode. Trying suppressed-comma-msextension.cpp locally, it seems to pass without -fms-compatibility too. Am I missing something, or does http://reviews.llvm.org/D15670 lack a check for MicrosoftExt? http://reviews.llvm.org/D16503 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r259564 - Creating release candidate rc2 from release_380 branch
Author: hans Date: Tue Feb 2 15:10:52 2016 New Revision: 259564 URL: http://llvm.org/viewvc/llvm-project?rev=259564&view=rev Log: Creating release candidate rc2 from release_380 branch Added: libcxx/tags/RELEASE_380/rc2/ (props changed) - copied from r259563, libcxx/branches/release_38/ Propchange: libcxx/tags/RELEASE_380/rc2/ -- --- svn:mergeinfo (added) +++ svn:mergeinfo Tue Feb 2 15:10:52 2016 @@ -0,0 +1,2 @@ +/libcxx/branches/apple:136569-137939 +/libcxx/trunk:257682,257696,257702,258403 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] r259571 - Creating release candidate rc2 from release_380 branch
Author: hans Date: Tue Feb 2 15:11:13 2016 New Revision: 259571 URL: http://llvm.org/viewvc/llvm-project?rev=259571&view=rev Log: Creating release candidate rc2 from release_380 branch Added: libunwind/tags/RELEASE_380/rc2/ - copied from r259570, libunwind/branches/release_38/ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxxabi] r259565 - Creating release candidate rc2 from release_380 branch
Author: hans Date: Tue Feb 2 15:10:55 2016 New Revision: 259565 URL: http://llvm.org/viewvc/llvm-project?rev=259565&view=rev Log: Creating release candidate rc2 from release_380 branch Added: libcxxabi/tags/RELEASE_380/rc2/ (props changed) - copied from r259564, libcxxabi/branches/release_38/ Propchange: libcxxabi/tags/RELEASE_380/rc2/ -- svn:mergeinfo = /libcxxabi/trunk:257896 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14274: Add alloc_size attribute to clang
george.burgess.iv added inline comments. Comment at: lib/Sema/SemaDeclAttr.cpp:737 @@ +736,3 @@ +unsigned FuncParamNo, unsigned AttrArgNo) { + assert(Attr.getArg(AttrArgNo).is()); + // FuncParamNo is base-1 aaron.ballman wrote: > Can be replaced with assert(Attr.isArgExpr(AttrArgNo) && "expected expression > argument"); Neat! Thanks. http://reviews.llvm.org/D14274 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14274: Add alloc_size attribute to clang
george.burgess.iv updated this revision to Diff 46693. george.burgess.iv marked 2 inline comments as done. george.burgess.iv added a comment. Addressed all feedback. http://reviews.llvm.org/D14274 Files: include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td include/clang/Basic/DiagnosticSemaKinds.td lib/AST/ExprConstant.cpp lib/CodeGen/CGCall.cpp lib/Sema/SemaDeclAttr.cpp test/CodeGen/alloc-size.c test/CodeGenCXX/global-init.cpp test/Sema/alloc-size.c test/SemaCXX/constant-expression-cxx11.cpp Index: test/SemaCXX/constant-expression-cxx11.cpp === --- test/SemaCXX/constant-expression-cxx11.cpp +++ test/SemaCXX/constant-expression-cxx11.cpp @@ -1156,7 +1156,7 @@ constexpr int m2b = const_cast(n2); // expected-error {{constant expression}} expected-note {{read of volatile object 'n2'}} struct T { int n; }; -const T t = { 42 }; // expected-note {{declared here}} +const T t = { 42 }; constexpr int f(volatile int &&r) { return r; // expected-note {{read of volatile-qualified type 'volatile int'}} @@ -1168,7 +1168,7 @@ int j : f(0); // expected-error {{constant expression}} expected-note {{in call to 'f(0)'}} int k : g(0); // expected-error {{constant expression}} expected-note {{temporary created here}} expected-note {{in call to 'g(0)'}} int l : n3; // expected-error {{constant expression}} expected-note {{read of non-const variable}} - int m : t.n; // expected-error {{constant expression}} expected-note {{read of non-constexpr variable}} + int m : t.n; // expected-warning{{width of bit-field 'm' (42 bits)}} }; } Index: test/Sema/alloc-size.c === --- /dev/null +++ test/Sema/alloc-size.c @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 %s -verify + +void *fail1(int a) __attribute__((alloc_size)); //expected-error{{'alloc_size' attribute takes at least 1 argument}} +void *fail2(int a) __attribute__((alloc_size())); //expected-error{{'alloc_size' attribute takes at least 1 argument}} + +void *fail3(int a) __attribute__((alloc_size(0))); //expected-error{{'alloc_size' attribute parameter 0 is out of bounds}} +void *fail4(int a) __attribute__((alloc_size(2))); //expected-error{{'alloc_size' attribute parameter 2 is out of bounds}} + +void *fail5(int a, int b) __attribute__((alloc_size(0, 1))); //expected-error{{'alloc_size' attribute parameter 0 is out of bounds}} +void *fail6(int a, int b) __attribute__((alloc_size(3, 1))); //expected-error{{'alloc_size' attribute parameter 3 is out of bounds}} + +void *fail7(int a, int b) __attribute__((alloc_size(1, 0))); //expected-error{{'alloc_size' attribute parameter 0 is out of bounds}} +void *fail8(int a, int b) __attribute__((alloc_size(1, 3))); //expected-error{{'alloc_size' attribute parameter 3 is out of bounds}} + +int fail9(int a) __attribute__((alloc_size(1))); //expected-warning{{'alloc_size' attribute only applies to return values that are pointers}} + +int fail10 __attribute__((alloc_size(1))); //expected-warning{{'alloc_size' attribute only applies to non-K&R-style functions}} + +void *fail11(void *a) __attribute__((alloc_size(1))); //expected-error{{'alloc_size' attribute argument may only refer to a function parameter of integer type}} + +void *fail12(int a) __attribute__((alloc_size("abc"))); //expected-error{{'alloc_size' attribute requires parameter 1 to be an integer constant}} +void *fail12(int a) __attribute__((alloc_size(1, "abc"))); //expected-error{{'alloc_size' attribute requires parameter 2 to be an integer constant}} +void *fail13(int a) __attribute__((alloc_size(1U<<31))); //expected-error{{integer constant expression evaluates to value 2147483648 that cannot be represented in a 32-bit signed integer type}} Index: test/CodeGenCXX/global-init.cpp === --- test/CodeGenCXX/global-init.cpp +++ test/CodeGenCXX/global-init.cpp @@ -18,9 +18,6 @@ // CHECK: @__dso_handle = external global i8 // CHECK: @c = global %struct.C zeroinitializer, align 8 -// It's okay if we ever implement the IR-generation optimization to remove this. -// CHECK: @_ZN5test3L3varE = internal constant i8* getelementptr inbounds ([7 x i8], [7 x i8]* - // PR6205: The casts should not require global initializers // CHECK: @_ZN6PR59741cE = external global %"struct.PR5974::C" // CHECK: @_ZN6PR59741aE = global %"struct.PR5974::A"* getelementptr inbounds (%"struct.PR5974::C", %"struct.PR5974::C"* @_ZN6PR59741cE, i32 0, i32 0) Index: test/CodeGen/alloc-size.c === --- /dev/null +++ test/CodeGen/alloc-size.c @@ -0,0 +1,347 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - 2>&1 | FileCheck %s + +#define NULL ((void *)0) + +int gi; + +typedef unsigned long size_t; + +// CHECK-DAG-RE: define void @my_malloc({{.*}}) #[[MALLOC_ATTR_NUMBER:[0-9]+]] +// N.B. LLVM's allocsize arg
Re: [PATCH] D16819: Remove llvm::(cast|isa) from lib/CodeGen/Address.h to fix build with gcc-4.8.1
rsmith accepted this revision. rsmith added a comment. This revision is now accepted and ready to land. Yuck. Yeah, LGTM. Do you need someone to commit this for you? Hans, this should go into 3.8 as well. http://reviews.llvm.org/D16819 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation
> On Jan 22, 2016, at 1:43 PM, Sean Silva via cfe-commits > wrote: > > silvas added a comment. > > In http://reviews.llvm.org/D15829#333902, @davidxl wrote: > >> For the longer term, one possible solution is to make FE based >> instrumentation only used for coverage testing which can be turned on >> with -fcoverage-mapping option (currently, -fcoverage-mapping can not >> be used alone and must be used together with >> -fprofile-instr-generate). To summarize: >> >> A. Current behavior: >> >> --- >> >> 1. -fprofile-instr-generate turns on FE based instrumentation >> 2. -fprofile-instr-generate -fcoverage-mapping turns on FE based >> instrumentation and coverage mapping data generation. >> 3. -fprofile-instr-use=<..> assumes profile data from FE instrumentation. >> >> B. Proposed new behavior: >> >> >> >> 1. -fprofile-instr-generate turns on IR late instrumentation >> 2. -fcoverage-mapping turns on FE instrumentation and coverage-mapping >> 3. -fprofile-instr-generate -fcoverage-mapping result in compiler warning >> 4. -fprofile-instr-use=<> will automatically determine how to use the >> profile data. > > > Very good observation that we can determine FE or IR automatically based on > the input profdata. That simplifies things. > >> B.2) above can be done today for improved usability. > > > I don't see how this improves usability. In fact, it is confusing because it > hijacks an existing option. Hijacking an existing option to do something different would definitely be a problem. Please find a way to specify IR-level instrumentation without breaking compatibility. If you want to replace the existing options with something different, we’ll need a transition period of at least 1-2 LLVM releases to migrate. > > Also B.3 causes existing user builds to emit a warning, which is annoying. > > I would propose the following modification of B: > > C.: > > 1. -fprofile-instr-generate defaults to IR instrumentation (i.e. behaves > exactly as before, except that it uses IR instrumentation) > 2. -fprofile-instr-generate -fcoverage-mapping turns on frontend > instrumentation and coverage. (i.e. behaves exactly as before) > 3. -fprofile-instr-use=<> automatically determines which method to use > > All existing user workflows continue to work, except for workflows that > attempt to `llvm-profdata merge` some old frontend profile data (e.g. they > have checked-in to version control and represents some special workload) with > the profile data from new binaries. The coverage mapping adds considerable cost. IR-level instrumentation has some problems that make it undesirable for our workflow, so we need a way to select front-end instrumentation without adding a bunch of unnecessary overhead (generating the coverage mapping when you’re not actually doing coverage testing). I disagree with your assessment that existing workflows would continue to “work” because ours would not. > > Concretely, imagine the following workflow: > > clang -fprofile-instr-generate foo.c -o foo > ./foo > llvm-profdata merge default.profraw -o new.profdata > llvm-profdata merge new.profdata > /versioncontrol/some-important-but-expensive-to-reproduce-workload.profdata > -o foo.profdata > clang -fprofile-instr-use=foo.profdata foo.c -o foo_pgo > > I think this is a reasonable breakage. We would need to add a note in the > release notes. Unfortunately this is not expected breakage if we claim to > have forward compatibility for profdata (which IIRC Apple requires; @bogner?). Yes, that is a requirement for us. We need existing profdata to work with newer versions of clang (which is why IR-level instrumentation doesn’t work for us). > But I think this case will be rare and exceptional enough that we can > tolerate it: > > - a simple immediate workaround is to specify `-fcoverage-mapping` (which > also adds some extra stuff, but works around the issue) > - Presumably > /versioncontrol/some-important-but-expensive-to-reproduce-workload.profdata > is regenerated with some frequency which is more frequent than upgrading the > compiler, and so it is likely reasonable to regenerate it alongside a > compiler upgrade, using the workaround until then. No, that assumption is not necessarily true for us. We need to be able to upgrade the compiler without breaking projects that we don’t control, and that includes regressing their performance because of an outdated profile. > > > >> B.1) needs a > >> transition period before the IR based instrumentation becomes > >> stablized (and can be flipped to the default). During the transition > >> period, the behavior of 1) does not change, but a cc1 option can be > >> used to turn on IR instrumentation (as proposed by Sean). > > > Just to clarify, users are not allowed to use cc1 options. The cc1 option is > purely for us as compiler developers to do integration and testing, put off > some discussio
Re: [PATCH] D16819: Remove llvm::(cast|isa) from lib/CodeGen/Address.h to fix build with gcc-4.8.1
rjmccall added a comment. LGTM, too. http://reviews.llvm.org/D16819 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15305: [CUDA] Do not allow dynamic initialization of global device side variables.
tra updated this revision to Diff 46696. tra marked 8 inline comments as done. tra added a comment. Addressed Richard's comments. Relaxed restrictions a bit to allow constant initializers even those CUDA would not considered to be empty. Updated test case accordingly. http://reviews.llvm.org/D15305 Files: include/clang/Basic/DiagnosticSemaKinds.td include/clang/Sema/Sema.h lib/CodeGen/CGDeclCXX.cpp lib/CodeGen/CodeGenModule.cpp lib/Sema/SemaCUDA.cpp lib/Sema/SemaDecl.cpp test/CodeGenCUDA/device-var-init.cu Index: test/CodeGenCUDA/device-var-init.cu === --- /dev/null +++ test/CodeGenCUDA/device-var-init.cu @@ -0,0 +1,393 @@ +// REQUIRES: nvptx-registered-target + +// Make sure we don't allow dynamic initialization for device +// variables, but accept empty constructors allowed by CUDA. + +// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -std=c++11 \ +// RUN: -fno-threadsafe-statics -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -std=c++11 \ +// RUN: -emit-llvm -DERROR_CASE -verify -o /dev/null %s + +#ifdef __clang__ +#include "Inputs/cuda.h" +#endif + +// Base classes with different initializer variants. + +// trivial constructor -- allowed +struct T { + int t; +}; + +// empty constructor +struct EC { + int ec; + __device__ EC() {} // -- allowed + __device__ EC(int) {} // -- not allowed +}; + +// empty templated constructor -- allowed with no arguments +struct ETC { + template __device__ ETC(T...) {} +}; + +// undefined constructor -- not allowed +struct UC { + int uc; + __device__ UC(); +}; + +// empty constructor w/ initializer list -- not allowed +struct ECI { + int eci; + __device__ ECI() : eci(1) {} +}; + +// non-empty constructor -- not allowed +struct NEC { + int nec; + __device__ NEC() { nec = 1; } +}; + +// no-constructor, virtual method -- not allowed +struct NCV { + int ncv; + __device__ virtual void vm() {} +}; + +// dynamic in-class field initializer -- not allowed +__device__ int f(); +struct NCF { + int ncf = f(); +}; + +// static in-class field initializer. NVCC does not allow it, but +// clang generates static initializer for this, so we'll accept it. +struct NCFS { + int ncfs = 3; +}; + +// undefined templated constructor -- not allowed +struct UTC { + template __device__ UTC(T...); +}; + +// non-empty templated constructor -- not allowed +struct NETC { + int netc; + template __device__ NETC(T...) { netc = 1; } +}; + +__device__ int d_v; +// CHECK: @d_v = addrspace(1) externally_initialized global i32 0, +__shared__ int s_v; +// CHECK: @s_v = addrspace(3) global i32 undef, +__constant__ int c_v; +// CHECK: addrspace(4) externally_initialized global i32 0, + +__device__ int d_v_i = 1; +// CHECK: @d_v_i = addrspace(1) externally_initialized global i32 1, +#ifdef ERROR_CASE +__shared__ int s_v_i = 1; +// expected-error@-1 {{initialization is not supported for __shared__ variables.}} +#endif +__constant__ int c_v_i = 1; +// CHECK: @c_v_i = addrspace(4) externally_initialized global i32 1, + +#ifdef ERROR_CASE +__device__ int d_v_f = f(); +// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}} +__shared__ int s_v_f = f(); +// expected-error@-1 {{initialization is not supported for __shared__ variables.}} +__constant__ int c_v_f = f(); +// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}} +#endif + +__device__ T d_t; +// CHECK: @d_t = addrspace(1) externally_initialized global %struct.T zeroinitializer +__shared__ T s_t; +// CHECK: @s_t = addrspace(3) global %struct.T undef, +__constant__ T c_t; +// CHECK: @c_t = addrspace(4) externally_initialized global %struct.T zeroinitializer, + +__device__ T d_t_i = {2}; +// CHECKL @d_t_i = addrspace(1) externally_initialized global %struct.T { i32 2 }, +#ifdef ERROR_CASE +__shared__ T s_t_i = {2}; +// expected-error@-1 {{initialization is not supported for __shared__ variables.}} +#endif +__constant__ T c_t_i = {2}; +// CHECK: @c_t_i = addrspace(4) externally_initialized global %struct.T { i32 2 }, + +__device__ EC d_ec; +// CHECK: @d_ec = addrspace(1) externally_initialized global %struct.EC zeroinitializer, +__shared__ EC s_ec; +// CHECK: @s_ec = addrspace(3) global %struct.EC undef, +__constant__ EC c_ec; +// CHECK: @c_ec = addrspace(4) externally_initialized global %struct.EC zeroinitializer, + +#if ERROR_CASE +__device__ EC d_ec_i(3); +// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}} +__shared__ EC s_ec_i(3); +// expected-error@-1 {{initialization is not supported for __shared__ variables.}} +__constant__ EC c_ec_i(3); +// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}} + +__device__ EC d_ec_i2 =
[PATCH] D16821: Add whole-program vtable optimization feature to Clang.
pcc created this revision. pcc added reviewers: joker.eph, pete, chandlerc. pcc added subscribers: hans, kcc, cfe-commits. This patch introduces the -fwhole-program-vtables flag, which enables the whole-program vtable optimization feature (D16795) in Clang. http://reviews.llvm.org/D16821 Files: docs/UsersManual.rst include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.def include/clang/Frontend/CodeGenOptions.h lib/CodeGen/CGClass.cpp lib/CodeGen/CGExprCXX.cpp lib/CodeGen/CGVTables.cpp lib/CodeGen/CodeGenFunction.h lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h lib/CodeGen/ItaniumCXXABI.cpp lib/CodeGen/MicrosoftCXXABI.cpp lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp runtime/CMakeLists.txt runtime/vtables_blacklist.txt test/CodeGenCXX/bitset-blacklist.cpp test/CodeGenCXX/bitsets.cpp test/CodeGenCXX/cfi-blacklist.cpp test/CodeGenCXX/cfi-vcall.cpp test/Driver/Inputs/resource_dir/vtables_blacklist.txt test/Driver/whole-program-vtables.c Index: test/Driver/whole-program-vtables.c === --- /dev/null +++ test/Driver/whole-program-vtables.c @@ -0,0 +1,11 @@ +// RUN: %clang -target x86_64-unknown-linux -fwhole-program-vtables -### %s 2>&1 | FileCheck --check-prefix=NO-LTO %s +// NO-LTO: invalid argument '-fwhole-program-vtables' only allowed with '-flto' + +// RUN: %clang -target x86_64-unknown-linux -resource-dir=%S/Inputs/resource_dir -flto -fwhole-program-vtables -### -c %s 2>&1 | FileCheck --check-prefix=BLACKLIST %s +// BLACKLIST: "-fwhole-program-vtables-blacklist={{.*}}vtables_blacklist.txt" + +// RUN: %clang -target x86_64-unknown-linux -fwhole-program-vtables-blacklist=nonexistent.txt -flto -fwhole-program-vtables -### -c %s 2>&1 | FileCheck --check-prefix=NON-EXISTENT-BLACKLIST %s +// NON-EXISTENT-BLACKLIST: no such file or directory: 'nonexistent.txt' + +// RUN: %clang -target x86_64-unknown-linux -fwhole-program-vtables-blacklist=%S/Inputs/resource_dir/vtables_blacklist.txt -flto -fwhole-program-vtables -### -c %s 2>&1 | FileCheck --check-prefix=CUSTOM-BLACKLIST %s +// CUSTOM-BLACKLIST: "-fwhole-program-vtables-blacklist={{.*}}Inputs/resource_dir/vtables_blacklist.txt" Index: test/CodeGenCXX/bitsets.cpp === --- test/CodeGenCXX/bitsets.cpp +++ test/CodeGenCXX/bitsets.cpp @@ -1,7 +1,12 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-vcall -fsanitize-trap=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=ITANIUM --check-prefix=NDIAG %s -// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=ITANIUM --check-prefix=DIAG --check-prefix=DIAG-ABORT %s -// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-vcall -fsanitize-recover=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=ITANIUM --check-prefix=DIAG --check-prefix=DIAG-RECOVER %s -// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fsanitize=cfi-vcall -fsanitize-trap=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=MS --check-prefix=NDIAG %s +// Tests for the cfi-vcall feature: +// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-vcall -fsanitize-trap=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CFI --check-prefix=ITANIUM --check-prefix=NDIAG %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CFI --check-prefix=ITANIUM --check-prefix=DIAG --check-prefix=DIAG-ABORT %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-vcall -fsanitize-recover=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CFI --check-prefix=ITANIUM --check-prefix=DIAG --check-prefix=DIAG-RECOVER %s +// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fsanitize=cfi-vcall -fsanitize-trap=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CFI --check-prefix=MS --check-prefix=NDIAG %s + +// Tests for the whole-program-vtables feature: +// RUN: %clang_cc1 -triple x86_64-unknown-linux -fwhole-program-vtables -emit-llvm -o - %s | FileCheck --check-prefix=VTABLE-OPT --check-prefix=ITANIUM %s +// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fwhole-program-vtables -emit-llvm -o - %s | FileCheck --check-prefix=VTABLE-OPT --check-prefix=MS %s // MS: @[[VTA:[0-9]*]] {{.*}} comdat($"\01??_7A@@6B@") // MS: @[[VTB:[0-9]*]] {{.*}} comdat($"\01??_7B@@6B0@@") @@ -53,29 +58,30 @@ void D::h() { } -// DIAG: @[[SRC:.*]] = private unnamed_addr constant [{{.*}} x i8] c"{{.*}}cfi-vcall.cpp\00", align 1 +// DIAG: @[[SRC:.*]] = private unnamed_addr constant [{{.*}} x i8] c"{{.*}}bitsets.cpp\00", align 1 // DIAG: @[[TYPE:.*]] = private unnamed_addr constant { i16, i16, [4 x i8] } { i16 -1, i16 0, [4 x i8] c"'A'\00" } -// DIAG: @[[BADTYPESTATIC:.*]] = private unnamed_addr global { i8, { [{{.*}} x
[PATCH] D16823: [cfi] Safe handling of unaddressable vtable pointers (clang).
eugenis created this revision. eugenis added reviewers: pcc, kcc. eugenis added a subscriber: cfe-commits. eugenis set the repository for this revision to rL LLVM. Avoid crashing when printing diagnostics for vtable-related CFI errors. In diagnostic mode, the frontend does an additional check of the vtable pointer against the set of all known vtable addresses and lets the runtime handler know if it is safe to inspect the vtable. Repository: rL LLVM http://reviews.llvm.org/D16823 Files: lib/CodeGen/CGClass.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CodeGenFunction.h lib/CodeGen/CodeGenModule.cpp test/CodeGen/cfi-check-fail.c test/CodeGenCXX/cfi-cast.cpp test/CodeGenCXX/cfi-vcall.cpp Index: test/CodeGenCXX/cfi-vcall.cpp === --- test/CodeGenCXX/cfi-vcall.cpp +++ test/CodeGenCXX/cfi-vcall.cpp @@ -55,7 +55,7 @@ // DIAG: @[[SRC:.*]] = private unnamed_addr constant [{{.*}} x i8] c"{{.*}}cfi-vcall.cpp\00", align 1 // DIAG: @[[TYPE:.*]] = private unnamed_addr constant { i16, i16, [4 x i8] } { i16 -1, i16 0, [4 x i8] c"'A'\00" } -// DIAG: @[[BADTYPESTATIC:.*]] = private unnamed_addr global { i8, { [{{.*}} x i8]*, i32, i32 }, { i16, i16, [4 x i8] }* } { i8 0, { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+21]], i32 3 }, { i16, i16, [4 x i8] }* @[[TYPE]] } +// DIAG: @[[BADTYPESTATIC:.*]] = private unnamed_addr global { i8, { [{{.*}} x i8]*, i32, i32 }, { i16, i16, [4 x i8] }* } { i8 0, { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+23]], i32 3 }, { i16, i16, [4 x i8] }* @[[TYPE]] } // ITANIUM: define void @_Z2afP1A // MS: define void @"\01?af@@YAXPEAUA@@@Z" @@ -68,10 +68,12 @@ // CHECK: [[TRAPBB]] // NDIAG-NEXT: call void @llvm.trap() // NDIAG-NEXT: unreachable + // DIAG-NEXT: [[VTVALID0:%[^ ]*]] = call i1 @llvm.bitset.test(i8* [[VT]], metadata !"all-vtables") // DIAG-NEXT: [[VTINT:%[^ ]*]] = ptrtoint i8* [[VT]] to i64 - // DIAG-ABORT-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(i8* getelementptr inbounds ({{.*}} @[[BADTYPESTATIC]], i32 0, i32 0), i64 [[VTINT]]) + // DIAG-NEXT: [[VTVALID:%[^ ]*]] = zext i1 [[VTVALID0]] to i64 + // DIAG-ABORT-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(i8* getelementptr inbounds ({{.*}} @[[BADTYPESTATIC]], i32 0, i32 0), i64 [[VTINT]], i64 [[VTVALID]]) // DIAG-ABORT-NEXT: unreachable - // DIAG-RECOVER-NEXT: call void @__ubsan_handle_cfi_check_fail(i8* getelementptr inbounds ({{.*}} @[[BADTYPESTATIC]], i32 0, i32 0), i64 [[VTINT]]) + // DIAG-RECOVER-NEXT: call void @__ubsan_handle_cfi_check_fail(i8* getelementptr inbounds ({{.*}} @[[BADTYPESTATIC]], i32 0, i32 0), i64 [[VTINT]], i64 [[VTVALID]]) // DIAG-RECOVER-NEXT: br label %[[CONTBB]] // CHECK: [[CONTBB]] @@ -157,32 +159,45 @@ } -// Check for the expected number of elements (9 or 15 respectively). -// MS: !llvm.bitsets = !{[[X:[^,]*(,[^,]*){8}]]} -// ITANIUM: !llvm.bitsets = !{[[X:[^,]*(,[^,]*){14}]]} +// Check for the expected number of elements (15 or 23 respectively). +// MS: !llvm.bitsets = !{[[X:[^,]*(,[^,]*){15}]]} +// ITANIUM: !llvm.bitsets = !{[[X:[^,]*(,[^,]*){23}]]} // ITANIUM-DAG: !{!"_ZTS1A", [3 x i8*]* @_ZTV1A, i64 16} +// ITANIUM-DAG: !{!"all-vtables", [3 x i8*]* @_ZTV1A, i64 16} // ITANIUM-DAG: !{!"_ZTS1A", [7 x i8*]* @_ZTCN12_GLOBAL__N_11DE0_1B, i64 32} +// ITANIUM-DAG: !{!"all-vtables", [7 x i8*]* @_ZTCN12_GLOBAL__N_11DE0_1B, i64 32} // ITANIUM-DAG: !{!"_ZTS1B", [7 x i8*]* @_ZTCN12_GLOBAL__N_11DE0_1B, i64 32} // ITANIUM-DAG: !{!"_ZTS1A", [9 x i8*]* @_ZTCN12_GLOBAL__N_11DE8_1C, i64 64} +// ITANIUM-DAG: !{!"all-vtables", [9 x i8*]* @_ZTCN12_GLOBAL__N_11DE8_1C, i64 64} // ITANIUM-DAG: !{!"_ZTS1C", [9 x i8*]* @_ZTCN12_GLOBAL__N_11DE8_1C, i64 32} // ITANIUM-DAG: !{!"_ZTS1A", [12 x i8*]* @_ZTVN12_GLOBAL__N_11DE, i64 32} +// ITANIUM-DAG: !{!"all-vtables", [12 x i8*]* @_ZTVN12_GLOBAL__N_11DE, i64 32} // ITANIUM-DAG: !{!"_ZTS1B", [12 x i8*]* @_ZTVN12_GLOBAL__N_11DE, i64 32} // ITANIUM-DAG: !{!"_ZTS1C", [12 x i8*]* @_ZTVN12_GLOBAL__N_11DE, i64 88} +// ITANIUM-DAG: !{!"all-vtables", [12 x i8*]* @_ZTVN12_GLOBAL__N_11DE, i64 88} // ITANIUM-DAG: !{![[DTYPE]], [12 x i8*]* @_ZTVN12_GLOBAL__N_11DE, i64 32} // ITANIUM-DAG: !{!"_ZTS1A", [7 x i8*]* @_ZTV1B, i64 32} +// ITANIUM-DAG: !{!"all-vtables", [7 x i8*]* @_ZTV1B, i64 32} // ITANIUM-DAG: !{!"_ZTS1B", [7 x i8*]* @_ZTV1B, i64 32} // ITANIUM-DAG: !{!"_ZTS1A", [5 x i8*]* @_ZTV1C, i64 32} // ITANIUM-DAG: !{!"_ZTS1C", [5 x i8*]* @_ZTV1C, i64 32} // ITANIUM-DAG: !{!"_ZTS1A", [3 x i8*]* @_ZTVZ3foovE2FA, i64 16} // ITANIUM-DAG: !{!{{[0-9]+}}, [3 x i8*]* @_ZTVZ3foovE2FA, i64 16} // MS-DAG: !{!"?AUA@@", [2 x i8*]* @[[VTA]], i64 8} +// MS-DAG: !{!"all-vtables", [2 x i8*]* @[[VTA]], i64 8} // MS-DAG: !{!"?AUB@@", [3 x i8*]* @[[VTB]], i64 8} +// MS-DAG: !{!"all-vtables", [3 x i8*]* @[[VTB]], i64 8} // MS-DAG: !{!"?AUA@@", [2 x i8*]* @[[VTAinB]], i64 8} +// MS-DAG: !{!"all-vtables", [2 x i8*]* @[
r259591 - ObjCXX: fix a crash during typo correction.
Author: mren Date: Tue Feb 2 16:23:03 2016 New Revision: 259591 URL: http://llvm.org/viewvc/llvm-project?rev=259591&view=rev Log: ObjCXX: fix a crash during typo correction. For ObjCXX, we can create a CastExpr with Kind being CK_UserDefinedConversion and SubExpr being BlockExpr. Specifically one can return BlockExpr from BuildCXXMemberCallExpr and the result can be used to build a CastExpr. Fix the assumption in CastExpr::getSubExprAsWritten that SubExpr can only be CXXMemberCallExpr. rdar://problem/24364077 Added: cfe/trunk/test/SemaObjCXX/block-for-lambda-conversion.mm Modified: cfe/trunk/lib/AST/Expr.cpp Modified: cfe/trunk/lib/AST/Expr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=259591&r1=259590&r2=259591&view=diff == --- cfe/trunk/lib/AST/Expr.cpp (original) +++ cfe/trunk/lib/AST/Expr.cpp Tue Feb 2 16:23:03 2016 @@ -1744,8 +1744,13 @@ Expr *CastExpr::getSubExprAsWritten() { // subexpression describing the call; strip it off. if (E->getCastKind() == CK_ConstructorConversion) SubExpr = cast(SubExpr)->getArg(0); -else if (E->getCastKind() == CK_UserDefinedConversion) - SubExpr = cast(SubExpr)->getImplicitObjectArgument(); +else if (E->getCastKind() == CK_UserDefinedConversion) { + assert((isa(SubExpr) || + isa(SubExpr)) && + "Unexpected SubExpr for CK_UserDefinedConversion."); + if (isa(SubExpr)) +SubExpr = cast(SubExpr)->getImplicitObjectArgument(); +} // If the subexpression we're left with is an implicit cast, look // through that, too. Added: cfe/trunk/test/SemaObjCXX/block-for-lambda-conversion.mm URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/block-for-lambda-conversion.mm?rev=259591&view=auto == --- cfe/trunk/test/SemaObjCXX/block-for-lambda-conversion.mm (added) +++ cfe/trunk/test/SemaObjCXX/block-for-lambda-conversion.mm Tue Feb 2 16:23:03 2016 @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -std=c++11 %s + +enum NSEventType { + NSEventTypeFlagsChanged = 12 +}; + +enum NSEventMask { + NSEventMaskLeftMouseDown = 1 +}; + +static const NSEventType NSFlagsChanged = NSEventTypeFlagsChanged; + +@interface NSObject +@end +@interface NSEvent : NSObject { +} ++ (nullable id) +addMonitor:(NSEventMask)mask handler:(NSEvent *_Nullable (^)(NSEvent *))block; +@end + +void test(id weakThis) { + id m_flagsChangedEventMonitor = [NSEvent + addMonitor:NSFlagsChangedMask //expected-error {{use of undeclared identifier 'NSFlagsChangedMask'}} + handler:[weakThis](NSEvent *flagsChangedEvent) { + return flagsChangedEvent; + }]; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r259592 - [CUDA] Do not allow dynamic initialization of global device side variables.
Author: tra Date: Tue Feb 2 16:29:48 2016 New Revision: 259592 URL: http://llvm.org/viewvc/llvm-project?rev=259592&view=rev Log: [CUDA] Do not allow dynamic initialization of global device side variables. In general CUDA does not allow dynamic initialization of global device-side variables. One exception is that CUDA allows records with empty constructors as described in section E2.2.1 of CUDA 7.5 Programming guide. This patch applies initializer checks for all device-side variables. Empty constructors are accepted, but no code is generated for them. Differential Revision: http://reviews.llvm.org/D15305 Added: cfe/trunk/test/CodeGenCUDA/device-var-init.cu Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/CodeGen/CGDeclCXX.cpp cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/Sema/SemaCUDA.cpp cfe/trunk/lib/Sema/SemaDecl.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=259592&r1=259591&r2=259592&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Feb 2 16:29:48 2016 @@ -6436,6 +6436,11 @@ def err_variadic_device_fn : Error< def err_va_arg_in_device : Error< "CUDA device code does not support va_arg">; def err_alias_not_supported_on_nvptx : Error<"CUDA does not support aliases">; +def err_dynamic_var_init : Error< +"dynamic initialization is not supported for " +"__device__, __constant__, and __shared__ variables.">; +def err_shared_var_init : Error< +"initialization is not supported for __shared__ variables.">; def warn_non_pod_vararg_with_format_string : Warning< "cannot pass %select{non-POD|non-trivial}0 object of type %1 to variadic " Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=259592&r1=259591&r2=259592&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Tue Feb 2 16:29:48 2016 @@ -8834,6 +8834,10 @@ public: bool ConstRHS, bool Diagnose); + /// \return true if \p CD can be considered empty according to CUDA + /// (E.2.3.1 in CUDA 7.5 Programming guide). + bool isEmptyCudaConstructor(SourceLocation Loc, CXXConstructorDecl *CD); + /// \name Code completion //@{ /// \brief Describes the context in which code completion occurs. Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=259592&r1=259591&r2=259592&view=diff == --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Tue Feb 2 16:29:48 2016 @@ -304,6 +304,17 @@ void CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, llvm::GlobalVariable *Addr, bool PerformInit) { + + // According to E.2.3.1 in CUDA-7.5 Programming guide: __device__, + // __constant__ and __shared__ variables defined in namespace scope, + // that are of class type, cannot have a non-empty constructor. All + // the checks have been done in Sema by now. Whatever initializers + // are allowed are empty and we just need to ignore them here. + if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice && + (D->hasAttr() || D->hasAttr() || + D->hasAttr())) +return; + // Check if we've already initialized this decl. auto I = DelayedCXXInitPosition.find(D); if (I != DelayedCXXInitPosition.end() && I->second == ~0U) Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=259592&r1=259591&r2=259592&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Feb 2 16:29:48 2016 @@ -2334,18 +2334,13 @@ void CodeGenModule::EmitGlobalVarDefinit const VarDecl *InitDecl; const Expr *InitExpr = D->getAnyInitializer(InitDecl); - // CUDA E.2.4.1 "__shared__ variables cannot have an initialization as part - // of their declaration." - if (getLangOpts().CPlusPlus && getLangOpts().CUDAIsDevice - && D->hasAttr()) { -if (InitExpr) { - const auto *C = dyn_cast(InitExpr); - if (C == nullptr || !C->getConstructor()->hasTrivialBody()) -Error(D->getLocation(), - "__shared__ variable cannot have an initialization."); -} +
Re: [PATCH] D16823: [cfi] Safe handling of unaddressable vtable pointers (clang).
samsonov added a subscriber: samsonov. Comment at: lib/CodeGen/CGExpr.cpp:2494 @@ +2493,3 @@ + llvm::Value *ValidVtable = nullptr; + if (CheckAndAppendValidVtable) { +llvm::Value *AllVtables = llvm::MetadataAsValue::get( This is really ugly. Why are you not passing it down in DynamicArgs? Is it performance penalty you don't want to pay if the check will not succeed? How large will it be? Repository: rL LLVM http://reviews.llvm.org/D16823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15305: [CUDA] Do not allow dynamic initialization of global device side variables.
This revision was automatically updated to reflect the committed changes. Closed by commit rL259592: [CUDA] Do not allow dynamic initialization of global device side variables. (authored by tra). Changed prior to commit: http://reviews.llvm.org/D15305?vs=46696&id=46707#toc Repository: rL LLVM http://reviews.llvm.org/D15305 Files: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/CodeGen/CGDeclCXX.cpp cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/Sema/SemaCUDA.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/test/CodeGenCUDA/device-var-init.cu Index: cfe/trunk/test/CodeGenCUDA/device-var-init.cu === --- cfe/trunk/test/CodeGenCUDA/device-var-init.cu +++ cfe/trunk/test/CodeGenCUDA/device-var-init.cu @@ -0,0 +1,393 @@ +// REQUIRES: nvptx-registered-target + +// Make sure we don't allow dynamic initialization for device +// variables, but accept empty constructors allowed by CUDA. + +// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -std=c++11 \ +// RUN: -fno-threadsafe-statics -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -std=c++11 \ +// RUN: -emit-llvm -DERROR_CASE -verify -o /dev/null %s + +#ifdef __clang__ +#include "Inputs/cuda.h" +#endif + +// Base classes with different initializer variants. + +// trivial constructor -- allowed +struct T { + int t; +}; + +// empty constructor +struct EC { + int ec; + __device__ EC() {} // -- allowed + __device__ EC(int) {} // -- not allowed +}; + +// empty templated constructor -- allowed with no arguments +struct ETC { + template __device__ ETC(T...) {} +}; + +// undefined constructor -- not allowed +struct UC { + int uc; + __device__ UC(); +}; + +// empty constructor w/ initializer list -- not allowed +struct ECI { + int eci; + __device__ ECI() : eci(1) {} +}; + +// non-empty constructor -- not allowed +struct NEC { + int nec; + __device__ NEC() { nec = 1; } +}; + +// no-constructor, virtual method -- not allowed +struct NCV { + int ncv; + __device__ virtual void vm() {} +}; + +// dynamic in-class field initializer -- not allowed +__device__ int f(); +struct NCF { + int ncf = f(); +}; + +// static in-class field initializer. NVCC does not allow it, but +// clang generates static initializer for this, so we'll accept it. +struct NCFS { + int ncfs = 3; +}; + +// undefined templated constructor -- not allowed +struct UTC { + template __device__ UTC(T...); +}; + +// non-empty templated constructor -- not allowed +struct NETC { + int netc; + template __device__ NETC(T...) { netc = 1; } +}; + +__device__ int d_v; +// CHECK: @d_v = addrspace(1) externally_initialized global i32 0, +__shared__ int s_v; +// CHECK: @s_v = addrspace(3) global i32 undef, +__constant__ int c_v; +// CHECK: addrspace(4) externally_initialized global i32 0, + +__device__ int d_v_i = 1; +// CHECK: @d_v_i = addrspace(1) externally_initialized global i32 1, +#ifdef ERROR_CASE +__shared__ int s_v_i = 1; +// expected-error@-1 {{initialization is not supported for __shared__ variables.}} +#endif +__constant__ int c_v_i = 1; +// CHECK: @c_v_i = addrspace(4) externally_initialized global i32 1, + +#ifdef ERROR_CASE +__device__ int d_v_f = f(); +// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}} +__shared__ int s_v_f = f(); +// expected-error@-1 {{initialization is not supported for __shared__ variables.}} +__constant__ int c_v_f = f(); +// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}} +#endif + +__device__ T d_t; +// CHECK: @d_t = addrspace(1) externally_initialized global %struct.T zeroinitializer +__shared__ T s_t; +// CHECK: @s_t = addrspace(3) global %struct.T undef, +__constant__ T c_t; +// CHECK: @c_t = addrspace(4) externally_initialized global %struct.T zeroinitializer, + +__device__ T d_t_i = {2}; +// CHECKL @d_t_i = addrspace(1) externally_initialized global %struct.T { i32 2 }, +#ifdef ERROR_CASE +__shared__ T s_t_i = {2}; +// expected-error@-1 {{initialization is not supported for __shared__ variables.}} +#endif +__constant__ T c_t_i = {2}; +// CHECK: @c_t_i = addrspace(4) externally_initialized global %struct.T { i32 2 }, + +__device__ EC d_ec; +// CHECK: @d_ec = addrspace(1) externally_initialized global %struct.EC zeroinitializer, +__shared__ EC s_ec; +// CHECK: @s_ec = addrspace(3) global %struct.EC undef, +__constant__ EC c_ec; +// CHECK: @c_ec = addrspace(4) externally_initialized global %struct.EC zeroinitializer, + +#if ERROR_CASE +__device__ EC d_ec_i(3); +// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables.}} +__shared__ EC s_ec_i(3); +// expected-error@-1 {{initialization is not supported for __shared__ variables.}} +__constant__ EC c_ec
Re: [PATCH] D15977: [Clang] Supporting all entities declared in lexical scope in LLVM debug info
aaboud marked an inline comment as done. aaboud added a comment. Thanks David for the comments. See answer below. Comment at: lib/CodeGen/CGDebugInfo.cpp:1489 @@ +1488,3 @@ + if (I != LexicalBlockMap.end()) { +RetainedTypes.push_back(Ty.getAsOpaquePtr()); +return I->second; dblaikie wrote: > aaboud wrote: > > dblaikie wrote: > > > Why does the type need to be added to the retained types list? > > Excellent question :) > > This was your suggestion few months ago. > > The reason is that backend will need to know what types are declared in > > lexical blocks. > > Imported entities are collected in the import entity list, while types are > > collected in the retained types. > > > > Check line 518 at DwarfDebug.cpp (http://reviews.llvm.org/D15976#51cfb106) > Not quite following - could we discover the types lazily as we're generating > DWARF in the backend - if we happen to emit a variable of that type & > generate the DIE* for the type, etc? (so that if a type becomes unused it's > able to be dropped - rather than being preserved only when the type is local) > > I suppose that would make it difficult to choose which scopes we had to > preserve when emitting debug info in the backend (if we didn't see a type > until after the scope was created - we wouldn't've known whether to > emit/create that scope or collapse it into its parent, etc) - so this > probably isn't possible/practical. Your analysis is correct. I just tried to re-check how we can discover types lazily, but I could not figure out how to make sure the lexical scope would be created for these types. I guess we can revisit this issue later and re-think a better implementation that make sure optimized types will not be emitted in the debug info. However, I think we can do that in a separate (following) patch. Comment at: test/CodeGenCXX/debug-info-lb.cpp:14 @@ +13,3 @@ +static int bar = 0; +{ + X a(x); dblaikie wrote: > This block seems unnecessary, and its contents are probably more complicated > than needed. This seems to suffice: > > X a; > Y b; > > & the global variable is emitted without referencing it anyway. > > (you could drop the int return and x parameter, too - no need to return > anything from the function, and the if (x) could be removed - the scope can > remain & still produce the same debug info I think) OK, I simplify the test, and it is still does what I needed. The only thing that I need to clarify is the extra block scope that I added to wrap the "a" and "b" variable definition. The reason I did that is to test the case where the types "X" and "Y" are defined in a different scope than they are used at. Without handling this case correctly, the LLVM IR could mistakenly associate "X" and "Y" to the scope of the usage and not the definition, i.e. the scope of "a" and "b", to test that I had to have different scope as in the example. I added a comment in the test explaining that. http://reviews.llvm.org/D15977 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15977: [Clang] Supporting all entities declared in lexical scope in LLVM debug info
aaboud updated this revision to Diff 46708. aaboud added a comment. Reduced the LIT tests and added comment explaining part of it. http://reviews.llvm.org/D15977 Files: lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDebugInfo.h lib/CodeGen/CGDecl.cpp test/CodeGenCXX/debug-info-lb.cpp Index: lib/CodeGen/CGDecl.cpp === --- lib/CodeGen/CGDecl.cpp +++ lib/CodeGen/CGDecl.cpp @@ -83,26 +83,30 @@ case Decl::UsingShadow: case Decl::ObjCTypeParam: llvm_unreachable("Declaration should not be in declstmts!"); - case Decl::Function: // void X(); - case Decl::Record:// struct/union/class X; - case Decl::Enum: // enum X; - case Decl::EnumConstant: // enum ? { X = ? } - case Decl::CXXRecord: // struct/union/class X; [C++] + case Decl::Function: // void X(); case Decl::StaticAssert: // static_assert(X, ""); [C++0x] case Decl::Label:// __label__ x; case Decl::Import: case Decl::OMPThreadPrivate: case Decl::Empty: // None of these decls require codegen support. return; + case Decl::Record: // struct/union/class X; + case Decl::Enum: // enum X; + case Decl::EnumConstant: // enum ? { X = ? } + case Decl::CXXRecord:// struct/union/class X; [C++] +if (CGDebugInfo *DI = getDebugInfo()) + DI->recordDeclarationLexicalScope(D); +return; + case Decl::NamespaceAlias: if (CGDebugInfo *DI = getDebugInfo()) -DI->EmitNamespaceAlias(cast(D)); + DI->EmitNamespaceAlias(cast(D)); return; case Decl::Using: // using X; [C++] if (CGDebugInfo *DI = getDebugInfo()) -DI->EmitUsingDecl(cast(D)); + DI->EmitUsingDecl(cast(D)); return; case Decl::UsingDirective: // using namespace X; [C++] if (CGDebugInfo *DI = getDebugInfo()) @@ -120,6 +124,9 @@ const TypedefNameDecl &TD = cast(D); QualType Ty = TD.getUnderlyingType(); +if (CGDebugInfo *DI = getDebugInfo()) + DI->recordDeclarationLexicalScope(D); + if (Ty->isVariablyModifiedType()) EmitVariablyModifiedType(Ty); } Index: lib/CodeGen/CGDebugInfo.h === --- lib/CodeGen/CGDebugInfo.h +++ lib/CodeGen/CGDebugInfo.h @@ -114,6 +114,11 @@ /// Keep track of our current nested lexical block. std::vector> LexicalBlockStack; + + /// Map of AST declaration to its lexical block scope. + llvm::DenseMap> + LexicalBlockMap; + llvm::DenseMap RegionMap; /// Keep track of LexicalBlockStack counter at the beginning of a /// function. This is used to pop unbalanced regions at the end of a @@ -365,6 +370,12 @@ /// Emit an Objective-C interface type standalone debug info. llvm::DIType *getOrCreateInterfaceType(QualType Ty, SourceLocation Loc); + /// Map AST declaration to its lexical block scope if available. + void recordDeclarationLexicalScope(const Decl &D); + + /// Get lexical scope of AST declaration. + llvm::DIScope *getDeclarationLexicalScope(const Decl &D, QualType Ty); + /// Emit standalone debug info for a type. llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation Loc); Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -831,15 +831,18 @@ llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty, llvm::DIFile *Unit) { + TypedefNameDecl *TD = Ty->getDecl(); // We don't set size information, but do specify where the typedef was // declared. - SourceLocation Loc = Ty->getDecl()->getLocation(); + SourceLocation Loc = TD->getLocation(); + + llvm::DIScope *TDContext = getDeclarationLexicalScope(*TD, QualType(Ty, 0)); // Typedefs are derived from some other type. return DBuilder.createTypedef( getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit), Ty->getDecl()->getName(), getOrCreateFile(Loc), getLineNumber(Loc), - getDeclContextDescriptor(Ty->getDecl())); + TDContext); } llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty, @@ -1472,6 +1475,23 @@ return T; } +void CGDebugInfo::recordDeclarationLexicalScope(const Decl &D) { + assert(LexicalBlockMap.find(&D) == LexicalBlockMap.end() && + "D is already mapped to lexical block scope"); + if (!LexicalBlockStack.empty()) +LexicalBlockMap[&D] = LexicalBlockStack.back(); +} + +llvm::DIScope *CGDebugInfo::getDeclarationLexicalScope(const Decl &D, + QualType Ty) { + auto I = LexicalBlockMap.find(&D); + if (I != LexicalBlockMap.end()) { +RetainedTypes.push_back(Ty.getAsOpaquePtr()); +return I->second; + } + return getDeclContextDescriptor(cast(&D)); +} + void CGDebugInfo::completeType(const EnumDecl *ED) { if (DebugKind <= CodeGenOptions::DebugLineTablesOnly) return; @@ -2043,7
Re: [PATCH] D15977: [Clang] Supporting all entities declared in lexical scope in LLVM debug info
dblaikie added a comment. Looks good - though you could do that one further simplification to the test case, I think. (removing x/if x) Comment at: test/CodeGenCXX/debug-info-lb.cpp:5 @@ +4,3 @@ + static int bar = 1; + if (x) + { Looks like you could remove this "if (x)" and the "int x" parameter & still keep the test otherwise in tact. http://reviews.llvm.org/D15977 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16823: [cfi] Safe handling of unaddressable vtable pointers (clang).
eugenis added inline comments. Comment at: lib/CodeGen/CGExpr.cpp:2494 @@ +2493,3 @@ + llvm::Value *ValidVtable = nullptr; + if (CheckAndAppendValidVtable) { +llvm::Value *AllVtables = llvm::MetadataAsValue::get( samsonov wrote: > This is really ugly. Why are you not passing it down in DynamicArgs? Is it > performance penalty you don't want to pay if the check will not succeed? How > large will it be? Yes, I want this code to be on the failing side of the check. This would cost about the same as the check itself, so I suspect it could double the overhead. Repository: rL LLVM http://reviews.llvm.org/D16823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16823: [cfi] Safe handling of unaddressable vtable pointers (clang).
pcc added inline comments. Comment at: lib/CodeGen/CGExpr.cpp:2494 @@ +2493,3 @@ + llvm::Value *ValidVtable = nullptr; + if (CheckAndAppendValidVtable) { +llvm::Value *AllVtables = llvm::MetadataAsValue::get( eugenis wrote: > samsonov wrote: > > This is really ugly. Why are you not passing it down in DynamicArgs? Is it > > performance penalty you don't want to pay if the check will not succeed? > > How large will it be? > Yes, I want this code to be on the failing side of the check. > This would cost about the same as the check itself, so I suspect it could > double the overhead. > I would just emit the call unconditionally. We don't care too much about the performance in non-trapping mode, and if it becomes a problem in practice we can see if we can have the optimizer move the call into the conditional block (which I suspect it already knows how to do). Comment at: lib/CodeGen/CodeGenModule.cpp:4053 @@ +4052,3 @@ + + if (!CodeGenOpts.SanitizeTrap.has(SanitizerKind::CFIVCall) || + !CodeGenOpts.SanitizeTrap.has(SanitizerKind::CFINVCall) || This conditional doesn't look right. It should be something like ```if (sanitize.has(this) && !sanitizetrap.has(this)) || (sanitize.has(that) && !sanitizetrap.has(that)) || ... ``` But that's sufficiently ugly that I wonder if we should just do this unconditionally. It shouldn't make a difference to the generated code either way. Repository: rL LLVM http://reviews.llvm.org/D16823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r259598 - Work around build failure due to GCC 4.8.1 bug. We don't completely understand
Author: rsmith Date: Tue Feb 2 17:11:49 2016 New Revision: 259598 URL: http://llvm.org/viewvc/llvm-project?rev=259598&view=rev Log: Work around build failure due to GCC 4.8.1 bug. We don't completely understand the details of the bug, but avoiding overloading llvm::cast with another function template sidesteps it. See gcc.gnu.org/PR58022 for details of the bug, and llvm.org/PR26362 for more backgound on how it manifested in Clang. Patch by Igor Sugak! Modified: cfe/trunk/lib/CodeGen/Address.h Modified: cfe/trunk/lib/CodeGen/Address.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Address.h?rev=259598&r1=259597&r2=259598&view=diff == --- cfe/trunk/lib/CodeGen/Address.h (original) +++ cfe/trunk/lib/CodeGen/Address.h Tue Feb 2 17:11:49 2016 @@ -104,23 +104,15 @@ public: }; } -} -namespace llvm { - // Present a minimal LLVM-like casting interface. - template inline U cast(clang::CodeGen::Address addr) { -return U::castImpl(addr); - } - template inline bool isa(clang::CodeGen::Address addr) { -return U::isaImpl(addr); - } +// Present a minimal LLVM-like casting interface. +template inline U cast(CodeGen::Address addr) { + return U::castImpl(addr); +} +template inline bool isa(CodeGen::Address addr) { + return U::isaImpl(addr); } -namespace clang { - // Make our custom isa and cast available in namespace clang, to mirror - // what we do for LLVM's versions in Basic/LLVM.h. - using llvm::isa; - using llvm::cast; } #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16819: Remove llvm::(cast|isa) from lib/CodeGen/Address.h to fix build with gcc-4.8.1
rsmith closed this revision. rsmith added a comment. Thanks, committed as r259598. http://reviews.llvm.org/D16819 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r259598 - Work around build failure due to GCC 4.8.1 bug. We don't completely understand
Hans, this fixes a compile failure with one of our supported host compilers (GCC 4.8.1). Can we get this patch into 3.8? On Tue, Feb 2, 2016 at 3:11 PM, Richard Smith via cfe-commits wrote: > Author: rsmith > Date: Tue Feb 2 17:11:49 2016 > New Revision: 259598 > > URL: http://llvm.org/viewvc/llvm-project?rev=259598&view=rev > Log: > Work around build failure due to GCC 4.8.1 bug. We don't completely understand > the details of the bug, but avoiding overloading llvm::cast with another > function template sidesteps it. > > See gcc.gnu.org/PR58022 for details of the bug, and llvm.org/PR26362 for more > backgound on how it manifested in Clang. Patch by Igor Sugak! > > Modified: > cfe/trunk/lib/CodeGen/Address.h > > Modified: cfe/trunk/lib/CodeGen/Address.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Address.h?rev=259598&r1=259597&r2=259598&view=diff > == > --- cfe/trunk/lib/CodeGen/Address.h (original) > +++ cfe/trunk/lib/CodeGen/Address.h Tue Feb 2 17:11:49 2016 > @@ -104,23 +104,15 @@ public: > }; > > } > -} > > -namespace llvm { > - // Present a minimal LLVM-like casting interface. > - template inline U cast(clang::CodeGen::Address addr) { > -return U::castImpl(addr); > - } > - template inline bool isa(clang::CodeGen::Address addr) { > -return U::isaImpl(addr); > - } > +// Present a minimal LLVM-like casting interface. > +template inline U cast(CodeGen::Address addr) { > + return U::castImpl(addr); > +} > +template inline bool isa(CodeGen::Address addr) { > + return U::isaImpl(addr); > } > > -namespace clang { > - // Make our custom isa and cast available in namespace clang, to mirror > - // what we do for LLVM's versions in Basic/LLVM.h. > - using llvm::isa; > - using llvm::cast; > } > > #endif > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16503: [MSVC Compat] Warn when suppressing a trailing comma in macro args
ehsan added a comment. In http://reviews.llvm.org/D16503#342116, @thakis wrote: > Sorry for the slow response. I was reading http://reviews.llvm.org/D15670 to > understand this patch, and I couldn't find anything in that patch that > enables this extension only in Microsoft mode. Trying > suppressed-comma-msextension.cpp locally, it seems to pass without > -fms-compatibility too. Am I missing something, or does > http://reviews.llvm.org/D15670 lack a check for MicrosoftExt? Hmm, is the `PP.getLangOpts().MSVCCompat` check earlier in `MaybeRemoveCommaBeforeVaArgs()` insufficient? (Note that this whole thing mostly builds on top of r167613 which was done by Andy, so it's possible that I needed to do something extra and I forgot that...) http://reviews.llvm.org/D16503 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r259598 - Work around build failure due to GCC 4.8.1 bug. We don't completely understand
Yes! r259603. Cheers, Hans On Tue, Feb 2, 2016 at 3:17 PM, Richard Smith wrote: > Hans, this fixes a compile failure with one of our supported host > compilers (GCC 4.8.1). Can we get this patch into 3.8? > > On Tue, Feb 2, 2016 at 3:11 PM, Richard Smith via cfe-commits > wrote: >> Author: rsmith >> Date: Tue Feb 2 17:11:49 2016 >> New Revision: 259598 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=259598&view=rev >> Log: >> Work around build failure due to GCC 4.8.1 bug. We don't completely >> understand >> the details of the bug, but avoiding overloading llvm::cast with another >> function template sidesteps it. >> >> See gcc.gnu.org/PR58022 for details of the bug, and llvm.org/PR26362 for more >> backgound on how it manifested in Clang. Patch by Igor Sugak! >> >> Modified: >> cfe/trunk/lib/CodeGen/Address.h >> >> Modified: cfe/trunk/lib/CodeGen/Address.h >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Address.h?rev=259598&r1=259597&r2=259598&view=diff >> == >> --- cfe/trunk/lib/CodeGen/Address.h (original) >> +++ cfe/trunk/lib/CodeGen/Address.h Tue Feb 2 17:11:49 2016 >> @@ -104,23 +104,15 @@ public: >> }; >> >> } >> -} >> >> -namespace llvm { >> - // Present a minimal LLVM-like casting interface. >> - template inline U cast(clang::CodeGen::Address addr) { >> -return U::castImpl(addr); >> - } >> - template inline bool isa(clang::CodeGen::Address addr) { >> -return U::isaImpl(addr); >> - } >> +// Present a minimal LLVM-like casting interface. >> +template inline U cast(CodeGen::Address addr) { >> + return U::castImpl(addr); >> +} >> +template inline bool isa(CodeGen::Address addr) { >> + return U::isaImpl(addr); >> } >> >> -namespace clang { >> - // Make our custom isa and cast available in namespace clang, to mirror >> - // what we do for LLVM's versions in Basic/LLVM.h. >> - using llvm::isa; >> - using llvm::cast; >> } >> >> #endif >> >> >> ___ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r259604 - Fix rejects-valid when forming a pointer-to-member with 'decltype(expr)::*'.
Author: rsmith Date: Tue Feb 2 17:34:49 2016 New Revision: 259604 URL: http://llvm.org/viewvc/llvm-project?rev=259604&view=rev Log: Fix rejects-valid when forming a pointer-to-member with 'decltype(expr)::*'. Modified: cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/test/Parser/cxx0x-decl.cpp Modified: cfe/trunk/lib/Parse/ParseDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=259604&r1=259603&r2=259604&view=diff == --- cfe/trunk/lib/Parse/ParseDecl.cpp (original) +++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Feb 2 17:34:49 2016 @@ -4931,7 +4931,7 @@ void Parser::ParseDeclaratorInternal(Dec // Member pointers get special handling, since there's no place for the // scope spec in the generic path below. if (getLangOpts().CPlusPlus && - (Tok.is(tok::coloncolon) || + (Tok.is(tok::coloncolon) || Tok.is(tok::kw_decltype) || (Tok.is(tok::identifier) && (NextToken().is(tok::coloncolon) || NextToken().is(tok::less))) || Tok.is(tok::annot_cxxscope))) { Modified: cfe/trunk/test/Parser/cxx0x-decl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-decl.cpp?rev=259604&r1=259603&r2=259604&view=diff == --- cfe/trunk/test/Parser/cxx0x-decl.cpp (original) +++ cfe/trunk/test/Parser/cxx0x-decl.cpp Tue Feb 2 17:34:49 2016 @@ -17,6 +17,8 @@ auto g() -> enum E { return E(); } +int decltype(f())::*ptr_mem_decltype; + class ExtraSemiAfterMemFn { // Due to a peculiarity in the C++11 grammar, a deleted or defaulted function // is permitted to be followed by either one or two semicolons. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16823: [cfi] Safe handling of unaddressable vtable pointers (clang).
eugenis added inline comments. Comment at: lib/CodeGen/CGExpr.cpp:2494 @@ +2493,3 @@ + llvm::Value *ValidVtable = nullptr; + if (CheckAndAppendValidVtable) { +llvm::Value *AllVtables = llvm::MetadataAsValue::get( pcc wrote: > eugenis wrote: > > samsonov wrote: > > > This is really ugly. Why are you not passing it down in DynamicArgs? Is > > > it performance penalty you don't want to pay if the check will not > > > succeed? How large will it be? > > Yes, I want this code to be on the failing side of the check. > > This would cost about the same as the check itself, so I suspect it could > > double the overhead. > > > I would just emit the call unconditionally. We don't care too much about the > performance in non-trapping mode, and if it becomes a problem in practice we > can see if we can have the optimizer move the call into the conditional block > (which I suspect it already knows how to do). I care about performance in non-trapping mode. Doing this change would not make the code any less ugly. For example, EmitCheck may not use the argument if the check has -fsanitize-trap behaviour, in which case we get an unused llvm.bitset.test call that affects some of the clang tests. Repository: rL LLVM http://reviews.llvm.org/D16823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15120: Add support for __float128 type to be used by targets that support it
hubert.reinterpretcast added a comment. In http://reviews.llvm.org/D15120#340515, @nemanjai wrote: > If the reviewers don't mind, I would like to keep this patch with diagnostics > for interoperability between the two types for now. This is simply because > enabling such interoperability requires changes to some of the conversion > infrastructure (i.e. allowing FPTrunc/FPExt for types of the same width, > etc.). This is to prevent crashes on code such as: > > __float128 foo(long double d) { > return d; > } > > > A test case like that will trip asserts when attempting to generate code. Of > course, this is easy to fix (3 minor changes in 2 files) but even if we emit > that IR, the back end will fail when trying to compile it. > What I meant to do with this patch is to just get the Clang support in and > emit diagnostics for things that the target isn't able to do yet. I will > follow this up with a patch that will: > > 1. Remove the diagnostics > 2. Allow the conversions > 3. Provide libcalls for the necessary operations (similarly to what GCC does) This sounds good to me. @rjmccall @rsmith, are we good to move forward with this first patch? Comment at: lib/Sema/SemaExpr.cpp:1156 @@ +1155,3 @@ + + QualType LHSElemType = dyn_cast(LHSType) ? +cast(LHSType)->getElementType() : LHSType; The result of the `dyn_cast` can be saved instead of using `cast` after the `dyn_cast`. Repository: rL LLVM http://reviews.llvm.org/D15120 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r259609 - PR24989: Stop trying to use the C++11 rules for lambda return type inference in
Author: rsmith Date: Tue Feb 2 17:58:56 2016 New Revision: 259609 URL: http://llvm.org/viewvc/llvm-project?rev=259609&view=rev Log: PR24989: Stop trying to use the C++11 rules for lambda return type inference in C++14 generic lambdas. It conflicts with the C++14 return type deduction mechanism, and results in us failing to actually deduce the lambda's return type in some cases. Modified: cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaLambda.cpp cfe/trunk/test/SemaCXX/cxx1y-deduced-return-type.cpp Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=259609&r1=259608&r2=259609&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Feb 2 17:58:56 2016 @@ -11131,22 +11131,26 @@ Decl *Sema::ActOnFinishFunctionBody(Decl if (FD) { FD->setBody(Body); -if (getLangOpts().CPlusPlus14 && !FD->isInvalidDecl() && Body && -!FD->isDependentContext() && FD->getReturnType()->isUndeducedType()) { - // If the function has a deduced result type but contains no 'return' - // statements, the result type as written must be exactly 'auto', and - // the deduced result type is 'void'. - if (!FD->getReturnType()->getAs()) { -Diag(dcl->getLocation(), diag::err_auto_fn_no_return_but_not_auto) -<< FD->getReturnType(); -FD->setInvalidDecl(); - } else { -// Substitute 'void' for the 'auto' in the type. -TypeLoc ResultType = getReturnTypeLoc(FD); -Context.adjustDeducedFunctionResultType( -FD, SubstAutoType(ResultType.getType(), Context.VoidTy)); +if (getLangOpts().CPlusPlus14) { + if (!FD->isInvalidDecl() && Body && !FD->isDependentContext() && + FD->getReturnType()->isUndeducedType()) { +// If the function has a deduced result type but contains no 'return' +// statements, the result type as written must be exactly 'auto', and +// the deduced result type is 'void'. +if (!FD->getReturnType()->getAs()) { + Diag(dcl->getLocation(), diag::err_auto_fn_no_return_but_not_auto) + << FD->getReturnType(); + FD->setInvalidDecl(); +} else { + // Substitute 'void' for the 'auto' in the type. + TypeLoc ResultType = getReturnTypeLoc(FD); + Context.adjustDeducedFunctionResultType( + FD, SubstAutoType(ResultType.getType(), Context.VoidTy)); +} } } else if (getLangOpts().CPlusPlus11 && isLambdaCallOperator(FD)) { + // In C++11, we don't use 'auto' deduction rules for lambda call + // operators because we don't support return type deduction. auto *LSI = getCurLambda(); if (LSI->HasImplicitReturnType) { deduceClosureReturnType(*LSI); Modified: cfe/trunk/lib/Sema/SemaLambda.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=259609&r1=259608&r2=259609&view=diff == --- cfe/trunk/lib/Sema/SemaLambda.cpp (original) +++ cfe/trunk/lib/Sema/SemaLambda.cpp Tue Feb 2 17:58:56 2016 @@ -617,6 +617,8 @@ void Sema::deduceClosureReturnType(Captu assert(CSI.HasImplicitReturnType); // If it was ever a placeholder, it had to been deduced to DependentTy. assert(CSI.ReturnType.isNull() || !CSI.ReturnType->isUndeducedType()); + assert((!isa(CSI) || !getLangOpts().CPlusPlus14) && + "lambda expressions use auto deduction in C++14 onwards"); // C++ core issue 975: // If a lambda-expression does not include a trailing-return-type, Modified: cfe/trunk/test/SemaCXX/cxx1y-deduced-return-type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-deduced-return-type.cpp?rev=259609&r1=259608&r2=259609&view=diff == --- cfe/trunk/test/SemaCXX/cxx1y-deduced-return-type.cpp (original) +++ cfe/trunk/test/SemaCXX/cxx1y-deduced-return-type.cpp Tue Feb 2 17:58:56 2016 @@ -496,3 +496,9 @@ namespace TrailingReturnTypeForConversio } }; }; + +namespace PR24989 { + auto x = [](auto){}; + using T = decltype(x); + void (T::*p)(int) const = &T::operator(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16823: [cfi] Safe handling of unaddressable vtable pointers (clang).
eugenis updated this revision to Diff 46718. eugenis added a comment. Moved bitset.text call outside. LLVM is smart enough to sink it along the cold branch, so performance should not suffer. Repository: rL LLVM http://reviews.llvm.org/D16823 Files: lib/CodeGen/CGClass.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CodeGenModule.cpp test/CodeGen/cfi-check-fail.c test/CodeGenCXX/cfi-cast.cpp test/CodeGenCXX/cfi-vcall.cpp Index: test/CodeGenCXX/cfi-vcall.cpp === --- test/CodeGenCXX/cfi-vcall.cpp +++ test/CodeGenCXX/cfi-vcall.cpp @@ -55,23 +55,25 @@ // DIAG: @[[SRC:.*]] = private unnamed_addr constant [{{.*}} x i8] c"{{.*}}cfi-vcall.cpp\00", align 1 // DIAG: @[[TYPE:.*]] = private unnamed_addr constant { i16, i16, [4 x i8] } { i16 -1, i16 0, [4 x i8] c"'A'\00" } -// DIAG: @[[BADTYPESTATIC:.*]] = private unnamed_addr global { i8, { [{{.*}} x i8]*, i32, i32 }, { i16, i16, [4 x i8] }* } { i8 0, { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+21]], i32 3 }, { i16, i16, [4 x i8] }* @[[TYPE]] } +// DIAG: @[[BADTYPESTATIC:.*]] = private unnamed_addr global { i8, { [{{.*}} x i8]*, i32, i32 }, { i16, i16, [4 x i8] }* } { i8 0, { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+23]], i32 3 }, { i16, i16, [4 x i8] }* @[[TYPE]] } // ITANIUM: define void @_Z2afP1A // MS: define void @"\01?af@@YAXPEAUA@@@Z" void af(A *a) { // ITANIUM: [[P:%[^ ]*]] = call i1 @llvm.bitset.test(i8* [[VT:%[^ ]*]], metadata !"_ZTS1A") // MS: [[P:%[^ ]*]] = call i1 @llvm.bitset.test(i8* [[VT:%[^ ]*]], metadata !"?AUA@@") + // DIAG-NEXT: [[VTVALID0:%[^ ]*]] = call i1 @llvm.bitset.test(i8* [[VT]], metadata !"all-vtables") // CHECK-NEXT: br i1 [[P]], label %[[CONTBB:[^ ,]*]], label %[[TRAPBB:[^ ,]*]] // CHECK-NEXT: {{^$}} // CHECK: [[TRAPBB]] // NDIAG-NEXT: call void @llvm.trap() // NDIAG-NEXT: unreachable // DIAG-NEXT: [[VTINT:%[^ ]*]] = ptrtoint i8* [[VT]] to i64 - // DIAG-ABORT-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(i8* getelementptr inbounds ({{.*}} @[[BADTYPESTATIC]], i32 0, i32 0), i64 [[VTINT]]) + // DIAG-NEXT: [[VTVALID:%[^ ]*]] = zext i1 [[VTVALID0]] to i64 + // DIAG-ABORT-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(i8* getelementptr inbounds ({{.*}} @[[BADTYPESTATIC]], i32 0, i32 0), i64 [[VTINT]], i64 [[VTVALID]]) // DIAG-ABORT-NEXT: unreachable - // DIAG-RECOVER-NEXT: call void @__ubsan_handle_cfi_check_fail(i8* getelementptr inbounds ({{.*}} @[[BADTYPESTATIC]], i32 0, i32 0), i64 [[VTINT]]) + // DIAG-RECOVER-NEXT: call void @__ubsan_handle_cfi_check_fail(i8* getelementptr inbounds ({{.*}} @[[BADTYPESTATIC]], i32 0, i32 0), i64 [[VTINT]], i64 [[VTVALID]]) // DIAG-RECOVER-NEXT: br label %[[CONTBB]] // CHECK: [[CONTBB]] @@ -157,32 +159,45 @@ } -// Check for the expected number of elements (9 or 15 respectively). -// MS: !llvm.bitsets = !{[[X:[^,]*(,[^,]*){8}]]} -// ITANIUM: !llvm.bitsets = !{[[X:[^,]*(,[^,]*){14}]]} +// Check for the expected number of elements (15 or 23 respectively). +// MS: !llvm.bitsets = !{[[X:[^,]*(,[^,]*){15}]]} +// ITANIUM: !llvm.bitsets = !{[[X:[^,]*(,[^,]*){23}]]} // ITANIUM-DAG: !{!"_ZTS1A", [3 x i8*]* @_ZTV1A, i64 16} +// ITANIUM-DAG: !{!"all-vtables", [3 x i8*]* @_ZTV1A, i64 16} // ITANIUM-DAG: !{!"_ZTS1A", [7 x i8*]* @_ZTCN12_GLOBAL__N_11DE0_1B, i64 32} +// ITANIUM-DAG: !{!"all-vtables", [7 x i8*]* @_ZTCN12_GLOBAL__N_11DE0_1B, i64 32} // ITANIUM-DAG: !{!"_ZTS1B", [7 x i8*]* @_ZTCN12_GLOBAL__N_11DE0_1B, i64 32} // ITANIUM-DAG: !{!"_ZTS1A", [9 x i8*]* @_ZTCN12_GLOBAL__N_11DE8_1C, i64 64} +// ITANIUM-DAG: !{!"all-vtables", [9 x i8*]* @_ZTCN12_GLOBAL__N_11DE8_1C, i64 64} // ITANIUM-DAG: !{!"_ZTS1C", [9 x i8*]* @_ZTCN12_GLOBAL__N_11DE8_1C, i64 32} // ITANIUM-DAG: !{!"_ZTS1A", [12 x i8*]* @_ZTVN12_GLOBAL__N_11DE, i64 32} +// ITANIUM-DAG: !{!"all-vtables", [12 x i8*]* @_ZTVN12_GLOBAL__N_11DE, i64 32} // ITANIUM-DAG: !{!"_ZTS1B", [12 x i8*]* @_ZTVN12_GLOBAL__N_11DE, i64 32} // ITANIUM-DAG: !{!"_ZTS1C", [12 x i8*]* @_ZTVN12_GLOBAL__N_11DE, i64 88} +// ITANIUM-DAG: !{!"all-vtables", [12 x i8*]* @_ZTVN12_GLOBAL__N_11DE, i64 88} // ITANIUM-DAG: !{![[DTYPE]], [12 x i8*]* @_ZTVN12_GLOBAL__N_11DE, i64 32} // ITANIUM-DAG: !{!"_ZTS1A", [7 x i8*]* @_ZTV1B, i64 32} +// ITANIUM-DAG: !{!"all-vtables", [7 x i8*]* @_ZTV1B, i64 32} // ITANIUM-DAG: !{!"_ZTS1B", [7 x i8*]* @_ZTV1B, i64 32} // ITANIUM-DAG: !{!"_ZTS1A", [5 x i8*]* @_ZTV1C, i64 32} // ITANIUM-DAG: !{!"_ZTS1C", [5 x i8*]* @_ZTV1C, i64 32} // ITANIUM-DAG: !{!"_ZTS1A", [3 x i8*]* @_ZTVZ3foovE2FA, i64 16} // ITANIUM-DAG: !{!{{[0-9]+}}, [3 x i8*]* @_ZTVZ3foovE2FA, i64 16} // MS-DAG: !{!"?AUA@@", [2 x i8*]* @[[VTA]], i64 8} +// MS-DAG: !{!"all-vtables", [2 x i8*]* @[[VTA]], i64 8} // MS-DAG: !{!"?AUB@@", [3 x i8*]* @[[VTB]], i64 8} +// MS-DAG: !{!"all-vtables", [3 x i8*]* @[[VTB]], i64 8} // MS-DAG: !{!"?AUA@@", [2 x i8*]* @[[VTAinB]], i64 8} +// MS-DAG: !{!"all-vt
Re: [PATCH] D16823: [cfi] Safe handling of unaddressable vtable pointers (clang).
eugenis updated this revision to Diff 46723. eugenis marked an inline comment as done. Repository: rL LLVM http://reviews.llvm.org/D16823 Files: lib/CodeGen/CGClass.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h test/CodeGen/cfi-check-fail.c test/CodeGenCXX/cfi-cast.cpp test/CodeGenCXX/cfi-vcall.cpp Index: test/CodeGenCXX/cfi-vcall.cpp === --- test/CodeGenCXX/cfi-vcall.cpp +++ test/CodeGenCXX/cfi-vcall.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-vcall -fsanitize-trap=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=ITANIUM --check-prefix=NDIAG %s -// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=ITANIUM --check-prefix=DIAG --check-prefix=DIAG-ABORT %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-vcall -fsanitize-trap=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=ITANIUM --check-prefix=ITANIUM-NDIAG --check-prefix=NDIAG %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=ITANIUM --check-prefix=ITANIUM-DIAG --check-prefix=DIAG --check-prefix=DIAG-ABORT %s // RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-vcall -fsanitize-recover=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=ITANIUM --check-prefix=DIAG --check-prefix=DIAG-RECOVER %s // RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fsanitize=cfi-vcall -fsanitize-trap=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=MS --check-prefix=NDIAG %s @@ -55,23 +55,25 @@ // DIAG: @[[SRC:.*]] = private unnamed_addr constant [{{.*}} x i8] c"{{.*}}cfi-vcall.cpp\00", align 1 // DIAG: @[[TYPE:.*]] = private unnamed_addr constant { i16, i16, [4 x i8] } { i16 -1, i16 0, [4 x i8] c"'A'\00" } -// DIAG: @[[BADTYPESTATIC:.*]] = private unnamed_addr global { i8, { [{{.*}} x i8]*, i32, i32 }, { i16, i16, [4 x i8] }* } { i8 0, { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+21]], i32 3 }, { i16, i16, [4 x i8] }* @[[TYPE]] } +// DIAG: @[[BADTYPESTATIC:.*]] = private unnamed_addr global { i8, { [{{.*}} x i8]*, i32, i32 }, { i16, i16, [4 x i8] }* } { i8 0, { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+23]], i32 3 }, { i16, i16, [4 x i8] }* @[[TYPE]] } // ITANIUM: define void @_Z2afP1A // MS: define void @"\01?af@@YAXPEAUA@@@Z" void af(A *a) { // ITANIUM: [[P:%[^ ]*]] = call i1 @llvm.bitset.test(i8* [[VT:%[^ ]*]], metadata !"_ZTS1A") // MS: [[P:%[^ ]*]] = call i1 @llvm.bitset.test(i8* [[VT:%[^ ]*]], metadata !"?AUA@@") + // DIAG-NEXT: [[VTVALID0:%[^ ]*]] = call i1 @llvm.bitset.test(i8* [[VT]], metadata !"all-vtables") // CHECK-NEXT: br i1 [[P]], label %[[CONTBB:[^ ,]*]], label %[[TRAPBB:[^ ,]*]] // CHECK-NEXT: {{^$}} // CHECK: [[TRAPBB]] // NDIAG-NEXT: call void @llvm.trap() // NDIAG-NEXT: unreachable // DIAG-NEXT: [[VTINT:%[^ ]*]] = ptrtoint i8* [[VT]] to i64 - // DIAG-ABORT-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(i8* getelementptr inbounds ({{.*}} @[[BADTYPESTATIC]], i32 0, i32 0), i64 [[VTINT]]) + // DIAG-NEXT: [[VTVALID:%[^ ]*]] = zext i1 [[VTVALID0]] to i64 + // DIAG-ABORT-NEXT: call void @__ubsan_handle_cfi_check_fail_abort(i8* getelementptr inbounds ({{.*}} @[[BADTYPESTATIC]], i32 0, i32 0), i64 [[VTINT]], i64 [[VTVALID]]) // DIAG-ABORT-NEXT: unreachable - // DIAG-RECOVER-NEXT: call void @__ubsan_handle_cfi_check_fail(i8* getelementptr inbounds ({{.*}} @[[BADTYPESTATIC]], i32 0, i32 0), i64 [[VTINT]]) + // DIAG-RECOVER-NEXT: call void @__ubsan_handle_cfi_check_fail(i8* getelementptr inbounds ({{.*}} @[[BADTYPESTATIC]], i32 0, i32 0), i64 [[VTINT]], i64 [[VTVALID]]) // DIAG-RECOVER-NEXT: br label %[[CONTBB]] // CHECK: [[CONTBB]] @@ -157,32 +159,47 @@ } -// Check for the expected number of elements (9 or 15 respectively). -// MS: !llvm.bitsets = !{[[X:[^,]*(,[^,]*){8}]]} -// ITANIUM: !llvm.bitsets = !{[[X:[^,]*(,[^,]*){14}]]} +// Check for the expected number of elements (15 or 23 respectively). +// MS-NDIAG: !llvm.bitsets = !{[[X:[^,]*(,[^,]*){9}]]} +// MS-DIAG: !llvm.bitsets = !{[[X:[^,]*(,[^,]*){15}]]} +// ITANIUM-NDIAG: !llvm.bitsets = !{[[X:[^,]*(,[^,]*){14}]]} +// ITANIUM-DIAG: !llvm.bitsets = !{[[X:[^,]*(,[^,]*){23}]]} // ITANIUM-DAG: !{!"_ZTS1A", [3 x i8*]* @_ZTV1A, i64 16} +// ITANIUM-DIAG-DAG: !{!"all-vtables", [3 x i8*]* @_ZTV1A, i64 16} // ITANIUM-DAG: !{!"_ZTS1A", [7 x i8*]* @_ZTCN12_GLOBAL__N_11DE0_1B, i64 32} +// ITANIUM-DIAG-DAG: !{!"all-vtables", [7 x i8*]* @_ZTCN12_GLOBAL__N_11DE0_1B, i64 32} // ITANIUM-DAG: !{!"_ZTS1B", [7 x i8*]* @_ZTCN12_GLOBAL__N_11DE0_1B, i64 32} // ITANIUM-DAG: !{!"_ZTS1A", [9 x i8*]* @_ZTCN12_GLOBAL__N_11DE8_1C, i64 64} +// ITANIUM-DIAG-DAG:
Re: [PATCH] D16823: [cfi] Safe handling of unaddressable vtable pointers (clang).
eugenis added inline comments. Comment at: lib/CodeGen/CodeGenModule.cpp:4053 @@ +4052,3 @@ + + if (!CodeGenOpts.SanitizeTrap.has(SanitizerKind::CFIVCall) || + !CodeGenOpts.SanitizeTrap.has(SanitizerKind::CFINVCall) || I don't like emitting all these bitset entries if they are not needed. Fixed. Repository: rL LLVM http://reviews.llvm.org/D16823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits