[PATCH] D30375: Function with unparsed body is a definition
sepavloff updated this revision to Diff 101517. sepavloff added a comment. Rebased patch https://reviews.llvm.org/D30375 Files: include/clang/AST/Decl.h include/clang/Sema/Sema.h lib/Parse/Parser.cpp lib/Sema/SemaCUDA.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp test/SemaCXX/friend2.cpp Index: test/SemaCXX/friend2.cpp === --- test/SemaCXX/friend2.cpp +++ test/SemaCXX/friend2.cpp @@ -170,3 +170,15 @@ template class Test; } + +namespace pr14785 { +template +struct Somewhat { + void internal() const { } + friend void operator+(int const &, Somewhat const &) {} // expected-error{{redefinition of 'operator+'}} +}; + +void operator+(int const &, Somewhat const &x) { // expected-note {{previous definition is here}} + x.internal(); // expected-note{{in instantiation of template class 'pr14785::Somewhat' requested here}} +} +} Index: lib/Sema/SemaTemplateInstantiateDecl.cpp === --- lib/Sema/SemaTemplateInstantiateDecl.cpp +++ lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -3894,6 +3894,7 @@ SubstQualifier(*this, PatternDecl, Function, TemplateArgs); ActOnStartOfFunctionDef(nullptr, Function); +ActOnStartOfFunctionBody(Function); // Enter the scope of this instantiation. We don't use // PushDeclContext because we don't have a scope. Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -12028,11 +12028,6 @@ return D; } - // Mark this function as "will have a body eventually". This lets users to - // call e.g. isInlineDefinitionExternallyVisible while we're still parsing - // this function. - FD->setWillHaveBody(); - // If we are instantiating a generic lambda call operator, push // a LambdaScopeInfo onto the function stack. But use the information // that's already been calculated (ActOnLambdaExpr) to prime the current @@ -12202,6 +12197,19 @@ return Decl; } +/// Semantic action called by parser when it expects that the current function +/// definition will have a body statement. +void Sema::ActOnStartOfFunctionBody(Decl *D) { + if (!D) +return; + if (FunctionDecl *FD = dyn_cast(D)) { +// Mark this function as "will have a body eventually". This lets users to +// call e.g. isInlineDefinitionExternallyVisible while we're still parsing +// this function. +FD->setWillHaveBody(); + } +} + Decl *Sema::ActOnFinishFunctionBody(Decl *D, Stmt *BodyArg) { return ActOnFinishFunctionBody(D, BodyArg, false); } Index: lib/Sema/SemaCUDA.cpp === --- lib/Sema/SemaCUDA.cpp +++ lib/Sema/SemaCUDA.cpp @@ -629,12 +629,6 @@ // emitted, because (say) the definition could include "inline". FunctionDecl *Def = FD->getDefinition(); - // We may currently be parsing the body of FD, in which case - // FD->getDefinition() will be null, but we still want to treat FD as though - // it's a definition. - if (!Def && FD->willHaveBody()) -Def = FD; - if (Def && !isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(Def))) return true; Index: lib/Parse/Parser.cpp === --- lib/Parse/Parser.cpp +++ lib/Parse/Parser.cpp @@ -1186,6 +1186,8 @@ return Actions.ActOnFinishFunctionBody(Res, nullptr, false); } + Actions.ActOnStartOfFunctionBody(Res); + if (Tok.is(tok::kw_try)) return ParseFunctionTryBlock(Res, BodyScope); Index: include/clang/Sema/Sema.h === --- include/clang/Sema/Sema.h +++ include/clang/Sema/Sema.h @@ -1981,6 +1981,7 @@ bool canSkipFunctionBody(Decl *D); void computeNRVO(Stmt *Body, sema::FunctionScopeInfo *Scope); + void ActOnStartOfFunctionBody(Decl *Decl); Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body); Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation); Decl *ActOnSkippedFunctionBody(Decl *Decl); Index: include/clang/AST/Decl.h === --- include/clang/AST/Decl.h +++ include/clang/AST/Decl.h @@ -1837,7 +1837,7 @@ /// bool isThisDeclarationADefinition() const { return IsDeleted || IsDefaulted || Body || IsLateTemplateParsed || - hasDefiningAttr(); + WillHaveBody || hasDefiningAttr(); } /// doesThisDeclarationHaveABody - Returns whether this specific ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r304776 - Fix a mistake in the clang format documentation (BreakBeforeTernaryOperators)
Author: sylvestre Date: Tue Jun 6 02:26:19 2017 New Revision: 304776 URL: http://llvm.org/viewvc/llvm-project?rev=304776&view=rev Log: Fix a mistake in the clang format documentation (BreakBeforeTernaryOperators) Patch sent through github by Jason Hsu Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=304776&r1=304775&r2=304776&view=diff == --- cfe/trunk/docs/ClangFormatStyleOptions.rst (original) +++ cfe/trunk/docs/ClangFormatStyleOptions.rst Tue Jun 6 02:26:19 2017 @@ -894,7 +894,7 @@ the configuration (without a prefix: ``A ? firstValue : SecondValueVeryVeryVeryVeryLong; - true: + false: veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription ? firstValue : SecondValueVeryVeryVeryVeryLong; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33676: Place implictly declared functions at block scope
chill updated this revision to Diff 101522. chill added a comment. Update 1 notes. The scopes for compound statements are explicitly marked as such, so then `Sema::ImplicitylDefineFunction` can ascend to the nearest enclosing scope. The function scopes (ones with `Scope:FnScope`) do not necessarily have the `Scope::CompoundStmtScope` flag set, that's why this flag is tested separately. I have considered, for consistency, setting the compound statement flag to all kinds of compound statement scopes, including function scopes, try/catch/SEH, block scopes, etc., but , given that this makes difference just for C90, I decided that such sweeping changes are unwarranted. https://reviews.llvm.org/D33676 Files: include/clang/Sema/Scope.h lib/Parse/ParseStmt.cpp lib/Sema/SemaDecl.cpp test/Sema/implicit-decl-c90.c test/Sema/implicit-decl.c Index: test/Sema/implicit-decl.c === --- test/Sema/implicit-decl.c +++ test/Sema/implicit-decl.c @@ -9,16 +9,15 @@ int32_t *vector[16]; const char compDesc[16 + 1]; int32_t compCount = 0; - if (_CFCalendarDecomposeAbsoluteTimeV(compDesc, vector, compCount)) { // expected-note {{previous implicit declaration is here}} \ - expected-error {{implicit declaration of function '_CFCalendarDecomposeAbsoluteTimeV' is invalid in C99}} + if (_CFCalendarDecomposeAbsoluteTimeV(compDesc, vector, compCount)) { // expected-error {{implicit declaration of function '_CFCalendarDecomposeAbsoluteTimeV' is invalid in C99}} } printg("Hello, World!\n"); // expected-error{{implicit declaration of function 'printg' is invalid in C99}} \ // expected-note{{did you mean 'printf'?}} __builtin_is_les(1, 3); // expected-error{{use of unknown builtin '__builtin_is_les'}} } -Boolean _CFCalendarDecomposeAbsoluteTimeV(const char *componentDesc, int32_t **vector, int32_t count) { // expected-error{{conflicting types for '_CFCalendarDecomposeAbsoluteTimeV'}} +Boolean _CFCalendarDecomposeAbsoluteTimeV(const char *componentDesc, int32_t **vector, int32_t count) { return 0; } Index: test/Sema/implicit-decl-c90.c === --- /dev/null +++ test/Sema/implicit-decl-c90.c @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 %s -std=c90 -verify -fsyntax-only +void t0(int x) { + int (*p)(); + if(x > 0) +x = g() + 1; + p = g; + if(x < 0) { +extern void u(int (*)[h()]); +int (*q)() = h; + } + p = h; /* expected-error {{use of undeclared identifier 'h'}} */ +} + +void t1(int x) { + int (*p)(); + switch (x) { +g(); + case 0: +x = h() + 1; +break; + case 1: +p = g; +p = h; +break; + } + p = g; /* expected-error {{use of undeclared identifier 'g'}} */ + p = h; /* expected-error {{use of undeclared identifier 'h'}} */ +} + +int (*p)() = g; /* expected-error {{use of undeclared identifier 'g'}} */ +int (*q)() = h; /* expected-error {{use of undeclared identifier 'h'}} */ + +float g(); /* not expecting conflicting types diagnostics here */ Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -12605,12 +12605,16 @@ SourceLocation()); D.SetIdentifier(&II, Loc); - // Insert this function into translation-unit scope. + // Insert this function into the enclosing block scope. + while (S && !S->isCompoundStmtScope() && !S->isFunctionScope()) +S = S->getParent(); + if (S == nullptr) +S = TUScope; DeclContext *PrevDC = CurContext; CurContext = Context.getTranslationUnitDecl(); - FunctionDecl *FD = cast(ActOnDeclarator(TUScope, D)); + FunctionDecl *FD = cast(ActOnDeclarator(S, D)); FD->setImplicit(); CurContext = PrevDC; Index: lib/Parse/ParseStmt.cpp === --- lib/Parse/ParseStmt.cpp +++ lib/Parse/ParseStmt.cpp @@ -840,7 +840,8 @@ } StmtResult Parser::ParseCompoundStatement(bool isStmtExpr) { - return ParseCompoundStatement(isStmtExpr, Scope::DeclScope); + return ParseCompoundStatement(isStmtExpr, +Scope::DeclScope | Scope::CompoundStmtScope); } /// ParseCompoundStatement - Parse a "{}" block. Index: include/clang/Sema/Scope.h === --- include/clang/Sema/Scope.h +++ include/clang/Sema/Scope.h @@ -124,6 +124,9 @@ /// We are currently in the filter expression of an SEH except block. SEHFilterScope = 0x20, + +/// This is a compound statement scope. +CompoundStmtScope = 0x40, }; private: /// The parent scope for this scope. This is null for the translation-unit @@ -429,6 +432,9 @@ /// \brief Determine whether this scope is a SEH '__except' block. bool isSEHExceptScope() const { return getFlags() & Scope::SEHExceptScope; } + /// \brief Deter
r304781 - [ARM] Add support for target("arm") and target("thumb").
Author: fhahn Date: Tue Jun 6 04:26:15 2017 New Revision: 304781 URL: http://llvm.org/viewvc/llvm-project?rev=304781&view=rev Log: [ARM] Add support for target("arm") and target("thumb"). Summary: This patch adds support for the target("arm") and target("thumb") attributes, which can be used to force the compiler to generated ARM or Thumb code for a function. In LLVM, ARM or Thumb code generation can be controlled by the thumb-mode target feature. But GCC already uses target("arm") and target("thumb"), so we have to substitute "arm" with -thumb-mode and "thumb" with +thumb-mode. Reviewers: echristo, pcc, kristof.beyls Reviewed By: echristo Subscribers: ahatanak, aemerson, javed.absar, kristof.beyls, cfe-commits Differential Revision: https://reviews.llvm.org/D33721 Added: cfe/trunk/test/CodeGen/arm-target-attr.c Modified: cfe/trunk/lib/Basic/Targets.cpp Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=304781&r1=304780&r2=304781&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Tue Jun 6 04:26:15 2017 @@ -5438,7 +5438,17 @@ public: if (Feature[0] == '+') Features[Feature.drop_front(1)] = true; -return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec); +// Convert user-provided arm and thumb GNU target attributes to +// [-|+]thumb-mode target features respectively. +std::vector UpdatedFeaturesVec(FeaturesVec); +for (auto &Feature : UpdatedFeaturesVec) { + if (Feature.compare("+arm") == 0) +Feature = "-thumb-mode"; + else if (Feature.compare("+thumb") == 0) +Feature = "+thumb-mode"; +} + +return TargetInfo::initFeatureMap(Features, Diags, CPU, UpdatedFeaturesVec); } bool handleTargetFeatures(std::vector &Features, Added: cfe/trunk/test/CodeGen/arm-target-attr.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-target-attr.c?rev=304781&view=auto == --- cfe/trunk/test/CodeGen/arm-target-attr.c (added) +++ cfe/trunk/test/CodeGen/arm-target-attr.c Tue Jun 6 04:26:15 2017 @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -triple thumb-apple-darwin -emit-llvm -o - %s | FileCheck --check-prefix CHECKPOS %s +// RUN: %clang_cc1 -triple thumb-apple-darwin -emit-llvm -o - %s | FileCheck --check-prefix CHECKNEG %s +// RUN: %clang_cc1 -triple arm-apple-darwin -emit-llvm -o - %s | FileCheck --check-prefix CHECKPOS %s +// RUN: %clang_cc1 -triple arm-apple-darwin -emit-llvm -o - %s | FileCheck --check-prefix CHECKNEG %s + +__attribute__((target("arm"))) void test_target_arm() { + // CHECKPOS: define void @test_target_arm() [[ARM_ATTRS:#[0-9]+]] + // CHECKNEG: define void @test_target_arm() [[ARM_ATTRS:#[0-9]+]] +} + +__attribute__((target("thumb"))) void test_target_thumb() { + // CHECKPOS: define void @test_target_thumb() [[THUMB_ATTRS:#[0-9]+]] + // CHECKNEG: define void @test_target_thumb() [[THUMB_ATTRS:#[0-9]+]] +} + +// CHECKPOS: attributes [[ARM_ATTRS]] = { {{.*}} "target-features"="{{.*}}-thumb-mode{{.*}}" +// CHECKPOS: attributes [[THUMB_ATTRS]] = { {{.*}} "target-features"="{{.*}}+thumb-mode{{.*}}" +// CHECKNEG-NOT: attributes [[ARM_ATTRS]] = { {{.*}} "target-features"="{{.*}}+thumb-mode{{.*}}" +// CHECKNEG-NOT: attributes [[THUMB_ATTRS]] = { {{.*}} "target-features"="{{.*}}-thumb-mode{{.*}}" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33930: Do not pick up by default the LLVM style if passing -format
v.g.vassilev created this revision. This adds a new flag `-style` which is passed to `clang-apply-replacements` and defaults to `file` meaning it would pick up the closest `.clang-format` file in tree. Repository: rL LLVM https://reviews.llvm.org/D33930 Files: clang-tidy/tool/run-clang-tidy.py Index: clang-tidy/tool/run-clang-tidy.py === --- clang-tidy/tool/run-clang-tidy.py +++ clang-tidy/tool/run-clang-tidy.py @@ -105,6 +105,8 @@ invocation = [args.clang_apply_replacements_binary] if args.format: invocation.append('-format') + if args.style: +invocation.append('-style=' + args.style) invocation.append(tmpdir) subprocess.call(invocation) @@ -148,6 +150,8 @@ parser.add_argument('-fix', action='store_true', help='apply fix-its') parser.add_argument('-format', action='store_true', help='Reformat code ' 'after applying fixes') + parser.add_argument('-style', default=['file'], help='The style of reformat ' + 'code after applying fixes') parser.add_argument('-p', dest='build_path', help='Path used to read a compile command database.') parser.add_argument('-extra-arg', dest='extra_arg', Index: clang-tidy/tool/run-clang-tidy.py === --- clang-tidy/tool/run-clang-tidy.py +++ clang-tidy/tool/run-clang-tidy.py @@ -105,6 +105,8 @@ invocation = [args.clang_apply_replacements_binary] if args.format: invocation.append('-format') + if args.style: +invocation.append('-style=' + args.style) invocation.append(tmpdir) subprocess.call(invocation) @@ -148,6 +150,8 @@ parser.add_argument('-fix', action='store_true', help='apply fix-its') parser.add_argument('-format', action='store_true', help='Reformat code ' 'after applying fixes') + parser.add_argument('-style', default=['file'], help='The style of reformat ' + 'code after applying fixes') parser.add_argument('-p', dest='build_path', help='Path used to read a compile command database.') parser.add_argument('-extra-arg', dest='extra_arg', ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33644: Add default values for function parameter chunks
yvvan added a comment. Waiting for review... https://reviews.llvm.org/D33644 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33493: Speed up preamble loading, reduce global completion cache calls
yvvan updated this revision to Diff 101533. yvvan added a comment. Remove global completion cache part because it's probably not always valid. https://reviews.llvm.org/D33493 Files: include/clang/Frontend/ASTUnit.h lib/Frontend/ASTUnit.cpp Index: lib/Frontend/ASTUnit.cpp === --- lib/Frontend/ASTUnit.cpp +++ lib/Frontend/ASTUnit.cpp @@ -1148,6 +1148,8 @@ if (SavedMainFileBuffer) TranslateStoredDiagnostics(getFileManager(), getSourceManager(), PreambleDiagnostics, StoredDiagnostics); + else +SrcLocCache.clear(); if (!Act->Execute()) goto error; @@ -2579,20 +2581,25 @@ SmallVector Result; Result.reserve(Diags.size()); - const FileEntry *PreviousFE = nullptr; - FileID FID; + for (const StandaloneDiagnostic &SD : Diags) { // Rebuild the StoredDiagnostic. if (SD.Filename.empty()) continue; const FileEntry *FE = FileMgr.getFile(SD.Filename); if (!FE) continue; -if (FE != PreviousFE) { +FileID FID; +SourceLocation FileLoc; +auto ItFileID = SrcLocCache.find(SD.Filename); +if (ItFileID == SrcLocCache.end()) { FID = SrcMgr.translateFile(FE); - PreviousFE = FE; + FileLoc = SrcMgr.getLocForStartOfFile(FID); + SrcLocCache.insert(std::make_pair(SD.Filename, FileLoc)); +} else { + FileLoc = ItFileID->second; } -SourceLocation FileLoc = SrcMgr.getLocForStartOfFile(FID); + if (FileLoc.isInvalid()) continue; SourceLocation L = FileLoc.getLocWithOffset(SD.LocOffset); Index: include/clang/Frontend/ASTUnit.h === --- include/clang/Frontend/ASTUnit.h +++ include/clang/Frontend/ASTUnit.h @@ -185,6 +185,12 @@ /// some number of calls. unsigned PreambleRebuildCounter; + /// \brief Cache pairs "filename - source location" + /// + /// This cache is used when loading preambule to increase performance + /// of that loading + std::map SrcLocCache; + public: class PreambleData { const FileEntry *File; Index: lib/Frontend/ASTUnit.cpp === --- lib/Frontend/ASTUnit.cpp +++ lib/Frontend/ASTUnit.cpp @@ -1148,6 +1148,8 @@ if (SavedMainFileBuffer) TranslateStoredDiagnostics(getFileManager(), getSourceManager(), PreambleDiagnostics, StoredDiagnostics); + else +SrcLocCache.clear(); if (!Act->Execute()) goto error; @@ -2579,20 +2581,25 @@ SmallVector Result; Result.reserve(Diags.size()); - const FileEntry *PreviousFE = nullptr; - FileID FID; + for (const StandaloneDiagnostic &SD : Diags) { // Rebuild the StoredDiagnostic. if (SD.Filename.empty()) continue; const FileEntry *FE = FileMgr.getFile(SD.Filename); if (!FE) continue; -if (FE != PreviousFE) { +FileID FID; +SourceLocation FileLoc; +auto ItFileID = SrcLocCache.find(SD.Filename); +if (ItFileID == SrcLocCache.end()) { FID = SrcMgr.translateFile(FE); - PreviousFE = FE; + FileLoc = SrcMgr.getLocForStartOfFile(FID); + SrcLocCache.insert(std::make_pair(SD.Filename, FileLoc)); +} else { + FileLoc = ItFileID->second; } -SourceLocation FileLoc = SrcMgr.getLocForStartOfFile(FID); + if (FileLoc.isInvalid()) continue; SourceLocation L = FileLoc.getLocWithOffset(SD.LocOffset); Index: include/clang/Frontend/ASTUnit.h === --- include/clang/Frontend/ASTUnit.h +++ include/clang/Frontend/ASTUnit.h @@ -185,6 +185,12 @@ /// some number of calls. unsigned PreambleRebuildCounter; + /// \brief Cache pairs "filename - source location" + /// + /// This cache is used when loading preambule to increase performance + /// of that loading + std::map SrcLocCache; + public: class PreambleData { const FileEntry *File; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33932: [clang-format] Add support for case-insensitive header matching and use it to improve support for LLVM-style include sorting.
chandlerc created this revision. Herald added subscribers: mcrosier, sanjoy, klimek. This really is a collection of improvements to the rules for LLVM include sorting: - We have gmock headers now, so it adds support for those to one of the categories. - LLVM does use 'FooTest.cpp' files to test 'Foo.h' so it adds that suffix for finding a main header. - At times the test file's case may not match the header file's case, so adds support for case-insensitive regex matching of these things. With this set of changes, I can't spot any misbehaviors when re-sorting all of LLVM's unittest '#include' lines. Note that I don't know the first thing about testing clang-format, so please feel free to tell me what all I need to be doing here. https://reviews.llvm.org/D33932 Files: include/clang/Format/Format.h lib/Format/Format.cpp unittests/Format/SortIncludesTest.cpp Index: unittests/Format/SortIncludesTest.cpp === --- unittests/Format/SortIncludesTest.cpp +++ unittests/Format/SortIncludesTest.cpp @@ -264,6 +264,24 @@ "#include \"c.h\"\n" "#include \"llvm/a.h\"\n", "a.cc")); + + // Support case-sensitive and case insensitive matching. + Style.IncludeRegexCaseInsensitive = false; + EXPECT_EQ("#include \"b.h\"\n" +"#include \"c.h\"\n" +"#include \"llvm/A.h\"\n", +sort("#include \"c.h\"\n" + "#include \"b.h\"\n" + "#include \"llvm/A.h\"\n", + "a_TEST.cc")); + Style.IncludeRegexCaseInsensitive = true; + EXPECT_EQ("#include \"llvm/A.h\"\n" +"#include \"b.h\"\n" +"#include \"c.h\"\n", +sort("#include \"c.h\"\n" + "#include \"b.h\"\n" + "#include \"llvm/A.h\"\n", + "a_TEST.cc")); } TEST_F(SortIncludesTest, NegativePriorities) { Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -346,6 +346,8 @@ IO.mapOptional("ForEachMacros", Style.ForEachMacros); IO.mapOptional("IncludeCategories", Style.IncludeCategories); IO.mapOptional("IncludeIsMainRegex", Style.IncludeIsMainRegex); +IO.mapOptional("IncludeRegexCaseInsensitive", + Style.IncludeRegexCaseInsensitive); IO.mapOptional("IndentCaseLabels", Style.IndentCaseLabels); IO.mapOptional("IndentWidth", Style.IndentWidth); IO.mapOptional("IndentWrappedFunctionNames", @@ -572,9 +574,10 @@ LLVMStyle.ForEachMacros.push_back("Q_FOREACH"); LLVMStyle.ForEachMacros.push_back("BOOST_FOREACH"); LLVMStyle.IncludeCategories = {{"^\"(llvm|llvm-c|clang|clang-c)/", 2}, - {"^(<|\"(gtest|isl|json)/)", 3}, + {"^(<|\"(gtest|gmock|isl|json)/)", 3}, {".*", 1}}; - LLVMStyle.IncludeIsMainRegex = "$"; + LLVMStyle.IncludeIsMainRegex = "(Test)?$"; + LLVMStyle.IncludeRegexCaseInsensitive = true; LLVMStyle.IndentCaseLabels = false; LLVMStyle.IndentWrappedFunctionNames = false; LLVMStyle.IndentWidth = 2; @@ -1400,7 +1403,10 @@ : Style(Style), FileName(FileName) { FileStem = llvm::sys::path::stem(FileName); for (const auto &Category : Style.IncludeCategories) - CategoryRegexs.emplace_back(Category.Regex); + CategoryRegexs.emplace_back(Category.Regex, + Style.IncludeRegexCaseInsensitive + ? llvm::Regex::IgnoreCase + : llvm::Regex::NoFlags); IsMainFile = FileName.endswith(".c") || FileName.endswith(".cc") || FileName.endswith(".cpp") || FileName.endswith(".c++") || FileName.endswith(".cxx") || FileName.endswith(".m") || @@ -1428,9 +1434,13 @@ return false; StringRef HeaderStem = llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(1)); -if (FileStem.startswith(HeaderStem)) { +if (FileStem.startswith(HeaderStem) || +(Style.IncludeRegexCaseInsensitive && + FileStem.startswith_lower(HeaderStem))) { llvm::Regex MainIncludeRegex( - (HeaderStem + Style.IncludeIsMainRegex).str()); + (HeaderStem + Style.IncludeIsMainRegex).str(), + Style.IncludeRegexCaseInsensitive ? llvm::Regex::IgnoreCase +: llvm::Regex::NoFlags); if (MainIncludeRegex.match(FileStem)) return true; } Index: include/clang/Format/Format.h === --- include/clang/Format/Format.h +++ include/clang/Format/Format.h @@ -914,7 +914,7 @@ /// IncludeCategories: /// - Regex: '^"(llvm|llvm-c|clang|clang-c)/' /// Priority:2 - /// - Regex: '^(<|"(gtest|isl|json)/)' +
[PATCH] D33875: PR27037: Use correct CVR qualifier on an upcast on method pointer call
tzik updated this revision to Diff 101536. tzik added a comment. Cover indirect case and non-CVR qualifiers https://reviews.llvm.org/D33875 Files: lib/Sema/SemaExprCXX.cpp test/SemaCXX/PR27037.cpp Index: test/SemaCXX/PR27037.cpp === --- /dev/null +++ test/SemaCXX/PR27037.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +struct A { + void f(); +}; + +struct B : A {}; + +void m() { + const B b; + (b.*&B::f)(); // expected-error{{drops 'const' qualifier}} + ((&b)->*&B::f)(); // expected-error{{drops 'const' qualifier}} +} Index: lib/Sema/SemaExprCXX.cpp === --- lib/Sema/SemaExprCXX.cpp +++ lib/Sema/SemaExprCXX.cpp @@ -5104,7 +5104,9 @@ return QualType(); // Cast LHS to type of use. -QualType UseType = isIndirect ? Context.getPointerType(Class) : Class; +QualType UseType = Context.getQualifiedType(Class, LHSType.getQualifiers()); +if (isIndirect) + UseType = Context.getPointerType(UseType); ExprValueKind VK = isIndirect ? VK_RValue : LHS.get()->getValueKind(); LHS = ImpCastExprToType(LHS.get(), UseType, CK_DerivedToBase, VK, &BasePath); Index: test/SemaCXX/PR27037.cpp === --- /dev/null +++ test/SemaCXX/PR27037.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +struct A { + void f(); +}; + +struct B : A {}; + +void m() { + const B b; + (b.*&B::f)(); // expected-error{{drops 'const' qualifier}} + ((&b)->*&B::f)(); // expected-error{{drops 'const' qualifier}} +} Index: lib/Sema/SemaExprCXX.cpp === --- lib/Sema/SemaExprCXX.cpp +++ lib/Sema/SemaExprCXX.cpp @@ -5104,7 +5104,9 @@ return QualType(); // Cast LHS to type of use. -QualType UseType = isIndirect ? Context.getPointerType(Class) : Class; +QualType UseType = Context.getQualifiedType(Class, LHSType.getQualifiers()); +if (isIndirect) + UseType = Context.getPointerType(UseType); ExprValueKind VK = isIndirect ? VK_RValue : LHS.get()->getValueKind(); LHS = ImpCastExprToType(LHS.get(), UseType, CK_DerivedToBase, VK, &BasePath); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33102: [clang] Implement -Wcast-qual for C++
lebedev.ri added a comment. In https://reviews.llvm.org/D33102#773296, @dblaikie wrote: > I still feel like that's more testing than would be ideal (does the context > of the cast matter? Wether it's dereferenced, a struct member access, > assigned, initialized, etc - it doesn't look like it from the code, etc). Looking at the `CastsAwayConstness()` function in lib/Sema/SemaCast.cpp: https://github.com/llvm-mirror/clang/blob/432ed0e4a6d58f7dda8992a167aad43bc91f76c6/lib/Sema/SemaCast.cpp#L505-L510 You can see that it asserts that the pointer is one of three types. So i think it it is best to have maybe slightly overlapping test coverage here, rather than be surprised one day that such trivial cases no longer warn... > But sure. Could you also (manually, I guess) confirm that this matches GCC's > cast-qual behavior (insofar as the warning fires in the same situations). If > there are any deviations, let's chat about them. Sure. 1. Gcc produces the same //count// of the warnings: $ pwd llvm/tools/clang/test $ grep -o "expected-warning" Sema/warn-cast-qual.c | wc -l 14 $ gcc -x c -fsyntax-only -Wcast-qual -c Sema/warn-cast-qual.c 2>&1 | grep ": warning: " | wc -l 14 $ gcc -x c++ -fsyntax-only -Wcast-qual -c Sema/warn-cast-qual.c 2>&1 | grep ": warning: " | wc -l 14 $ grep -o "expected-warning" SemaCXX/warn-cast-qual.cpp | wc -l 39 $ gcc -x c++ -fsyntax-only -Wcast-qual -c SemaCXX/warn-cast-qual.cpp 2>&1 | grep ": warning: " | wc -l 39 2. I'm not quite sure how to non-manually compare the warnings, so i'll just show the gcc output on these three cases. Since the clang warnings are appended as comments at the end of the each line that should warn, visual comparison is possible: 2.1. $ gcc -x c -fsyntax-only -Wcast-qual -c Sema/warn-cast-qual.c Sema/warn-cast-qual.c: In function ‘foo’: Sema/warn-cast-qual.c:9:13: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] char *y = (char *)ptr; // expected-warning {{cast from 'const char *' to 'char *' drops const qualifier}} ^ Sema/warn-cast-qual.c:10:15: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] char **y1 = (char **)ptrptr; // expected-warning {{cast from 'const char *const' to 'char *' drops const qualifier}} ^ Sema/warn-cast-qual.c:11:21: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] const char **y2 = (const char **)ptrptr; // expected-warning {{cast from 'const char *const *' to 'const char **' drops const qualifier}} ^ Sema/warn-cast-qual.c:14:14: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] char *z1 = (char *)(const void *)ptr; // expected-warning {{cast from 'const void *' to 'char *' drops const qualifier}} ^ Sema/warn-cast-qual.c:17:16: warning: cast discards ‘volatile’ qualifier from pointer target type [-Wcast-qual] char *vol2 = (char *)vol; // expected-warning {{cast from 'volatile char *' to 'char *' drops volatile qualifier}} ^ Sema/warn-cast-qual.c:19:17: warning: cast discards ‘const volatile’ qualifier from pointer target type [-Wcast-qual] char *volc2 = (char *)volc; // expected-warning {{cast from 'const volatile char *' to 'char *' drops const and volatile qualifiers}} ^ Sema/warn-cast-qual.c:22:28: warning: to be safe all intermediate pointers in cast from ‘int **’ to ‘const int **’ must be ‘const’ qualified [-Wcast-qual] const int **intptrptrc = (const int **)intptrptr; // expected-warning {{cast from 'int **' to 'const int **' must have all intermediate pointers const qualified}} ^ Sema/warn-cast-qual.c:23:31: warning: to be safe all intermediate pointers in cast from ‘int **’ to ‘volatile int **’ must be ‘const’ qualified [-Wcast-qual] volatile int **intptrptrv = (volatile int **)intptrptr; // expected-warning {{cast from 'int **' to 'volatile int **' must have all intermediate pointers const qualified}} ^ Sema/warn-cast-qual.c:29:23: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] char **charptrptr = (char **)charptrptrc; // expected-warning {{cast from 'const char *' to 'char *' drops const qualifier}} ^ Sema/warn-cast-qual.c:32:19: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] char *charptr = (char *)constcharptr; // expected-warning {{cast from 'const char *' to 'char *' drops const qualifier}} ^ Sema/warn-cast-qual.c:33:31: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] const char *constcharptr2 = (char *)constcharptr; // expected-warning {{cast from 'const char *' to 'char *' drops const qualifier}} ^ Sema/warn-ca
[PATCH] D33102: [clang] Implement -Wcast-qual for C++
lebedev.ri added a comment. (tested with: gcc version 6.3.0 20170516 (Debian 6.3.0-18) ```) Repository: rL LLVM https://reviews.llvm.org/D33102 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33875: PR27037: Use correct CVR qualifier on an upcast on method pointer call
tzik marked an inline comment as done. tzik added inline comments. Comment at: lib/Sema/SemaExprCXX.cpp:5108 QualType UseType = isIndirect ? Context.getPointerType(Class) : Class; +UseType = UseType.withCVRQualifiers(LHS.get()->getType().getCVRQualifiers()); ExprValueKind VK = isIndirect ? VK_RValue : LHS.get()->getValueKind(); rsmith wrote: > In the "indirect" case, the cv-qualifiers should be taken from the pointee > type of the LHS and applied to the pointee type of UseType. I believe this > patch will not be enough to cause us to reject the indirect version of your > testcase: > > ``` > ((&b)->*&B::f)(); // expected-error{{drops 'const' qualifier}} > ``` > > Moreover, we should be preserving all qualifiers, not just cvr-qualifiers; > for example, this should also preserve the address space. Make sense. OK, I updated the CL to cover that cases. Could you take another look? https://reviews.llvm.org/D33875 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33930: Do not pick up by default the LLVM style if passing -format
v.g.vassilev updated this revision to Diff 101540. v.g.vassilev added a comment. Use string. https://reviews.llvm.org/D33930 Files: clang-tidy/tool/run-clang-tidy.py Index: clang-tidy/tool/run-clang-tidy.py === --- clang-tidy/tool/run-clang-tidy.py +++ clang-tidy/tool/run-clang-tidy.py @@ -105,6 +105,8 @@ invocation = [args.clang_apply_replacements_binary] if args.format: invocation.append('-format') + if args.style: +invocation.append('-style=' + args.style) invocation.append(tmpdir) subprocess.call(invocation) @@ -148,6 +150,8 @@ parser.add_argument('-fix', action='store_true', help='apply fix-its') parser.add_argument('-format', action='store_true', help='Reformat code ' 'after applying fixes') + parser.add_argument('-style', default='file', help='The style of reformat ' + 'code after applying fixes') parser.add_argument('-p', dest='build_path', help='Path used to read a compile command database.') parser.add_argument('-extra-arg', dest='extra_arg', Index: clang-tidy/tool/run-clang-tidy.py === --- clang-tidy/tool/run-clang-tidy.py +++ clang-tidy/tool/run-clang-tidy.py @@ -105,6 +105,8 @@ invocation = [args.clang_apply_replacements_binary] if args.format: invocation.append('-format') + if args.style: +invocation.append('-style=' + args.style) invocation.append(tmpdir) subprocess.call(invocation) @@ -148,6 +150,8 @@ parser.add_argument('-fix', action='store_true', help='apply fix-its') parser.add_argument('-format', action='store_true', help='Reformat code ' 'after applying fixes') + parser.add_argument('-style', default='file', help='The style of reformat ' + 'code after applying fixes') parser.add_argument('-p', dest='build_path', help='Path used to read a compile command database.') parser.add_argument('-extra-arg', dest='extra_arg', ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33932: [clang-format] Add support for case-insensitive header matching and use it to improve support for LLVM-style include sorting.
ioeric accepted this revision. ioeric added a comment. This revision is now accepted and ready to land. Lgtm. Comment at: lib/Format/Format.cpp:1406 for (const auto &Category : Style.IncludeCategories) - CategoryRegexs.emplace_back(Category.Regex); + CategoryRegexs.emplace_back(Category.Regex, + Style.IncludeRegexCaseInsensitive Also add tests for these non-main categories? https://reviews.llvm.org/D33932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31972: Do not force the frame pointer by default for ARM EABI
chrib updated this revision to Diff 101543. chrib added a comment. Herald added a subscriber: kristof.beyls. - Merge branch 'master' of ssh://codex.cro.st.com/llvm-arm/clang - Don't need a frame pointer for EABIHF also (AAPCS) https://reviews.llvm.org/D31972 Files: lib/Driver/ToolChains/Clang.cpp test/Driver/frame-pointer.c Index: test/Driver/frame-pointer.c === --- test/Driver/frame-pointer.c +++ test/Driver/frame-pointer.c @@ -33,6 +33,9 @@ // RUN: %clang -target mips64el-linux-gnu -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s // RUN: %clang -target mips64el-linux-gnu -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s +// RUN: %clang -target arm-none-eabi -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s +// RUN: %clang -target arm-none-eabi -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s + // CHECK0-32: -mdisable-fp-elim // CHECK1-32-NOT: -mdisable-fp-elim // CHECK2-32-NOT: -mdisable-fp-elim Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -566,6 +566,18 @@ } } + if (Triple.getEnvironment() == llvm::Triple::EABI || + Triple.getEnvironment() == llvm::Triple::EABIHF) { +// Don't use a frame pointer on AAPCS when optimizing. +switch (Triple.getArch()) { +case llvm::Triple::arm: +case llvm::Triple::thumb: + return !areOptimizationsEnabled(Args); +default: + return true; +} + } + return true; } Index: test/Driver/frame-pointer.c === --- test/Driver/frame-pointer.c +++ test/Driver/frame-pointer.c @@ -33,6 +33,9 @@ // RUN: %clang -target mips64el-linux-gnu -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s // RUN: %clang -target mips64el-linux-gnu -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s +// RUN: %clang -target arm-none-eabi -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s +// RUN: %clang -target arm-none-eabi -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s + // CHECK0-32: -mdisable-fp-elim // CHECK1-32-NOT: -mdisable-fp-elim // CHECK2-32-NOT: -mdisable-fp-elim Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -566,6 +566,18 @@ } } + if (Triple.getEnvironment() == llvm::Triple::EABI || + Triple.getEnvironment() == llvm::Triple::EABIHF) { +// Don't use a frame pointer on AAPCS when optimizing. +switch (Triple.getArch()) { +case llvm::Triple::arm: +case llvm::Triple::thumb: + return !areOptimizationsEnabled(Args); +default: + return true; +} + } + return true; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33932: [clang-format] Add support for case-insensitive header matching and use it to improve support for LLVM-style include sorting.
chandlerc updated this revision to Diff 101544. chandlerc added a comment. Add test coverage for the case-insensitive category logic. https://reviews.llvm.org/D33932 Files: include/clang/Format/Format.h lib/Format/Format.cpp unittests/Format/SortIncludesTest.cpp Index: unittests/Format/SortIncludesTest.cpp === --- unittests/Format/SortIncludesTest.cpp +++ unittests/Format/SortIncludesTest.cpp @@ -264,6 +264,38 @@ "#include \"c.h\"\n" "#include \"llvm/a.h\"\n", "a.cc")); + + // Support case-sensitive and case insensitive matching. + Style.IncludeRegexCaseInsensitive = false; + EXPECT_EQ("#include \"GTest/GTest.h\"\n" +"#include \"LLVM/z.h\"\n" +"#include \"b.h\"\n" +"#include \"c.h\"\n" +"#include \"llvm/A.h\"\n" +"#include \"gmock/gmock.h\"\n", +sort("#include \"c.h\"\n" + "#include \"b.h\"\n" + "#include \"GTest/GTest.h\"\n" + "#include \"llvm/A.h\"\n" + "#include \"gmock/gmock.h\"\n" + "#include \"LLVM/z.h\"\n", + "a_TEST.cc")); + Style.IncludeRegexCaseInsensitive = true; + EXPECT_EQ("#include \"llvm/A.h\"\n" +"#include \"b.h\"\n" +"#include \"c.h\"\n" +"#include \"LLVM/z.h\"\n" +"#include \"llvm/X.h\"\n" +"#include \"GTest/GTest.h\"\n" +"#include \"gmock/gmock.h\"\n", +sort("#include \"c.h\"\n" + "#include \"b.h\"\n" + "#include \"GTest/GTest.h\"\n" + "#include \"llvm/A.h\"\n" + "#include \"gmock/gmock.h\"\n" + "#include \"llvm/X.h\"\n" + "#include \"LLVM/z.h\"\n", + "a_TEST.cc")); } TEST_F(SortIncludesTest, NegativePriorities) { Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -346,6 +346,8 @@ IO.mapOptional("ForEachMacros", Style.ForEachMacros); IO.mapOptional("IncludeCategories", Style.IncludeCategories); IO.mapOptional("IncludeIsMainRegex", Style.IncludeIsMainRegex); +IO.mapOptional("IncludeRegexCaseInsensitive", + Style.IncludeRegexCaseInsensitive); IO.mapOptional("IndentCaseLabels", Style.IndentCaseLabels); IO.mapOptional("IndentWidth", Style.IndentWidth); IO.mapOptional("IndentWrappedFunctionNames", @@ -572,9 +574,10 @@ LLVMStyle.ForEachMacros.push_back("Q_FOREACH"); LLVMStyle.ForEachMacros.push_back("BOOST_FOREACH"); LLVMStyle.IncludeCategories = {{"^\"(llvm|llvm-c|clang|clang-c)/", 2}, - {"^(<|\"(gtest|isl|json)/)", 3}, + {"^(<|\"(gtest|gmock|isl|json)/)", 3}, {".*", 1}}; - LLVMStyle.IncludeIsMainRegex = "$"; + LLVMStyle.IncludeIsMainRegex = "(Test)?$"; + LLVMStyle.IncludeRegexCaseInsensitive = true; LLVMStyle.IndentCaseLabels = false; LLVMStyle.IndentWrappedFunctionNames = false; LLVMStyle.IndentWidth = 2; @@ -1400,7 +1403,10 @@ : Style(Style), FileName(FileName) { FileStem = llvm::sys::path::stem(FileName); for (const auto &Category : Style.IncludeCategories) - CategoryRegexs.emplace_back(Category.Regex); + CategoryRegexs.emplace_back(Category.Regex, + Style.IncludeRegexCaseInsensitive + ? llvm::Regex::IgnoreCase + : llvm::Regex::NoFlags); IsMainFile = FileName.endswith(".c") || FileName.endswith(".cc") || FileName.endswith(".cpp") || FileName.endswith(".c++") || FileName.endswith(".cxx") || FileName.endswith(".m") || @@ -1428,9 +1434,13 @@ return false; StringRef HeaderStem = llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(1)); -if (FileStem.startswith(HeaderStem)) { +if (FileStem.startswith(HeaderStem) || +(Style.IncludeRegexCaseInsensitive && + FileStem.startswith_lower(HeaderStem))) { llvm::Regex MainIncludeRegex( - (HeaderStem + Style.IncludeIsMainRegex).str()); + (HeaderStem + Style.IncludeIsMainRegex).str(), + Style.IncludeRegexCaseInsensitive ? llvm::Regex::IgnoreCase +: llvm::Regex::NoFlags); if (MainIncludeRegex.match(FileStem)) return true; } Index: include/clang/Format/Format.h === --- include/clang/Format/Format.h +++ include/clang/Format/Format.h @@ -914,7 +914,7 @@ /// IncludeCategories: /// - Regex: '^"(llvm|llvm-c|clang|clang-c)/' /// Priority:2 - /// - Regex: '^(<|"(gtest|isl
[PATCH] D33932: [clang-format] Add support for case-insensitive header matching and use it to improve support for LLVM-style include sorting.
chandlerc marked an inline comment as done. chandlerc added a comment. Added more tests, PTAL? https://reviews.llvm.org/D33932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33401: [mips] Add runtime options to enable/disable generation of madd.fmt, msub.fmt
sdardis accepted this revision. sdardis added a comment. This revision is now accepted and ready to land. The new define also requires a test in test/Preprocessor/init.c - test that by default the new define isn't present, and in some case, when supplied with the -mno-madd4 that it is present. LGTM with that change. https://reviews.llvm.org/D33401 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31972: Do not force the frame pointer by default for ARM EABI
chrib added inline comments. Comment at: lib/Driver/ToolChains/Clang.cpp:569 + if (Triple.getEnvironment() == llvm::Triple::EABI) { +switch (Triple.getArch()) { efriedma wrote: > chrib wrote: > > efriedma wrote: > > > Specifically checking for "llvm::Triple::EABI" is suspicious... what are > > > you trying to distinguish? > > I'm targeting the AAPCS for bare toolsets, (we could also test EABIHF by > > the way) > > > > I'm not sure about the other ABIs (such as llvm::Triple::OpenBSD) so it is > > probably conservative and stick to what I can test. Do you think this > > pertains to more, for instance to AAPCS-LINUX, without breaking anything ? > > > So... something like isTargetAEABI() in ARMSubtarget.h? > > Please clarify the comment, and add a check for EABIHF. yes, (although I'm not sure for Darwin). The closest check for AAPCS I've found is Clang::AddARMTargetArgs. I've updated the patch to check EABIHF as well. https://reviews.llvm.org/D31972 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33589: clang-format: consider not splitting tokens in optimization
Typz added a comment. In https://reviews.llvm.org/D33589#769893, @krasimir wrote: > I think that what you're trying to solve is not practically that important, > is unlikely to improve the handling of comments, and will add a lot of > complexity. Not sure the 'approach' I have in this patch is nice, but it does solve my problem: it is quite simple, and avoids reflowing (and actually, sometimes breaking, since comments are not so structured...) the comments. e.g. if I have a line followed by a relatively long comment, with my patch it will really consider the penaltys properly, and not split a line which is slightly longer [with ColumnLimit=30] : int a; //< a very long comment vs int a; //< a very long //< comment > From a usability perspective, I think that people are happy enough when their > comments don't exceed the line limit. I personally wouldn't want the opposite > to happen. I've even seen style guides that have 80 columns limit for > comments and 100 for code. That is a matter of taste and coding style: I prefer overflowing by a few characters instead of introducing an extra line... I see no reason to allow PenaltyExcessCharacter > Comments are treated in a somewhat ad-hoc style in clang-format, which is > because they are inherently free text and don't have a specific format. > People just expect comments to be handled quite differently than source code. > There are at least three separate parts in clang-format that make up the > formatting of comments: the normal parsing and optimization pipeline, the > BreakableLineCommentSection / BreakableBlockComment classes that are > responsible for breaking and reflowing inside comment sections, and the > consecutive trailing comment alignment in the WhitespaceManager. This patch > takes into account the first aspect but not the consequences for the other > aspects: for example it allows for the first line comment token in a > multiline line comment section to get out of the column limit, but will > reflow the rest of the lines. A WhitespaceManager-related issue is that > because a trailing line comment for some declaration might not get split, it > might not be aligned with the surrounding trailing line comments, which I > think is a less desirable effect. Not sure I understand the case you are speaking about, can you please provide an exemple? (on a separate topic, I could indeed not find a penalty for breaking alignment; I think the optimizer should account for that as well... any hint on where to look for adding this?) > Optimizing the layout in comment sections by using the optimizing formatter > sounds good, but because comments mostly contain free text that can be > structured in unexpected ways, I think that the ad-hoc approach works better. > Think of not destroying ASCII art and supporting bulleted and numbered lists > for example. We don't really want to leak lots of comment-related formatting > tweaks into the general pipeline itself. Good, one less choice :-) > I see you point that PenaltyBreakComment and PenaltyExcessCharacter are not > taken into account while comment placement, but they are taken into account > at a higher level by treating the whole comment section as a unit. For > example, if you have a long declaration that has multiple potential split > points followed by a long trailing comment section, the penalty induced by > the number of lines that are needed and the number of unbroken characters for > the formatting of the comment section is taken into account while optimizing > the layout of the whole code fragment. If you reduce PenaltyExcessCharacter you see that comments can never overflow: the optimizer will consider splitting the comments or splitting the remaining of the code, but will (currently) not allow the comment to overflow just a bit. > The formatted currently supports somewhat limited version of allowing comment > lines exceeding the column limit, like long hyperlinks for example. I think > that if there are some other examples which are both widespread and super > annoying, we may consider them separately. This patch does not try to address these special cases, and should not change the behavior in this case. https://reviews.llvm.org/D33589 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32480: clang-format: Add CompactNamespaces option
Typz added a comment. So how do I proceed? 1. Keep the CompactNamespace option, and make "compacted" namespaces always add at most one level of indentation 2. Or assume that this can only ever usefully work with the behavior of NI_None and add an additional enum value NI_Compact. And should we limit 'compacting' to namespace which start and end at consecutive lines [e.g. exactly the same conditions as C++17 nested namespaces], or is the current implementation enough [merge all adjacent beginning and all adjacent endings] ? https://reviews.llvm.org/D32480 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33447: clang-format: add option to merge empty function body
Typz added a comment. ping https://reviews.llvm.org/D33447 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33932: [clang-format] Add support for case-insensitive header matching and use it to improve support for LLVM-style include sorting.
ioeric added inline comments. Comment at: unittests/Format/SortIncludesTest.cpp:269 + // Support case-sensitive and case insensitive matching. + Style.IncludeRegexCaseInsensitive = false; + EXPECT_EQ("#include \"GTest/GTest.h\"\n" I think this TEST is only for main header sorting. Could you split tests for other categories into a separate TEST? https://reviews.llvm.org/D33932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33930: Do not pick up by default the LLVM style if passing -format
bkramer accepted this revision. bkramer added a comment. This revision is now accepted and ready to land. Looks good, but I'm wondering if we should also change the default in clang-apply-replacements itself. https://reviews.llvm.org/D33930 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33857: Correctly Indent Nested JavaScript Literals.
mprobst accepted this revision. mprobst added a comment. This revision is now accepted and ready to land. LGTM Repository: rL LLVM https://reviews.llvm.org/D33857 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r304791 - clang-format: [JS] Correctly Indent Nested JavaScript Literals.
Author: mprobst Date: Tue Jun 6 07:38:29 2017 New Revision: 304791 URL: http://llvm.org/viewvc/llvm-project?rev=304791&view=rev Log: clang-format: [JS] Correctly Indent Nested JavaScript Literals. Nested literals are sometimes only indented by 2 spaces, instead of respecting the IndentWidth option. There are existing unit tests (FormatTestJS.ArrayLiterals) that only pass because the style used to test them uses an IndentWidth of 2. This change removes the magic 2 and always uses the IndentWidth. I've added 6 tests. The first 4 of these tests fail before this change, while the last 2 already pass, but were added just to make sure it the change works with all types of braces. Patch originally by Jared Neil, thanks! Differential Revision: https://reviews.llvm.org/D33857 Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp cfe/trunk/unittests/Format/FormatTestJS.cpp Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=304791&r1=304790&r2=304791&view=diff == --- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original) +++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Tue Jun 6 07:38:29 2017 @@ -1036,8 +1036,8 @@ void ContinuationIndenter::moveStatePast State.Stack.back().NestedBlockIndent); if (Current.isOneOf(tok::l_brace, TT_ArrayInitializerLSquare)) { if (Current.opensBlockOrBlockTypeList(Style)) { - NewIndent = State.Stack.back().NestedBlockIndent + Style.IndentWidth; - NewIndent = std::min(State.Column + 2, NewIndent); + NewIndent = Style.IndentWidth + + std::min(State.Column, State.Stack.back().NestedBlockIndent); } else { NewIndent = State.Stack.back().LastSpace + Style.ContinuationIndentWidth; } Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=304791&r1=304790&r2=304791&view=diff == --- cfe/trunk/unittests/Format/FormatTestJS.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Jun 6 07:38:29 2017 @@ -1869,5 +1869,44 @@ TEST_F(FormatTestJS, Exponentiation) { verifyFormat("squared **= 2;"); } +TEST_F(FormatTestJS, NestedLiterals) { + FormatStyle FourSpaces = getGoogleJSStyleWithColumns(15); + FourSpaces.IndentWidth = 4; + verifyFormat("var l = [\n" + "[\n" + "1,\n" + "],\n" + "];", FourSpaces); + verifyFormat("var l = [\n" + "{\n" + "1: 1,\n" + "},\n" + "];", FourSpaces); + verifyFormat("someFunction(\n" + "p1,\n" + "[\n" + "1,\n" + "],\n" + ");", FourSpaces); + verifyFormat("someFunction(\n" + "p1,\n" + "{\n" + "1: 1,\n" + "},\n" + ");", FourSpaces); + verifyFormat("var o = {\n" + "1: 1,\n" + "2: {\n" + "3: 3,\n" + "},\n" + "};", FourSpaces); + verifyFormat("var o = {\n" + "1: 1,\n" + "2: [\n" + "3,\n" + "],\n" + "};", FourSpaces); +} + } // end namespace tooling } // end namespace clang ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33857: Correctly Indent Nested JavaScript Literals.
This revision was automatically updated to reflect the committed changes. Closed by commit rL304791: clang-format: [JS] Correctly Indent Nested JavaScript Literals. (authored by mprobst). Changed prior to commit: https://reviews.llvm.org/D33857?vs=101296&id=101547#toc Repository: rL LLVM https://reviews.llvm.org/D33857 Files: cfe/trunk/lib/Format/ContinuationIndenter.cpp cfe/trunk/unittests/Format/FormatTestJS.cpp Index: cfe/trunk/lib/Format/ContinuationIndenter.cpp === --- cfe/trunk/lib/Format/ContinuationIndenter.cpp +++ cfe/trunk/lib/Format/ContinuationIndenter.cpp @@ -1036,8 +1036,8 @@ State.Stack.back().NestedBlockIndent); if (Current.isOneOf(tok::l_brace, TT_ArrayInitializerLSquare)) { if (Current.opensBlockOrBlockTypeList(Style)) { - NewIndent = State.Stack.back().NestedBlockIndent + Style.IndentWidth; - NewIndent = std::min(State.Column + 2, NewIndent); + NewIndent = Style.IndentWidth + + std::min(State.Column, State.Stack.back().NestedBlockIndent); } else { NewIndent = State.Stack.back().LastSpace + Style.ContinuationIndentWidth; } Index: cfe/trunk/unittests/Format/FormatTestJS.cpp === --- cfe/trunk/unittests/Format/FormatTestJS.cpp +++ cfe/trunk/unittests/Format/FormatTestJS.cpp @@ -1869,5 +1869,44 @@ verifyFormat("squared **= 2;"); } +TEST_F(FormatTestJS, NestedLiterals) { + FormatStyle FourSpaces = getGoogleJSStyleWithColumns(15); + FourSpaces.IndentWidth = 4; + verifyFormat("var l = [\n" + "[\n" + "1,\n" + "],\n" + "];", FourSpaces); + verifyFormat("var l = [\n" + "{\n" + "1: 1,\n" + "},\n" + "];", FourSpaces); + verifyFormat("someFunction(\n" + "p1,\n" + "[\n" + "1,\n" + "],\n" + ");", FourSpaces); + verifyFormat("someFunction(\n" + "p1,\n" + "{\n" + "1: 1,\n" + "},\n" + ");", FourSpaces); + verifyFormat("var o = {\n" + "1: 1,\n" + "2: {\n" + "3: 3,\n" + "},\n" + "};", FourSpaces); + verifyFormat("var o = {\n" + "1: 1,\n" + "2: [\n" + "3,\n" + "],\n" + "};", FourSpaces); +} + } // end namespace tooling } // end namespace clang Index: cfe/trunk/lib/Format/ContinuationIndenter.cpp === --- cfe/trunk/lib/Format/ContinuationIndenter.cpp +++ cfe/trunk/lib/Format/ContinuationIndenter.cpp @@ -1036,8 +1036,8 @@ State.Stack.back().NestedBlockIndent); if (Current.isOneOf(tok::l_brace, TT_ArrayInitializerLSquare)) { if (Current.opensBlockOrBlockTypeList(Style)) { - NewIndent = State.Stack.back().NestedBlockIndent + Style.IndentWidth; - NewIndent = std::min(State.Column + 2, NewIndent); + NewIndent = Style.IndentWidth + + std::min(State.Column, State.Stack.back().NestedBlockIndent); } else { NewIndent = State.Stack.back().LastSpace + Style.ContinuationIndentWidth; } Index: cfe/trunk/unittests/Format/FormatTestJS.cpp === --- cfe/trunk/unittests/Format/FormatTestJS.cpp +++ cfe/trunk/unittests/Format/FormatTestJS.cpp @@ -1869,5 +1869,44 @@ verifyFormat("squared **= 2;"); } +TEST_F(FormatTestJS, NestedLiterals) { + FormatStyle FourSpaces = getGoogleJSStyleWithColumns(15); + FourSpaces.IndentWidth = 4; + verifyFormat("var l = [\n" + "[\n" + "1,\n" + "],\n" + "];", FourSpaces); + verifyFormat("var l = [\n" + "{\n" + "1: 1,\n" + "},\n" + "];", FourSpaces); + verifyFormat("someFunction(\n" + "p1,\n" + "[\n" + "1,\n" + "],\n" + ");", FourSpaces); + verifyFormat("someFunction(\n" + "p1,\n" + "{\n" + "1: 1,\n" + "},\n" + ");", FourSpaces); + verifyFormat("var o = {\n" + "1: 1,\n" + "2: {\n" + "3: 3,\n" + "},\n" + "};", FourSpaces); + verifyFormat("var o = {\n" + "1: 1,\n" + "2: [\n" + "3,\n" + "],\n" + "};", FourSpaces); +} + } // end na
[PATCH] D27918: [analyzer] OStreamChecker
gamesh411 marked 6 inline comments as done. gamesh411 added a comment. Update diff. Comment at: lib/StaticAnalyzer/Checkers/OStreamFormatChecker.cpp:263-282 + mutable IdentifierInfo *II_BasicOstream, *II_Flags, *II_Setf, *II_Unsetf, + *II_Setiosflags, *II_Resetiosflags, *II_Precision, *II_SetPrecision, + *II_BaseField, *II_Hex, *II_Dec, *II_Oct, *II_AdjustField, *II_Left, + *II_Right, *II_Internal, *II_BoolAlpha, *II_NoBoolAlpha, *II_ShowPos, + *II_NoShowPos, *II_ShowBase, *II_NoShowBase, *II_UpperCase, + *II_NoUpperCase, *II_ShowPoint, *II_NoShowPoint, *II_FloatField, + *II_Fixed, *II_Scientific; NoQ wrote: > If you ever want to extend the `CallDescription` class to cover your use > case, please let us know :) > > While most of these aren't functions, the approach used in this class could > be used here as well - making initialization code shorter. I will look at the CallDescription class, and how the checker can benefit. Is it still a problem, that we can not initialize IdentifierInfos during checker construction? If so, how will would a CallDescription implementation solve that? Comment at: lib/StaticAnalyzer/Checkers/OStreamFormatChecker.cpp:387 + +static Optional tryEvaluateAsInt(const Expr *E, ProgramStateRef S, + CheckerContext C) { NoQ wrote: > I think you should use `SimpleSValBuilder::getKnownValue()`. The > `EvaluateAsInt` part doesn't add much because the analyzer's engine should > already be more powerful than that. On the other hand, the > `ConstraintManager::getSymVal()` thing, which is already done in > `SimpleSValBuilder::getKnownValue()`, may be useful. I have tried an implementation of getKnownValue(), and it more terse, and did not handle the cases it should have had to anyway. Comment at: lib/StaticAnalyzer/Checkers/OStreamFormatChecker.cpp:513 + +bool OStreamFormatChecker::evalCall(const CallExpr *CE, +CheckerContext &C) const { NoQ wrote: > One of the practical differences between `checkPostCall` and `evalCall` is > that in the latter you have full control over the function execution, > including invalidations that the call causes. Your code not only sets the > return value, but also removes invalidations that normally happen. Like, > normally when an unknown function is called, it is either inlined and > therefore modeled directly, or destroys all information about any global > variables or heap memory that it might have touched. By implementing > `evalCall`, you are saying that the only effect of calling `operator<<()` on > a `basic_ostream` is returning the first argument lvalue, and nothing else > happens; inlining is suppressed, invalidation is suppressed. > > I'm not sure if it's a good thing. On one hand, this is not entirely true, > because the operator changes the internal state of the stream and maybe of > some global stuff inside the standard library. On the other hand, it is > unlikely to matter in practice, as far as i can see. > > Would it undermine any of your efforts here if you add a manual invalidation > of the stream object and of the `GlobalSystemSpaceRegion` memory space (you > could construct a temporary `CallEvent` and call one of its methods if it > turns out to be easier)? > > I'm not exactly in favor of turning this into `checkPostCall()` because > binding expressions in that callback may cause hard-to-notice conflicts > across multiple checkers. Some checkers may even take the old value before > it's replaced. For `evalCall()` we at least have an assert. > > If you intend to keep the return value as the only effect, there's option of > making a synthesized body in our body farm, which is even better at avoiding > inter-checker conflicts. Body farms were created for that specific purpose, > even though they also have their drawbacks (sometimes `evalCall` is more > flexible than anything we could synthesize, eg. D20811). > > If you have considered all the alternative options mentioned above and > rejected them, could you add a comment explaining why? :) I am not familiar with the BodyFarm approach, however I tried something along the lines of: auto CEvt = ResultEqualsFirstParam->getStateManager().getCallEventManager().getSimpleCall(CE, S, C.getLocationContext()); ProgramStateRef StreamStateInvalidated = CEvt->invalidateRegions(C.blockCount()); It however broke test2 (where the state is set to hex formatting, then, back to dec). Any tips why resetting regions could cause problems? https://reviews.llvm.org/D27918 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27918: [analyzer] OStreamChecker
gamesh411 updated this revision to Diff 101549. gamesh411 marked an inline comment as done. gamesh411 added a comment. Update diff. https://reviews.llvm.org/D27918 Files: include/clang/StaticAnalyzer/Checkers/Checkers.td lib/StaticAnalyzer/Checkers/CMakeLists.txt lib/StaticAnalyzer/Checkers/OStreamFormatChecker.cpp test/Analysis/Inputs/system-header-simulator-cxx-iostream.h test/Analysis/ostream-format.cpp Index: test/Analysis/ostream-format.cpp === --- /dev/null +++ test/Analysis/ostream-format.cpp @@ -0,0 +1,74 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.cplusplus.OStreamFormat -verify -std=c++11 %s + +#include "Inputs/system-header-simulator-cxx-iostream.h" + + +class StreamState { +public: + StreamState(std::ostream &out) + : m_out(out), m_fmt(out.flags()), m_prec(out.precision()) {} + + ~StreamState() { +m_out.precision(m_prec); +m_out.flags(m_fmt); + } + +private: + std::ostream &m_out; + std::ios_base::fmtflags m_fmt; + std::streamsize m_prec; +}; + +void test1(int i) { + std::cout << std::hex << i; +} // expected-warning{{Possibly forgotten ostream format modification in scope}} + +void test2(int i) { std::cout << std::hex << i << std::dec; } // OK. + +void test3(int i) { + std::cout << std::hex << i; + std::cout << std::dec; +} // ok + +void test4(float f) { + std::cout << std::setprecision(2) +<< f; // The stream state is chaged, but not restored. +} // expected-warning{{Possibly forgotten ostream format modification in scope}} + +int test5() { + std::cout.setf(std::ios::hex, + std::ios::basefield); // Set hex as the basefield. + std::cout.setf(std::ios::showbase); // Activating showbase. + std::cout << 100 << '\n'; + std::cout.unsetf(std::ios::showbase); // Deactivating showbase. + std::cout << 100 << '\n'; + return 0; // The stream state is chaged, but not restored. +} // expected-warning{{Possibly forgotten ostream format modification in scope}} + +void test6(std::string &results) { + StreamState ss(std::cout); + std::cout << std::setiosflags(std::ios::fixed) +<< std::setprecision(6); // The stream state is set here. + std::cout << results << std::endl; +} // OK, stream state is recovered here. + +void test7(int i) { + std::cout << std::hex << i; + std::cout.setf(std::ios::dec); +} // OK. + +void test8(float i) { + std::cout << std::setprecision(12) << i; + std::cout.precision(6); +} // OK. + +void test9(float i) { + std::cout.precision(6); + std::cout << std::setprecision(12) << i; +} // expected-warning{{Possibly forgotten ostream format modification in scope}} + +void test10(float i) { + std::cout.precision(12); + std::cout << std::setprecision(6) << i; +} // OK. + Index: test/Analysis/Inputs/system-header-simulator-cxx-iostream.h === --- /dev/null +++ test/Analysis/Inputs/system-header-simulator-cxx-iostream.h @@ -0,0 +1,195 @@ +// Like the compiler, the static analyzer treats some functions differently if +// they come from a system header -- for example, it is assumed that system +// functions do not arbitrarily free() their parameters, and that some bugs +// found in system headers cannot be fixed by the user and should be +// suppressed. +#pragma clang system_header + +namespace std { +typedef unsigned streamsize; + +namespace ios { +int boolalpha; +int dec; +int fixed; +int hex; +int internal; +int left; +int oct; +int right; +int scientific; +int showbase; +int showpoint; +int showpos; +int skipws; +int unitbuf; +int uppercase; +int adjustfield; +int basefield; +int floatfield; +} + +class ios_base { +public: + typedef int fmtflags; + fmtflags m_fmt; + fmtflags flags() const; + fmtflags flags(fmtflags); + fmtflags setf(fmtflags); + fmtflags setf(fmtflags, fmtflags); + void unsetf(fmtflags); + streamsize precision() const; + streamsize precision(streamsize); + streamsize width() const; + streamsize width(streamsize); +}; + +template class basic_ios : public ios_base {}; + +// Simple manipulators. + +ios_base &boolalpha(ios_base &); +ios_base &noboolalpha(ios_base &); +ios_base &showbase(ios_base &); +ios_base &noshowbase(ios_base &); +ios_base &showpoint(ios_base &); +ios_base &noshowpoint(ios_base &); +ios_base &showpos(ios_base &); +ios_base &noshowpos(ios_base &); +ios_base &skipws(ios_base &); +ios_base &noskipws(ios_base &); +ios_base &uppercase(ios_base &); +ios_base &nouppercase(ios_base &); +ios_base &unitbuf(ios_base &); +ios_base &nounitbuf(ios_base &); +ios_base &internal(ios_base &); +ios_base &left(ios_base &); +ios_base &right(ios_base &); +ios_base &dec(ios_base &); +ios_base &hex(ios_base &); +ios_base &oct(ios_base &); +ios_base &fixed(ios_base &); +ios_base &scientific(ios_base &); +ios_base &hexfloat(ios_base &); +ios_base &defaultfloat(ios_base &); + + +template class basic_ostream : public basic_ios { +public: + basic_
[PATCH] D33941: [Driver] Add test to cover case when LSan is not supported
m.ostapenko created this revision. This commit adds a testcase for uncovered code paths in LSan options parsing logic in driver. Repository: rL LLVM https://reviews.llvm.org/D33941 Files: test/Driver/fsanitize.c Index: test/Driver/fsanitize.c === --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -271,6 +271,12 @@ // RUN: %clang -target thumbeb-linux -fsanitize=address,leak -fno-sanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANL-NO-SANA-THUMBEB // CHECK-SANA-SANL-NO-SANA-THUMBEB: "-fsanitize=leak" +// RUN: %clang -target mips-unknown-linux -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-MIPS +// CHECK-SANL-MIPS: unsupported option '-fsanitize=leak' for target 'mips-unknown-linux' + +// RUN: %clang -target powerpc-unknown-linux -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-PPC +// CHECK-SANL-PPC: unsupported option '-fsanitize=leak' for target 'powerpc-unknown-linux' + // RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN // CHECK-MSAN: "-fno-assume-sane-operator-new" // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN Index: test/Driver/fsanitize.c === --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -271,6 +271,12 @@ // RUN: %clang -target thumbeb-linux -fsanitize=address,leak -fno-sanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANL-NO-SANA-THUMBEB // CHECK-SANA-SANL-NO-SANA-THUMBEB: "-fsanitize=leak" +// RUN: %clang -target mips-unknown-linux -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-MIPS +// CHECK-SANL-MIPS: unsupported option '-fsanitize=leak' for target 'mips-unknown-linux' + +// RUN: %clang -target powerpc-unknown-linux -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-PPC +// CHECK-SANL-PPC: unsupported option '-fsanitize=leak' for target 'powerpc-unknown-linux' + // RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN // CHECK-MSAN: "-fno-assume-sane-operator-new" // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33401: [mips] Add runtime options to enable/disable generation of madd.fmt, msub.fmt
smaksimovic updated this revision to Diff 101562. smaksimovic added a comment. Provided define checks, one when the target feature is present, other when the feature isn't provided at all (default). https://reviews.llvm.org/D33401 Files: include/clang/Driver/Options.td lib/Basic/Targets.cpp lib/Driver/ToolChains/Arch/Mips.cpp test/CodeGen/mips-madd4.c test/Preprocessor/init.c Index: test/Preprocessor/init.c === --- test/Preprocessor/init.c +++ test/Preprocessor/init.c @@ -4664,6 +4664,16 @@ // RUN: | FileCheck -match-full-lines -check-prefix MIPS-MSA %s // MIPS-MSA:#define __mips_msa 1 // +// RUN: %clang_cc1 -target-feature +nomadd4 \ +// RUN: -E -dM -triple=mips-none-none < /dev/null \ +// RUN: | FileCheck -match-full-lines -check-prefix MIPS-NOMADD4 %s +// MIPS-NOMADD4:#define __mips_no_madd4 1 +// +// RUN: %clang_cc1 \ +// RUN: -E -dM -triple=mips-none-none < /dev/null \ +// RUN: | FileCheck -match-full-lines -check-prefix MIPS-MADD4 %s +// MIPS-MADD4-NOT:#define __mips_no_madd4 1 +// // RUN: %clang_cc1 -target-cpu mips32r3 -target-feature +nan2008 \ // RUN: -E -dM -triple=mips-none-none < /dev/null \ // RUN: | FileCheck -match-full-lines -check-prefix MIPS-NAN2008 %s Index: test/CodeGen/mips-madd4.c === --- test/CodeGen/mips-madd4.c +++ test/CodeGen/mips-madd4.c @@ -0,0 +1,86 @@ +// RUN: %clang --target=mips64-unknown-linux -S -mmadd4%s -o -| FileCheck %s -check-prefix=MADD4 +// RUN: %clang --target=mips64-unknown-linux -S -mno-madd4 %s -o -| FileCheck %s -check-prefix=NOMADD4 +// RUN: %clang --target=mips64-unknown-linux -S -mmadd4-fno-honor-nans %s -o -| FileCheck %s -check-prefix=MADD4-NONAN +// RUN: %clang --target=mips64-unknown-linux -S -mno-madd4 -fno-honor-nans %s -o -| FileCheck %s -check-prefix=NOMADD4-NONAN + +float madd_s (float f, float g, float h) +{ + return (f * g) + h; +} +// MADD4: madd.s +// NOMADD4: mul.s +// NOMADD4: add.s + +float msub_s (float f, float g, float h) +{ + return (f * g) - h; +} +// MADD4: msub.s +// NOMADD4: mul.s +// NOMADD4: sub.s + +double madd_d (double f, double g, double h) +{ + return (f * g) + h; +} +// MADD4: madd.d +// NOMADD4: mul.d +// NOMADD4: add.d + +double msub_d (double f, double g, double h) +{ + return (f * g) - h; +} +// MADD4: msub.d +// NOMADD4: mul.d +// NOMADD4: sub.d + + +float nmadd_s (float f, float g, float h) +{ + // FIXME: Zero has been explicitly placed to force generation of a positive + // zero in IR until pattern used to match this instruction is changed to + // comply with negative zero as well. + return 0-((f * g) + h); +} +// MADD4-NONAN: nmadd.s +// NOMADD4-NONAN: mul.s +// NOMADD4-NONAN: add.s +// NOMADD4-NONAN: sub.s + +float nmsub_s (float f, float g, float h) +{ + // FIXME: Zero has been explicitly placed to force generation of a positive + // zero in IR until pattern used to match this instruction is changed to + // comply with negative zero as well. + return 0-((f * g) - h); +} +// MADD4-NONAN: nmsub.s +// NOMADD4-NONAN: mul.s +// NOMADD4-NONAN: sub.s +// NOMADD4-NONAN: sub.s + +double nmadd_d (double f, double g, double h) +{ + // FIXME: Zero has been explicitly placed to force generation of a positive + // zero in IR until pattern used to match this instruction is changed to + // comply with negative zero as well. + return 0-((f * g) + h); +} +// MADD4-NONAN: nmadd.d +// NOMADD4-NONAN: mul.d +// NOMADD4-NONAN: add.d +// NOMADD4-NONAN: sub.d + +double nmsub_d (double f, double g, double h) +{ + // FIXME: Zero has been explicitly placed to force generation of a positive + // zero in IR until pattern used to match this instruction is changed to + // comply with negative zero as well. + return 0-((f * g) - h); +} +// MADD4-NONAN: nmsub.d +// NOMADD4-NONAN: mul.d +// NOMADD4-NONAN: sub.d +// NOMADD4-NONAN: sub.d + Index: lib/Driver/ToolChains/Arch/Mips.cpp === --- lib/Driver/ToolChains/Arch/Mips.cpp +++ lib/Driver/ToolChains/Arch/Mips.cpp @@ -298,6 +298,13 @@ AddTargetFeature(Args, Features, options::OPT_mno_odd_spreg, options::OPT_modd_spreg, "nooddspreg"); + + if(Arg *A = Args.getLastArg(options::OPT_mmadd4, options::OPT_mno_madd4)) { +if(A->getOption().matches(options::OPT_mmadd4)) + Features.push_back("-nomadd4"); +else + Features.push_back("+nomadd4"); + } } mips::NanEncoding mips::getSupportedNanEncoding(StringRef &CPU) { Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -7716,6 +7716,7 @@ NoDSP, DSP1, DSP2 } DspRev; bool HasMSA; + bool DisableMadd4; protected: bool HasFP64; @@ -7726,7 +7727,7 @@ : TargetInfo(Triple), IsMips16(false), IsMicromips(false), IsNan2008(false
[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications
hintonda reopened this revision. hintonda added a comment. This revision is now accepted and ready to land. Reopening due to test failures on Linux -- was rolled back. https://reviews.llvm.org/D20693 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang-tools-extra] r304583 - [clang-tidy] Add `const` to operator() to fix a warning.
On Mon, Jun 5, 2017 at 7:11 PM, David Blaikie wrote: > what was the warning? > I don't remember the exact warning text, but the idea was that a non-const operator() could not be called. The change is reasonable in any case: the operator() here has no reason to be non-const. > > On Fri, Jun 2, 2017 at 11:48 AM Alexander Kornienko via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: alexfh >> Date: Fri Jun 2 13:47:50 2017 >> New Revision: 304583 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=304583&view=rev >> Log: >> [clang-tidy] Add `const` to operator() to fix a warning. >> >> Modified: >> clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.h >> >> Modified: clang-tools-extra/trunk/clang-tidy/misc/ >> LambdaFunctionNameCheck.h >> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/ >> trunk/clang-tidy/misc/LambdaFunctionNameCheck.h?rev= >> 304583&r1=304582&r2=304583&view=diff >> >> == >> --- clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.h >> (original) >> +++ clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.h >> Fri Jun 2 13:47:50 2017 >> @@ -25,7 +25,7 @@ namespace misc { >> class LambdaFunctionNameCheck : public ClangTidyCheck { >> public: >>struct SourceRangeLessThan { >> -bool operator()(const SourceRange &L, const SourceRange &R) { >> +bool operator()(const SourceRange &L, const SourceRange &R) const { >>if (L.getBegin() == R.getBegin()) { >> return L.getEnd() < R.getEnd(); >>} >> >> >> ___ >> 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
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
ABataev marked 7 inline comments as done. ABataev added inline comments. Comment at: include/clang/AST/Decl.h:1387 +IPK_CapturedContext, /// Parameter for captured context +IPK_GeneralParam,/// General implicit parameter + }; rjmccall wrote: > I would just call this "Other" and document it as being for kinds of implicit > parameters that we haven't seen a purpose in categorizing yet. (Or you could > just classify them all, I suppose.) > > We can use C++11 features in Clang now, so I would recommend hoisting this > type out of ImplicitParamDecl and making it an enum class. You can then drop > the "IPK_" prefixes. It's hard to classify them, in most cases they just represent some general parameters used for correct codegen of function types and that's it. https://reviews.llvm.org/D33735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33356: [Nios2] Changes in frontend to support Nios2 LLVM target
craig.topper accepted this revision. craig.topper added a comment. This revision is now accepted and ready to land. LGTM Comment at: lib/Basic/Targets.cpp:7678 +for (const char *feature : allFeatures) { +Features[feature] = isFeatureSupportedByCPU(feature, CPU); +} This is indented too far. Can you fix when you commit? https://reviews.llvm.org/D33356 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.
ABataev updated this revision to Diff 101571. ABataev marked an inline comment as done. ABataev added a comment. Address John comments. https://reviews.llvm.org/D33735 Files: include/clang/AST/Decl.h lib/AST/ASTImporter.cpp lib/AST/Decl.cpp lib/AST/DeclObjC.cpp lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGCXXABI.cpp lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDeclCXX.cpp lib/CodeGen/CGException.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CGObjC.cpp lib/CodeGen/CGOpenMPRuntime.cpp lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp lib/CodeGen/CGStmtOpenMP.cpp lib/CodeGen/CodeGenFunction.cpp lib/CodeGen/ItaniumCXXABI.cpp lib/CodeGen/MicrosoftCXXABI.cpp lib/Sema/SemaStmt.cpp lib/Serialization/ASTReaderDecl.cpp lib/Serialization/ASTWriterDecl.cpp test/CodeGen/captured-statements.c test/CodeGenCXX/captured-statements.cpp Index: test/CodeGenCXX/captured-statements.cpp === --- test/CodeGenCXX/captured-statements.cpp +++ test/CodeGenCXX/captured-statements.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t +// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3 @@ -194,3 +194,18 @@ void call_test_captured_linkage() { test_captured_linkage(); } + +// CHECK-1-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-1-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-2-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-2-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-3-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-3-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-4-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-4-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-5-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-5-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-6-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-6-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) +// CHECK-7-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer) +// CHECK-7-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial) Index: test/CodeGen/captured-statements.c === --- test/CodeGen/captured-statements.c +++ test/CodeGen/captured-statements.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t +// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-GLOBALS // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2 @@ -98,3 +98,8 @@ // CHECK-GLOBALS: load i32, i32* @global // CHECK-GLOBALS: load i32, i32* @ // CHECK-GLOBALS: load i32, i32* @e + +// CHECK-GLOBALS-NOT: DIFlagObjectPointer +// CHECK-1-NOT: DIFlagObjectPointer +// CHECK-2-NOT: DIFlagObjectPointer +// CHECK-3-NOT: DIFlagObjectPointer Index: lib/Serialization/ASTWriterDecl.cpp === --- lib/Serialization/ASTWriterDecl.cpp +++ lib/Serialization/ASTWriterDecl.cpp @@ -915,6 +915,10 @@ Record.push_back(D->isConstexpr()); Record.push_back(D->isInitCapture()); Record.push_back(D->isPreviousDeclInSameBlockScope()); +if (auto *IPD = dyn_cast(D)) + Record.push_back(static_cast(IPD->getParameterKind())); +else + Record.push_back(0); } Record.push_back(D->getLinkageInternal()); @@ -1989,6 +1993,7 @@ Abv->Add(BitCodeAbbrevOp(0)); // isConstexpr Abv->Add(BitCodeAbbrevOp(0)); // isInitCapture Abv->Add(BitCodeAbbrevOp(0)); // isPrevDeclInSameScope + Abv->Add(BitCodeAbbrevOp(0)); // ImplicitParamKind Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // IsInitICE (local) Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // VarKind (local enum) Index: lib/Serialization/ASTReaderDecl.cpp === --- lib/Serialization/ASTReaderDecl.cpp +++ lib/Serialization/ASTReaderDecl.cpp @@ -1229,6 +1229,7 @@
[PATCH] D33478: [libclang] When getting platform availabilities, merge multiple declarations if possible
rdwampler updated this revision to Diff 101569. rdwampler added a comment. Rearrange `if` statements in `getCursorPlatformAvailabilityForDecl` to return early if we do not need to merge availability attributes. Use ranged for loop. https://reviews.llvm.org/D33478 Files: test/Index/availability.c tools/libclang/CIndex.cpp Index: tools/libclang/CIndex.cpp === --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -7200,15 +7200,11 @@ return Out; } -static int getCursorPlatformAvailabilityForDecl(const Decl *D, -int *always_deprecated, -CXString *deprecated_message, -int *always_unavailable, -CXString *unavailable_message, - CXPlatformAvailability *availability, -int availability_size) { +static void getCursorPlatformAvailabilityForDecl( +const Decl *D, int *always_deprecated, CXString *deprecated_message, +int *always_unavailable, CXString *unavailable_message, +SmallVectorImpl &AvailabilityAttrs) { bool HadAvailAttr = false; - int N = 0; for (auto A : D->attrs()) { if (DeprecatedAttr *Deprecated = dyn_cast(A)) { HadAvailAttr = true; @@ -7220,7 +7216,7 @@ } continue; } - + if (UnavailableAttr *Unavailable = dyn_cast(A)) { HadAvailAttr = true; if (always_unavailable) @@ -7231,38 +7227,72 @@ } continue; } - + if (AvailabilityAttr *Avail = dyn_cast(A)) { + AvailabilityAttrs.push_back(Avail); HadAvailAttr = true; - if (N < availability_size) { -availability[N].Platform - = cxstring::createDup(Avail->getPlatform()->getName()); -availability[N].Introduced = convertVersion(Avail->getIntroduced()); -availability[N].Deprecated = convertVersion(Avail->getDeprecated()); -availability[N].Obsoleted = convertVersion(Avail->getObsoleted()); -availability[N].Unavailable = Avail->getUnavailable(); -availability[N].Message = cxstring::createDup(Avail->getMessage()); - } - ++N; } } if (!HadAvailAttr) if (const EnumConstantDecl *EnumConst = dyn_cast(D)) - return getCursorPlatformAvailabilityForDecl( -cast(EnumConst->getDeclContext()), - always_deprecated, - deprecated_message, - always_unavailable, - unavailable_message, - availability, - availability_size); - - return N; + getCursorPlatformAvailabilityForDecl( + cast(EnumConst->getDeclContext()), always_deprecated, + deprecated_message, always_unavailable, unavailable_message, + AvailabilityAttrs); + + if (AvailabilityAttrs.empty()) +return; + + std::sort(AvailabilityAttrs.begin(), AvailabilityAttrs.end(), +[](AvailabilityAttr *LHS, AvailabilityAttr *RHS) { + return LHS->getPlatform() > RHS->getPlatform(); +}); + ASTContext &Ctx = D->getASTContext(); + auto It = std::unique( + AvailabilityAttrs.begin(), AvailabilityAttrs.end(), + [&Ctx](AvailabilityAttr *LHS, AvailabilityAttr *RHS) { +if (LHS->getPlatform() == RHS->getPlatform()) { + if (LHS->getIntroduced() == RHS->getIntroduced() && + LHS->getDeprecated() == RHS->getDeprecated() && + LHS->getObsoleted() == RHS->getObsoleted() && + LHS->getMessage() == RHS->getMessage() && + LHS->getReplacement() == RHS->getReplacement()) +return true; + + if ((!LHS->getIntroduced().empty() && + !RHS->getIntroduced().empty()) || + (!LHS->getDeprecated().empty() && + !RHS->getDeprecated().empty()) || + (!LHS->getObsoleted().empty() && !RHS->getObsoleted().empty()) || + (!LHS->getMessage().empty() && !RHS->getMessage().empty())) +return false; + + if (LHS->getIntroduced().empty() && !RHS->getIntroduced().empty()) +LHS->setIntroduced(Ctx, RHS->getIntroduced()); + + if (LHS->getDeprecated().empty() && !RHS->getDeprecated().empty()) { +LHS->setDeprecated(Ctx, RHS->getDeprecated()); +if (!LHS->getMessage().empty()) + LHS->setMessage(Ctx, RHS->getMessage()); +if (!LHS->getReplacement().empty()) + LHS->setReplacement(Ctx, RHS->getReplacement()); + } + + if (LHS->getObsoleted().empty() && !RHS->
[PATCH] D33944: git-clang-format: Add --cached option to format index
kevinoid created this revision. kevinoid added a project: clang-tools-extra. Add --cached option to git-clang-format which behaves analogously to the use of --cached for other git subcommands, by causing the operation to work against the index state rather than the working directory state. This can be particularly useful for hook scripts which need to check or change the formatting of the index state before commit. Repository: rL LLVM https://reviews.llvm.org/D33944 Files: tools/clang-format/git-clang-format Index: tools/clang-format/git-clang-format === --- tools/clang-format/git-clang-format +++ tools/clang-format/git-clang-format @@ -92,6 +92,8 @@ p.add_argument('--binary', default=config.get('clangformat.binary', 'clang-format'), help='path to clang-format'), + p.add_argument('--cached', action='store_true', + help='format index instead of working directory'), p.add_argument('--commit', default=config.get('clangformat.commit', 'HEAD'), help='default commit to use if none is specified'), @@ -129,10 +131,12 @@ if len(commits) > 1: if not opts.diff: die('--diff is required when two commits are given') +if opts.cached: + die('--cached is not applicable when two commits are given') else: if len(commits) > 2: die('at most two commits allowed; %d given' % len(commits)) - changed_lines = compute_diff_and_extract_lines(commits, files) + changed_lines = compute_diff_and_extract_lines(commits, files, opts.cached) if opts.verbose >= 1: ignored_files = set(changed_lines) filter_by_extension(changed_lines, opts.extensions.lower().split(',')) @@ -154,15 +158,17 @@ cd_to_toplevel() if len(commits) > 1: old_tree = commits[1] -new_tree = run_clang_format_and_save_to_tree(changed_lines, - revision=commits[1], - binary=opts.binary, - style=opts.style) +fmt_tree = commits[1] + elif opts.cached: +old_tree = run('git', 'write-tree') +fmt_tree = old_tree else: old_tree = create_tree_from_workdir(changed_lines) -new_tree = run_clang_format_and_save_to_tree(changed_lines, - binary=opts.binary, - style=opts.style) +fmt_tree = None + new_tree = run_clang_format_and_save_to_tree(changed_lines, + revision=fmt_tree, + binary=opts.binary, + style=opts.style) if opts.verbose >= 1: print('old tree: %s' % old_tree) print('new tree: %s' % new_tree) @@ -173,7 +179,7 @@ print_diff(old_tree, new_tree) else: changed_files = apply_changes(old_tree, new_tree, force=opts.force, - patch_mode=opts.patch) + patch_mode=opts.patch, cached=opts.cached) if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1: print('changed files:') for filename in changed_files: @@ -261,9 +267,9 @@ return convert_string(stdout.strip()) -def compute_diff_and_extract_lines(commits, files): +def compute_diff_and_extract_lines(commits, files, cached=False): """Calls compute_diff() followed by extract_lines().""" - diff_process = compute_diff(commits, files) + diff_process = compute_diff(commits, files, cached) changed_lines = extract_lines(diff_process.stdout) diff_process.stdout.close() diff_process.wait() @@ -273,7 +279,7 @@ return changed_lines -def compute_diff(commits, files): +def compute_diff(commits, files, cached=False): """Return a subprocess object producing the diff from `commits`. The return value's `stdin` file object will produce a patch with the @@ -283,7 +289,11 @@ git_tool = 'diff-index' if len(commits) > 1: git_tool = 'diff-tree' - cmd = ['git', git_tool, '-p', '-U0'] + commits + ['--'] + cmd = ['git', git_tool, '-p', '-U0'] + if cached: +cmd.append('--cached') + cmd.extend(commits) + cmd.append('--') cmd.extend(files) p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) p.stdin.close() @@ -487,23 +497,39 @@ '--']) -def apply_changes(old_tree, new_tree, force=False, patch_mode=False): - """Apply the changes in `new_tree` to the working directory. +def apply_changes(old_tree, new_tree, force=False, patch_mode=False, + cached=False): + """Apply the changes in `new_tree` to the working directory or index. Bails if there are local changes in those files and not `force`. If - `patch_mode`, runs `git checkout --patch` to select hunks interactively.""" + `patch_mode`,
[PATCH] D33945: [OpenCL] Add support for missing sub_group functions.
joey created this revision. Herald added subscribers: Anastasia, yaxunl. This adds get_kernel_max_sub_group_size_for_ndrange and get_kernel_sub_group_count_for_ndrange. Note this also changes err_opencl_requires_extension to print the name of the function that the diagnostic is warning about. https://reviews.llvm.org/D33945 Files: CodeGen/CGBuiltin.cpp CodeGenOpenCL/cl20-device-side-enqueue.cl CodeGenOpenCL/pipe_builtin.cl Sema/Sema.cpp Sema/SemaChecking.cpp SemaOpenCL/cl20-device-side-enqueue.cl SemaOpenCL/extension-begin.cl SemaOpenCL/invalid-pipe-builtin-cl2.0.cl SemaOpenCL/sub-group-bifs.cl clang/Basic/Builtins.def clang/Basic/DiagnosticSemaKinds.td clang/Sema/Sema.h Index: SemaOpenCL/sub-group-bifs.cl === --- /dev/null +++ SemaOpenCL/sub-group-bifs.cl @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.0 + +#pragma OPENCL EXTENSION cl_khr_subgroups : enable + +typedef struct {} ndrange_t; + +kernel void foo(global int *buf) +{ + ndrange_t n; + buf[0] = get_kernel_max_sub_group_size_for_ndrange(n, ^(){}); + buf[0] = get_kernel_max_sub_group_size_for_ndrange(0, ^(){}); // expected-error{{illegal call to 'get_kernel_max_sub_group_size_for_ndrange', expected 'ndrange_t' argument type}} +} + +kernel void bar(global int *buf) +{ + ndrange_t n; + buf[0] = get_kernel_sub_group_count_for_ndrange(n, ^(){}); + buf[0] = get_kernel_sub_group_count_for_ndrange(0, ^(){}); // expected-error{{illegal call to 'get_kernel_sub_group_count_for_ndrange', expected 'ndrange_t' argument type}} +} + +#pragma OPENCL EXTENSION cl_khr_subgroups : disable + +kernel void foo1(global int *buf) +{ + ndrange_t n; + buf[0] = get_kernel_max_sub_group_size_for_ndrange(n, ^(){}); // expected-error {{use of declaration 'get_kernel_max_sub_group_size_for_ndrange' requires cl_khr_subgroups extension to be enabled}} +} + +kernel void bar1(global int *buf) +{ + ndrange_t n; + buf[0] = get_kernel_sub_group_count_for_ndrange(n, ^(){}); // expected-error {{use of declaration 'get_kernel_sub_group_count_for_ndrange' requires cl_khr_subgroups extension to be enabled}} +} Index: SemaOpenCL/invalid-pipe-builtin-cl2.0.cl === --- SemaOpenCL/invalid-pipe-builtin-cl2.0.cl +++ SemaOpenCL/invalid-pipe-builtin-cl2.0.cl @@ -1,5 +1,7 @@ // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 +#pragma OPENCL EXTENSION cl_khr_subgroups : enable + void test1(read_only pipe int p, global int* ptr){ int tmp; reserve_id_t rid; Index: SemaOpenCL/extension-begin.cl === --- SemaOpenCL/extension-begin.cl +++ SemaOpenCL/extension-begin.cl @@ -46,7 +46,7 @@ const struct A test_A_local; // expected-error {{use of type 'struct A' requires my_ext extension to be enabled}} TypedefOfA test_typedef_A; // expected-error {{use of type 'TypedefOfA' (aka 'struct A') requires my_ext extension to be enabled}} PointerOfA test_A_pointer; // expected-error {{use of type 'PointerOfA' (aka 'const struct A *') requires my_ext extension to be enabled}} - f(); // expected-error {{use of declaration requires my_ext extension to be enabled}} + f(); // expected-error {{use of declaration 'f' requires my_ext extension to be enabled}} g(0); // expected-error {{no matching function for call to 'g'}} // expected-note@-26 {{candidate disabled due to OpenCL extension}} // expected-note@-22 {{candidate function not viable: requires 0 arguments, but 1 was provided}} Index: SemaOpenCL/cl20-device-side-enqueue.cl === --- SemaOpenCL/cl20-device-side-enqueue.cl +++ SemaOpenCL/cl20-device-side-enqueue.cl @@ -19,19 +19,19 @@ return 0; }); - enqueue_kernel(vptr, flags, ndrange, ^(void) { // expected-error{{illegal call to enqueue_kernel, expected 'queue_t' argument type}} + enqueue_kernel(vptr, flags, ndrange, ^(void) { // expected-error{{illegal call to 'enqueue_kernel', expected 'queue_t' argument type}} return 0; }); - enqueue_kernel(default_queue, vptr, ndrange, ^(void) { // expected-error{{illegal call to enqueue_kernel, expected 'kernel_enqueue_flags_t' (i.e. uint) argument type}} + enqueue_kernel(default_queue, vptr, ndrange, ^(void) { // expected-error{{illegal call to 'enqueue_kernel', expected 'kernel_enqueue_flags_t' (i.e. uint) argument type}} return 0; }); - enqueue_kernel(default_queue, flags, vptr, ^(void) { // expected-error{{illegal call to enqueue_kernel, expected 'ndrange_t' argument type}} + enqueue_kernel(default_queue, flags, vptr, ^(void) { // expected-error{{illegal call to 'enqueue_kernel', expected 'ndrange_t' argument type}} return 0; }); - enqueue_kernel(default_queue, flags, ndrange, vptr); // expected-error{{illegal call to enqueue_kernel, expected block argument}}
[PATCH] D33726: [driver][netbsd] Build and pass `-L` arguments to the linker
krytarowski added a subscriber: ruiu. krytarowski added a comment. @ruiu what's your opinion on this? Repository: rL LLVM https://reviews.llvm.org/D33726 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33726: [driver][netbsd] Build and pass `-L` arguments to the linker
ruiu added a comment. I'm totally against adding per-OS path knowledge to our linker. Compilers already know include paths and I don't want to maintain another list of paths in the linker. Also this can be more confusing than useful when you are doing cross-linking. For all OSes other than NetBSD, LLD works fine with the clang driver as the driver passes include paths to the linker. I don't see any reason not to do the same thing for NetBSD. That stands even if the linker has to have a list of include paths. Repository: rL LLVM https://reviews.llvm.org/D33726 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33726: [driver][netbsd] Build and pass `-L` arguments to the linker
krytarowski added a comment. I concur this, linkers are to used through a compiler frontend and `libtool` (which wraps a compiler). Repository: rL LLVM https://reviews.llvm.org/D33726 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r304811 - [clang-tidy] misc-inaccurate-erase: support call by pointer
Author: alexfh Date: Tue Jun 6 12:49:45 2017 New Revision: 304811 URL: http://llvm.org/viewvc/llvm-project?rev=304811&view=rev Log: [clang-tidy] misc-inaccurate-erase: support call by pointer + replace matchesName calls with more efficient alternatives. Modified: clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp clang-tools-extra/trunk/test/clang-tidy/misc-inaccurate-erase.cpp Modified: clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp?rev=304811&r1=304810&r2=304811&view=diff == --- clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp Tue Jun 6 12:49:45 2017 @@ -18,6 +18,10 @@ namespace clang { namespace tidy { namespace misc { +namespace { +AST_MATCHER(Decl, isInStdNamespace) { return Node.isInStdNamespace(); } +} + void InaccurateEraseCheck::registerMatchers(MatchFinder *Finder) { // Only register the matchers for C++; the functionality currently does not // provide any benefit to other languages, despite being benign. @@ -30,13 +34,14 @@ void InaccurateEraseCheck::registerMatch .bind("InaccEndCall", anything())); + const auto DeclInStd = decl(isInStdNamespace()); Finder->addMatcher( cxxMemberCallExpr( - on(hasType(namedDecl(matchesName("^::std::", + on(anyOf(hasType(DeclInStd), hasType(pointsTo(DeclInStd, callee(cxxMethodDecl(hasName("erase"))), argumentCountIs(1), hasArgument(0, has(ignoringParenImpCasts( - callExpr(callee(functionDecl(matchesName( - "^::std::(remove(_if)?|unique)$"))), + callExpr(callee(functionDecl(hasAnyName( + "remove", "remove_if", "unique"))), CheckForEndCall) .bind("InaccAlgCall", unless(isInTemplateInstantiation())) Modified: clang-tools-extra/trunk/test/clang-tidy/misc-inaccurate-erase.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-inaccurate-erase.cpp?rev=304811&r1=304810&r2=304811&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/misc-inaccurate-erase.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/misc-inaccurate-erase.cpp Tue Jun 6 12:49:45 2017 @@ -56,6 +56,12 @@ int main() { // CHECK-FIXES: {{^ }}v.erase(remove(v.begin(), v.end(), 10), v.end());{{$}} v.erase(remove(v.begin(), v.end(), 20), v.end()); + auto *p = &v; + p->erase(remove(p->begin(), p->end(), 11)); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this call will remove at most one + // CHECK-FIXES: {{^ }}p->erase(remove(p->begin(), p->end(), 11), p->end());{{$}} + + // Fix is not trivial. auto it = v.end(); v.erase(remove(v.begin(), it, 10)); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D33102: [clang] Implement -Wcast-qual for C++
On Tue, Jun 6, 2017 at 3:59 AM Roman Lebedev via Phabricator < revi...@reviews.llvm.org> wrote: > lebedev.ri added a comment. > > In https://reviews.llvm.org/D33102#773296, @dblaikie wrote: > > > I still feel like that's more testing than would be ideal (does the > context of the cast matter? Wether it's dereferenced, a struct member > access, assigned, initialized, etc - it doesn't look like it from the code, > etc). > > > Looking at the `CastsAwayConstness()` function in lib/Sema/SemaCast.cpp: > https://github.com/llvm-mirror/clang/blob/432ed0e4a6d58f7dda8992a167aad43bc91f76c6/lib/Sema/SemaCast.cpp#L505-L510 > You can see that it asserts that the pointer is one of three types. So i > think it it is best to have maybe slightly overlapping test coverage here, > rather than be surprised one day that such trivial cases no longer warn... > > > But sure. Could you also (manually, I guess) confirm that this matches > GCC's cast-qual behavior (insofar as the warning fires in the same > situations). If there are any deviations, let's chat about them. > > Sure. > > 1. Gcc produces the same //count// of the warnings: > > $ pwd > llvm/tools/clang/test > $ grep -o "expected-warning" Sema/warn-cast-qual.c | wc -l > 14 > $ gcc -x c -fsyntax-only -Wcast-qual -c Sema/warn-cast-qual.c 2>&1 | > grep ": warning: " | wc -l > 14 > $ gcc -x c++ -fsyntax-only -Wcast-qual -c Sema/warn-cast-qual.c 2>&1 | > grep ": warning: " | wc -l > 14 > $ grep -o "expected-warning" SemaCXX/warn-cast-qual.cpp | wc -l > 39 > $ gcc -x c++ -fsyntax-only -Wcast-qual -c SemaCXX/warn-cast-qual.cpp > 2>&1 | grep ": warning: " | wc -l > 39 > > 2. I'm not quite sure how to non-manually compare the warnings, so i'll > just show the gcc output on these three cases. Since the clang warnings are > appended as comments at the end of the each line that should warn, visual > comparison is possible: > Works for the positive cases, not the negative ones. (though if the counts are exactly the same, then so long as there are no false positives there aren't any false negatives either) > > 2.1. > > $ gcc -x c -fsyntax-only -Wcast-qual -c Sema/warn-cast-qual.c > Sema/warn-cast-qual.c: In function ‘foo’: > Sema/warn-cast-qual.c:9:13: warning: cast discards ‘const’ qualifier > from pointer target type [-Wcast-qual] > char *y = (char *)ptr; // expected-warning {{cast from 'const char *' > to 'char *' drops const qualifier}} >^ > Sema/warn-cast-qual.c:10:15: warning: cast discards ‘const’ qualifier > from pointer target type [-Wcast-qual] > char **y1 = (char **)ptrptr; // expected-warning {{cast from 'const > char *const' to 'char *' drops const qualifier}} > ^ > Sema/warn-cast-qual.c:11:21: warning: cast discards ‘const’ qualifier > from pointer target type [-Wcast-qual] > const char **y2 = (const char **)ptrptr; // expected-warning {{cast > from 'const char *const *' to 'const char **' drops const qualifier}} >^ > Sema/warn-cast-qual.c:14:14: warning: cast discards ‘const’ qualifier > from pointer target type [-Wcast-qual] > char *z1 = (char *)(const void *)ptr; // expected-warning {{cast from > 'const void *' to 'char *' drops const qualifier}} > ^ > Sema/warn-cast-qual.c:17:16: warning: cast discards ‘volatile’ qualifier > from pointer target type [-Wcast-qual] > char *vol2 = (char *)vol; // expected-warning {{cast from 'volatile > char *' to 'char *' drops volatile qualifier}} > ^ > Sema/warn-cast-qual.c:19:17: warning: cast discards ‘const volatile’ > qualifier from pointer target type [-Wcast-qual] > char *volc2 = (char *)volc; // expected-warning {{cast from 'const > volatile char *' to 'char *' drops const and volatile qualifiers}} >^ > Sema/warn-cast-qual.c:22:28: warning: to be safe all intermediate > pointers in cast from ‘int **’ to ‘const int **’ must be ‘const’ qualified > [-Wcast-qual] > const int **intptrptrc = (const int **)intptrptr; // expected-warning > {{cast from 'int **' to 'const int **' must have all intermediate pointers > const qualified}} > ^ > Sema/warn-cast-qual.c:23:31: warning: to be safe all intermediate > pointers in cast from ‘int **’ to ‘volatile int **’ must be ‘const’ > qualified [-Wcast-qual] > volatile int **intptrptrv = (volatile int **)intptrptr; // > expected-warning {{cast from 'int **' to 'volatile int **' must have all > intermediate pointers const qualified}} > ^ > Sema/warn-cast-qual.c:29:23: warning: cast discards ‘const’ qualifier > from pointer target type [-Wcast-qual] > char **charptrptr = (char **)charptrptrc; // expected-warning {{cast > from 'const char *' to 'char *' drops const qualifier}} > ^ > Sema/warn-cast-qual.c:32:19: warning: cast discards ‘const’ qualifier > from pointer target type [-Wcast-qual] > char *charp
[PATCH] D33478: [libclang] When getting platform availabilities, merge multiple declarations if possible
arphaman added a comment. It seems that there's a slight bug in the patch: If I print the output of the following code using `c-index-test -test-load-source all`: void bar2(void) __attribute__((availability(macosx, introduced=10.4))) __attribute__((availability(macosx, deprecated=10.5, message="use x"))); I see availability that includes a deprecation message: `FunctionDecl=bar2:15:6 (deprecated) (macos, introduced=10.4, deprecated=10.5, message="use x")`. However, if I look at the output of the following code: void bar2(void) __attribute__((availability(macosx, deprecated=10.5, message="use x"))) __attribute__((availability(macosx, introduced=10.4))); I get something that doesn't include the message: `FunctionDecl=bar2:15:6 (deprecated) (macos, introduced=10.4, deprecated=10.5)`. Comment at: test/Index/availability.c:13 + +void bar(void) __attribute__((availability(macosx,introduced=10.4))) __attribute__((availability(ios,introduced=3.2))) __attribute__((availability(macosx,deprecated=10.5,message="use foobar"))); Please add a test for merge of the `obsoleted` clause as well. Comment at: tools/libclang/CIndex.cpp:7239 if (const EnumConstantDecl *EnumConst = dyn_cast(D)) - return getCursorPlatformAvailabilityForDecl( - cast(EnumConst->getDeclContext()), - always_deprecated, - deprecated_message, - always_unavailable, - unavailable_message, - availability, - availability_size); - - return N; + getCursorPlatformAvailabilityForDecl( + cast(EnumConst->getDeclContext()), always_deprecated, You should be able to keep the `return` here, since you will `sort` and `unique` the attributes in this call to `getCursorPlatformAvailabilityForDecl`. Comment at: tools/libclang/CIndex.cpp:7255 + [&Ctx](AvailabilityAttr *LHS, AvailabilityAttr *RHS) { +if (LHS->getPlatform() == RHS->getPlatform()) { + if (LHS->getIntroduced() == RHS->getIntroduced() && Please invert this `if` and `return false` early instead of leaving it at the end of the lambda. https://reviews.llvm.org/D33478 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r304813 - add missing constexpr to optional::value_or
Author: caseycarter Date: Tue Jun 6 13:47:26 2017 New Revision: 304813 URL: http://llvm.org/viewvc/llvm-project?rev=304813&view=rev Log: add missing constexpr to optional::value_or [Credit to cpplearner] Differential Revision: https://reviews.llvm.org/D27850 Modified: libcxx/trunk/include/optional libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp Modified: libcxx/trunk/include/optional URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/optional?rev=304813&r1=304812&r2=304813&view=diff == --- libcxx/trunk/include/optional (original) +++ libcxx/trunk/include/optional Tue Jun 6 13:47:26 2017 @@ -897,7 +897,7 @@ public: template _LIBCPP_INLINE_VISIBILITY -value_type value_or(_Up&& __v) && +constexpr value_type value_or(_Up&& __v) && { static_assert(is_move_constructible_v, "optional::value_or: T must be move constructible"); Modified: libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp?rev=304813&r1=304812&r2=304813&view=diff == --- libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp Tue Jun 6 13:47:26 2017 @@ -10,7 +10,7 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 // -// template T optional::value_or(U&& v) &&; +// template constexpr T optional::value_or(U&& v) &&; #include #include @@ -26,22 +26,22 @@ struct Y { int i_; -Y(int i) : i_(i) {} +constexpr Y(int i) : i_(i) {} }; struct X { int i_; -X(int i) : i_(i) {} -X(X&& x) : i_(x.i_) {x.i_ = 0;} -X(const Y& y) : i_(y.i_) {} -X(Y&& y) : i_(y.i_+1) {} +constexpr X(int i) : i_(i) {} +constexpr X(X&& x) : i_(x.i_) {x.i_ = 0;} +constexpr X(const Y& y) : i_(y.i_) {} +constexpr X(Y&& y) : i_(y.i_+1) {} friend constexpr bool operator==(const X& x, const X& y) {return x.i_ == y.i_;} }; -int main() +constexpr int test() { { optional opt(in_place, 2); @@ -65,4 +65,10 @@ int main() assert(std::move(opt).value_or(Y(3)) == 4); assert(!opt); } +return 0; +} + +int main() +{ +static_assert(test() == 0); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27850: [libcxx] add missing constexpr to optional::value_or
This revision was automatically updated to reflect the committed changes. Closed by commit rL304813: add missing constexpr to optional::value_or (authored by CaseyCarter). Changed prior to commit: https://reviews.llvm.org/D27850?vs=82653&id=101597#toc Repository: rL LLVM https://reviews.llvm.org/D27850 Files: libcxx/trunk/include/optional libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp Index: libcxx/trunk/include/optional === --- libcxx/trunk/include/optional +++ libcxx/trunk/include/optional @@ -897,7 +897,7 @@ template _LIBCPP_INLINE_VISIBILITY -value_type value_or(_Up&& __v) && +constexpr value_type value_or(_Up&& __v) && { static_assert(is_move_constructible_v, "optional::value_or: T must be move constructible"); Index: libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp === --- libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp +++ libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp @@ -10,7 +10,7 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 // -// template T optional::value_or(U&& v) &&; +// template constexpr T optional::value_or(U&& v) &&; #include #include @@ -26,22 +26,22 @@ { int i_; -Y(int i) : i_(i) {} +constexpr Y(int i) : i_(i) {} }; struct X { int i_; -X(int i) : i_(i) {} -X(X&& x) : i_(x.i_) {x.i_ = 0;} -X(const Y& y) : i_(y.i_) {} -X(Y&& y) : i_(y.i_+1) {} +constexpr X(int i) : i_(i) {} +constexpr X(X&& x) : i_(x.i_) {x.i_ = 0;} +constexpr X(const Y& y) : i_(y.i_) {} +constexpr X(Y&& y) : i_(y.i_+1) {} friend constexpr bool operator==(const X& x, const X& y) {return x.i_ == y.i_;} }; -int main() +constexpr int test() { { optional opt(in_place, 2); @@ -65,4 +65,10 @@ assert(std::move(opt).value_or(Y(3)) == 4); assert(!opt); } +return 0; +} + +int main() +{ +static_assert(test() == 0); } Index: libcxx/trunk/include/optional === --- libcxx/trunk/include/optional +++ libcxx/trunk/include/optional @@ -897,7 +897,7 @@ template _LIBCPP_INLINE_VISIBILITY -value_type value_or(_Up&& __v) && +constexpr value_type value_or(_Up&& __v) && { static_assert(is_move_constructible_v, "optional::value_or: T must be move constructible"); Index: libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp === --- libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp +++ libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp @@ -10,7 +10,7 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 // -// template T optional::value_or(U&& v) &&; +// template constexpr T optional::value_or(U&& v) &&; #include #include @@ -26,22 +26,22 @@ { int i_; -Y(int i) : i_(i) {} +constexpr Y(int i) : i_(i) {} }; struct X { int i_; -X(int i) : i_(i) {} -X(X&& x) : i_(x.i_) {x.i_ = 0;} -X(const Y& y) : i_(y.i_) {} -X(Y&& y) : i_(y.i_+1) {} +constexpr X(int i) : i_(i) {} +constexpr X(X&& x) : i_(x.i_) {x.i_ = 0;} +constexpr X(const Y& y) : i_(y.i_) {} +constexpr X(Y&& y) : i_(y.i_+1) {} friend constexpr bool operator==(const X& x, const X& y) {return x.i_ == y.i_;} }; -int main() +constexpr int test() { { optional opt(in_place, 2); @@ -65,4 +65,10 @@ assert(std::move(opt).value_or(Y(3)) == 4); assert(!opt); } +return 0; +} + +int main() +{ +static_assert(test() == 0); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26065: Improve diagnostics if friend function redefines file-level function.
arphaman added inline comments. Comment at: lib/Sema/SemaDeclCXX.cpp:646 + // in this case, redefinition will be diagnosed later. + (New->isInlineSpecified() || !New->isOutOfLine() || + !New->getLexicalDeclContext()->isRecord())) { This is somewhat confusing to me: are you using the `!New->isOutOfLine() || !New->getLexicalDeclContext()->isRecord()` check to ensure that this new declaration is not a `friend`? https://reviews.llvm.org/D26065 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33926: [clang] Remove double semicolons. NFC.
efriedma accepted this revision. efriedma added a comment. This revision is now accepted and ready to land. You don't need to ask for review for a trivial change like this. https://reviews.llvm.org/D33926 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33493: Speed up preamble loading
arphaman added a comment. Can you use a local map in `TranslateStoredDiagnostics` instead of storing one in the `ASTUnit`, or do you need to keep it around? https://reviews.llvm.org/D33493 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33833: Fix PR 33189: Clang assertion on template destructor declaration
kuang_he updated this revision to Diff 101601. kuang_he added a comment. Patch updated addressing comment. https://reviews.llvm.org/D33833 Files: lib/AST/DeclCXX.cpp test/SemaCXX/PR33189.cpp Index: test/SemaCXX/PR33189.cpp === --- /dev/null +++ test/SemaCXX/PR33189.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s + +class U +{ + template + ~U() { } // expected-error{{destructor cannot be declared as a template}} +}; Index: lib/AST/DeclCXX.cpp === --- lib/AST/DeclCXX.cpp +++ lib/AST/DeclCXX.cpp @@ -1417,11 +1417,8 @@ Context.getCanonicalType(ClassType)); DeclContext::lookup_result R = lookup(Name); - if (R.empty()) -return nullptr; - CXXDestructorDecl *Dtor = cast(R.front()); - return Dtor; + return R.empty() ? nullptr : dyn_cast(R.front()); } bool CXXRecordDecl::isAnyDestructorNoReturn() const { Index: test/SemaCXX/PR33189.cpp === --- /dev/null +++ test/SemaCXX/PR33189.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s + +class U +{ + template + ~U() { } // expected-error{{destructor cannot be declared as a template}} +}; Index: lib/AST/DeclCXX.cpp === --- lib/AST/DeclCXX.cpp +++ lib/AST/DeclCXX.cpp @@ -1417,11 +1417,8 @@ Context.getCanonicalType(ClassType)); DeclContext::lookup_result R = lookup(Name); - if (R.empty()) -return nullptr; - CXXDestructorDecl *Dtor = cast(R.front()); - return Dtor; + return R.empty() ? nullptr : dyn_cast(R.front()); } bool CXXRecordDecl::isAnyDestructorNoReturn() const { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33493: Speed up preamble loading
yvvan added a comment. In https://reviews.llvm.org/D33493#774264, @arphaman wrote: > Can you use a local map in `TranslateStoredDiagnostics` instead of storing > one in the `ASTUnit`, or do you need to keep it around? The whole purpose is to use it between different TranslateStoredDiagnostics calls because it scans the same files every time. And this cache allows it to reuse the source location. https://reviews.llvm.org/D33493 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r304823 - [clang] Remove double semicolons. NFC.
Author: mgrang Date: Tue Jun 6 14:47:56 2017 New Revision: 304823 URL: http://llvm.org/viewvc/llvm-project?rev=304823&view=rev Log: [clang] Remove double semicolons. NFC. Reviewers: rsmith, craig.topper, efriedma Reviewed By: efriedma Subscribers: efriedma, cfe-commits Tags: #clang-c Differential Revision: https://reviews.llvm.org/D33926 Modified: cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/Sema/SemaType.cpp Modified: cfe/trunk/lib/AST/Type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=304823&r1=304822&r2=304823&view=diff == --- cfe/trunk/lib/AST/Type.cpp (original) +++ cfe/trunk/lib/AST/Type.cpp Tue Jun 6 14:47:56 2017 @@ -1344,7 +1344,7 @@ Optional> Type::getOb } else if (getAs()) { ASTContext &ctx = dc->getParentASTContext(); objectType = ctx.getObjCObjectType(ctx.ObjCBuiltinIdTy, { }, { }) - ->castAs();; + ->castAs(); } else { objectType = getAs(); } Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=304823&r1=304822&r2=304823&view=diff == --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Tue Jun 6 14:47:56 2017 @@ -3367,7 +3367,7 @@ classifyPointerDeclarator(Sema &S, QualT if (auto objcClass = type->getAs()) { if (objcClass->getInterface()->getIdentifier() == S.getNSErrorIdent()) { if (numNormalPointers == 2 && numTypeSpecifierPointers < 2) - return PointerDeclaratorKind::NSErrorPointerPointer;; + return PointerDeclaratorKind::NSErrorPointerPointer; } break; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33926: [clang] Remove double semicolons. NFC.
This revision was automatically updated to reflect the committed changes. Closed by commit rL304823: [clang] Remove double semicolons. NFC. (authored by mgrang). Changed prior to commit: https://reviews.llvm.org/D33926?vs=101506&id=101604#toc Repository: rL LLVM https://reviews.llvm.org/D33926 Files: cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/Sema/SemaType.cpp Index: cfe/trunk/lib/AST/Type.cpp === --- cfe/trunk/lib/AST/Type.cpp +++ cfe/trunk/lib/AST/Type.cpp @@ -1344,7 +1344,7 @@ } else if (getAs()) { ASTContext &ctx = dc->getParentASTContext(); objectType = ctx.getObjCObjectType(ctx.ObjCBuiltinIdTy, { }, { }) - ->castAs();; + ->castAs(); } else { objectType = getAs(); } Index: cfe/trunk/lib/Sema/SemaType.cpp === --- cfe/trunk/lib/Sema/SemaType.cpp +++ cfe/trunk/lib/Sema/SemaType.cpp @@ -3367,7 +3367,7 @@ if (auto objcClass = type->getAs()) { if (objcClass->getInterface()->getIdentifier() == S.getNSErrorIdent()) { if (numNormalPointers == 2 && numTypeSpecifierPointers < 2) - return PointerDeclaratorKind::NSErrorPointerPointer;; + return PointerDeclaratorKind::NSErrorPointerPointer; } break; Index: cfe/trunk/lib/AST/Type.cpp === --- cfe/trunk/lib/AST/Type.cpp +++ cfe/trunk/lib/AST/Type.cpp @@ -1344,7 +1344,7 @@ } else if (getAs()) { ASTContext &ctx = dc->getParentASTContext(); objectType = ctx.getObjCObjectType(ctx.ObjCBuiltinIdTy, { }, { }) - ->castAs();; + ->castAs(); } else { objectType = getAs(); } Index: cfe/trunk/lib/Sema/SemaType.cpp === --- cfe/trunk/lib/Sema/SemaType.cpp +++ cfe/trunk/lib/Sema/SemaType.cpp @@ -3367,7 +3367,7 @@ if (auto objcClass = type->getAs()) { if (objcClass->getInterface()->getIdentifier() == S.getNSErrorIdent()) { if (numNormalPointers == 2 && numTypeSpecifierPointers < 2) - return PointerDeclaratorKind::NSErrorPointerPointer;; + return PointerDeclaratorKind::NSErrorPointerPointer; } break; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33875: PR27037: Use correct CVR qualifier on an upcast on method pointer call
rsmith accepted this revision. rsmith added a comment. This revision is now accepted and ready to land. Looks good to me, thanks! Do you need someone to commit this for you? https://reviews.llvm.org/D33875 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33941: [Driver] Add test to cover case when LSan is not supported
dblaikie accepted this revision. dblaikie added a comment. This revision is now accepted and ready to land. Looks good - thanks! Repository: rL LLVM https://reviews.llvm.org/D33941 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30375: Function with unparsed body is a definition
rsmith added a comment. If you want to take this path, you should also add `ActOnStartOfFunctionBody` calls to the other parts of the parser that parse function definitions: `Parser::ParseLateTemplatedFuncDef`, `Parser::ParseLexedObjCMethodDefs`, and `Parser::ParseLexedMethodDefs`. You should also rename `ActOnFinishFunctionBody` to something like `ActOnFinishFunctionDef` to avoid confusion, because it pairs with `ActOnStartOfFunctionDef` not the new `ActOnStartFunctionBody`. However, I wonder if there isn't a simpler way to handle this, rather than adding another function that is called almost every time that `ActOnStartOfFunctionDef` is called: the `Declarator` object passed to `ActOnStartOfFunctionDef` already carries a `FunctionDefinitionKind` which tells you whether the function definition has a body. You could extend the non-`Declarator` overload to also take a `FunctionDefinitionKind` and then update the callers to pass in the right value. Then in `ActOnStartOfFunctionDef`, only set `WillHaveBody` if the kind is `FDK_Definition`. https://reviews.llvm.org/D30375 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33953: [libcxx] [test] Add more tests to tuple_size_structured_bindings.pass.cpp and make it friendlier to C1XX.
STL_MSFT created this revision. [libcxx] [test] Add more tests to tuple_size_structured_bindings.pass.cpp and make it friendlier to C1XX. Style/paranoia: 42.1 doesn't have an exact binary representation. Although this doesn't cause failures, it makes me uncomfortable, so I'm changing it to 42.5. C1XX rightly warns about unreferenced variables. Adding tests for their values makes C1XX happy and improves test coverage. C1XX (somewhat obnoxiously) warns about seeing a struct specialized as a class. Although the Standard doesn't care, saying struct consistently is better. (The Standard itself is still inconsistent about whether to depict tuple_element and tuple_size as structs or classes.) https://reviews.llvm.org/D33953 Files: test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp Index: test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp === --- test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp +++ test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp @@ -64,18 +64,22 @@ void test_decomp_pair() { typedef std::pair T; { -T s{99, 42.1}; +T s{99, 42.5}; auto [m1, m2] = s; auto& [r1, r2] = s; assert(m1 == 99); +assert(m2 == 42.5); assert(&r1 == &std::get<0>(s)); +assert(&r2 == &std::get<1>(s)); } { -T const s{99, 42.1}; +T const s{99, 42.5}; auto [m1, m2] = s; auto& [r1, r2] = s; assert(m1 == 99); +assert(m2 == 42.5); assert(&r1 == &std::get<0>(s)); +assert(&r2 == &std::get<1>(s)); } } @@ -86,14 +90,22 @@ auto [m1, m2, m3] = s; auto& [r1, r2, r3] = s; assert(m1 == 99); +assert(m2 == 42); +assert(m3 == -1); assert(&r1 == &std::get<0>(s)); +assert(&r2 == &std::get<1>(s)); +assert(&r3 == &std::get<2>(s)); } { T const s{{99, 42, -1}}; auto [m1, m2, m3] = s; auto& [r1, r2, r3] = s; assert(m1 == 99); +assert(m2 == 42); +assert(m3 == -1); assert(&r1 == &std::get<0>(s)); +assert(&r2 == &std::get<1>(s)); +assert(&r3 == &std::get<2>(s)); } } @@ -105,8 +117,7 @@ int get(Test const&) { static_assert(N == 0, ""); return -1; } template <> -class std::tuple_element<0, Test> { -public: +struct std::tuple_element<0, Test> { typedef int type; }; @@ -117,8 +128,7 @@ } template <> -class std::tuple_size { -public: +struct std::tuple_size { static const size_t value = 1; }; Index: test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp === --- test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp +++ test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp @@ -64,18 +64,22 @@ void test_decomp_pair() { typedef std::pair T; { -T s{99, 42.1}; +T s{99, 42.5}; auto [m1, m2] = s; auto& [r1, r2] = s; assert(m1 == 99); +assert(m2 == 42.5); assert(&r1 == &std::get<0>(s)); +assert(&r2 == &std::get<1>(s)); } { -T const s{99, 42.1}; +T const s{99, 42.5}; auto [m1, m2] = s; auto& [r1, r2] = s; assert(m1 == 99); +assert(m2 == 42.5); assert(&r1 == &std::get<0>(s)); +assert(&r2 == &std::get<1>(s)); } } @@ -86,14 +90,22 @@ auto [m1, m2, m3] = s; auto& [r1, r2, r3] = s; assert(m1 == 99); +assert(m2 == 42); +assert(m3 == -1); assert(&r1 == &std::get<0>(s)); +assert(&r2 == &std::get<1>(s)); +assert(&r3 == &std::get<2>(s)); } { T const s{{99, 42, -1}}; auto [m1, m2, m3] = s; auto& [r1, r2, r3] = s; assert(m1 == 99); +assert(m2 == 42); +assert(m3 == -1); assert(&r1 == &std::get<0>(s)); +assert(&r2 == &std::get<1>(s)); +assert(&r3 == &std::get<2>(s)); } } @@ -105,8 +117,7 @@ int get(Test const&) { static_assert(N == 0, ""); return -1; } template <> -class std::tuple_element<0, Test> { -public: +struct std::tuple_element<0, Test> { typedef int type; }; @@ -117,8 +128,7 @@ } template <> -class std::tuple_size { -public: +struct std::tuple_size { static const size_t value = 1; }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33955: [libcxx] [test] Remove a Clang/C2 workaround.
STL_MSFT created this revision. [libcxx] [test] Remove a Clang/C2 workaround. Clang/LLVM doesn't need this workaround. https://reviews.llvm.org/D33955 Files: test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp Index: test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp === --- test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp +++ test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp @@ -48,14 +48,12 @@ assert(X::dtor_called == false); assert(static_cast(opt) == false); } -assert(X::dtor_called == false); // TRANSITION, Clang/C2 VSO#239997 { optional opt(X{}); X::dtor_called = false; opt.reset(); assert(X::dtor_called == true); assert(static_cast(opt) == false); X::dtor_called = false; } -assert(X::dtor_called == false); // TRANSITION, Clang/C2 VSO#239997 } Index: test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp === --- test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp +++ test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp @@ -48,14 +48,12 @@ assert(X::dtor_called == false); assert(static_cast(opt) == false); } -assert(X::dtor_called == false); // TRANSITION, Clang/C2 VSO#239997 { optional opt(X{}); X::dtor_called = false; opt.reset(); assert(X::dtor_called == true); assert(static_cast(opt) == false); X::dtor_called = false; } -assert(X::dtor_called == false); // TRANSITION, Clang/C2 VSO#239997 } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D33102: [clang] Implement -Wcast-qual for C++
On Tue, Jun 6, 2017 at 8:52 PM, David Blaikie wrote: > > > On Tue, Jun 6, 2017 at 3:59 AM Roman Lebedev via Phabricator > wrote: >> >> lebedev.ri added a comment. >> >> In https://reviews.llvm.org/D33102#773296, @dblaikie wrote: >> >> > I still feel like that's more testing than would be ideal (does the >> > context of the cast matter? Wether it's dereferenced, a struct member >> > access, assigned, initialized, etc - it doesn't look like it from the code, >> > etc). >> >> >> Looking at the `CastsAwayConstness()` function in lib/Sema/SemaCast.cpp: >> https://github.com/llvm-mirror/clang/blob/432ed0e4a6d58f7dda8992a167aad43bc91f76c6/lib/Sema/SemaCast.cpp#L505-L510 >> You can see that it asserts that the pointer is one of three types. So i >> think it it is best to have maybe slightly overlapping test coverage here, >> rather than be surprised one day that such trivial cases no longer warn... >> >> > But sure. Could you also (manually, I guess) confirm that this matches >> > GCC's cast-qual behavior (insofar as the warning fires in the same >> > situations). If there are any deviations, let's chat about them. >> >> Sure. >> >> 1. Gcc produces the same //count// of the warnings: >> >> $ pwd >> llvm/tools/clang/test >> $ grep -o "expected-warning" Sema/warn-cast-qual.c | wc -l >> 14 >> $ gcc -x c -fsyntax-only -Wcast-qual -c Sema/warn-cast-qual.c 2>&1 | >> grep ": warning: " | wc -l >> 14 >> $ gcc -x c++ -fsyntax-only -Wcast-qual -c Sema/warn-cast-qual.c 2>&1 | >> grep ": warning: " | wc -l >> 14 >> $ grep -o "expected-warning" SemaCXX/warn-cast-qual.cpp | wc -l >> 39 >> $ gcc -x c++ -fsyntax-only -Wcast-qual -c SemaCXX/warn-cast-qual.cpp >> 2>&1 | grep ": warning: " | wc -l >> 39 >> >> 2. I'm not quite sure how to non-manually compare the warnings, so i'll >> just show the gcc output on these three cases. Since the clang warnings are >> appended as comments at the end of the each line that should warn, visual >> comparison is possible: > Works for the positive cases, not the negative ones. (though if the counts > are exactly the same, then so long as there are no false positives there > aren't any false negatives either) Yes, fair enough, i do not have anything to add here. >> >> >> 2.1. >> >> $ gcc -x c -fsyntax-only -Wcast-qual -c Sema/warn-cast-qual.c >> Sema/warn-cast-qual.c: In function ‘foo’: >> Sema/warn-cast-qual.c:9:13: warning: cast discards ‘const’ qualifier >> from pointer target type [-Wcast-qual] >> char *y = (char *)ptr; // expected-warning {{cast from 'const char *' >> to 'char *' drops const qualifier}} >>^ >> Sema/warn-cast-qual.c:10:15: warning: cast discards ‘const’ qualifier >> from pointer target type [-Wcast-qual] >> char **y1 = (char **)ptrptr; // expected-warning {{cast from 'const >> char *const' to 'char *' drops const qualifier}} >> ^ >> Sema/warn-cast-qual.c:11:21: warning: cast discards ‘const’ qualifier >> from pointer target type [-Wcast-qual] >> const char **y2 = (const char **)ptrptr; // expected-warning {{cast >> from 'const char *const *' to 'const char **' drops const qualifier}} >>^ >> Sema/warn-cast-qual.c:14:14: warning: cast discards ‘const’ qualifier >> from pointer target type [-Wcast-qual] >> char *z1 = (char *)(const void *)ptr; // expected-warning {{cast from >> 'const void *' to 'char *' drops const qualifier}} >> ^ >> Sema/warn-cast-qual.c:17:16: warning: cast discards ‘volatile’ qualifier >> from pointer target type [-Wcast-qual] >> char *vol2 = (char *)vol; // expected-warning {{cast from 'volatile >> char *' to 'char *' drops volatile qualifier}} >> ^ >> Sema/warn-cast-qual.c:19:17: warning: cast discards ‘const volatile’ >> qualifier from pointer target type [-Wcast-qual] >> char *volc2 = (char *)volc; // expected-warning {{cast from 'const >> volatile char *' to 'char *' drops const and volatile qualifiers}} >>^ >> Sema/warn-cast-qual.c:22:28: warning: to be safe all intermediate >> pointers in cast from ‘int **’ to ‘const int **’ must be ‘const’ qualified >> [-Wcast-qual] >> const int **intptrptrc = (const int **)intptrptr; // expected-warning >> {{cast from 'int **' to 'const int **' must have all intermediate pointers >> const qualified}} >> ^ >> Sema/warn-cast-qual.c:23:31: warning: to be safe all intermediate >> pointers in cast from ‘int **’ to ‘volatile int **’ must be ‘const’ >> qualified [-Wcast-qual] >> volatile int **intptrptrv = (volatile int **)intptrptr; // >> expected-warning {{cast from 'int **' to 'volatile int **' must have all >> intermediate pointers const qualified}} >> ^ >> Sema/warn-cast-qual.c:29:23: warning: cast discards ‘const’ qualifier >> from pointer target type [-Wcast-qual] >> char **charptrptr = (char **)charptrptrc; // expected-warning {{cast >> from 'const ch
[PATCH] D33959: Adjust SetVersionPrinter call for D33899
dim created this revision. In https://reviews.llvm.org/D33899, I'm adding a `raw_ostream &` parameter to the function objects passed to `cl::SetVersionPrinter`. Adjust the call in clang-apply-replacements for this. https://reviews.llvm.org/D33959 Files: clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp Index: clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp === --- clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp +++ clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp @@ -82,8 +82,8 @@ }; } // namespace -static void printVersion() { - outs() << "clang-apply-replacements version " CLANG_VERSION_STRING << "\n"; +static void printVersion(raw_ostream &OS) { + OS << "clang-apply-replacements version " CLANG_VERSION_STRING << "\n"; } /// \brief Convenience function to get rewritten content for \c Filename from @@ -199,7 +199,7 @@ int main(int argc, char **argv) { cl::HideUnrelatedOptions(makeArrayRef(VisibleCategories)); - cl::SetVersionPrinter(&printVersion); + cl::SetVersionPrinter(printVersion); cl::ParseCommandLineOptions(argc, argv); IntrusiveRefCntPtr DiagOpts(new DiagnosticOptions()); Index: clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp === --- clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp +++ clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp @@ -82,8 +82,8 @@ }; } // namespace -static void printVersion() { - outs() << "clang-apply-replacements version " CLANG_VERSION_STRING << "\n"; +static void printVersion(raw_ostream &OS) { + OS << "clang-apply-replacements version " CLANG_VERSION_STRING << "\n"; } /// \brief Convenience function to get rewritten content for \c Filename from @@ -199,7 +199,7 @@ int main(int argc, char **argv) { cl::HideUnrelatedOptions(makeArrayRef(VisibleCategories)); - cl::SetVersionPrinter(&printVersion); + cl::SetVersionPrinter(printVersion); cl::ParseCommandLineOptions(argc, argv); IntrusiveRefCntPtr DiagOpts(new DiagnosticOptions()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33900: Print registered targets in clang's version information
mehdi_amini accepted this revision. mehdi_amini added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D33900 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31972: Do not force the frame pointer by default for ARM EABI
efriedma added a comment. Please start a thread on cfe-dev about this; most developers don't read cfe-commits, and thinking about it a bit more, I'm not confident omitting frame pointers is really a good default. I would guess there's existing code which depends on frame pointers to come up with a stack trace, since table-based unwinding is complicated and takes up a lot of space. Grepping over the in-tree tests, it looks like the "eabi" triples used in practice are "arm-non-eabi", "arm-netbsd-eabi" and variants of "thumbv7m-apple-darwin-eabi" (and variants of those). Please make sure you aren't changing the behavior of netbsd and "Darwin" targets. https://reviews.llvm.org/D31972 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33719: Add _Float16 as a C/C++ source language type
bruno added a comment. > About the tests and using --target=aarch64: you're right that there should > nothing be ARM specific here, but it is just that for Aarch64 it will show > "half" IR types which I preferred, while it looks like x86 way of dealing > with is to convert it and work on i16 types. Perhaps I need tests for both? The ideal is to have x86 and ARM tests when testing for the codegen part of it. Keep in mind that you need "REQUIRES: -registered-target" for those. https://reviews.llvm.org/D33719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33732: Catch invalid bitwise operation on vector of floats
bruno accepted this revision. bruno added a comment. This revision is now accepted and ready to land. LGTM Comment at: test/Sema/ext_vector_ops.c:22 + int array2[17]; + // FIXME: error message below needs type! + (void)(array2[v2ua]); // expected-error{{array subscript is not an integer}} Can you file a PR for this? https://reviews.llvm.org/D33732 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r304836 - Print registered targets in clang's version information
Author: dim Date: Tue Jun 6 16:54:21 2017 New Revision: 304836 URL: http://llvm.org/viewvc/llvm-project?rev=304836&view=rev Log: Print registered targets in clang's version information Summary: Other llvm tools display their registered targets when showing version information, but for some reason clang has never done this. To support this, D33899 adds the llvm parts, which make it possible to print version information to arbitrary raw_ostreams. This change adds a call to printRegisteredTargetsForVersion in clang's PrintVersion, and adds a raw_ostream parameter to two other PrintVersion functions. Reviewers: beanz, chandlerc, dberris, mehdi_amini, zturner Reviewed By: mehdi_amini Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33900 Modified: cfe/trunk/lib/Driver/Driver.cpp cfe/trunk/tools/clang-format/ClangFormat.cpp cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=304836&r1=304835&r2=304836&view=diff == --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Tue Jun 6 16:54:21 2017 @@ -68,6 +68,7 @@ #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Process.h" #include "llvm/Support/Program.h" +#include "llvm/Support/TargetRegistry.h" #include "llvm/Support/raw_ostream.h" #include #include @@ -1116,6 +1117,10 @@ void Driver::PrintVersion(const Compilat // Print out the install directory. OS << "InstalledDir: " << InstalledDir << '\n'; + + // Print registered targets. + OS << '\n'; + llvm::TargetRegistry::printRegisteredTargetsForVersion(OS); } /// PrintDiagnosticCategories - Implement the --print-diagnostic-categories Modified: cfe/trunk/tools/clang-format/ClangFormat.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/ClangFormat.cpp?rev=304836&r1=304835&r2=304836&view=diff == --- cfe/trunk/tools/clang-format/ClangFormat.cpp (original) +++ cfe/trunk/tools/clang-format/ClangFormat.cpp Tue Jun 6 16:54:21 2017 @@ -328,8 +328,7 @@ static bool format(StringRef FileName) { } // namespace format } // namespace clang -static void PrintVersion() { - raw_ostream &OS = outs(); +static void PrintVersion(raw_ostream &OS) { OS << clang::getClangToolFullVersion("clang-format") << '\n'; } Modified: cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp?rev=304836&r1=304835&r2=304836&view=diff == --- cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp (original) +++ cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp Tue Jun 6 16:54:21 2017 @@ -915,8 +915,7 @@ static bool UnbundleFiles() { return false; } -static void PrintVersion() { - raw_ostream &OS = outs(); +static void PrintVersion(raw_ostream &OS) { OS << clang::getClangToolFullVersion("clang-offload-bundler") << '\n'; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r304837 - Adjust SetVersionPrinter call for D33899
Author: dim Date: Tue Jun 6 16:54:45 2017 New Revision: 304837 URL: http://llvm.org/viewvc/llvm-project?rev=304837&view=rev Log: Adjust SetVersionPrinter call for D33899 Summary: In D33899, I'm adding a `raw_ostream &` parameter to the function objects passed to `cl::SetVersionPrinter`. Adjust the call in clang-apply-replacements for this. Reviewers: klimek, alexfh Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33959 Modified: clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp Modified: clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp?rev=304837&r1=304836&r2=304837&view=diff == --- clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp (original) +++ clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp Tue Jun 6 16:54:45 2017 @@ -82,8 +82,8 @@ private: }; } // namespace -static void printVersion() { - outs() << "clang-apply-replacements version " CLANG_VERSION_STRING << "\n"; +static void printVersion(raw_ostream &OS) { + OS << "clang-apply-replacements version " CLANG_VERSION_STRING << "\n"; } /// \brief Convenience function to get rewritten content for \c Filename from @@ -199,7 +199,7 @@ applyFormatting(const std::vector DiagOpts(new DiagnosticOptions()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33959: Adjust SetVersionPrinter call for D33899
This revision was automatically updated to reflect the committed changes. Closed by commit rL304837: Adjust SetVersionPrinter call for D33899 (authored by dim). Changed prior to commit: https://reviews.llvm.org/D33959?vs=101623&id=101630#toc Repository: rL LLVM https://reviews.llvm.org/D33959 Files: clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp Index: clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp === --- clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp +++ clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp @@ -82,8 +82,8 @@ }; } // namespace -static void printVersion() { - outs() << "clang-apply-replacements version " CLANG_VERSION_STRING << "\n"; +static void printVersion(raw_ostream &OS) { + OS << "clang-apply-replacements version " CLANG_VERSION_STRING << "\n"; } /// \brief Convenience function to get rewritten content for \c Filename from @@ -199,7 +199,7 @@ int main(int argc, char **argv) { cl::HideUnrelatedOptions(makeArrayRef(VisibleCategories)); - cl::SetVersionPrinter(&printVersion); + cl::SetVersionPrinter(printVersion); cl::ParseCommandLineOptions(argc, argv); IntrusiveRefCntPtr DiagOpts(new DiagnosticOptions()); Index: clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp === --- clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp +++ clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp @@ -82,8 +82,8 @@ }; } // namespace -static void printVersion() { - outs() << "clang-apply-replacements version " CLANG_VERSION_STRING << "\n"; +static void printVersion(raw_ostream &OS) { + OS << "clang-apply-replacements version " CLANG_VERSION_STRING << "\n"; } /// \brief Convenience function to get rewritten content for \c Filename from @@ -199,7 +199,7 @@ int main(int argc, char **argv) { cl::HideUnrelatedOptions(makeArrayRef(VisibleCategories)); - cl::SetVersionPrinter(&printVersion); + cl::SetVersionPrinter(printVersion); cl::ParseCommandLineOptions(argc, argv); IntrusiveRefCntPtr DiagOpts(new DiagnosticOptions()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D33719: Add _Float16 as a C/C++ source language type
On 5 June 2017 at 03:49, Sjoerd Meijer via Phabricator via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Yes, initially I wanted to unconditionally support _Float16, but now that > you asked how about it, I agree it makes more sense to enable it for C11 > and C++11 and have: KEYWORD(_Float16, KEYC11|KEYCXX11) Why? All of the other C11 keywords are made available (as an extension) in all language modes. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32385: [libcxx] optional: Implement LWG 2900 and P0602
CaseyCarter updated this revision to Diff 101631. CaseyCarter edited the summary of this revision. CaseyCarter added a comment. Incorporate the libcxx test tree `special_member_gen` test into the std test, making my per-SMF triviality tests unnecessary. https://reviews.llvm.org/D32385 Files: include/optional test/libcxx/utilities/optional/optional.object/special_member_gen.pass.cpp test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp test/std/utilities/optional/optional.object/special_member_gen.pass.cpp Index: test/std/utilities/optional/optional.object/special_member_gen.pass.cpp === --- test/std/utilities/optional/optional.object/special_member_gen.pass.cpp +++ test/std/utilities/optional/optional.object/special_member_gen.pass.cpp @@ -33,10 +33,38 @@ "optional is copy assignable if and only if T is both copy " "constructible and copy assignable."); static_assert(std::is_move_assignable_v == -((std::is_copy_constructible_v && std::is_copy_assignable_v) || - (std::is_move_constructible_v && std::is_move_assignable_v)), -"optional is move assignable if and only if T is both move assignable and " -"move constructible, or both copy constructible and copy assignable."); +((std::is_move_constructible_v && std::is_move_assignable_v) || + (std::is_copy_constructible_v && std::is_copy_assignable_v)), +"optional is move assignable if and only if T is both move constructible and " +"move assignable, or both copy constructible and copy assignable."); + +// The following tests are for not-yet-standardized behavior (P0602): +static_assert(std::is_trivially_destructible_v == +std::is_trivially_destructible_v, +"optional is trivially destructible if and only if T is."); +static_assert(std::is_trivially_copy_constructible_v == +std::is_trivially_copy_constructible_v, +"optional is trivially copy constructible if and only if T is."); +static_assert(std::is_trivially_move_constructible_v == +std::is_trivially_move_constructible_v || +(!std::is_move_constructible_v && std::is_trivially_copy_constructible_v), +"optional is trivially move constructible if T is trivially move constructible, " +"or if T is trivially copy constructible and is not move constructible."); +static_assert(std::is_trivially_copy_assignable_v == +(std::is_trivially_destructible_v && + std::is_trivially_copy_constructible_v && + std::is_trivially_copy_assignable_v), +"optional is trivially copy assignable if and only if T is trivially destructible, " +"trivially copy constructible, and trivially copy assignable."); +static_assert(std::is_trivially_move_assignable_v == +(std::is_trivially_destructible_v && + ((std::is_trivially_move_constructible_v && std::is_trivially_move_assignable_v) || + ((!std::is_move_constructible_v || !std::is_move_assignable_v) && + std::is_trivially_copy_constructible_v && std::is_trivially_copy_assignable_v))), +"optional is trivially move assignable if T is trivially destructible, and either " +"(1) trivially move constructible and trivially move assignable, or " +"(2) not move constructible or not move assignable, and " +"trivially copy constructible and trivially copy assignable."); }; template static void sink(Args&&...) {} Index: test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp === --- test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp +++ test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp @@ -55,10 +55,10 @@ void test_throwing_ctor() { #ifndef TEST_HAS_NO_EXCEPTIONS struct Z { - Z() : count(0) {} - Z(Z&& o) : count(o.count + 1) - { if (count == 2) throw 6; } - int count; +Z() : count(0) {} +Z(Z&& o) : count(o.count + 1) +{ if (count == 2) throw 6; } +int count; }; Z z; optional rhs(std::move(z)); @@ -157,7 +157,7 @@ test(3); static_assert(constexpr_test(), "" ); static_assert(constexpr_test(3), "" ); - + { optional o(42); optional o2(std::move(o)); Index: test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp === --- test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp +++ test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp @@ -45,10 +45,10 @@ void test_throwing_ctor() { #ifn
r304840 - [DOXYGEN] Corrected several typos and incorrect parameters description that Sony's techinical writer found during review.
Author: kromanova Date: Tue Jun 6 17:58:01 2017 New Revision: 304840 URL: http://llvm.org/viewvc/llvm-project?rev=304840&view=rev Log: [DOXYGEN] Corrected several typos and incorrect parameters description that Sony's techinical writer found during review. I got an OK from Eric Christopher to commit doxygen comments without prior code review upstream. Modified: cfe/trunk/lib/Headers/avxintrin.h cfe/trunk/lib/Headers/bmiintrin.h cfe/trunk/lib/Headers/emmintrin.h cfe/trunk/lib/Headers/xmmintrin.h Modified: cfe/trunk/lib/Headers/avxintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avxintrin.h?rev=304840&r1=304839&r2=304840&view=diff == --- cfe/trunk/lib/Headers/avxintrin.h (original) +++ cfe/trunk/lib/Headers/avxintrin.h Tue Jun 6 17:58:01 2017 @@ -3603,7 +3603,7 @@ _mm256_stream_si256(__m256i *__a, __m256 /// /// \param __a ///A pointer to a 32-byte aligned memory location that will receive the -///integer values. +///double-precision floating-point values. /// \param __b ///A 256-bit vector of [4 x double] containing the values to be moved. static __inline void __DEFAULT_FN_ATTRS Modified: cfe/trunk/lib/Headers/bmiintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/bmiintrin.h?rev=304840&r1=304839&r2=304840&view=diff == --- cfe/trunk/lib/Headers/bmiintrin.h (original) +++ cfe/trunk/lib/Headers/bmiintrin.h Tue Jun 6 17:58:01 2017 @@ -148,7 +148,7 @@ __blsi_u32(unsigned int __X) } /// \brief Creates a mask whose bits are set to 1, using bit 0 up to and -///including the least siginificant bit that is set to 1 in the source +///including the least significant bit that is set to 1 in the source ///operand and returns the result. /// /// \headerfile @@ -164,7 +164,7 @@ __blsmsk_u32(unsigned int __X) return __X ^ (__X - 1); } -/// \brief Clears the least siginificant bit that is set to 1 in the source +/// \brief Clears the least significant bit that is set to 1 in the source ///operand and returns the result. /// /// \headerfile @@ -309,7 +309,7 @@ __blsi_u64(unsigned long long __X) } /// \brief Creates a mask whose bits are set to 1, using bit 0 up to and -///including the least siginificant bit that is set to 1 in the source +///including the least significant bit that is set to 1 in the source ///operand and returns the result. /// /// \headerfile @@ -325,7 +325,7 @@ __blsmsk_u64(unsigned long long __X) return __X ^ (__X - 1); } -/// \brief Clears the least siginificant bit that is set to 1 in the source +/// \brief Clears the least significant bit that is set to 1 in the source ///operand and returns the result. /// /// \headerfile Modified: cfe/trunk/lib/Headers/emmintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/emmintrin.h?rev=304840&r1=304839&r2=304840&view=diff == --- cfe/trunk/lib/Headers/emmintrin.h (original) +++ cfe/trunk/lib/Headers/emmintrin.h Tue Jun 6 17:58:01 2017 @@ -302,7 +302,7 @@ _mm_min_pd(__m128d __a, __m128d __b) return __builtin_ia32_minpd((__v2df)__a, (__v2df)__b); } -/// \brief Compares lower 64-bits double-precision values of both operands, and +/// \brief Compares lower 64-bit double-precision values of both operands, and ///returns the greater of the pair of values in the lower 64-bits of the ///result. The upper 64 bits of the result are copied from the upper double- ///precision value of the first operand. @@ -1652,7 +1652,7 @@ _mm_loadu_pd(double const *__dp) /// /// This intrinsic corresponds to the VMOVQ / MOVQ instruction. /// -/// \param __dp +/// \param __a ///A pointer to a 64-bit memory location. The address of the memory ///location does not have to be aligned. /// \returns A 128-bit vector of [2 x i64] containing the loaded value. @@ -1674,7 +1674,7 @@ _mm_loadu_si64(void const *__a) /// This intrinsic corresponds to the VMOVSD / MOVSD instruction. /// /// \param __dp -///An pointer to a memory location containing a double-precision value. +///A pointer to a memory location containing a double-precision value. ///The address of the memory location does not have to be aligned. /// \returns A 128-bit vector of [2 x double] containing the loaded value. static __inline__ __m128d __DEFAULT_FN_ATTRS @@ -1911,12 +1911,38 @@ _mm_store_sd(double *__dp, __m128d __a) ((struct __mm_store_sd_struct*)__dp)->__u = __a[0]; } +/// \brief Moves packed double-precision values from a 128-bit vector of +///[2 x double] to a memory location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVAPD / MOVAPS instruction. +/// +/// \param __dp +///A pointer to an aligned memory location that can stor
[libcxx] r304847 - [test] Test changes to accommodate LWG 2904 "Make variant move-assignment more exception safe"
Author: caseycarter Date: Tue Jun 6 19:06:04 2017 New Revision: 304847 URL: http://llvm.org/viewvc/llvm-project?rev=304847&view=rev Log: [test] Test changes to accommodate LWG 2904 "Make variant move-assignment more exception safe" Also: Move constexpr / triviality extension tests into the std tree and make them conditional on _LIBCPP_VERSION / _MSVC_STL_VERSION. https://reviews.llvm.org/D32671 Removed: libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.ctor/move.pass.cpp Modified: libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp libcxx/trunk/test/support/variant_test_helpers.hpp Removed: libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp?rev=304846&view=auto == --- libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp (original) +++ libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp (removed) @@ -1,209 +0,0 @@ -// -*- C++ -*- -//===--===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===--===// - -// UNSUPPORTED: c++98, c++03, c++11, c++14 - -// The following compilers don't generate constexpr special members correctly. -// XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8 -// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8.0 - -// - -// template class variant; - -// variant& operator=(variant const&); - -#include -#include - -#include "test_macros.h" - -struct NTCopyAssign { - constexpr NTCopyAssign(int v) : value(v) {} - NTCopyAssign(const NTCopyAssign &) = default; - NTCopyAssign(NTCopyAssign &&) = default; - NTCopyAssign &operator=(const NTCopyAssign &that) { -value = that.value; -return *this; - }; - NTCopyAssign &operator=(NTCopyAssign &&) = delete; - int value; -}; - -static_assert(!std::is_trivially_copy_assignable::value, ""); -static_assert(std::is_copy_assignable::value, ""); - -struct TCopyAssign { - constexpr TCopyAssign(int v) : value(v) {} - TCopyAssign(const TCopyAssign &) = default; - TCopyAssign(TCopyAssign &&) = default; - TCopyAssign &operator=(const TCopyAssign &) = default; - TCopyAssign &operator=(TCopyAssign &&) = delete; - int value; -}; - -static_assert(std::is_trivially_copy_assignable::value, ""); - -struct TCopyAssignNTMoveAssign { - constexpr TCopyAssignNTMoveAssign(int v) : value(v) {} - TCopyAssignNTMoveAssign(const TCopyAssignNTMoveAssign &) = default; - TCopyAssignNTMoveAssign(TCopyAssignNTMoveAssign &&) = default; - TCopyAssignNTMoveAssign &operator=(const TCopyAssignNTMoveAssign &) = default; - TCopyAssignNTMoveAssign &operator=(TCopyAssignNTMoveAssign &&that) { -value = that.value; -that.value = -1; -return *this; - } - int value; -}; - -static_assert(std::is_trivially_copy_assignable_v, ""); - -void test_copy_assignment_sfinae() { - { -using V = std::variant; -static_assert(std::is_trivially_copy_assignable::value, ""); - } - { -using V = std::variant; -static_assert(!std::is_trivially_copy_assignable::value, ""); -static_assert(std::is_copy_assignable::value, ""); - } - { -using V = std::variant; -static_assert(std::is_trivially_copy_assignable::value, ""); - } - { -using V = std::variant; -static_assert(std::is_trivially_copy_assignable::value, ""); - } -} - -template struct Result { size_t index; T value; }; - -void test_copy_assignment_same_index() { - { -struct { - constexpr Result operator()() const { -using V = std::variant; -V v(43); -V v2(42); -v = v2; -return {v.index(), std::get<0>(v)}; - } -} test; -constexpr auto result = test(); -static_assert(result.index == 0, ""); -static_assert(result.value == 42, ""); - } - { -struct { - constexpr Result operator()() const { -using V = std::var
r304852 - Improve error recovery for missing 'template' keyword in contexts where the
Author: rsmith Date: Tue Jun 6 19:29:44 2017 New Revision: 304852 URL: http://llvm.org/viewvc/llvm-project?rev=304852&view=rev Log: Improve error recovery for missing 'template' keyword in contexts where the template is valid with or without it (with different meanings). If we see "dependent.x<...", and what follows the '<' is a valid expression, we must parse the '<' as a comparison rather than a template angle bracket. When we later come to instantiate, if we find that the LHS of the '<' actually names an overload set containing function templates, produce a diagnostic suggesting that the 'template' keyword was missed rather than producing a mysterious diagnostic saying that the function must be called (and pointing at what looks to already be a function call!). Modified: cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/SemaTemplate/dependent-template-recover.cpp Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=304852&r1=304851&r2=304852&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jun 6 19:29:44 2017 @@ -11828,6 +11828,32 @@ ExprResult Sema::BuildBinOp(Scope *S, So RHSExpr->getType()->isOverloadableType()) return BuildOverloadedBinOp(*this, S, OpLoc, Opc, LHSExpr, RHSExpr); } + +// If we're instantiating "a.x < b" or "A::x < b" and 'x' names a function +// template, diagnose the missing 'template' keyword instead of diagnosing +// an invalid use of a bound member function. +// +// Note that "A::x < b" might be valid if 'b' has an overloadable type due +// to C++1z [over.over]/1.4, but we already checked for that case above. +if (Opc == BO_LT && inTemplateInstantiation() && +(pty->getKind() == BuiltinType::BoundMember || + pty->getKind() == BuiltinType::Overload)) { + auto *OE = dyn_cast(LHSExpr); + if (OE && !OE->hasTemplateKeyword() && !OE->hasExplicitTemplateArgs() && + std::any_of(OE->decls_begin(), OE->decls_end(), [](NamedDecl *ND) { +return isa(ND); + })) { +if (auto *Q = OE->getQualifier()) { + Diag(OE->getQualifierLoc().getBeginLoc(), + diag::err_template_kw_missing) +<< OE->getName().getAsString() << ""; +} else { + Diag(OE->getNameLoc(), diag::err_template_kw_missing) +<< OE->getName().getAsString() << ""; +} +return ExprError(); + } +} ExprResult LHS = CheckPlaceholderExpr(LHSExpr); if (LHS.isInvalid()) return ExprError(); Modified: cfe/trunk/test/SemaTemplate/dependent-template-recover.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/dependent-template-recover.cpp?rev=304852&r1=304851&r2=304852&view=diff == --- cfe/trunk/test/SemaTemplate/dependent-template-recover.cpp (original) +++ cfe/trunk/test/SemaTemplate/dependent-template-recover.cpp Tue Jun 6 19:29:44 2017 @@ -17,6 +17,28 @@ struct X { } }; +struct MrsBadcrumble { + friend MrsBadcrumble operator<(void (*)(int), MrsBadcrumble); + friend void operator>(MrsBadcrumble, int); +} mb; + +template void f(T t) { + t.f(0); // expected-error {{missing 'template' keyword prior to dependent template name 'f'}} + t.T::f(0); // expected-error {{missing 'template' keyword prior to dependent template name 'f'}} + T::g(0); // expected-error {{missing 'template' keyword prior to dependent template name 'g'}} + + // Note: no diagnostic here, this is actually valid as a comparison between + // the decayed pointer to Y::g<> and mb! + T::g(0); +} + +struct Y { + template void f(int); + template static void g(int); // expected-warning 0-1{{extension}} +}; +void q() { void (*p)(int) = Y::g; } +template void f<0>(Y); // expected-note {{in instantiation of}} + namespace PR9401 { // From GCC PR c++/45558 template ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33875: PR27037: Use correct CVR qualifier on an upcast on method pointer call
tzik marked an inline comment as done. tzik added a comment. In https://reviews.llvm.org/D33875#774293, @rsmith wrote: > Looks good to me, thanks! Do you need someone to commit this for you? Yes, could you commit this? https://reviews.llvm.org/D33875 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications
hintonda updated this revision to Diff 101659. hintonda added a comment. Herald added a subscriber: xazax.hun. In order to fix diagnostic corruption in some of the buildbot tests (unable to reproduce locally): - make NoexceptMacro a static variable so it's lifetime doesn't end when UseNoexceptCheck is destroyed. - pass a const char* instead of a StringRef to DiagnosticBuilder so it won't create a temporary std::string and cache the address of the temporary char * it owns. https://reviews.llvm.org/D20693 Files: clang-tidy/modernize/CMakeLists.txt clang-tidy/modernize/ModernizeTidyModule.cpp clang-tidy/modernize/UseNoexceptCheck.cpp clang-tidy/modernize/UseNoexceptCheck.h docs/ReleaseNotes.rst docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/modernize-use-noexcept.rst test/clang-tidy/modernize-use-noexcept-macro.cpp test/clang-tidy/modernize-use-noexcept-opt.cpp test/clang-tidy/modernize-use-noexcept.cpp Index: test/clang-tidy/modernize-use-noexcept.cpp === --- /dev/null +++ test/clang-tidy/modernize-use-noexcept.cpp @@ -0,0 +1,104 @@ +// RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \ +// RUN: -- -std=c++11 + +class A {}; +class B {}; + +void foo() throw(); +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept] +// CHECK-FIXES: void foo() noexcept; + +template +void foo() throw(); +void footest() { foo(); foo(); } +// CHECK-MESSAGES: :[[@LINE-2]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept] +// CHECK-FIXES: void foo() noexcept; + +void bar() throw(...); +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw(...)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept] +// CHECK-FIXES: void bar() noexcept(false); + +void k() throw(int(int)); +// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int))' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept] +// CHECK-FIXES: void k() noexcept(false); + +void foobar() throw(A, B) +{} +// CHECK-MESSAGES: :[[@LINE-2]]:15: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept] +// CHECK-FIXES: void foobar() noexcept(false) + +void baz(int = (throw A(), 0)) throw(A, B) {} +// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept] +// CHECK-FIXES: void baz(int = (throw A(), 0)) noexcept(false) {} + +void g(void (*fp)(void) throw()); +// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept] +// CHECK-FIXES: void g(void (*fp)(void) noexcept); + +void f(void (*fp)(void) throw(int)) throw(char); +// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept] +// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: dynamic exception specification 'throw(char)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept] +// CHECK-FIXES: void f(void (*fp)(void) noexcept(false)) noexcept(false); + +#define THROW throw +void h(void (*fp)(void) THROW(int)) THROW(char); +// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'THROW(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept] +// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: dynamic exception specification 'THROW(char)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept] +// CHECK-FIXES: void h(void (*fp)(void) noexcept(false)) noexcept(false); + +void j() throw(int(int) throw(void(void) throw(int))); +// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int) throw(void(void) throw(int)))' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept] +// CHECK-FIXES: void j() noexcept(false); + +class Y { + Y() throw() = default; +}; +// CHECK-MESSAGES: :[[@LINE-2]]:7: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept] +// CHECK-FIXES: Y() noexcept = default; + +struct Z { + void operator delete(void *ptr) throw(); + void operator delete[](void *ptr) throw(int); + ~Z() throw(int) {} +}; +// CHECK-MESSAGES: :[[@LINE-4]]:35: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept] +// CHECK-MESSAGES: :[[@LINE-4]]:37: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [
[PATCH] D17215: [Sema] Fix PR14211 Crash for explicit instantiation of overloaded template function within class template
hintonda added a comment. Since I don't have commit access, could you commit this for me? thanks... don https://reviews.llvm.org/D17215 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r304859 - [WebAssembly] Set MaxAtomicInlineWidth to 64.
Author: djg Date: Tue Jun 6 21:22:40 2017 New Revision: 304859 URL: http://llvm.org/viewvc/llvm-project?rev=304859&view=rev Log: [WebAssembly] Set MaxAtomicInlineWidth to 64. The WebAssembly threads proposal has changed such that C++ implementations can now declare that atomics up to 64 bits are "lock free" in C++'s terms. Modified: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/test/Preprocessor/init.c Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=304859&r1=304858&r2=304859&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Tue Jun 6 21:22:40 2017 @@ -8476,7 +8476,7 @@ public: explicit WebAssembly32TargetInfo(const llvm::Triple &T, const TargetOptions &Opts) : WebAssemblyTargetInfo(T, Opts) { -MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32; +MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64; resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128"); } Modified: cfe/trunk/test/Preprocessor/init.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=304859&r1=304858&r2=304859&view=diff == --- cfe/trunk/test/Preprocessor/init.c (original) +++ cfe/trunk/test/Preprocessor/init.c Tue Jun 6 21:22:40 2017 @@ -8851,7 +8851,7 @@ // WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_CHAR32_T_LOCK_FREE 2 // WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_CHAR_LOCK_FREE 2 // WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_INT_LOCK_FREE 2 -// WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_LLONG_LOCK_FREE 1 +// WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_LLONG_LOCK_FREE 2 // WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_LONG_LOCK_FREE 2 // WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_POINTER_LOCK_FREE 2 // WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_SHORT_LOCK_FREE 2 @@ -8895,7 +8895,7 @@ // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR_LOCK_FREE 2 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_INT_LOCK_FREE 2 -// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 1 +// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 2 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LONG_LOCK_FREE 2 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_POINTER_LOCK_FREE 2 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_SHORT_LOCK_FREE 2 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r304862 - Fix a couple of class template argument deduction crashes with libc++'s tuple.
Author: rsmith Date: Tue Jun 6 21:42:27 2017 New Revision: 304862 URL: http://llvm.org/viewvc/llvm-project?rev=304862&view=rev Log: Fix a couple of class template argument deduction crashes with libc++'s tuple. RecursiveASTVisitor was not properly recursing through a SubstTemplateTypeParmTypes, resulting in crashes in pack expansion where we couldn't always find an unexpanded pack within a pack expansion. We also have an issue where substitution of deduced template arguments for an implicit deduction guide creates the "impossible" case of naming a non-dependent member of the current instantiation, but within a specialization that is actually instantiated from a different (partial/explicit) specialization of the template. We resolve this by declaring that constructors that do so can only be used to deduce specializations of the primary template. I'm running this past CWG to see if people agree this is the right thing to do. Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=304862&r1=304861&r2=304862&view=diff == --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original) +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Tue Jun 6 21:42:27 2017 @@ -1021,8 +1021,12 @@ DEF_TRAVERSE_TYPE(DeducedTemplateSpecial DEF_TRAVERSE_TYPE(RecordType, {}) DEF_TRAVERSE_TYPE(EnumType, {}) DEF_TRAVERSE_TYPE(TemplateTypeParmType, {}) -DEF_TRAVERSE_TYPE(SubstTemplateTypeParmType, {}) -DEF_TRAVERSE_TYPE(SubstTemplateTypeParmPackType, {}) +DEF_TRAVERSE_TYPE(SubstTemplateTypeParmType, { + TRY_TO(TraverseType(T->getReplacementType())); +}) +DEF_TRAVERSE_TYPE(SubstTemplateTypeParmPackType, { + TRY_TO(TraverseTemplateArgument(T->getArgumentPack())); +}) DEF_TRAVERSE_TYPE(TemplateSpecializationType, { TRY_TO(TraverseTemplateName(T->getTemplateName())); @@ -1249,8 +1253,12 @@ DEF_TRAVERSE_TYPELOC(DeducedTemplateSpec DEF_TRAVERSE_TYPELOC(RecordType, {}) DEF_TRAVERSE_TYPELOC(EnumType, {}) DEF_TRAVERSE_TYPELOC(TemplateTypeParmType, {}) -DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmType, {}) -DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmPackType, {}) +DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmType, { + TRY_TO(TraverseType(TL.getTypePtr()->getReplacementType())); +}) +DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmPackType, { + TRY_TO(TraverseTemplateArgument(TL.getTypePtr()->getArgumentPack())); +}) // FIXME: use the loc for the template name? DEF_TRAVERSE_TYPELOC(TemplateSpecializationType, { Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=304862&r1=304861&r2=304862&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jun 6 21:42:27 2017 @@ -5613,6 +5613,11 @@ def err_enumerator_does_not_exist : Erro def note_enum_specialized_here : Note< "enum %0 was explicitly specialized here">; +def err_specialization_not_primary_template : Error< + "cannot reference member of primary template because deduced class " + "template specialization %0 is %select{instantiated from a partial|" + "an explicit}1 specialization">; + def err_member_redeclared : Error<"class member cannot be redeclared">; def ext_member_redeclared : ExtWarn<"class member cannot be redeclared">, InGroup; Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=304862&r1=304861&r2=304862&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Tue Jun 6 21:42:27 2017 @@ -7640,6 +7640,9 @@ public: LateInstantiatedAttrVec *LateAttrs = nullptr, LocalInstantiationScope *OuterMostScope = nullptr); + bool usesPartialOrExplicitSpecialization( + SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec); + bool InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=304862&r1=304861&r2=304862&view=diff =
r304863 - Fixed warning: 'virtual void clang::ExternalASTSource::CompleteType(clang::ObjCInterfaceDecl*)' was hidden.
Author: gkistanova Date: Tue Jun 6 21:44:42 2017 New Revision: 304863 URL: http://llvm.org/viewvc/llvm-project?rev=304863&view=rev Log: Fixed warning: 'virtual void clang::ExternalASTSource::CompleteType(clang::ObjCInterfaceDecl*)' was hidden. Modified: cfe/trunk/include/clang/AST/ExternalASTMerger.h Modified: cfe/trunk/include/clang/AST/ExternalASTMerger.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTMerger.h?rev=304863&r1=304862&r2=304863&view=diff == --- cfe/trunk/include/clang/AST/ExternalASTMerger.h (original) +++ cfe/trunk/include/clang/AST/ExternalASTMerger.h Tue Jun 6 21:44:42 2017 @@ -45,6 +45,8 @@ public: llvm::function_ref IsKindWeWant, SmallVectorImpl &Result) override; + using ExternalASTSource::CompleteType; + void CompleteType(TagDecl *Tag) override; }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33976: [clang] Fix format specifiers fixits
alexshap created this revision. This diff fixes printf "fixits" in the case when there is a wrapping macro and the format string needs multiple replacements. In the presence of a macro there was an extra logic in EditedSource.cpp to handle multiple uses of the same macro argument (see the old comment inside EditedSource::canInsertInOffset) which was mistriggering when the argument was used only once but required multiple adjustments), as a result the "fixit" was breaking down the format string by dropping the second format specifier, i.e. Log1("test 4: %s %s", getNSInteger(), getNSInteger()) was getting replaced with Log1("test 4: %ld ", (long)getNSInteger(), (long)getNSInteger()) (if one removed the macro and used printf directly it would work fine). In this diff we track the location where the macro argument is used and (as it was before) the modifications originating from all the locations except the first one are rejected, but multiple changes are allowed. Test plan: make check-all Repository: rL LLVM https://reviews.llvm.org/D33976 Files: include/clang/Edit/EditedSource.h lib/Edit/EditedSource.cpp test/FixIt/fixit-format-darwin.m Index: test/FixIt/fixit-format-darwin.m === --- test/FixIt/fixit-format-darwin.m +++ test/FixIt/fixit-format-darwin.m @@ -0,0 +1,60 @@ +// RUN: cp %s %t +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -fblocks -Wformat -fixit %t +// RUN: grep -v CHECK %t > %t2 +// RUN: FileCheck -input-file=%t2 %s + +/* This is a test of code modifications created by darwin format fix-its hints + that are provided as part of warning */ + +int printf(const char * restrict, ...); + +#if __LP64__ +typedef long NSInteger; +typedef unsigned long NSUInteger; +#else +typedef int NSInteger; +typedef unsigned int NSUInteger; +#endif +NSInteger getNSInteger(); +NSUInteger getNSUInteger(); + +#define Log1(...) \ +do { \ + printf(__VA_ARGS__); \ +} while (0) + +#define Log2(...) \ +do { \ + printf(__VA_ARGS__); \ + printf(__VA_ARGS__); \ +} while (0) \ + +#define Log3(X, Y, Z) \ +do { \ + printf(X, Y); \ + printf(X, Z); \ +} while (0) \ + +void test() { + printf("test 1: %s", getNSInteger()); + // CHECK: printf("test 1: %ld", (long)getNSInteger()); + printf("test 2: %s %s", getNSInteger(), getNSInteger()); + // CHECK: printf("test 2: %ld %ld", (long)getNSInteger(), (long)getNSInteger()); + + Log1("test 3: %s", getNSInteger()); + // CHECK: Log1("test 3: %ld", (long)getNSInteger()); + Log1("test 4: %s %s", getNSInteger(), getNSInteger()); + // CHECK: Log1("test 4: %ld %ld", (long)getNSInteger(), (long)getNSInteger()); + + Log2("test 5: %s", getNSInteger()); + // CHECK: Log2("test 5: %ld", (long)getNSInteger()); + Log2("test 6: %s %s", getNSInteger(), getNSInteger()); + // CHECK: Log2("test 6: %ld %ld", (long)getNSInteger(), (long)getNSInteger()); + + // Aritificial test to check that X (in Log3(X, Y, Z)) + // is modified only according to the diagnostics + // for the first printf and the modification caused + // by the second printf is dropped + Log3("test 7: %s", getNSInteger(), getNSUInteger()); + // CHECK: Log3("test 7: %ld", (long)getNSInteger(), (unsigned long)getNSUInteger()); +} Index: lib/Edit/EditedSource.cpp === --- lib/Edit/EditedSource.cpp +++ lib/Edit/EditedSource.cpp @@ -25,30 +25,28 @@ void EditedSource::deconstructMacroArgLoc(SourceLocation Loc, SourceLocation &ExpansionLoc, - IdentifierInfo *&II) { + MacroArgUse &ArgUse) { assert(SourceMgr.isMacroArgExpansion(Loc)); SourceLocation DefArgLoc = SourceMgr.getImmediateExpansionRange(Loc).first; ExpansionLoc = SourceMgr.getImmediateExpansionRange(DefArgLoc).first; SmallString<20> Buf; StringRef ArgName = Lexer::getSpelling(SourceMgr.getSpellingLoc(DefArgLoc), Buf, SourceMgr, LangOpts); - II = nullptr; - if (!ArgName.empty()) { -II = &IdentTable.get(ArgName); - } + ArgUse = {nullptr, SourceLocation()}; + if (!ArgName.empty()) +ArgUse = {&IdentTable.get(ArgName), SourceMgr.getSpellingLoc(DefArgLoc)}; } void EditedSource::startingCommit() {} void EditedSource::finishedCommit() { for (auto &ExpArg : CurrCommitMacroArgExps) { SourceLocation ExpLoc; -IdentifierInfo *II; -std::tie(ExpLoc, II) = ExpArg; -auto &ArgNames = ExpansionToArgMap[ExpLoc.getRawEncoding()]; -if (std::find(ArgNames.begin(), ArgNames.end(), II) == ArgNames.end()) { - ArgNames.push_back(II); -} +MacroArgUse ArgUse; +std::tie(ExpLoc, ArgUse) = ExpArg; +auto &ArgUses = ExpansionToArgMap[ExpLoc.getRawEncoding()]; +if (std::find(ArgUses.begin(), ArgUses.end(), ArgUse) == ArgUses.end()) + ArgUses.push_back(ArgUse); } CurrCommit
[PATCH] D26065: Improve diagnostics if friend function redefines file-level function.
sepavloff added inline comments. Comment at: lib/Sema/SemaDeclCXX.cpp:646 + // in this case, redefinition will be diagnosed later. + (New->isInlineSpecified() || !New->isOutOfLine() || + !New->getLexicalDeclContext()->isRecord())) { arphaman wrote: > This is somewhat confusing to me: are you using the `!New->isOutOfLine() || > !New->getLexicalDeclContext()->isRecord()` check to ensure that this new > declaration is not a `friend`? Indeed, this check is obscure. Replaced by call to `getFriendObjectKind`. https://reviews.llvm.org/D26065 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26065: Improve diagnostics if friend function redefines file-level function.
sepavloff updated this revision to Diff 101666. sepavloff added a comment. Rebased and enhance check https://reviews.llvm.org/D26065 Files: lib/Sema/SemaDeclCXX.cpp test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp Index: test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp === --- test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp +++ test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp @@ -4,3 +4,31 @@ } inline void f0(); // expected-error {{inline declaration of 'f0' follows non-inline definition}} + +void func_01() {} // expected-note{{previous definition is here}} +struct C01 { + friend void func_01() {} // expected-error{{redefinition of 'func_01'}} +}; + +void func_02() {} // expected-note{{previous definition is here}} +struct C02 { + friend inline void func_02(); // expected-error{{inline declaration of 'func_02' follows non-inline definition}} +}; + +void func_03() {} // expected-note{{previous definition is here}} +struct C03 { + friend inline void func_03() {} // expected-error{{inline declaration of 'func_03' follows non-inline definition}} +}; + +void func_04() {} // expected-note{{previous definition is here}} +inline void func_04() {} // expected-error{{inline declaration of 'func_04' follows non-inline definition}} + +void func_06() {} // expected-note{{previous definition is here}} +template struct C06 { + friend inline void func_06() {} // expected-error{{inline declaration of 'func_06' follows non-inline definition}} +}; + +void func_07() {} // expected-note{{previous definition is here}} +template struct C07 { + friend inline void func_07(); // expected-error{{inline declaration of 'func_07' follows non-inline definition}} +}; Index: lib/Sema/SemaDeclCXX.cpp === --- lib/Sema/SemaDeclCXX.cpp +++ lib/Sema/SemaDeclCXX.cpp @@ -638,7 +638,12 @@ Diag(Old->getLocation(), diag::note_previous_declaration); Invalid = true; } else if (!Old->getMostRecentDecl()->isInlined() && New->isInlined() && - Old->isDefined(Def)) { + Old->isDefined(Def) && + // If a friend function is inlined but does not have 'inline' + // specifier, it is a definition. Do not report attribute conflict + // in this case, redefinition will be diagnosed later. + (New->isInlineSpecified() || + New->getFriendObjectKind() == Decl::FOK_None)) { // C++11 [dcl.fcn.spec]p4: // If the definition of a function appears in a translation unit before its // first declaration as inline, the program is ill-formed. Index: test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp === --- test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp +++ test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp @@ -4,3 +4,31 @@ } inline void f0(); // expected-error {{inline declaration of 'f0' follows non-inline definition}} + +void func_01() {} // expected-note{{previous definition is here}} +struct C01 { + friend void func_01() {} // expected-error{{redefinition of 'func_01'}} +}; + +void func_02() {} // expected-note{{previous definition is here}} +struct C02 { + friend inline void func_02(); // expected-error{{inline declaration of 'func_02' follows non-inline definition}} +}; + +void func_03() {} // expected-note{{previous definition is here}} +struct C03 { + friend inline void func_03() {} // expected-error{{inline declaration of 'func_03' follows non-inline definition}} +}; + +void func_04() {} // expected-note{{previous definition is here}} +inline void func_04() {} // expected-error{{inline declaration of 'func_04' follows non-inline definition}} + +void func_06() {} // expected-note{{previous definition is here}} +template struct C06 { + friend inline void func_06() {} // expected-error{{inline declaration of 'func_06' follows non-inline definition}} +}; + +void func_07() {} // expected-note{{previous definition is here}} +template struct C07 { + friend inline void func_07(); // expected-error{{inline declaration of 'func_07' follows non-inline definition}} +}; Index: lib/Sema/SemaDeclCXX.cpp === --- lib/Sema/SemaDeclCXX.cpp +++ lib/Sema/SemaDeclCXX.cpp @@ -638,7 +638,12 @@ Diag(Old->getLocation(), diag::note_previous_declaration); Invalid = true; } else if (!Old->getMostRecentDecl()->isInlined() && New->isInlined() && - Old->isDefined(Def)) { + Old->isDefined(Def) && + // If a friend function is inlined but does not have 'inline' + // specifier, it is a definition. Do not report attribute conflict + // in this case, redefinition will be diagnosed later. + (New->isInlineSpecified() || + New->getFriendObjectKind() == Decl::FOK_None)) { // C++11 [dcl.fcn.spec]p4: // If the definition of a
r304868 - Reorder and reformat.
Author: chapuni Date: Tue Jun 6 23:48:45 2017 New Revision: 304868 URL: http://llvm.org/viewvc/llvm-project?rev=304868&view=rev Log: Reorder and reformat. Modified: cfe/trunk/lib/AST/CMakeLists.txt Modified: cfe/trunk/lib/AST/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CMakeLists.txt?rev=304868&r1=304867&r2=304868&view=diff == --- cfe/trunk/lib/AST/CMakeLists.txt (original) +++ cfe/trunk/lib/AST/CMakeLists.txt Tue Jun 6 23:48:45 2017 @@ -1,4 +1,6 @@ -set(LLVM_LINK_COMPONENTS support) +set(LLVM_LINK_COMPONENTS + Support + ) add_clang_library(clangAST APValue.cpp ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r304869 - Update libdeps to add BinaryFormat, introduced in r304864.
Author: chapuni Date: Tue Jun 6 23:48:49 2017 New Revision: 304869 URL: http://llvm.org/viewvc/llvm-project?rev=304869&view=rev Log: Update libdeps to add BinaryFormat, introduced in r304864. Modified: cfe/trunk/lib/AST/CMakeLists.txt cfe/trunk/lib/Driver/CMakeLists.txt Modified: cfe/trunk/lib/AST/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CMakeLists.txt?rev=304869&r1=304868&r2=304869&view=diff == --- cfe/trunk/lib/AST/CMakeLists.txt (original) +++ cfe/trunk/lib/AST/CMakeLists.txt Tue Jun 6 23:48:49 2017 @@ -1,4 +1,5 @@ set(LLVM_LINK_COMPONENTS + BinaryFormat Support ) Modified: cfe/trunk/lib/Driver/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/CMakeLists.txt?rev=304869&r1=304868&r2=304869&view=diff == --- cfe/trunk/lib/Driver/CMakeLists.txt (original) +++ cfe/trunk/lib/Driver/CMakeLists.txt Tue Jun 6 23:48:49 2017 @@ -1,4 +1,5 @@ set(LLVM_LINK_COMPONENTS + BinaryFormat Option Support ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33955: [libcxx] [test] Remove a Clang/C2 workaround.
CaseyCarter accepted this revision. CaseyCarter added a comment. This revision is now accepted and ready to land. As the party who originally put this workaround in place, I'll happily certify that it never affected any platforms that anyone but we Microsofters care about. I'll take responsibility for any buildbot fallout - forward any nasty notices to me. https://reviews.llvm.org/D33955 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33976: [clang] Fix format specifiers fixits
mehdi_amini added a comment. Interestingly I got the opposite issue recently: calling through a macro with a single format specifier was *adding* new specific in the fixit in some conditions. I'm not the best person to review this change though, let me add a few folks. Repository: rL LLVM https://reviews.llvm.org/D33976 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33977: [libcxx][WIP] Experimental support for a scheduler for use in the parallel stl algorithms
erik.pilkington created this revision. Herald added a reviewer: EricWF. This patch adds a simple work-stealing scheduler meant for use as a fallback implementation for the C++17 parallel stl algorithms. This scheme follows a very simple fork/join API that should be easy to map onto different underlying concurrency implementations if they are available. This should be suitable for implementing par & par_unseq on top of. I also tried this out with a lock-free deque[0]. This provides a modest performance improvement, and might be worth implementing. For the sake of doing this incrementally this patch just contains a locking deque. Please see the recent thread on cfe-dev for context: http://lists.llvm.org/pipermail/cfe-dev/2017-May/053841.html I'm still pretty new to libc++ and to parallel stuff, so please feel free to tear this patch apart! Thanks for taking a look, Erik [0]: https://pdfs.semanticscholar.org/3771/77bb82105c35e6e26ebad1698a20688473bd.pdf https://reviews.llvm.org/D33977 Files: include/experimental/execution src/experimental/execution.cpp test/libcxx/experimental/execution/fork_join.pass.cpp Index: test/libcxx/experimental/execution/fork_join.pass.cpp === --- /dev/null +++ test/libcxx/experimental/execution/fork_join.pass.cpp @@ -0,0 +1,58 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +#include +#include +#include + +// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 + +using namespace std; +using namespace experimental; + +int parallel_fibb(int n, __task t) { + if (n < 2) +return 1; + + int lhs; + t.__fork([&](__task t) { lhs = parallel_fibb(n - 2, t); }); + int rhs = parallel_fibb(n - 1, t); + t.__join(); + return rhs + lhs; +} + +void fork_many(int n, __task t) { + atomic count(0); + for (int i = 0; i < n; ++i) +t.__fork([&](__task) { ++count; }); + + t.__join(); + assert(count.load() == n); +} + +int main() { + { +int res; +__evaluate_parallel_task([&](__task t) { res = parallel_fibb(10, t); }); +assert(res == 89); + } + + { +__evaluate_parallel_task([&](__task t) { fork_many(100, t); }); + } + + { +auto f = async(launch::async, [] { + __evaluate_parallel_task([&](__task t) { fork_many(100, t); }); +}); +__evaluate_parallel_task([&](__task t) { fork_many(100, t); }); +f.get(); + } +} Index: src/experimental/execution.cpp === --- /dev/null +++ src/experimental/execution.cpp @@ -0,0 +1,243 @@ +// -*- C++ -*- +//=== execution.cpp ---===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +#include "experimental/__config" +#ifndef _LIBCPP_HAS_NO_THREADS + +#include "experimental/execution" +#include "atomic" +#include "deque" +#include "mutex" +#include "vector" +#include "thread" + +_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL + +namespace { +class task_group; +class worker; +class bound_task; + +// FIXME: replace this with a lock free version. +template +class stealing_deque { + deque queue_; + mutex lock_; + +public: + stealing_deque() = default; + stealing_deque(const stealing_deque& other) : queue_(other.queue_) {} + + void emplace_back(T&& input) { +lock_guard ul(lock_); +queue_.emplace_back(move(input)); + } + + bool pop_back(T& output) { +lock_guard ul(lock_); +if (queue_.empty()) + return false; +output = queue_.back(); +queue_.pop_back(); +return true; + } + + bool steal(T& output) { +lock_guard ul(lock_); +if (queue_.empty()) + return false; +output = queue_.front(); +queue_.pop_front(); +return true; + } +}; + +// Task that has been fork()'d, but is free to be stolen by another worker. +struct unbound_task { + bound_task* parent_; + __callable_task task_; + + unbound_task() = default; + unbound_task(const __callable_task& task) : parent_(nullptr), task_(task) {} + unbound_task(bound_task* parent, __callable_task&& task) + : parent_(parent), task_(move(task)) {} +}; + +class worker { + stealing_deque queue_; + task_group& group_; + atomic dead_; + + friend class task_group; + + unsigned get_worker_id(); + +public: + worker(task_group& group) : group_(group), dead_(true) {} + worker(const worker& other) + : queue_(other.queue_), group_(other.group_), dead_(true) {} + + void def
Re: r304852 - Improve error recovery for missing 'template' keyword in contexts where the
Hi Richard, See below. On 06/07/2017 02:29 AM, Richard Smith via cfe-commits wrote: Author: rsmith Date: Tue Jun 6 19:29:44 2017 New Revision: 304852 URL: http://llvm.org/viewvc/llvm-project?rev=304852&view=rev Log: Improve error recovery for missing 'template' keyword in contexts where the template is valid with or without it (with different meanings). If we see "dependent.x<...", and what follows the '<' is a valid expression, we must parse the '<' as a comparison rather than a template angle bracket. When we later come to instantiate, if we find that the LHS of the '<' actually names an overload set containing function templates, produce a diagnostic suggesting that the 'template' keyword was missed rather than producing a mysterious diagnostic saying that the function must be called (and pointing at what looks to already be a function call!). Modified: cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/SemaTemplate/dependent-template-recover.cpp Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=304852&r1=304851&r2=304852&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jun 6 19:29:44 2017 @@ -11828,6 +11828,32 @@ ExprResult Sema::BuildBinOp(Scope *S, So RHSExpr->getType()->isOverloadableType()) return BuildOverloadedBinOp(*this, S, OpLoc, Opc, LHSExpr, RHSExpr); } + +// If we're instantiating "a.x < b" or "A::x < b" and 'x' names a function +// template, diagnose the missing 'template' keyword instead of diagnosing +// an invalid use of a bound member function. +// +// Note that "A::x < b" might be valid if 'b' has an overloadable type due +// to C++1z [over.over]/1.4, but we already checked for that case above. +if (Opc == BO_LT && inTemplateInstantiation() && +(pty->getKind() == BuiltinType::BoundMember || + pty->getKind() == BuiltinType::Overload)) { + auto *OE = dyn_cast(LHSExpr); + if (OE && !OE->hasTemplateKeyword() && !OE->hasExplicitTemplateArgs() && + std::any_of(OE->decls_begin(), OE->decls_end(), [](NamedDecl *ND) { +return isa(ND); + })) { +if (auto *Q = OE->getQualifier()) { I'm getting a compiler warning that looks reasonable here: ../tools/clang/lib/Sema/SemaExpr.cpp:11846:19: error: unused variable 'Q' [-Werror,-Wunused-variable] if (auto *Q = OE->getQualifier()) { ^ 1 error generated. I got the above with clang 3.6. Regards, Mikael + Diag(OE->getQualifierLoc().getBeginLoc(), + diag::err_template_kw_missing) +<< OE->getName().getAsString() << ""; +} else { + Diag(OE->getNameLoc(), diag::err_template_kw_missing) +<< OE->getName().getAsString() << ""; +} +return ExprError(); + } +} ExprResult LHS = CheckPlaceholderExpr(LHSExpr); if (LHS.isInvalid()) return ExprError(); Modified: cfe/trunk/test/SemaTemplate/dependent-template-recover.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/dependent-template-recover.cpp?rev=304852&r1=304851&r2=304852&view=diff == --- cfe/trunk/test/SemaTemplate/dependent-template-recover.cpp (original) +++ cfe/trunk/test/SemaTemplate/dependent-template-recover.cpp Tue Jun 6 19:29:44 2017 @@ -17,6 +17,28 @@ struct X { } }; +struct MrsBadcrumble { + friend MrsBadcrumble operator<(void (*)(int), MrsBadcrumble); + friend void operator>(MrsBadcrumble, int); +} mb; + +template void f(T t) { + t.f(0); // expected-error {{missing 'template' keyword prior to dependent template name 'f'}} + t.T::f(0); // expected-error {{missing 'template' keyword prior to dependent template name 'f'}} + T::g(0); // expected-error {{missing 'template' keyword prior to dependent template name 'g'}} + + // Note: no diagnostic here, this is actually valid as a comparison between + // the decayed pointer to Y::g<> and mb! + T::g(0); +} + +struct Y { + template void f(int); + template static void g(int); // expected-warning 0-1{{extension}} +}; +void q() { void (*p)(int) = Y::g; } +template void f<0>(Y); // expected-note {{in instantiation of}} + namespace PR9401 { // From GCC PR c++/45558 template ___ 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
r304870 - Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
Author: gkistanova Date: Wed Jun 7 01:25:05 2017 New Revision: 304870 URL: http://llvm.org/viewvc/llvm-project?rev=304870&view=rev Log: Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC. Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=304870&r1=304869&r2=304870&view=diff == --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original) +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Jun 7 01:25:05 2017 @@ -4020,6 +4020,7 @@ bool Sema::CheckTemplateTypeArgument(Tem } } // fallthrough +LLVM_FALLTHROUGH; } default: { // We have a template type parameter but the template argument @@ -7594,6 +7595,7 @@ Sema::CheckSpecializationInstantiationRe return false; } // Fall through + LLVM_FALLTHROUGH; case TSK_ExplicitInstantiationDeclaration: case TSK_ExplicitInstantiationDefinition: @@ -9379,6 +9381,7 @@ Sema::CheckTypenameType(ElaboratedTypeKe } // Fall through to create a dependent typename type, from which we can recover // better. + LLVM_FALLTHROUGH; case LookupResult::NotFoundInCurrentInstantiation: // Okay, it's a member of an unknown instantiation. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r304872 - Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
Author: gkistanova Date: Wed Jun 7 01:31:55 2017 New Revision: 304872 URL: http://llvm.org/viewvc/llvm-project?rev=304872&view=rev Log: Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC. Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=304872&r1=304871&r2=304872&view=diff == --- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original) +++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Wed Jun 7 01:31:55 2017 @@ -1860,6 +1860,7 @@ static void AddOrdinaryNameResults(Sema: AddStaticAssertResult(Builder, Results, SemaRef.getLangOpts()); } + LLVM_FALLTHROUGH; // Fall through (for statement expressions). case Sema::PCC_ForInit: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits