LLVM buildmaster will be restarted in few minutes
Hello everyone, LLVM buildmaster will be restarted in few minutes. Thank you for understanding. Thanks Galina ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30806: [nonnull] Teach Clang to attach the nonnull LLVM attribute to declarations and calls instead of just definitions, and then teach it to *not* attach such attributes even if the source c
ahatanak added a comment. Are users allowed to call these routines with a null pointer and a non-zero size? Or can we assume that if the size is known to be non-zero at compile time, the pointers are not null? I'm thinking we might miss optimization opportunities if it's not possible to mark the pointer parameters as nonnull. https://reviews.llvm.org/D30806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30806: [nonnull] Teach Clang to attach the nonnull LLVM attribute to declarations and calls instead of just definitions, and then teach it to *not* attach such attributes even if the source c
chandlerc added a comment. In https://reviews.llvm.org/D30806#697372, @ahatanak wrote: > Are users allowed to call these routines with a null pointer and a non-zero > size? Or can we assume that if the size is known to be non-zero at compile > time, the pointers are not null? If the sizes are non-zero, all of these will access memory through the pointer. But we don't currently have any way of easily expressing this in the IR. We could try something fancy like call-side attributes when the size is known, but it is pretty redundant -- we could just teach the same things that look at the attributes to know that these are reads or writes of a constant size... > I'm thinking we might miss optimization opportunities if it's not possible to > mark the pointer parameters as nonnull. Note that currently, *nothing marks these parameters as nonnull*. So in all the years that folks have used Clang and LLVM with libc headers that have an __attribute__((nonnull)), no one has found a performance problem with this as the root cause and fixed it. To me, this indicates that this isn't that important of an optimization *for these libc routines*. If someone ever comes up with a testcase where this is important thing for performance, I think we can cross the bridge of finding a fancier way to analyze things then. https://reviews.llvm.org/D30806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30806: [nonnull] Teach Clang to attach the nonnull LLVM attribute to declarations and calls instead of just definitions, and then teach it to *not* attach such attributes even if the source c
majnemer added inline comments. Comment at: lib/AST/ASTContext.cpp:8786 +if (OverrideNonnull && OverrideNonnullArgs) + *OverrideNonnullArgs |= 1 << ArgTypes.size(); + `1U` to avoid overflow UB? Comment at: lib/CodeGen/CGCall.cpp:2082 + if (getNonNullAttr(FD, PVD, ParamType, PVD->getFunctionScopeIndex()) && + (OverrideNonnullArgs & (1 << ArgNo)) == 0) +Attrs.addAttribute(llvm::Attribute::NonNull); Ditto. https://reviews.llvm.org/D30806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30792: Use callback for internalizing linked symbols.
JDevlieghere updated this revision to Diff 91282. JDevlieghere marked 3 inline comments as done. JDevlieghere added a comment. - Reformat - Call helper rather than initializing the pass Repository: rL LLVM https://reviews.llvm.org/D30792 Files: include/clang/CodeGen/CodeGenAction.h include/clang/Frontend/CodeGenOptions.h lib/CodeGen/CodeGenAction.cpp lib/Frontend/CompilerInvocation.cpp Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -727,11 +727,11 @@ CodeGenOptions::BitcodeFileToLink F; F.Filename = A->getValue(); if (A->getOption().matches(OPT_mlink_cuda_bitcode)) { - F.LinkFlags = llvm::Linker::Flags::LinkOnlyNeeded | -llvm::Linker::Flags::InternalizeLinkedSymbols; + F.LinkFlags = llvm::Linker::Flags::LinkOnlyNeeded; // When linking CUDA bitcode, propagate function attributes so that // e.g. libdevice gets fast-math attrs if we're building with fast-math. F.PropagateAttrs = true; + F.Internalize = true; } Opts.LinkBitcodeFiles.push_back(F); } Index: lib/CodeGen/CodeGenAction.cpp === --- lib/CodeGen/CodeGenAction.cpp +++ lib/CodeGen/CodeGenAction.cpp @@ -28,6 +28,7 @@ #include "llvm/IR/DebugInfo.h" #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/DiagnosticPrinter.h" +#include "llvm/IR/GlobalValue.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/IRReader/IRReader.h" @@ -38,6 +39,8 @@ #include "llvm/Support/Timer.h" #include "llvm/Support/ToolOutputFile.h" #include "llvm/Support/YAMLTraits.h" +#include "llvm/Transforms/IPO/Internalize.h" + #include using namespace clang; using namespace llvm; @@ -168,8 +171,22 @@ Gen->CGM().AddDefaultFnAttrs(F); CurLinkModule = LM.Module.get(); -if (Linker::linkModules(*getModule(), std::move(LM.Module), -LM.LinkFlags)) + +bool Err; +if (LM.Internalize) { + Err = Linker::linkModules( + *getModule(), std::move(LM.Module), LM.LinkFlags, + [](llvm::Module &M, llvm::StringSet<> GVS) { +internalizeModule(M, [&M, &GVS](const llvm::GlobalValue &GV) { + return !GV.hasName() || (GVS.count(GV.getName()) == 0); +}); + }); +} else { + Err = Linker::linkModules(*getModule(), std::move(LM.Module), +LM.LinkFlags); +} + +if (Err) return true; } return false; // success @@ -319,7 +336,7 @@ void OptimizationFailureHandler( const llvm::DiagnosticInfoOptimizationFailure &D); }; - + void BackendConsumer::anchor() {} } @@ -388,7 +405,7 @@ // code. if (LocCookie.isValid()) { Diags.Report(LocCookie, DiagID).AddString(Message); - + if (D.getLoc().isValid()) { DiagnosticBuilder B = Diags.Report(Loc, diag::note_fe_inline_asm_here); // Convert the SMDiagnostic ranges into SourceRange and attach them @@ -401,7 +418,7 @@ } return; } - + // Otherwise, report the backend issue as occurring in the generated .s file. // If Loc is invalid, we still need to report the issue, it just gets no // location info. Index: include/clang/Frontend/CodeGenOptions.h === --- include/clang/Frontend/CodeGenOptions.h +++ include/clang/Frontend/CodeGenOptions.h @@ -137,6 +137,8 @@ /// our CodeGenOptions, much as we set attrs on functions that we generate /// ourselves. bool PropagateAttrs = false; +/// If true, we use LLVM module internalizer. +bool Internalize = false; /// Bitwise combination of llvm::Linker::Flags, passed to the LLVM linker. unsigned LinkFlags = 0; }; Index: include/clang/CodeGen/CodeGenAction.h === --- include/clang/CodeGen/CodeGenAction.h +++ include/clang/CodeGen/CodeGenAction.h @@ -36,6 +36,9 @@ /// function ourselves. bool PropagateAttrs; +/// If true, we use LLVM module internalizer. +bool Internalize; + /// Bitwise combination of llvm::LinkerFlags used when we link the module. unsigned LinkFlags; }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30806: [nonnull] Teach Clang to attach the nonnull LLVM attribute to declarations and calls instead of just definitions, and then teach it to *not* attach such attributes even if the source c
chandlerc added inline comments. Comment at: lib/AST/ASTContext.cpp:8786 +if (OverrideNonnull && OverrideNonnullArgs) + *OverrideNonnullArgs |= 1 << ArgTypes.size(); + majnemer wrote: > `1U` to avoid overflow UB? I'd mildly prefer an assert (or rely on UBSan) that it *doesn't* overflow. Also note that this is the same pattern we use just a few lines down for the ICE argument bitmask -- we have a pretty baked in assumption that all the builtins here don't have more than 31 arguments. Anyways, happy to make whatever change you would prefer here. I just copied the code below, I don't have any strong opinion here. Comment at: lib/CodeGen/CGCall.cpp:2082 + if (getNonNullAttr(FD, PVD, ParamType, PVD->getFunctionScopeIndex()) && + (OverrideNonnullArgs & (1 << ArgNo)) == 0) +Attrs.addAttribute(llvm::Attribute::NonNull); majnemer wrote: > Ditto. See above, I'll keep these in sync. However, this exposes a related bug: we shouldn't be even doing this bit test if the function isn't a builtin. I'll add a check for that. That seems cleaner than relying on the bittest itself failing. https://reviews.llvm.org/D30806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30806: [nonnull] Teach Clang to attach the nonnull LLVM attribute to declarations and calls instead of just definitions, and then teach it to *not* attach such attributes even if the source c
chandlerc updated this revision to Diff 91286. chandlerc added a comment. Update to fix subtle bugs in handling arguments. Thanks to David for the review comments that caused me to see the issue here. https://reviews.llvm.org/D30806 Files: include/clang/AST/ASTContext.h include/clang/Basic/Builtins.def lib/AST/ASTContext.cpp lib/CodeGen/CGBuiltin.cpp lib/CodeGen/CGCall.cpp lib/Sema/SemaChecking.cpp test/CodeGen/nonnull.c Index: test/CodeGen/nonnull.c === --- test/CodeGen/nonnull.c +++ test/CodeGen/nonnull.c @@ -49,3 +49,87 @@ // CHECK: define void @bar8(i32* nonnull %a, i32* nonnull %b) void bar8(int *a, int *b) __attribute__((nonnull)) __attribute__((nonnull(1))) {} + +// CHECK: declare void @foo_decl(i32* nonnull) +void foo_decl(int *__attribute__((nonnull))); + +// CHECK: declare void @bar_decl(i32* nonnull) +void bar_decl(int *) __attribute__((nonnull(1))); + +// CHECK: declare void @bar2_decl(i32*, i32* nonnull) +void bar2_decl(int *, int *) __attribute__((nonnull(2))); + +// CHECK: declare nonnull i32* @bar3_decl() +int *bar3_decl(void) __attribute__((returns_nonnull)); + +// CHECK: declare i32 @bar4_decl(i32, i32* nonnull) +int bar4_decl(int, int *) __attribute__((nonnull)); + +// CHECK: declare i32 @bar5_decl(i32, i32* nonnull) +int bar5_decl(int, int *) __attribute__((nonnull(1, 2))); + +// CHECK: declare i32 @bar6_decl(i64) +int bar6_decl(TransparentUnion) __attribute__((nonnull(1))); + +// CHECK: declare void @bar7_decl(i32* nonnull, i32* nonnull) +void bar7_decl(int *, int *) +__attribute__((nonnull(1))) __attribute__((nonnull(2))); + +// CHECK: declare void @bar8_decl(i32* nonnull, i32* nonnull) +void bar8_decl(int *, int *) +__attribute__((nonnull)) __attribute__((nonnull(1))); + +// Clang specially disables nonnull attributes on some library builtin +// functions to work around the fact that the standard and some vendors mark +// them as nonnull even though they are frequently called in practice with null +// arguments if a corresponding size argument is zero. + +// CHECK: declare i8* @memcpy(i8*, i8*, i64) +void *memcpy(void *, const void *, unsigned long) +__attribute__((nonnull(1, 2))) __attribute__((returns_nonnull)); + +// CHECK: declare i32 @memcmp(i8*, i8*, i64) +int memcmp(const void *, const void *, unsigned long) __attribute__((nonnull(1, 2))); + +// CHECK: declare i8* @memmove(i8*, i8*, i64) +void *memmove(void *, const void *, unsigned long) +__attribute__((nonnull(1, 2))) __attribute__((returns_nonnull)); + +// CHECK: declare i8* @strncpy(i8*, i8*, i64) +char *strncpy(char *, const char *, unsigned long) +__attribute__((nonnull(1, 2))) __attribute__((returns_nonnull)); + +// CHECK: declare i32 @strncmp(i8*, i8*, i64) +int strncmp(const char *, const char *, unsigned long) __attribute__((nonnull(1, 2))); + +// CHECK: declare nonnull i8* @strncat(i8* nonnull, i8*, i64) +char *strncat(char *, const char *, unsigned long) +__attribute__((nonnull(1, 2))) __attribute__((returns_nonnull)); + +// CHECK: declare i8* @memchr(i8*, i32, i64) +void *memchr(const void *__attribute__((nonnull)), int, unsigned long) +__attribute__((returns_nonnull)); + +// CHECK: declare i8* @memset(i8*, i32, i64) +void *memset(void *__attribute__((nonnull)), int, unsigned long) +__attribute__((returns_nonnull)); + +void use_declarations(int *p, void *volatile *sink) { + foo_decl(p); + bar_decl(p); + bar2_decl(p, p); + (void)bar3_decl(); + bar4_decl(42, p); + bar5_decl(42, p); + bar6_decl(p); + bar7_decl(p, p); + bar8_decl(p, p); + *sink = (void *)&memcpy; + *sink = (void *)&memcmp; + *sink = (void *)&memmove; + *sink = (void *)&strncpy; + *sink = (void *)&strncmp; + *sink = (void *)&strncat; + *sink = (void *)&memchr; + *sink = (void *)&memset; +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -735,7 +735,8 @@ // Find out if any arguments are required to be integer constant expressions. unsigned ICEArguments = 0; ASTContext::GetBuiltinTypeError Error; - Context.GetBuiltinType(BuiltinID, Error, &ICEArguments); + Context.GetBuiltinType(BuiltinID, Error, /*OverrideNonnullReturn=*/nullptr, + /*OverrideNonnullArgs=*/nullptr, &ICEArguments); if (Error != ASTContext::GE_None) ICEArguments = 0; // Don't diagnose previously diagnosed errors. Index: lib/CodeGen/CGCall.cpp === --- lib/CodeGen/CGCall.cpp +++ lib/CodeGen/CGCall.cpp @@ -1759,6 +1759,34 @@ F.addAttributes(llvm::AttributeSet::FunctionIndex, AS); } +/// Returns the attribute (either parameter attribute, or function +/// attribute), which declares argument ArgNo to be non-null. +static const NonNullAttr *getNonNullAttr(const Decl *FD, const ParmVarDecl *PVD, +
[PATCH] D30777: Added `applyAtomicChanges` function.
ioeric updated this revision to Diff 91288. ioeric marked 7 inline comments as done. ioeric added a comment. - Addressed review comments. https://reviews.llvm.org/D30777 Files: include/clang/Tooling/Refactoring/AtomicChange.h lib/Tooling/Refactoring/AtomicChange.cpp unittests/Tooling/RefactoringTest.cpp Index: unittests/Tooling/RefactoringTest.cpp === --- unittests/Tooling/RefactoringTest.cpp +++ unittests/Tooling/RefactoringTest.cpp @@ -1290,5 +1290,435 @@ Replacement(Context.Sources, SourceLocation(), 0, "b"))); } +class ApplyAtomicChangesTest : public ::testing::Test { +protected: + ApplyAtomicChangesTest() : FilePath("file.cc") { +Spec.Cleanup = true; +Spec.Format = ApplyChangesSpec::kAll; +Spec.Style = format::getLLVMStyle(); + } + + ~ApplyAtomicChangesTest() override {} + + void setInput(llvm::StringRef Input) { +Code = Input; +FID = Context.createInMemoryFile(FilePath, Code); + } + + SourceLocation getLoc(unsigned Offset) const { +return Context.Sources.getLocForStartOfFile(FID).getLocWithOffset(Offset); + } + + AtomicChange replacementToAtomicChange(llvm::StringRef Key, unsigned Offset, + unsigned Length, + llvm::StringRef Text) { +AtomicChange Change(FilePath, Key); +llvm::Error Err = +Change.replace(Context.Sources, getLoc(Offset), Length, Text); +EXPECT_FALSE(Err); +return Change; + } + + std::string rewrite(bool FailureExpected = false) { +llvm::Expected ChangedCode = +applyAtomicChanges(FilePath, Code, Changes, Spec); +EXPECT_EQ(FailureExpected, !ChangedCode); +if (!ChangedCode) { + llvm::errs() << "Failed to apply changes: " + << llvm::toString(ChangedCode.takeError()) << "\n"; + return ""; +} +return *ChangedCode; + } + + RewriterTestContext Context; + FileID FID; + ApplyChangesSpec Spec; + std::string Code; + std::string FilePath; + llvm::SmallVector Changes; +}; + +TEST_F(ApplyAtomicChangesTest, BasicRefactoring) { + setInput("int a;"); + AtomicChange Change(FilePath, "key1"); + Changes.push_back(replacementToAtomicChange("key1", 4, 1, "b")); + EXPECT_EQ("int b;", rewrite()); +} + +TEST_F(ApplyAtomicChangesTest, SeveralRefactorings) { + setInput("int a;\n" + "int b;"); + Changes.push_back(replacementToAtomicChange("key1", 0, 3, "float")); + Changes.push_back(replacementToAtomicChange("key2", 4, 1, "f")); + Changes.push_back(replacementToAtomicChange("key3", 11, 1, "g")); + Changes.push_back(replacementToAtomicChange("key4", 7, 3, "float")); + EXPECT_EQ("float f;\n" +"float g;", +rewrite()); +} + +TEST_F(ApplyAtomicChangesTest, IgnorePathsInRefactorings) { + setInput("int a;\n" + "int b;"); + Changes.push_back(replacementToAtomicChange("key1", 4, 1, "aa")); + + FileID ID = Context.createInMemoryFile("AnotherFile", "12345678912345"); + Changes.emplace_back("AnotherFile", "key2"); + auto Err = Changes.back().replace( + Context.Sources, + Context.Sources.getLocForStartOfFile(ID).getLocWithOffset(11), 1, "bb"); + ASSERT_TRUE(!Err); + EXPECT_EQ("int aa;\n" +"int bb;", +rewrite()); +} + +TEST_F(ApplyAtomicChangesTest, AppliesDuplicateInsertions) { + setInput("int a;"); + Changes.push_back(replacementToAtomicChange("key1", 5, 0, "b")); + Changes.push_back(replacementToAtomicChange("key2", 5, 0, "b")); + EXPECT_EQ("int abb;", rewrite()); +} + +TEST_F(ApplyAtomicChangesTest, BailsOnOverlappingRefactorings) { + setInput("int a;"); + Changes.push_back(replacementToAtomicChange("key1", 0, 5, "float f")); + Changes.push_back(replacementToAtomicChange("key2", 4, 1, "b")); + EXPECT_EQ("", rewrite(/*FailureExpected=*/true)); +} + +TEST_F(ApplyAtomicChangesTest, BasicReformatting) { + setInput("int a;"); + Changes.push_back(replacementToAtomicChange("key1", 5, 1, "b")); + EXPECT_EQ("int b;", rewrite()); +} + +TEST_F(ApplyAtomicChangesTest, OnlyFormatWhenViolateColumnLimits) { + Spec.Format = ApplyChangesSpec::kViolations; + Spec.Style.ColumnLimit = 8; + setInput("int a;\n" + "inta;\n" + "int ;\n"); + Changes.push_back(replacementToAtomicChange("key1", 5, 1, "x")); + Changes.push_back(replacementToAtomicChange("key2", 15, 1, "x")); + Changes.push_back(replacementToAtomicChange("key3", 23, 8, "xx")); + EXPECT_EQ("int x;\n" +"int x;\n" +"int xx;\n", +rewrite()); +} + +TEST_F(ApplyAtomicChangesTest, LastLineViolateColumnLimits) { + Spec.Format = ApplyChangesSpec::kViolations; + Spec.Style.ColumnLimit = 8; + setInput("int a;\n" + "inta;"); + Changes.push_back(replacementToAtomicChange("key1", 0, 1, "i")); + Changes.push_back(replacementToAtomicChange("key2", 15, 2, "y;")); + EXPECT_EQ("int a;\n" +"int y;", +
[PATCH] D30792: Use callback for internalizing linked symbols.
JDevlieghere updated this revision to Diff 91292. JDevlieghere added a comment. - Pass StringSet by const ref. Repository: rL LLVM https://reviews.llvm.org/D30792 Files: include/clang/CodeGen/CodeGenAction.h include/clang/Frontend/CodeGenOptions.h lib/CodeGen/CodeGenAction.cpp lib/Frontend/CompilerInvocation.cpp Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -727,11 +727,11 @@ CodeGenOptions::BitcodeFileToLink F; F.Filename = A->getValue(); if (A->getOption().matches(OPT_mlink_cuda_bitcode)) { - F.LinkFlags = llvm::Linker::Flags::LinkOnlyNeeded | -llvm::Linker::Flags::InternalizeLinkedSymbols; + F.LinkFlags = llvm::Linker::Flags::LinkOnlyNeeded; // When linking CUDA bitcode, propagate function attributes so that // e.g. libdevice gets fast-math attrs if we're building with fast-math. F.PropagateAttrs = true; + F.Internalize = true; } Opts.LinkBitcodeFiles.push_back(F); } Index: lib/CodeGen/CodeGenAction.cpp === --- lib/CodeGen/CodeGenAction.cpp +++ lib/CodeGen/CodeGenAction.cpp @@ -28,6 +28,7 @@ #include "llvm/IR/DebugInfo.h" #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/DiagnosticPrinter.h" +#include "llvm/IR/GlobalValue.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/IRReader/IRReader.h" @@ -38,6 +39,8 @@ #include "llvm/Support/Timer.h" #include "llvm/Support/ToolOutputFile.h" #include "llvm/Support/YAMLTraits.h" +#include "llvm/Transforms/IPO/Internalize.h" + #include using namespace clang; using namespace llvm; @@ -168,8 +171,22 @@ Gen->CGM().AddDefaultFnAttrs(F); CurLinkModule = LM.Module.get(); -if (Linker::linkModules(*getModule(), std::move(LM.Module), -LM.LinkFlags)) + +bool Err; +if (LM.Internalize) { + Err = Linker::linkModules( + *getModule(), std::move(LM.Module), LM.LinkFlags, + [](llvm::Module &M, const llvm::StringSet<> &GVS) { +internalizeModule(M, [&M, &GVS](const llvm::GlobalValue &GV) { + return !GV.hasName() || (GVS.count(GV.getName()) == 0); +}); + }); +} else { + Err = Linker::linkModules(*getModule(), std::move(LM.Module), +LM.LinkFlags); +} + +if (Err) return true; } return false; // success @@ -319,7 +336,7 @@ void OptimizationFailureHandler( const llvm::DiagnosticInfoOptimizationFailure &D); }; - + void BackendConsumer::anchor() {} } @@ -388,7 +405,7 @@ // code. if (LocCookie.isValid()) { Diags.Report(LocCookie, DiagID).AddString(Message); - + if (D.getLoc().isValid()) { DiagnosticBuilder B = Diags.Report(Loc, diag::note_fe_inline_asm_here); // Convert the SMDiagnostic ranges into SourceRange and attach them @@ -401,7 +418,7 @@ } return; } - + // Otherwise, report the backend issue as occurring in the generated .s file. // If Loc is invalid, we still need to report the issue, it just gets no // location info. Index: include/clang/Frontend/CodeGenOptions.h === --- include/clang/Frontend/CodeGenOptions.h +++ include/clang/Frontend/CodeGenOptions.h @@ -137,6 +137,8 @@ /// our CodeGenOptions, much as we set attrs on functions that we generate /// ourselves. bool PropagateAttrs = false; +/// If true, we use LLVM module internalizer. +bool Internalize = false; /// Bitwise combination of llvm::Linker::Flags, passed to the LLVM linker. unsigned LinkFlags = 0; }; Index: include/clang/CodeGen/CodeGenAction.h === --- include/clang/CodeGen/CodeGenAction.h +++ include/clang/CodeGen/CodeGenAction.h @@ -36,6 +36,9 @@ /// function ourselves. bool PropagateAttrs; +/// If true, we use LLVM module internalizer. +bool Internalize; + /// Bitwise combination of llvm::LinkerFlags used when we link the module. unsigned LinkFlags; }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30813: [clang-rename] Introduce an unittest skeleton for clang-rename.
hokein created this revision. Herald added a subscriber: mgorny. This will make references rename tests easier. https://reviews.llvm.org/D30813 Files: unittests/CMakeLists.txt unittests/clang-rename/CMakeLists.txt unittests/clang-rename/ClangRenameTests.cpp Index: unittests/clang-rename/ClangRenameTests.cpp === --- /dev/null +++ unittests/clang-rename/ClangRenameTests.cpp @@ -0,0 +1,144 @@ +#include "RenamingAction.h" +#include "USRFindingAction.h" +#include "unittests/Tooling/RewriterTestContext.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/Basic/FileManager.h" +#include "clang/Basic/FileSystemOptions.h" +#include "clang/Basic/VirtualFileSystem.h" +#include "clang/Format/Format.h" +#include "clang/Frontend/CompilerInstance.h" +#include "clang/Frontend/PCHContainerOperations.h" +#include "clang/Tooling/Refactoring.h" +#include "clang/Tooling/Tooling.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Format.h" +#include "llvm/Support/MemoryBuffer.h" +#include "gtest/gtest.h" +#include +#include +#include + +namespace clang { +namespace clang_rename { +namespace { + +struct Case { + std::string Before; + std::string After; +}; + +class ClangRenameTest : public testing::Test, +public testing::WithParamInterface { +protected: + void AppendToHeader(StringRef Code) { +HeaderContent += Code.str(); + } + + std::string runClangRenameOnCode(llvm::StringRef Code, + llvm::StringRef OldName, + llvm::StringRef NewName) { +std::string NewCode; +llvm::raw_string_ostream(NewCode) << llvm::format( +"#include \"%s\"\n%s", HeaderName.c_str(), Code.str().c_str()); +tooling::FileContentMappings FileContents = {{HeaderName, HeaderContent}, + {CCName, NewCode}}; +clang::RewriterTestContext Context; +Context.createInMemoryFile(HeaderName, HeaderContent); +clang::FileID InputFileID = Context.createInMemoryFile(CCName, NewCode); + +rename::USRFindingAction FindingAction({}, {OldName}); +std::unique_ptr USRFindingActionFactory = +tooling::newFrontendActionFactory(&FindingAction); + +if (!tooling::runToolOnCodeWithArgs( +USRFindingActionFactory->create(), NewCode, {"-std=c++11"}, CCName, +"clang-rename", std::make_shared(), +FileContents)) + return ""; + +const std::vector> &USRList = +FindingAction.getUSRList(); +const std::vector &PrevNames = FindingAction.getUSRSpellings(); +std::vector NewNames = {NewName}; +std::map FileToReplacements; +rename::RenamingAction RenameAction(NewNames, PrevNames, USRList, +FileToReplacements); +auto RenameActionFactory = tooling::newFrontendActionFactory(&RenameAction); +if (!tooling::runToolOnCodeWithArgs( +RenameActionFactory->create(), NewCode, {"-std=c++11"}, CCName, +"clang-rename", std::make_shared(), +FileContents)) + return ""; + +formatAndApplyAllReplacements(FileToReplacements, Context.Rewrite, "llvm"); +return Context.getRewrittenText(InputFileID); + } + + void CompareSnippets(StringRef Expected, StringRef Actual) { +std::string ExpectedCode; +llvm::raw_string_ostream(ExpectedCode) << llvm::format( +"#include \"%s\"\n%s", HeaderName.c_str(), Expected.str().c_str()); +EXPECT_EQ(format(ExpectedCode), format(Actual)); + } + + std::string format(llvm::StringRef Code) { +tooling::Replacements Replaces = format::reformat( +format::getLLVMStyle(), Code, {tooling::Range(0, Code.size())}); +auto ChangedCode = tooling::applyAllReplacements(Code, Replaces); +EXPECT_TRUE(static_cast(ChangedCode)); +if (!ChangedCode) { + llvm::errs() << llvm::toString(ChangedCode.takeError()); + return ""; +} +return *ChangedCode; + } + + std::string HeaderContent; + std::string HeaderName = "header.h"; + std::string CCName = "input.cc"; +}; + +class RenameClassTest : public ClangRenameTest { + public: + RenameClassTest() { +AppendToHeader("\nclass Foo {};\n"); + } +}; + +INSTANTIATE_TEST_CASE_P( +RenameTests, RenameClassTest, +testing::ValuesIn(std::vector({ + {"Foo f;", "Bar f;"}, + {"void f(Foo f) {}", "void f(Bar f) {}"}, + {"void f(Foo *f) {}", "void f(Bar *f) {}"}, + {"Foo f() { return Foo(); }", "Bar f() { return Bar(); }"}, +}))); + +TEST_P(RenameClassTest, RenameClasses) { + auto Param = GetParam(); + std::string OldName = "Foo"; + std::string NewName = "Bar"; + std::string Actual = runClangRenameOnCode(Param.Before, OldName, NewName); + CompareSnippets(Param.After, Actual); +} + +class RenameFunctionTest : public ClangRenameTest {}; + +INSTANTIATE_TEST_CASE_P( +RenameTests, RenameFunctio
[PATCH] D30813: [clang-rename] Introduce an unittest skeleton for clang-rename.
hokein updated this revision to Diff 91296. hokein added a comment. Add missing license. https://reviews.llvm.org/D30813 Files: unittests/CMakeLists.txt unittests/clang-rename/CMakeLists.txt unittests/clang-rename/ClangRenameTests.cpp Index: unittests/clang-rename/ClangRenameTests.cpp === --- /dev/null +++ unittests/clang-rename/ClangRenameTests.cpp @@ -0,0 +1,153 @@ +//===-- ClangRenameTests.cpp - clang-rename unit tests ===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "RenamingAction.h" +#include "USRFindingAction.h" +#include "unittests/Tooling/RewriterTestContext.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/Basic/FileManager.h" +#include "clang/Basic/FileSystemOptions.h" +#include "clang/Basic/VirtualFileSystem.h" +#include "clang/Format/Format.h" +#include "clang/Frontend/CompilerInstance.h" +#include "clang/Frontend/PCHContainerOperations.h" +#include "clang/Tooling/Refactoring.h" +#include "clang/Tooling/Tooling.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Format.h" +#include "llvm/Support/MemoryBuffer.h" +#include "gtest/gtest.h" +#include +#include +#include + +namespace clang { +namespace clang_rename { +namespace { + +struct Case { + std::string Before; + std::string After; +}; + +class ClangRenameTest : public testing::Test, +public testing::WithParamInterface { +protected: + void AppendToHeader(StringRef Code) { +HeaderContent += Code.str(); + } + + std::string runClangRenameOnCode(llvm::StringRef Code, + llvm::StringRef OldName, + llvm::StringRef NewName) { +std::string NewCode; +llvm::raw_string_ostream(NewCode) << llvm::format( +"#include \"%s\"\n%s", HeaderName.c_str(), Code.str().c_str()); +tooling::FileContentMappings FileContents = {{HeaderName, HeaderContent}, + {CCName, NewCode}}; +clang::RewriterTestContext Context; +Context.createInMemoryFile(HeaderName, HeaderContent); +clang::FileID InputFileID = Context.createInMemoryFile(CCName, NewCode); + +rename::USRFindingAction FindingAction({}, {OldName}); +std::unique_ptr USRFindingActionFactory = +tooling::newFrontendActionFactory(&FindingAction); + +if (!tooling::runToolOnCodeWithArgs( +USRFindingActionFactory->create(), NewCode, {"-std=c++11"}, CCName, +"clang-rename", std::make_shared(), +FileContents)) + return ""; + +const std::vector> &USRList = +FindingAction.getUSRList(); +const std::vector &PrevNames = FindingAction.getUSRSpellings(); +std::vector NewNames = {NewName}; +std::map FileToReplacements; +rename::RenamingAction RenameAction(NewNames, PrevNames, USRList, +FileToReplacements); +auto RenameActionFactory = tooling::newFrontendActionFactory(&RenameAction); +if (!tooling::runToolOnCodeWithArgs( +RenameActionFactory->create(), NewCode, {"-std=c++11"}, CCName, +"clang-rename", std::make_shared(), +FileContents)) + return ""; + +formatAndApplyAllReplacements(FileToReplacements, Context.Rewrite, "llvm"); +return Context.getRewrittenText(InputFileID); + } + + void CompareSnippets(StringRef Expected, StringRef Actual) { +std::string ExpectedCode; +llvm::raw_string_ostream(ExpectedCode) << llvm::format( +"#include \"%s\"\n%s", HeaderName.c_str(), Expected.str().c_str()); +EXPECT_EQ(format(ExpectedCode), format(Actual)); + } + + std::string format(llvm::StringRef Code) { +tooling::Replacements Replaces = format::reformat( +format::getLLVMStyle(), Code, {tooling::Range(0, Code.size())}); +auto ChangedCode = tooling::applyAllReplacements(Code, Replaces); +EXPECT_TRUE(static_cast(ChangedCode)); +if (!ChangedCode) { + llvm::errs() << llvm::toString(ChangedCode.takeError()); + return ""; +} +return *ChangedCode; + } + + std::string HeaderContent; + std::string HeaderName = "header.h"; + std::string CCName = "input.cc"; +}; + +class RenameClassTest : public ClangRenameTest { + public: + RenameClassTest() { +AppendToHeader("\nclass Foo {};\n"); + } +}; + +INSTANTIATE_TEST_CASE_P( +RenameTests, RenameClassTest, +testing::ValuesIn(std::vector({ + {"Foo f;", "Bar f;"}, + {"void f(Foo f) {}", "void f(Bar f) {}"}, + {"void f(Foo *f) {}", "void f(Bar *f) {}"}, + {"Foo f() { return Foo(); }", "Bar f() { return Bar(); }"}, +}))); + +TEST_P(RenameClassTest, RenameClasses) { +
[PATCH] D30813: [clang-rename] Introduce an unittest skeleton for clang-rename.
ioeric accepted this revision. ioeric added a comment. This revision is now accepted and ready to land. lg Comment at: unittests/clang-rename/ClangRenameTests.cpp:91 +"#include \"%s\"\n%s", HeaderName.c_str(), Expected.str().c_str()); +EXPECT_EQ(format(ExpectedCode), format(Actual)); + } I'd put EXPECT_EQ in test cases so that it would be easier to see which case fails. Maybe pull out a function for wrapping `Expected` and EXPECT_EQ on the formatted result and `format(Actual)`? https://reviews.llvm.org/D30813 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30183: Add -iframeworkwithsysroot compiler option
arphaman added a comment. Ping Repository: rL LLVM https://reviews.llvm.org/D30183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30813: [clang-rename] Introduce an unittest skeleton for clang-rename.
hokein marked an inline comment as done. hokein added inline comments. Comment at: unittests/clang-rename/ClangRenameTests.cpp:91 +"#include \"%s\"\n%s", HeaderName.c_str(), Expected.str().c_str()); +EXPECT_EQ(format(ExpectedCode), format(Actual)); + } ioeric wrote: > I'd put EXPECT_EQ in test cases so that it would be easier to see which case > fails. Maybe pull out a function for wrapping `Expected` and EXPECT_EQ on the > formatted result and `format(Actual)`? I don't see a strong benefit of it. As our test cases are generated by `INSTANTIATE_TEST_CASE_P`, pulling out this function doesn't make the failure output much clearer; this will also save us some keystrokes. I'd keep it at the moment. https://reviews.llvm.org/D30813 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r297450 - [clang-rename] Introduce an unittest skeleton for clang-rename.
Author: hokein Date: Fri Mar 10 04:30:14 2017 New Revision: 297450 URL: http://llvm.org/viewvc/llvm-project?rev=297450&view=rev Log: [clang-rename] Introduce an unittest skeleton for clang-rename. Summary: This will make references rename tests easier. Reviewers: ioeric Reviewed By: ioeric Subscribers: cfe-commits, alexfh, mgorny Differential Revision: https://reviews.llvm.org/D30813 Added: clang-tools-extra/trunk/unittests/clang-rename/CMakeLists.txt clang-tools-extra/trunk/unittests/clang-rename/ClangRenameTests.cpp Modified: clang-tools-extra/trunk/unittests/CMakeLists.txt Modified: clang-tools-extra/trunk/unittests/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/CMakeLists.txt?rev=297450&r1=297449&r2=297450&view=diff == --- clang-tools-extra/trunk/unittests/CMakeLists.txt (original) +++ clang-tools-extra/trunk/unittests/CMakeLists.txt Fri Mar 10 04:30:14 2017 @@ -10,4 +10,5 @@ add_subdirectory(clang-apply-replacement add_subdirectory(clang-move) add_subdirectory(clang-query) add_subdirectory(clang-tidy) +add_subdirectory(clang-rename) add_subdirectory(include-fixer) Added: clang-tools-extra/trunk/unittests/clang-rename/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-rename/CMakeLists.txt?rev=297450&view=auto == --- clang-tools-extra/trunk/unittests/clang-rename/CMakeLists.txt (added) +++ clang-tools-extra/trunk/unittests/clang-rename/CMakeLists.txt Fri Mar 10 04:30:14 2017 @@ -0,0 +1,28 @@ +set(LLVM_LINK_COMPONENTS + support + ) + +get_filename_component(CLANG_RENAME_SOURCE_DIR + ${CMAKE_CURRENT_SOURCE_DIR}/../../clang-rename REALPATH) +include_directories( + ${CLANG_RENAME_SOURCE_DIR} + ) + +# We'd like clang/unittests/Tooling/RewriterTestContext.h in the test. +include_directories(${CLANG_SOURCE_DIR}) + +add_extra_unittest(ClangRenameTests + ClangRenameTests.cpp + ) + +target_link_libraries(ClangRenameTests + clangAST + clangASTMatchers + clangBasic + clangFormat + clangFrontend + clangRename + clangRewrite + clangTooling + clangToolingCore + ) Added: clang-tools-extra/trunk/unittests/clang-rename/ClangRenameTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-rename/ClangRenameTests.cpp?rev=297450&view=auto == --- clang-tools-extra/trunk/unittests/clang-rename/ClangRenameTests.cpp (added) +++ clang-tools-extra/trunk/unittests/clang-rename/ClangRenameTests.cpp Fri Mar 10 04:30:14 2017 @@ -0,0 +1,153 @@ +//===-- ClangRenameTests.cpp - clang-rename unit tests ===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "RenamingAction.h" +#include "USRFindingAction.h" +#include "unittests/Tooling/RewriterTestContext.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/Basic/FileManager.h" +#include "clang/Basic/FileSystemOptions.h" +#include "clang/Basic/VirtualFileSystem.h" +#include "clang/Format/Format.h" +#include "clang/Frontend/CompilerInstance.h" +#include "clang/Frontend/PCHContainerOperations.h" +#include "clang/Tooling/Refactoring.h" +#include "clang/Tooling/Tooling.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Format.h" +#include "llvm/Support/MemoryBuffer.h" +#include "gtest/gtest.h" +#include +#include +#include + +namespace clang { +namespace clang_rename { +namespace { + +struct Case { + std::string Before; + std::string After; +}; + +class ClangRenameTest : public testing::Test, +public testing::WithParamInterface { +protected: + void AppendToHeader(StringRef Code) { +HeaderContent += Code.str(); + } + + std::string runClangRenameOnCode(llvm::StringRef Code, + llvm::StringRef OldName, + llvm::StringRef NewName) { +std::string NewCode; +llvm::raw_string_ostream(NewCode) << llvm::format( +"#include \"%s\"\n%s", HeaderName.c_str(), Code.str().c_str()); +tooling::FileContentMappings FileContents = {{HeaderName, HeaderContent}, + {CCName, NewCode}}; +clang::RewriterTestContext Context; +Context.createInMemoryFile(HeaderName, HeaderContent); +clang::FileID InputFileID = Context.createInMemoryFile(CCName, NewCode); + +rename::USRFindingAction FindingAction({}, {OldName}); +std::unique_ptr USRFindingActionFactory = +tooling::newFrontendActionFactory(&FindingAction); + +if (!tooling::runToo
[PATCH] D30813: [clang-rename] Introduce an unittest skeleton for clang-rename.
This revision was automatically updated to reflect the committed changes. hokein marked an inline comment as done. Closed by commit rL297450: [clang-rename] Introduce an unittest skeleton for clang-rename. (authored by hokein). Changed prior to commit: https://reviews.llvm.org/D30813?vs=91296&id=91303#toc Repository: rL LLVM https://reviews.llvm.org/D30813 Files: clang-tools-extra/trunk/unittests/CMakeLists.txt clang-tools-extra/trunk/unittests/clang-rename/CMakeLists.txt clang-tools-extra/trunk/unittests/clang-rename/ClangRenameTests.cpp Index: clang-tools-extra/trunk/unittests/clang-rename/CMakeLists.txt === --- clang-tools-extra/trunk/unittests/clang-rename/CMakeLists.txt +++ clang-tools-extra/trunk/unittests/clang-rename/CMakeLists.txt @@ -0,0 +1,28 @@ +set(LLVM_LINK_COMPONENTS + support + ) + +get_filename_component(CLANG_RENAME_SOURCE_DIR + ${CMAKE_CURRENT_SOURCE_DIR}/../../clang-rename REALPATH) +include_directories( + ${CLANG_RENAME_SOURCE_DIR} + ) + +# We'd like clang/unittests/Tooling/RewriterTestContext.h in the test. +include_directories(${CLANG_SOURCE_DIR}) + +add_extra_unittest(ClangRenameTests + ClangRenameTests.cpp + ) + +target_link_libraries(ClangRenameTests + clangAST + clangASTMatchers + clangBasic + clangFormat + clangFrontend + clangRename + clangRewrite + clangTooling + clangToolingCore + ) Index: clang-tools-extra/trunk/unittests/clang-rename/ClangRenameTests.cpp === --- clang-tools-extra/trunk/unittests/clang-rename/ClangRenameTests.cpp +++ clang-tools-extra/trunk/unittests/clang-rename/ClangRenameTests.cpp @@ -0,0 +1,153 @@ +//===-- ClangRenameTests.cpp - clang-rename unit tests ===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "RenamingAction.h" +#include "USRFindingAction.h" +#include "unittests/Tooling/RewriterTestContext.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/Basic/FileManager.h" +#include "clang/Basic/FileSystemOptions.h" +#include "clang/Basic/VirtualFileSystem.h" +#include "clang/Format/Format.h" +#include "clang/Frontend/CompilerInstance.h" +#include "clang/Frontend/PCHContainerOperations.h" +#include "clang/Tooling/Refactoring.h" +#include "clang/Tooling/Tooling.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Format.h" +#include "llvm/Support/MemoryBuffer.h" +#include "gtest/gtest.h" +#include +#include +#include + +namespace clang { +namespace clang_rename { +namespace { + +struct Case { + std::string Before; + std::string After; +}; + +class ClangRenameTest : public testing::Test, +public testing::WithParamInterface { +protected: + void AppendToHeader(StringRef Code) { +HeaderContent += Code.str(); + } + + std::string runClangRenameOnCode(llvm::StringRef Code, + llvm::StringRef OldName, + llvm::StringRef NewName) { +std::string NewCode; +llvm::raw_string_ostream(NewCode) << llvm::format( +"#include \"%s\"\n%s", HeaderName.c_str(), Code.str().c_str()); +tooling::FileContentMappings FileContents = {{HeaderName, HeaderContent}, + {CCName, NewCode}}; +clang::RewriterTestContext Context; +Context.createInMemoryFile(HeaderName, HeaderContent); +clang::FileID InputFileID = Context.createInMemoryFile(CCName, NewCode); + +rename::USRFindingAction FindingAction({}, {OldName}); +std::unique_ptr USRFindingActionFactory = +tooling::newFrontendActionFactory(&FindingAction); + +if (!tooling::runToolOnCodeWithArgs( +USRFindingActionFactory->create(), NewCode, {"-std=c++11"}, CCName, +"clang-rename", std::make_shared(), +FileContents)) + return ""; + +const std::vector> &USRList = +FindingAction.getUSRList(); +const std::vector &PrevNames = FindingAction.getUSRSpellings(); +std::vector NewNames = {NewName}; +std::map FileToReplacements; +rename::RenamingAction RenameAction(NewNames, PrevNames, USRList, +FileToReplacements); +auto RenameActionFactory = tooling::newFrontendActionFactory(&RenameAction); +if (!tooling::runToolOnCodeWithArgs( +RenameActionFactory->create(), NewCode, {"-std=c++11"}, CCName, +"clang-rename", std::make_shared(), +FileContents)) + return ""; + +formatAndApplyAllReplacements(FileToReplacements, Context.Rewrite, "llvm"); +return Context.getRewrittenText(InputFileID); + } + + void CompareSnippets(StringRef Expec
[PATCH] D29944: libclang: Print namespaces for typedefs and type aliases
arphaman accepted this revision. arphaman added a comment. This revision is now accepted and ready to land. LGTM, thanks for the fix. Do you need someone to commit it for you? https://reviews.llvm.org/D29944 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30766: Add support for attribute "enum_extensibility"
arphaman added inline comments. Comment at: include/clang/Basic/Attr.td:887 +def EnumExtensibility : InheritableAttr { + let Spellings = [GNU<"enum_extensibility">]; + let Subjects = SubjectList<[Enum]>; We might as well have a C++11 spelling in the `clang` namespace as well. Comment at: test/Sema/enum-attr.c:27 + +enum __attribute__((enum_extensibility(arg1))) EnumInvalidArg { // expected-warning{{'enum_extensibility' attribute argument not supported: 'arg1'}} + G Should this be an error instead? https://reviews.llvm.org/D30766 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30643: [OpenCL] Extended diagnostics for atomic initialization
echuraev updated this revision to Diff 91305. echuraev marked 2 inline comments as done. https://reviews.llvm.org/D30643 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaInit.cpp test/SemaOpenCL/atomic-init.cl Index: test/SemaOpenCL/atomic-init.cl === --- /dev/null +++ test/SemaOpenCL/atomic-init.cl @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s + +global atomic_int a1 = 0; + +kernel void test_atomic_initialization() { + atomic_int a2 = 0; // expected-error {{initialization of atomic variables is restricted to variables in global address space}} + private atomic_int a3 = 0; // expected-error {{initialization of atomic variables is restricted to variables in global address space}} + local atomic_int a4 = 0; // expected-error {{'__local' variable cannot have an initializer}} + global atomic_int a5 = 0; // expected-error {{function scope variable cannot be declared in global address space}} +} Index: lib/Sema/SemaInit.cpp === --- lib/Sema/SemaInit.cpp +++ lib/Sema/SemaInit.cpp @@ -6489,6 +6489,20 @@ << Init->getSourceRange(); } + // OpenCL v2.0 s6.13.11.1. atomic variables can be initialized in global scope + QualType ETy = Entity.getType(); + Qualifiers TyQualifiers = ETy.getQualifiers(); + bool HasGlobalAS = TyQualifiers.hasAddressSpace() && + TyQualifiers.getAddressSpace() == LangAS::opencl_global; + + if (S.getLangOpts().OpenCLVersion >= 200 && + ETy->isAtomicType() && !HasGlobalAS && + Entity.getKind() == InitializedEntity::EK_Variable && Args.size() > 0) { +S.Diag(Args[0]->getLocStart(), diag::err_atomic_init_addressspace) << +SourceRange(Entity.getDecl()->getLocStart(), Args[0]->getLocEnd()); +return ExprError(); + } + // Diagnose cases where we initialize a pointer to an array temporary, and the // pointer obviously outlives the temporary. if (Args.size() == 1 && Args[0]->getType()->isArrayType() && Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -8264,6 +8264,9 @@ "return value cannot be qualified with address space">; def err_opencl_constant_no_init : Error< "variable in constant address space must be initialized">; +// Atomics +def err_atomic_init_addressspace : Error< + "initialization of atomic variables is restricted to variables in global address space">; def err_atomic_init_constant : Error< "atomic variable can only be assigned to a compile time constant" " in the declaration statement in the program scope">; Index: test/SemaOpenCL/atomic-init.cl === --- /dev/null +++ test/SemaOpenCL/atomic-init.cl @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s + +global atomic_int a1 = 0; + +kernel void test_atomic_initialization() { + atomic_int a2 = 0; // expected-error {{initialization of atomic variables is restricted to variables in global address space}} + private atomic_int a3 = 0; // expected-error {{initialization of atomic variables is restricted to variables in global address space}} + local atomic_int a4 = 0; // expected-error {{'__local' variable cannot have an initializer}} + global atomic_int a5 = 0; // expected-error {{function scope variable cannot be declared in global address space}} +} Index: lib/Sema/SemaInit.cpp === --- lib/Sema/SemaInit.cpp +++ lib/Sema/SemaInit.cpp @@ -6489,6 +6489,20 @@ << Init->getSourceRange(); } + // OpenCL v2.0 s6.13.11.1. atomic variables can be initialized in global scope + QualType ETy = Entity.getType(); + Qualifiers TyQualifiers = ETy.getQualifiers(); + bool HasGlobalAS = TyQualifiers.hasAddressSpace() && + TyQualifiers.getAddressSpace() == LangAS::opencl_global; + + if (S.getLangOpts().OpenCLVersion >= 200 && + ETy->isAtomicType() && !HasGlobalAS && + Entity.getKind() == InitializedEntity::EK_Variable && Args.size() > 0) { +S.Diag(Args[0]->getLocStart(), diag::err_atomic_init_addressspace) << +SourceRange(Entity.getDecl()->getLocStart(), Args[0]->getLocEnd()); +return ExprError(); + } + // Diagnose cases where we initialize a pointer to an array temporary, and the // pointer obviously outlives the temporary. if (Args.size() == 1 && Args[0]->getType()->isArrayType() && Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -8264,6 +8264,9 @@ "return value cannot be qualified with address space">; def err_opencl_constant_no_in
[PATCH] D30643: [OpenCL] Extended diagnostics for atomic initialization
echuraev added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8263 +def err_atomic_init_addressspace : Error< + "initialization of atomic variables is restricted to variables in global address space">; def err_atomic_init_constant : Error< Anastasia wrote: > Could we combine this error diag with the one below? I guess they are > semantically very similar apart from one is about initialization and another > is about assignment? I'm not sure that it is a good idea to combine these errors. For example, if developer had declared a variable non-constant and not in global address space he would have got the same message for both errors. And it can be difficult to determine what the exact problem is. He can fix one of the problems but he will still get the same error. https://reviews.llvm.org/D30643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30810: Preserve vec3 type.
jaykang10 updated this revision to Diff 91306. jaykang10 added a comment. Added -f prefix to option name. https://reviews.llvm.org/D30810 Files: include/clang/Driver/CC1Options.td include/clang/Frontend/CodeGenOptions.def lib/CodeGen/CGExpr.cpp lib/Frontend/CompilerInvocation.cpp Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -713,6 +713,7 @@ } } + Opts.PreserveVec3Type = Args.hasArg(OPT_fpreserve_vec3_type); Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions); Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument); Opts.XRayInstructionThreshold = Index: lib/CodeGen/CGExpr.cpp === --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -1368,26 +1368,28 @@ QualType TBAABaseType, uint64_t TBAAOffset, bool isNontemporal) { - // For better performance, handle vector loads differently. - if (Ty->isVectorType()) { -const llvm::Type *EltTy = Addr.getElementType(); - -const auto *VTy = cast(EltTy); - -// Handle vectors of size 3 like size 4 for better performance. -if (VTy->getNumElements() == 3) { - - // Bitcast to vec4 type. - llvm::VectorType *vec4Ty = llvm::VectorType::get(VTy->getElementType(), - 4); - Address Cast = Builder.CreateElementBitCast(Addr, vec4Ty, "castToVec4"); - // Now load value. - llvm::Value *V = Builder.CreateLoad(Cast, Volatile, "loadVec4"); - - // Shuffle vector to get vec3. - V = Builder.CreateShuffleVector(V, llvm::UndefValue::get(vec4Ty), - {0, 1, 2}, "extractVec"); - return EmitFromMemory(V, Ty); + if (!CGM.getCodeGenOpts().PreserveVec3Type) { +// For better performance, handle vector loads differently. +if (Ty->isVectorType()) { + const llvm::Type *EltTy = Addr.getElementType(); + + const auto *VTy = cast(EltTy); + + // Handle vectors of size 3 like size 4 for better performance. + if (VTy->getNumElements() == 3) { + +// Bitcast to vec4 type. +llvm::VectorType *vec4Ty = +llvm::VectorType::get(VTy->getElementType(), 4); +Address Cast = Builder.CreateElementBitCast(Addr, vec4Ty, "castToVec4"); +// Now load value. +llvm::Value *V = Builder.CreateLoad(Cast, Volatile, "loadVec4"); + +// Shuffle vector to get vec3. +V = Builder.CreateShuffleVector(V, llvm::UndefValue::get(vec4Ty), +{0, 1, 2}, "extractVec"); +return EmitFromMemory(V, Ty); + } } } @@ -1456,23 +1458,24 @@ bool isNontemporal) { // Handle vectors differently to get better performance. - if (Ty->isVectorType()) { -llvm::Type *SrcTy = Value->getType(); -auto *VecTy = cast(SrcTy); -// Handle vec3 special. -if (VecTy->getNumElements() == 3) { - // Our source is a vec3, do a shuffle vector to make it a vec4. - llvm::Constant *Mask[] = {Builder.getInt32(0), Builder.getInt32(1), -Builder.getInt32(2), -llvm::UndefValue::get(Builder.getInt32Ty())}; - llvm::Value *MaskV = llvm::ConstantVector::get(Mask); - Value = Builder.CreateShuffleVector(Value, - llvm::UndefValue::get(VecTy), - MaskV, "extractVec"); - SrcTy = llvm::VectorType::get(VecTy->getElementType(), 4); -} -if (Addr.getElementType() != SrcTy) { - Addr = Builder.CreateElementBitCast(Addr, SrcTy, "storetmp"); + if (!CGM.getCodeGenOpts().PreserveVec3Type) { +if (Ty->isVectorType()) { + llvm::Type *SrcTy = Value->getType(); + auto *VecTy = cast(SrcTy); + // Handle vec3 special. + if (VecTy->getNumElements() == 3) { +// Our source is a vec3, do a shuffle vector to make it a vec4. +llvm::Constant *Mask[] = {Builder.getInt32(0), Builder.getInt32(1), + Builder.getInt32(2), + llvm::UndefValue::get(Builder.getInt32Ty())}; +llvm::Value *MaskV = llvm::ConstantVector::get(Mask); +Value = Builder.CreateShuffleVector(Value, llvm::UndefValue::get(VecTy), +MaskV, "extractVec"); +SrcTy = llvm::VectorType::get(VecTy->getElementType(), 4); + } + if (Addr.getElementType() != SrcTy) { +Addr = Builder.CreateElementBitCast(Addr, SrcTy, "storetmp"); + } } } Index: include/clang/Frontend/CodeGenOptions.def =
[PATCH] D30810: Preserve vec3 type.
jaykang10 updated this revision to Diff 91307. jaykang10 added a comment. Fixed typo. https://reviews.llvm.org/D30810 Files: include/clang/Driver/CC1Options.td include/clang/Frontend/CodeGenOptions.def lib/CodeGen/CGExpr.cpp lib/Frontend/CompilerInvocation.cpp Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -713,6 +713,7 @@ } } + Opts.PreserveVec3Type = Args.hasArg(OPT_fpreserve_vec3_type); Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions); Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument); Opts.XRayInstructionThreshold = Index: lib/CodeGen/CGExpr.cpp === --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -1368,26 +1368,28 @@ QualType TBAABaseType, uint64_t TBAAOffset, bool isNontemporal) { - // For better performance, handle vector loads differently. - if (Ty->isVectorType()) { -const llvm::Type *EltTy = Addr.getElementType(); - -const auto *VTy = cast(EltTy); - -// Handle vectors of size 3 like size 4 for better performance. -if (VTy->getNumElements() == 3) { - - // Bitcast to vec4 type. - llvm::VectorType *vec4Ty = llvm::VectorType::get(VTy->getElementType(), - 4); - Address Cast = Builder.CreateElementBitCast(Addr, vec4Ty, "castToVec4"); - // Now load value. - llvm::Value *V = Builder.CreateLoad(Cast, Volatile, "loadVec4"); - - // Shuffle vector to get vec3. - V = Builder.CreateShuffleVector(V, llvm::UndefValue::get(vec4Ty), - {0, 1, 2}, "extractVec"); - return EmitFromMemory(V, Ty); + if (!CGM.getCodeGenOpts().PreserveVec3Type) { +// For better performance, handle vector loads differently. +if (Ty->isVectorType()) { + const llvm::Type *EltTy = Addr.getElementType(); + + const auto *VTy = cast(EltTy); + + // Handle vectors of size 3 like size 4 for better performance. + if (VTy->getNumElements() == 3) { + +// Bitcast to vec4 type. +llvm::VectorType *vec4Ty = +llvm::VectorType::get(VTy->getElementType(), 4); +Address Cast = Builder.CreateElementBitCast(Addr, vec4Ty, "castToVec4"); +// Now load value. +llvm::Value *V = Builder.CreateLoad(Cast, Volatile, "loadVec4"); + +// Shuffle vector to get vec3. +V = Builder.CreateShuffleVector(V, llvm::UndefValue::get(vec4Ty), +{0, 1, 2}, "extractVec"); +return EmitFromMemory(V, Ty); + } } } @@ -1456,23 +1458,24 @@ bool isNontemporal) { // Handle vectors differently to get better performance. - if (Ty->isVectorType()) { -llvm::Type *SrcTy = Value->getType(); -auto *VecTy = cast(SrcTy); -// Handle vec3 special. -if (VecTy->getNumElements() == 3) { - // Our source is a vec3, do a shuffle vector to make it a vec4. - llvm::Constant *Mask[] = {Builder.getInt32(0), Builder.getInt32(1), -Builder.getInt32(2), -llvm::UndefValue::get(Builder.getInt32Ty())}; - llvm::Value *MaskV = llvm::ConstantVector::get(Mask); - Value = Builder.CreateShuffleVector(Value, - llvm::UndefValue::get(VecTy), - MaskV, "extractVec"); - SrcTy = llvm::VectorType::get(VecTy->getElementType(), 4); -} -if (Addr.getElementType() != SrcTy) { - Addr = Builder.CreateElementBitCast(Addr, SrcTy, "storetmp"); + if (!CGM.getCodeGenOpts().PreserveVec3Type) { +if (Ty->isVectorType()) { + llvm::Type *SrcTy = Value->getType(); + auto *VecTy = cast(SrcTy); + // Handle vec3 special. + if (VecTy->getNumElements() == 3) { +// Our source is a vec3, do a shuffle vector to make it a vec4. +llvm::Constant *Mask[] = {Builder.getInt32(0), Builder.getInt32(1), + Builder.getInt32(2), + llvm::UndefValue::get(Builder.getInt32Ty())}; +llvm::Value *MaskV = llvm::ConstantVector::get(Mask); +Value = Builder.CreateShuffleVector(Value, llvm::UndefValue::get(VecTy), +MaskV, "extractVec"); +SrcTy = llvm::VectorType::get(VecTy->getElementType(), 4); + } + if (Addr.getElementType() != SrcTy) { +Addr = Builder.CreateElementBitCast(Addr, SrcTy, "storetmp"); + } } } Index: include/clang/Frontend/CodeGenOptions.def =
[PATCH] D30816: [OpenCL] Added implicit conversion rank for overloading functions with vector data type in OpenCL
echuraev created this revision. Herald added a subscriber: yaxunl. I added a new rank to ImplicitConversionRank enum to resolve the function overload ambiguity with vector types. Rank of scalar types conversion is lower than vector splat. So, we can choose which function should we call. See test for more details. https://reviews.llvm.org/D30816 Files: include/clang/Sema/Overload.h lib/Sema/SemaOverload.cpp test/SemaOpenCL/overload-scalar-widening.cl Index: test/SemaOpenCL/overload-scalar-widening.cl === --- /dev/null +++ test/SemaOpenCL/overload-scalar-widening.cl @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 +// expected-no-diagnostics + +typedef short short4 __attribute__((ext_vector_type(4))); + +short4 __attribute__ ((overloadable)) clamp(short4 x, short4 minval, short4 maxval); +short4 __attribute__ ((overloadable)) clamp(short4 x, short minval, short maxval); + +void foo() +{ +short4 e0=0; +clamp(e0, 0, 255); +} Index: lib/Sema/SemaOverload.cpp === --- lib/Sema/SemaOverload.cpp +++ lib/Sema/SemaOverload.cpp @@ -131,7 +131,7 @@ ICR_Conversion, ICR_Conversion, ICR_Conversion, -ICR_Conversion, +ICR_OCL_Scalar_Widening, ICR_Complex_Real_Conversion, ICR_Conversion, ICR_Conversion, Index: include/clang/Sema/Overload.h === --- include/clang/Sema/Overload.h +++ include/clang/Sema/Overload.h @@ -98,6 +98,7 @@ ICR_Exact_Match = 0, ///< Exact Match ICR_Promotion, ///< Promotion ICR_Conversion, ///< Conversion +ICR_OCL_Scalar_Widening, ///< OpenCL Scalar Widening ICR_Complex_Real_Conversion, ///< Complex <-> Real conversion ICR_Writeback_Conversion,///< ObjC ARC writeback conversion ICR_C_Conversion,///< Conversion only allowed in the C standard. Index: test/SemaOpenCL/overload-scalar-widening.cl === --- /dev/null +++ test/SemaOpenCL/overload-scalar-widening.cl @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 +// expected-no-diagnostics + +typedef short short4 __attribute__((ext_vector_type(4))); + +short4 __attribute__ ((overloadable)) clamp(short4 x, short4 minval, short4 maxval); +short4 __attribute__ ((overloadable)) clamp(short4 x, short minval, short maxval); + +void foo() +{ +short4 e0=0; +clamp(e0, 0, 255); +} Index: lib/Sema/SemaOverload.cpp === --- lib/Sema/SemaOverload.cpp +++ lib/Sema/SemaOverload.cpp @@ -131,7 +131,7 @@ ICR_Conversion, ICR_Conversion, ICR_Conversion, -ICR_Conversion, +ICR_OCL_Scalar_Widening, ICR_Complex_Real_Conversion, ICR_Conversion, ICR_Conversion, Index: include/clang/Sema/Overload.h === --- include/clang/Sema/Overload.h +++ include/clang/Sema/Overload.h @@ -98,6 +98,7 @@ ICR_Exact_Match = 0, ///< Exact Match ICR_Promotion, ///< Promotion ICR_Conversion, ///< Conversion +ICR_OCL_Scalar_Widening, ///< OpenCL Scalar Widening ICR_Complex_Real_Conversion, ///< Complex <-> Real conversion ICR_Writeback_Conversion,///< ObjC ARC writeback conversion ICR_C_Conversion,///< Conversion only allowed in the C standard. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27753: [analyzer] alpha.security.DirtyScalar Checker
gerazo added a comment. > Stepping back a bit, what do you consider "dirty" vs "clean"? It seems that > you are looking for prove that the values are known to be within the bounds > of min and max int values. What happens if there is a comparison to an > unknown symbolic value? Should that be considered as clean or tainted? Are > there test cases for this? I consider values as clean when they were checked by the programmer from both sides. However, my implementation purely works from constraints in effect (and using min and max is just the broadest constraint I could find). So you are totally right that comparison with unknown symbols is not covered nor in implementation, nor in tests. Can you suggest a universally working method which can handle all cases (e.g. complex expressions on both sides of the operator)? If we could find such an approach, that would be something which could really go into the GenericTaintChecker as an improvement. And I would gladly rewrite this whole stuff to fit the more general solution. https://reviews.llvm.org/D27753 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30582: [Driver] Restructure handling of -ffast-math and similar options
john.brawn updated this revision to Diff 91311. john.brawn added a comment. Rebase on top of recent driver changes. Repository: rL LLVM https://reviews.llvm.org/D30582 Files: lib/Driver/ToolChains/Clang.cpp test/Driver/fast-math.c Index: test/Driver/fast-math.c === --- test/Driver/fast-math.c +++ test/Driver/fast-math.c @@ -148,20 +148,35 @@ // // One umbrella flag is *really* weird and also changes the semantics of the // program by adding a special preprocessor macro. Check that the frontend flag -// modeling this semantic change is provided. Also check that the semantic -// impact remains even if every optimization is disabled. +// modeling this semantic change is provided. Also check that the flag is not +// present if any of the optimization is disabled. // RUN: %clang -### -ffast-math -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s // RUN: %clang -### -fno-fast-math -ffast-math -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s -// RUN: %clang -### -ffast-math -fno-finite-math-only \ -// RUN: -fno-unsafe-math-optimizations -fmath-errno -c %s 2>&1 \ +// RUN: %clang -### -funsafe-math-optimizations -ffinite-math-only \ +// RUN: -fno-math-errno -ffp-contract=fast -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s +// RUN: %clang -### -fhonor-infinities -fhonor-nans -fno-math-errno \ +// RUN: -fassociative-math -freciprocal-math -fno-signed-zeros \ +// RUN: -fno-trapping-math -ffp-contract=fast -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s // CHECK-FAST-MATH: "-cc1" // CHECK-FAST-MATH: "-ffast-math" +// CHECK-FAST-MATH: "-ffinite-math-only" // // RUN: %clang -### -ffast-math -fno-fast-math -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s +// RUN: %clang -### -ffast-math -fno-finite-math-only -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s +// RUN: %clang -### -ffast-math -fno-unsafe-math-optimizations -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s +// RUN: %clang -### -ffast-math -fmath-errno -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s +// RUN: %clang -### -ffast-math -ffp-contract=on -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s +// RUN: %clang -### -ffast-math -ffp-contract=off -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s // CHECK-NO-FAST-MATH: "-cc1" // CHECK-NO-FAST-MATH-NOT: "-ffast-math" // @@ -179,6 +194,7 @@ // RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s // CHECK-NO-NO-INFS: "-cc1" // CHECK-NO-NO-INFS-NOT: "-menable-no-infs" +// CHECK-NO-NO-INFS-NOT: "-ffinite-math-only" // CHECK-NO-NO-INFS: "-o" // // RUN: %clang -### -fno-honor-nans -fhonor-nans -c %s 2>&1 \ @@ -193,6 +209,7 @@ // RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s // CHECK-NO-NO-NANS: "-cc1" // CHECK-NO-NO-NANS-NOT: "-menable-no-nans" +// CHECK-NO-NO-NANS-NOT: "-ffinite-math-only" // CHECK-NO-NO-NANS: "-o" // // RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \ Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -2301,98 +2301,129 @@ if (Args.hasArg(options::OPT_fsplit_stack)) CmdArgs.push_back("-split-stacks"); - // If -Ofast is the optimization level, then -ffast-math should be enabled. - // This alias option is being used to simplify the getLastArg logic. - OptSpecifier FastMathAliasOption = - OFastEnabled ? options::OPT_Ofast : options::OPT_ffast_math; - // Handle various floating point optimization flags, mapping them to the - // appropriate LLVM code generation flags. The pattern for all of these is to - // default off the codegen optimizations, and if any flag enables them and no - // flag disables them after the flag enabling them, enable the codegen - // optimization. This is complicated by several "umbrella" flags. - if (Arg *A = Args.getLastArg( - options::OPT_ffast_math, FastMathAliasOption, - options::OPT_fno_fast_math, options::OPT_ffinite_math_only, - options::OPT_fno_finite_math_only, options::OPT_fhonor_infinities, - options::OPT_fno_honor_infinities)) -if (A->getOption().getID() != options::OPT_fno_fast_math && -A->getOption().getID() != options::OPT_fno_finite_math_only && -A->getOption().getID() != options::OPT_fhonor_infinities) - CmdArgs.push_back("-menable-no-infs"); - if (Arg *A = Args.getLastArg( - options::OPT_ffast_math, FastMathAliasOption, - options::OPT_fno_fast_math, options::OPT_ffinite_math_only, - options::OPT_fno_finite_math_only, options::OPT_fhonor_nans, - options::OPT_fno_honor_nans)) -if (A->getOption().getID() != options::OPT_fno_fast_math && -
[PATCH] D29944: libclang: Print namespaces for typedefs and type aliases
redm123 added a comment. I guess so. I don't think I'm allowed to commit. So I would appreciate it. Which release version would that be in? 4.1 I guess? Thanks for your help! https://reviews.llvm.org/D29944 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r297455 - [clang-format] Use a reference in loop variable; NFC
Author: krasimir Date: Fri Mar 10 07:09:29 2017 New Revision: 297455 URL: http://llvm.org/viewvc/llvm-project?rev=297455&view=rev Log: [clang-format] Use a reference in loop variable; NFC Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=297455&r1=297454&r2=297455&view=diff == --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original) +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Fri Mar 10 07:09:29 2017 @@ -2155,7 +2155,7 @@ static bool continuesLineComment(const F // Scan for '{//'. If found, use the column of '{' as a min column for line // comment section continuation. const FormatToken *PreviousToken = nullptr; - for (const UnwrappedLineNode Node : Line.Tokens) { + for (const UnwrappedLineNode &Node : Line.Tokens) { if (PreviousToken && PreviousToken->is(tok::l_brace) && isLineComment(*Node.Tok)) { MinColumnToken = PreviousToken; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30798: [analyzer] Turn suppress-c++-stdlib on by default
xazax.hun added a comment. In https://reviews.llvm.org/D30798#697115, @zaks.anna wrote: > I've committed the change, but would very much appreciate community feedback > here if if there is any! I agree with the change. Users are usually not interested in the results from the standard library, and since the standard library supposed to be well tested, it is very unlikely that the analyzer could find a true positive there. One side effect would be the suppression of results that materialize due to the misuse of those APIs. Repository: rL LLVM https://reviews.llvm.org/D30798 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28136: [OpenCL] Implement as_type operator as alias of __builtin_astype.
echuraev updated this revision to Diff 91327. https://reviews.llvm.org/D28136 Files: lib/Headers/opencl-c.h test/SemaOpenCL/as_type.cl Index: test/SemaOpenCL/as_type.cl === --- test/SemaOpenCL/as_type.cl +++ test/SemaOpenCL/as_type.cl @@ -1,7 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -triple spir-unknown-unknown -o - -verify -fsyntax-only - -typedef __attribute__(( ext_vector_type(3) )) char char3; -typedef __attribute__(( ext_vector_type(16) )) char char16; +// RUN: %clang_cc1 %s -emit-llvm -triple spir-unknown-unknown -finclude-default-header -o - -verify -fsyntax-only char3 f1(char16 x) { return __builtin_astype(x, char3); // expected-error{{invalid reinterpretation: sizes of 'char3' (vector of 3 'char' values) and 'char16' (vector of 16 'char' values) must match}} @@ -11,3 +8,7 @@ return __builtin_astype(x, char16); // expected-error{{invalid reinterpretation: sizes of 'char16' (vector of 16 'char' values) and 'int' must match}} } +void foo() { +char src = 1; +int dst = as_int(src); // expected-error{{invalid reinterpretation: sizes of 'int' and 'char' must match}} +} Index: lib/Headers/opencl-c.h === --- lib/Headers/opencl-c.h +++ lib/Headers/opencl-c.h @@ -6584,777 +6584,85 @@ * OpenCL v1.1/1.2/2.0 s6.2.4.2 - as_type operators * Reinterprets a data type as another data type of the same size */ -char __ovld __cnfn as_char(char); -char __ovld __cnfn as_char(uchar); - -char2 __ovld __cnfn as_char2(char2); -char2 __ovld __cnfn as_char2(uchar2); -char2 __ovld __cnfn as_char2(short); -char2 __ovld __cnfn as_char2(ushort); - -char3 __ovld __cnfn as_char3(char3); -char3 __ovld __cnfn as_char3(char4); -char3 __ovld __cnfn as_char3(uchar3); -char3 __ovld __cnfn as_char3(uchar4); -char3 __ovld __cnfn as_char3(short2); -char3 __ovld __cnfn as_char3(ushort2); -char3 __ovld __cnfn as_char3(int); -char3 __ovld __cnfn as_char3(uint); -char3 __ovld __cnfn as_char3(float); - -char4 __ovld __cnfn as_char4(char3); -char4 __ovld __cnfn as_char4(char4); -char4 __ovld __cnfn as_char4(uchar3); -char4 __ovld __cnfn as_char4(uchar4); -char4 __ovld __cnfn as_char4(short2); -char4 __ovld __cnfn as_char4(ushort2); -char4 __ovld __cnfn as_char4(int); -char4 __ovld __cnfn as_char4(uint); -char4 __ovld __cnfn as_char4(float); - -char8 __ovld __cnfn as_char8(char8); -char8 __ovld __cnfn as_char8(uchar8); -char8 __ovld __cnfn as_char8(short3); -char8 __ovld __cnfn as_char8(short4); -char8 __ovld __cnfn as_char8(ushort3); -char8 __ovld __cnfn as_char8(ushort4); -char8 __ovld __cnfn as_char8(int2); -char8 __ovld __cnfn as_char8(uint2); -char8 __ovld __cnfn as_char8(long); -char8 __ovld __cnfn as_char8(ulong); -char8 __ovld __cnfn as_char8(float2); - -char16 __ovld __cnfn as_char16(char16); -char16 __ovld __cnfn as_char16(uchar16); -char16 __ovld __cnfn as_char16(short8); -char16 __ovld __cnfn as_char16(ushort8); -char16 __ovld __cnfn as_char16(int3); -char16 __ovld __cnfn as_char16(int4); -char16 __ovld __cnfn as_char16(uint3); -char16 __ovld __cnfn as_char16(uint4); -char16 __ovld __cnfn as_char16(long2); -char16 __ovld __cnfn as_char16(ulong2); -char16 __ovld __cnfn as_char16(float3); -char16 __ovld __cnfn as_char16(float4); - -uchar __ovld __cnfn as_uchar(char); -uchar __ovld __cnfn as_uchar(uchar); - -uchar2 __ovld __cnfn as_uchar2(char2); -uchar2 __ovld __cnfn as_uchar2(uchar2); -uchar2 __ovld __cnfn as_uchar2(short); -uchar2 __ovld __cnfn as_uchar2(ushort); - -uchar3 __ovld __cnfn as_uchar3(char3); -uchar3 __ovld __cnfn as_uchar3(char4); -uchar3 __ovld __cnfn as_uchar3(uchar3); -uchar3 __ovld __cnfn as_uchar3(uchar4); -uchar3 __ovld __cnfn as_uchar3(short2); -uchar3 __ovld __cnfn as_uchar3(ushort2); -uchar3 __ovld __cnfn as_uchar3(int); -uchar3 __ovld __cnfn as_uchar3(uint); -uchar3 __ovld __cnfn as_uchar3(float); - -uchar4 __ovld __cnfn as_uchar4(char3); -uchar4 __ovld __cnfn as_uchar4(char4); -uchar4 __ovld __cnfn as_uchar4(uchar3); -uchar4 __ovld __cnfn as_uchar4(uchar4); -uchar4 __ovld __cnfn as_uchar4(short2); -uchar4 __ovld __cnfn as_uchar4(ushort2); -uchar4 __ovld __cnfn as_uchar4(int); -uchar4 __ovld __cnfn as_uchar4(uint); -uchar4 __ovld __cnfn as_uchar4(float); - -uchar8 __ovld __cnfn as_uchar8(char8); -uchar8 __ovld __cnfn as_uchar8(uchar8); -uchar8 __ovld __cnfn as_uchar8(short3); -uchar8 __ovld __cnfn as_uchar8(short4); -uchar8 __ovld __cnfn as_uchar8(ushort3); -uchar8 __ovld __cnfn as_uchar8(ushort4); -uchar8 __ovld __cnfn as_uchar8(int2); -uchar8 __ovld __cnfn as_uchar8(uint2); -uchar8 __ovld __cnfn as_uchar8(long); -uchar8 __ovld __cnfn as_uchar8(ulong); -uchar8 __ovld __cnfn as_uchar8(float2); - -uchar16 __ovld __cnfn as_uchar16(char16); -uchar16 __ovld __cnfn as_uchar16(uchar16); -uchar16 __ovld __cnfn as_uchar16(short8); -uchar16 __ovld __cnfn as_uchar16(ushort8); -uchar16 __ovld __cnfn as_uchar16(int3); -uchar16 __ovld __cnfn as_uchar16(int4); -uchar1
[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration
Abpostelnicu updated this revision to Diff 91330. Abpostelnicu marked an inline comment as done. Repository: rL LLVM https://reviews.llvm.org/D30487 Files: docs/ClangFormatStyleOptions.rst include/clang/Format/Format.h lib/Format/ContinuationIndenter.cpp lib/Format/Format.cpp lib/Format/FormatToken.h lib/Format/TokenAnnotator.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -1029,6 +1029,17 @@ verifyFormat("class ::A::B {};"); } +TEST_F(FormatTest, BreakBeforeInheritanceComma) { + FormatStyle StyleWithInheritanceBreak = getLLVMStyle(); + StyleWithInheritanceBreak.BreakBeforeInheritanceComma = true; + + verifyFormat("class MyClass : public X {};", StyleWithInheritanceBreak); + verifyFormat("class MyClass\n" + ": public X\n" + ", public Y {};", + StyleWithInheritanceBreak); +} + TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) { verifyFormat("class A {\n} a, b;"); verifyFormat("struct A {\n} a, b;"); @@ -8582,6 +8593,7 @@ CHECK_PARSE_BOOL(BreakBeforeTernaryOperators); CHECK_PARSE_BOOL(BreakConstructorInitializersBeforeComma); CHECK_PARSE_BOOL(BreakStringLiterals); + CHECK_PARSE_BOOL(BreakBeforeInheritanceComma) CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine); CHECK_PARSE_BOOL(DerivePointerAlignment); CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding"); Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -676,6 +676,8 @@ case tok::comma: if (Contexts.back().InCtorInitializer) Tok->Type = TT_CtorInitializerComma; + else if (Contexts.back().InInhertianceList) +Tok->Type = TT_InheritanceComma; else if (Contexts.back().FirstStartOfName && (Contexts.size() == 1 || Line.startsWith(tok::kw_for))) { Contexts.back().FirstStartOfName->PartOfMultiVariableDeclStmt = true; @@ -945,6 +947,7 @@ bool CanBeExpression = true; bool InTemplateArgument = false; bool InCtorInitializer = false; +bool InInhertianceList = false; bool CaretFound = false; bool IsForEachMacro = false; }; @@ -1004,6 +1007,9 @@ Current.Previous->is(TT_CtorInitializerColon)) { Contexts.back().IsExpression = true; Contexts.back().InCtorInitializer = true; +} else if (Current.Previous && + Current.Previous->is(TT_InheritanceColon)) { + Contexts.back().InInhertianceList = true; } else if (Current.isOneOf(tok::r_paren, tok::greater, tok::comma)) { for (FormatToken *Previous = Current.Previous; Previous && Previous->isOneOf(tok::star, tok::amp); @@ -2474,6 +2480,10 @@ Style.BreakConstructorInitializersBeforeComma && !Style.ConstructorInitializerAllOnOneLineOrOnePerLine) return true; + // Break only if we have multiple inheritance. + if (Style.BreakBeforeInheritanceComma && + Right.is(TT_InheritanceComma)) + return true; if (Right.is(tok::string_literal) && Right.TokenText.startswith("R\"")) // Raw string literals are special wrt. line breaks. The author has made a // deliberate choice and might have aligned the contents of the string @@ -2653,6 +2663,12 @@ if (Right.is(TT_CtorInitializerComma) && Style.BreakConstructorInitializersBeforeComma) return true; + if (Left.is(TT_InheritanceComma) && + Style.BreakBeforeInheritanceComma) +return false; + if (Right.is(TT_InheritanceComma) && + Style.BreakBeforeInheritanceComma) +return true; if ((Left.is(tok::greater) && Right.is(tok::greater)) || (Left.is(tok::less) && Right.is(tok::less))) return false; Index: lib/Format/FormatToken.h === --- lib/Format/FormatToken.h +++ lib/Format/FormatToken.h @@ -48,6 +48,7 @@ TYPE(FunctionTypeLParen) \ TYPE(ImplicitStringLiteral) \ TYPE(InheritanceColon) \ + TYPE(InheritanceComma) \ TYPE(InlineASMBrace) \ TYPE(InlineASMColon) \ TYPE(JavaAnnotation) \ Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -298,6 +298,8 @@ IO.mapOptional("BreakStringLiterals", Style.BreakStringLiterals); IO.mapOptional("ColumnLimit", Style.ColumnLimit); IO.mapOptional("CommentPragmas", Style.CommentPragmas); +IO.mapOptional("BreakBeforeInheritanceComma", + Style.BreakBeforeInheritanceComma); IO.mapOptional("ConstructorInitializerAllOnOneLineOrOnePerLine", Style.ConstructorInitializerAllOnOneLineOrOnePerLine); IO.mapOptional("ConstructorInitializerIndentW
[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration
djasper added inline comments. Comment at: lib/Format/TokenAnnotator.cpp:2666 return true; + if (Left.is(TT_InheritanceComma) && + Style.BreakBeforeInheritanceComma) Do these now fit on one line? Repository: rL LLVM https://reviews.llvm.org/D30487 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration
Abpostelnicu added inline comments. Comment at: lib/Format/ContinuationIndenter.cpp:355 + if (Current.is(TT_InheritanceColon)) +State.Stack.back().NoLineBreak = true; djasper wrote: > Can you leave a comment here: > > // Don't break within the inheritance declaration unless the ":" is on a > new line. I've modified the comment since this should be valid only if Style.BreakBeforeInheritanceComma is set to true otherwise we would be in the strange case where the input where the input is: ``` class A : public B, public C {} ``` And this would be translated to something like: ``` class A : public B, public C {} ``` Repository: rL LLVM https://reviews.llvm.org/D30487 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30798: [analyzer] Turn suppress-c++-stdlib on by default
NoQ added a comment. I'd like to clarify that in case of path-sensitive analysis there are actually three warning classes to consider. 1. Warnings that reside completely in system headers and indicate bugs in system headers, most likely falsely. 2. Warnings that originate from the main file and indicate misuse of system header APIs, likely correctly. 3. Warnings that originate from the main file, but still indicate bugs in system headers, because the part of the path that stays in the main file is irrelevant to the warning. This change suppresses 3, and as a side effect we suppress 1, because discriminating between 1 and 3 is hard* . We never needed to suppress 2, because they're never created to begin with: AnalysisConsumer doesn't consider header-only functions for top-level analysis. __ // * I think that actually such discrimination is curious and probably worth investigating. We could try to see which symbols (originating from where) participate in the equation that expresses the invariant violation of which causes the warning. We could potentially improve our suppressions greatly (maybe even make them non-hackish) and probably avoid the common problems with inlining this way. Just brainstorming. Repository: rL LLVM https://reviews.llvm.org/D30798 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30798: [analyzer] Turn suppress-c++-stdlib on by default
a.sidorin added a comment. I have no any objection on this change. Repository: rL LLVM https://reviews.llvm.org/D30798 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28136: [OpenCL] Implement as_type operator as alias of __builtin_astype.
echuraev added a comment. In https://reviews.llvm.org/D28136#634356, @Anastasia wrote: > This has been discussed during the initial review for the header: > http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160425/157187.html > > The main issue is after preprocessing the header the original function name > is no longer available in diagnostics reported. The spec defines as_type as a > builtin function and not a macro. Additionally your patch would allow as_type > to be used with extra type (not only those defined in spec). Also I don't see > the problem to implement as_type with just simply calling a builtin. It > should be inlined later anyways. I think that this patch is really necessary because in some cases previous implementation doesn't give a diagnostic. Please see test case that I have added to this review. With current implementation //char// variable will be cast to //int//. You can see the following part of llvm ir: %0 = load i8, i8* %src, align 1 %conv = sext i8 %0 to i32 %call = call i32 @_Z6as_inti(i32 %conv) #2 So there is a bug and we didn't get error that the size of char isn't equal to size of int. Program is compiled without any problems. If as_type functions will be defined in macro then we will have the following message: error: invalid reinterpretation: sizes of 'float' and 'char' must match int dst = as_int( src ); ^~~ ././llvm/tools/clang/lib/Headers/opencl-c-common.h:6615:21: note: expanded from macro 'as_int' #define as_int(x) __builtin_astype((x), int) ^~~~ https://reviews.llvm.org/D28136 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration
Abpostelnicu updated this revision to Diff 91334. Repository: rL LLVM https://reviews.llvm.org/D30487 Files: docs/ClangFormatStyleOptions.rst include/clang/Format/Format.h lib/Format/ContinuationIndenter.cpp lib/Format/Format.cpp lib/Format/FormatToken.h lib/Format/TokenAnnotator.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -1029,6 +1029,17 @@ verifyFormat("class ::A::B {};"); } +TEST_F(FormatTest, BreakBeforeInheritanceComma) { + FormatStyle StyleWithInheritanceBreak = getLLVMStyle(); + StyleWithInheritanceBreak.BreakBeforeInheritanceComma = true; + + verifyFormat("class MyClass : public X {};", StyleWithInheritanceBreak); + verifyFormat("class MyClass\n" + ": public X\n" + ", public Y {};", + StyleWithInheritanceBreak); +} + TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) { verifyFormat("class A {\n} a, b;"); verifyFormat("struct A {\n} a, b;"); @@ -8582,6 +8593,7 @@ CHECK_PARSE_BOOL(BreakBeforeTernaryOperators); CHECK_PARSE_BOOL(BreakConstructorInitializersBeforeComma); CHECK_PARSE_BOOL(BreakStringLiterals); + CHECK_PARSE_BOOL(BreakBeforeInheritanceComma) CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine); CHECK_PARSE_BOOL(DerivePointerAlignment); CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding"); Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -676,6 +676,8 @@ case tok::comma: if (Contexts.back().InCtorInitializer) Tok->Type = TT_CtorInitializerComma; + else if (Contexts.back().InInhertianceList) +Tok->Type = TT_InheritanceComma; else if (Contexts.back().FirstStartOfName && (Contexts.size() == 1 || Line.startsWith(tok::kw_for))) { Contexts.back().FirstStartOfName->PartOfMultiVariableDeclStmt = true; @@ -945,6 +947,7 @@ bool CanBeExpression = true; bool InTemplateArgument = false; bool InCtorInitializer = false; +bool InInhertianceList = false; bool CaretFound = false; bool IsForEachMacro = false; }; @@ -1004,6 +1007,9 @@ Current.Previous->is(TT_CtorInitializerColon)) { Contexts.back().IsExpression = true; Contexts.back().InCtorInitializer = true; +} else if (Current.Previous && + Current.Previous->is(TT_InheritanceColon)) { + Contexts.back().InInhertianceList = true; } else if (Current.isOneOf(tok::r_paren, tok::greater, tok::comma)) { for (FormatToken *Previous = Current.Previous; Previous && Previous->isOneOf(tok::star, tok::amp); @@ -2474,6 +2480,10 @@ Style.BreakConstructorInitializersBeforeComma && !Style.ConstructorInitializerAllOnOneLineOrOnePerLine) return true; + // Break only if we have multiple inheritance. + if (Style.BreakBeforeInheritanceComma && + Right.is(TT_InheritanceComma)) + return true; if (Right.is(tok::string_literal) && Right.TokenText.startswith("R\"")) // Raw string literals are special wrt. line breaks. The author has made a // deliberate choice and might have aligned the contents of the string @@ -2653,6 +2663,10 @@ if (Right.is(TT_CtorInitializerComma) && Style.BreakConstructorInitializersBeforeComma) return true; + if (Left.is(TT_InheritanceComma) && Style.BreakBeforeInheritanceComma) +return false; + if (Right.is(TT_InheritanceComma) && Style.BreakBeforeInheritanceComma) +return true; if ((Left.is(tok::greater) && Right.is(tok::greater)) || (Left.is(tok::less) && Right.is(tok::less))) return false; Index: lib/Format/FormatToken.h === --- lib/Format/FormatToken.h +++ lib/Format/FormatToken.h @@ -48,6 +48,7 @@ TYPE(FunctionTypeLParen) \ TYPE(ImplicitStringLiteral) \ TYPE(InheritanceColon) \ + TYPE(InheritanceComma) \ TYPE(InlineASMBrace) \ TYPE(InlineASMColon) \ TYPE(JavaAnnotation) \ Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -298,6 +298,8 @@ IO.mapOptional("BreakStringLiterals", Style.BreakStringLiterals); IO.mapOptional("ColumnLimit", Style.ColumnLimit); IO.mapOptional("CommentPragmas", Style.CommentPragmas); +IO.mapOptional("BreakBeforeInheritanceComma", + Style.BreakBeforeInheritanceComma); IO.mapOptional("ConstructorInitializerAllOnOneLineOrOnePerLine", Style.ConstructorInitializerAllOnOneLineOrOnePerLine); IO.mapOptional("ConstructorInitializerIndentWidth", @@ -521,6 +523,7 @@ fals
[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration
kimgr added a comment. A few more 'inhertiance' left, otherwise spelling looks good to me :-) Comment at: lib/Format/TokenAnnotator.cpp:679 Tok->Type = TT_CtorInitializerComma; + else if (Contexts.back().InInhertianceList) +Tok->Type = TT_InheritanceComma; This still says 'Inhertiance' Comment at: lib/Format/TokenAnnotator.cpp:950 bool InCtorInitializer = false; +bool InInhertianceList = false; bool CaretFound = false; 'Inhertiance' Repository: rL LLVM https://reviews.llvm.org/D30487 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: Patch for Bug 30413, including test case
Hi Akira, Thank you very much! Please let me know if I need to take any further steps beyond this email to cfe-commits in order for the patch and the unit test to be committed. Thanks, David > On Mar 9, 2017, at 4:46 PM, Akira Hatanaka wrote: > > Hi David, > > The patch looks good to me. > >> On Mar 9, 2017, at 1:01 PM, Lobron, David wrote: >> >> Hi Akira, >> >>> My concern is that the patch changes the encoding of @encode(id) >>> on Darwin, which I think isn’t what you are trying to fix. If you compile >>> the following code with command “clang -cc1 -triple x86_64-apple-macosx”, >>> the type encoding changes after applying the patch. >>> >>> const char *foo() { >>> return @encode(id); >>> } >>> >>> It seems like you can fix your problem without affecting Darwin by passing >>> an extra argument to getObjCEncodingForType, just like >>> CGObjCCommonMac::GetMethodVarType does. >> >> Ah, thanks- I understand now. Yes, this change seems a lot safer, and I >> verified that it passes my test. I've attached my new patch file, and I've >> also attached the test again. Please let me know if this works for you or >> if you think it needs any additional work. >> >> --David >> >> > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30822: [clang-format] Indent the same amount a sequence of string literals
krasimir abandoned this revision. krasimir added a comment. this is nonsense https://reviews.llvm.org/D30822 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29944: libclang: Print namespaces for typedefs and type aliases
arphaman added a comment. In https://reviews.llvm.org/D29944#697587, @redm123 wrote: > I guess so. I don't think I'm allowed to commit. So I would appreciate it. Sure, I will commit it right now. > Which release version would that be in? 4.1 I guess? It will be in the next major release: 5.0 (After 4.0 LLVM switched to a different versioning system where major released will now go from 4.0 to 5.0, etc. instead of 4.0 to 4.1, etc.). > Thanks for your help! https://reviews.llvm.org/D29944 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration
Abpostelnicu updated this revision to Diff 91335. Abpostelnicu marked an inline comment as done. Abpostelnicu added a comment. Fixed two spell errors. Repository: rL LLVM https://reviews.llvm.org/D30487 Files: docs/ClangFormatStyleOptions.rst include/clang/Format/Format.h lib/Format/ContinuationIndenter.cpp lib/Format/Format.cpp lib/Format/FormatToken.h lib/Format/TokenAnnotator.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -1029,6 +1029,17 @@ verifyFormat("class ::A::B {};"); } +TEST_F(FormatTest, BreakBeforeInheritanceComma) { + FormatStyle StyleWithInheritanceBreak = getLLVMStyle(); + StyleWithInheritanceBreak.BreakBeforeInheritanceComma = true; + + verifyFormat("class MyClass : public X {};", StyleWithInheritanceBreak); + verifyFormat("class MyClass\n" + ": public X\n" + ", public Y {};", + StyleWithInheritanceBreak); +} + TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) { verifyFormat("class A {\n} a, b;"); verifyFormat("struct A {\n} a, b;"); @@ -8582,6 +8593,7 @@ CHECK_PARSE_BOOL(BreakBeforeTernaryOperators); CHECK_PARSE_BOOL(BreakConstructorInitializersBeforeComma); CHECK_PARSE_BOOL(BreakStringLiterals); + CHECK_PARSE_BOOL(BreakBeforeInheritanceComma) CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine); CHECK_PARSE_BOOL(DerivePointerAlignment); CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding"); Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -676,6 +676,8 @@ case tok::comma: if (Contexts.back().InCtorInitializer) Tok->Type = TT_CtorInitializerComma; + else if (Contexts.back().InInheritanceList) +Tok->Type = TT_InheritanceComma; else if (Contexts.back().FirstStartOfName && (Contexts.size() == 1 || Line.startsWith(tok::kw_for))) { Contexts.back().FirstStartOfName->PartOfMultiVariableDeclStmt = true; @@ -945,6 +947,7 @@ bool CanBeExpression = true; bool InTemplateArgument = false; bool InCtorInitializer = false; +bool InInheritanceList = false; bool CaretFound = false; bool IsForEachMacro = false; }; @@ -1004,6 +1007,9 @@ Current.Previous->is(TT_CtorInitializerColon)) { Contexts.back().IsExpression = true; Contexts.back().InCtorInitializer = true; +} else if (Current.Previous && + Current.Previous->is(TT_InheritanceColon)) { + Contexts.back().InInheritanceList = true; } else if (Current.isOneOf(tok::r_paren, tok::greater, tok::comma)) { for (FormatToken *Previous = Current.Previous; Previous && Previous->isOneOf(tok::star, tok::amp); @@ -2474,6 +2480,10 @@ Style.BreakConstructorInitializersBeforeComma && !Style.ConstructorInitializerAllOnOneLineOrOnePerLine) return true; + // Break only if we have multiple inheritance. + if (Style.BreakBeforeInheritanceComma && + Right.is(TT_InheritanceComma)) + return true; if (Right.is(tok::string_literal) && Right.TokenText.startswith("R\"")) // Raw string literals are special wrt. line breaks. The author has made a // deliberate choice and might have aligned the contents of the string @@ -2653,6 +2663,10 @@ if (Right.is(TT_CtorInitializerComma) && Style.BreakConstructorInitializersBeforeComma) return true; + if (Left.is(TT_InheritanceComma) && Style.BreakBeforeInheritanceComma) +return false; + if (Right.is(TT_InheritanceComma) && Style.BreakBeforeInheritanceComma) +return true; if ((Left.is(tok::greater) && Right.is(tok::greater)) || (Left.is(tok::less) && Right.is(tok::less))) return false; Index: lib/Format/FormatToken.h === --- lib/Format/FormatToken.h +++ lib/Format/FormatToken.h @@ -48,6 +48,7 @@ TYPE(FunctionTypeLParen) \ TYPE(ImplicitStringLiteral) \ TYPE(InheritanceColon) \ + TYPE(InheritanceComma) \ TYPE(InlineASMBrace) \ TYPE(InlineASMColon) \ TYPE(JavaAnnotation) \ Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -298,6 +298,8 @@ IO.mapOptional("BreakStringLiterals", Style.BreakStringLiterals); IO.mapOptional("ColumnLimit", Style.ColumnLimit); IO.mapOptional("CommentPragmas", Style.CommentPragmas); +IO.mapOptional("BreakBeforeInheritanceComma", + Style.BreakBeforeInheritanceComma); IO.mapOptional("ConstructorInitializerAllOnOneLineOrOnePerLine", Style.ConstructorInitializerAllOnOneLineOrOnePerLine); IO.
r297461 - [analyzer] Extend block in critical section check with C11 and Pthread APIs.
Author: xazax Date: Fri Mar 10 08:50:12 2017 New Revision: 297461 URL: http://llvm.org/viewvc/llvm-project?rev=297461&view=rev Log: [analyzer] Extend block in critical section check with C11 and Pthread APIs. Patch by Zoltan Daniel Torok! Differential Revision: https://reviews.llvm.org/D29567 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp cfe/trunk/test/Analysis/block-in-critical-section.cpp cfe/trunk/www/analyzer/alpha_checks.html Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp?rev=297461&r1=297460&r2=297461&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp Fri Mar 10 08:50:12 2017 @@ -29,7 +29,9 @@ namespace { class BlockInCriticalSectionChecker : public Checker { - CallDescription LockFn, UnlockFn, SleepFn, GetcFn, FgetsFn, ReadFn, RecvFn; + CallDescription LockFn, UnlockFn, SleepFn, GetcFn, FgetsFn, ReadFn, RecvFn, + PthreadLockFn, PthreadTryLockFn, PthreadUnlockFn, + MtxLock, MtxTimedLock, MtxTryLock, MtxUnlock; std::unique_ptr BlockInCritSectionBugType; @@ -40,6 +42,10 @@ class BlockInCriticalSectionChecker : pu public: BlockInCriticalSectionChecker(); + bool isBlockingFunction(const CallEvent &Call) const; + bool isLockFunction(const CallEvent &Call) const; + bool isUnlockFunction(const CallEvent &Call) const; + void checkPreCall(const CallEvent &Call, CheckerContext &C) const; /// Process unlock. @@ -55,34 +61,69 @@ REGISTER_TRAIT_WITH_PROGRAMSTATE(MutexCo BlockInCriticalSectionChecker::BlockInCriticalSectionChecker() : LockFn("lock"), UnlockFn("unlock"), SleepFn("sleep"), GetcFn("getc"), - FgetsFn("fgets"), ReadFn("read"), RecvFn("recv") { + FgetsFn("fgets"), ReadFn("read"), RecvFn("recv"), + PthreadLockFn("pthread_mutex_lock"), + PthreadTryLockFn("pthread_mutex_trylock"), + PthreadUnlockFn("pthread_mutex_unlock"), + MtxLock("mtx_lock"), + MtxTimedLock("mtx_timedlock"), + MtxTryLock("mtx_trylock"), + MtxUnlock("mtx_unlock") { // Initialize the bug type. BlockInCritSectionBugType.reset( new BugType(this, "Call to blocking function in critical section", "Blocking Error")); } +bool BlockInCriticalSectionChecker::isBlockingFunction(const CallEvent &Call) const { + if (Call.isCalled(SleepFn) + || Call.isCalled(GetcFn) + || Call.isCalled(FgetsFn) + || Call.isCalled(ReadFn) + || Call.isCalled(RecvFn)) { +return true; + } + return false; +} + +bool BlockInCriticalSectionChecker::isLockFunction(const CallEvent &Call) const { + if (Call.isCalled(LockFn) + || Call.isCalled(PthreadLockFn) + || Call.isCalled(PthreadTryLockFn) + || Call.isCalled(MtxLock) + || Call.isCalled(MtxTimedLock) + || Call.isCalled(MtxTryLock)) { +return true; + } + return false; +} + +bool BlockInCriticalSectionChecker::isUnlockFunction(const CallEvent &Call) const { + if (Call.isCalled(UnlockFn) + || Call.isCalled(PthreadUnlockFn) + || Call.isCalled(MtxUnlock)) { +return true; + } + return false; +} + void BlockInCriticalSectionChecker::checkPreCall(const CallEvent &Call, CheckerContext &C) const { } void BlockInCriticalSectionChecker::checkPostCall(const CallEvent &Call, CheckerContext &C) const { - if (!Call.isCalled(LockFn) - && !Call.isCalled(SleepFn) - && !Call.isCalled(GetcFn) - && !Call.isCalled(FgetsFn) - && !Call.isCalled(ReadFn) - && !Call.isCalled(RecvFn) - && !Call.isCalled(UnlockFn)) + if (!isBlockingFunction(Call) + && !isLockFunction(Call) + && !isUnlockFunction(Call)) return; ProgramStateRef State = C.getState(); unsigned mutexCount = State->get(); - if (Call.isCalled(UnlockFn) && mutexCount > 0) { + if (isUnlockFunction(Call) && mutexCount > 0) { State = State->set(--mutexCount); C.addTransition(State); - } else if (Call.isCalled(LockFn)) { + } else if (isLockFunction(Call)) { State = State->set(++mutexCount); C.addTransition(State); } else if (mutexCount > 0) { @@ -97,8 +138,11 @@ void BlockInCriticalSectionChecker::repo if (!ErrNode) return; - auto R = llvm::make_unique(*BlockInCritSectionBugType, - "A blocking function %s is called inside a critical section.", ErrNode); + std::string msg; + llvm::raw_string_ostream os(msg); + os << "Call to blocking function '" << Call.getCalleeIdentifier()->getName() + << "' inside of critical section"; + auto R = llvm::make_unique(*BlockInCr
r297465 - Print nested name specifiers for typedefs and type aliases
Author: arphaman Date: Fri Mar 10 09:04:58 2017 New Revision: 297465 URL: http://llvm.org/viewvc/llvm-project?rev=297465&view=rev Log: Print nested name specifiers for typedefs and type aliases Printing typedefs or type aliases using clang_getTypeSpelling() is missing the namespace they are defined in. This is in contrast to other types that always yield the full typename including namespaces. Patch by Michael Reiher! Differential Revision: https://reviews.llvm.org/D29944 Modified: cfe/trunk/lib/AST/TypePrinter.cpp cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp cfe/trunk/test/CXX/drs/dr2xx.cpp cfe/trunk/test/CXX/drs/dr5xx.cpp cfe/trunk/test/Index/annotate-nested-name-specifier.cpp cfe/trunk/test/Index/file-refs.cpp cfe/trunk/test/Index/print-type.cpp cfe/trunk/test/Index/recursive-cxx-member-calls.cpp cfe/trunk/test/Layout/ms-x86-basic-layout.cpp cfe/trunk/test/Misc/diag-template-diffing.cpp cfe/trunk/test/Modules/odr_hash.cpp cfe/trunk/test/SemaCXX/attr-noreturn.cpp cfe/trunk/test/SemaCXX/calling-conv-compat.cpp cfe/trunk/test/SemaCXX/cxx0x-initializer-aggregates.cpp cfe/trunk/test/SemaCXX/cxx1y-contextual-conversion-tweaks.cpp cfe/trunk/test/SemaCXX/enum-scoped.cpp cfe/trunk/test/SemaCXX/nested-name-spec.cpp cfe/trunk/test/SemaCXX/pseudo-destructors.cpp cfe/trunk/test/SemaObjCXX/arc-templates.mm cfe/trunk/test/SemaTemplate/member-access-ambig.cpp cfe/trunk/test/SemaTemplate/typename-specifier.cpp Modified: cfe/trunk/lib/AST/TypePrinter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=297465&r1=297464&r2=297465&view=diff == --- cfe/trunk/lib/AST/TypePrinter.cpp (original) +++ cfe/trunk/lib/AST/TypePrinter.cpp Fri Mar 10 09:04:58 2017 @@ -96,7 +96,7 @@ namespace { static bool canPrefixQualifiers(const Type *T, bool &NeedARCStrongQualifier); void spaceBeforePlaceHolder(raw_ostream &OS); -void printTypeSpec(const NamedDecl *D, raw_ostream &OS); +void printTypeSpec(NamedDecl *D, raw_ostream &OS); void printBefore(const Type *ty, Qualifiers qs, raw_ostream &OS); void printBefore(QualType T, raw_ostream &OS); @@ -798,7 +798,14 @@ void TypePrinter::printFunctionNoProtoAf printAfter(T->getReturnType(), OS); } -void TypePrinter::printTypeSpec(const NamedDecl *D, raw_ostream &OS) { +void TypePrinter::printTypeSpec(NamedDecl *D, raw_ostream &OS) { + + // Compute the full nested-name-specifier for this type. + // In C, this will always be empty except when the type + // being printed is anonymous within other Record. + if (!Policy.SuppressScope) +AppendScope(D->getDeclContext(), OS); + IdentifierInfo *II = D->getIdentifier(); OS << II->getName(); spaceBeforePlaceHolder(OS); Modified: cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp?rev=297465&r1=297464&r2=297465&view=diff == --- cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp (original) +++ cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp Fri Mar 10 09:04:58 2017 @@ -192,7 +192,7 @@ namespace InhCtor { // FIXME: Consider reusing the same diagnostic between dependent and non-dependent contexts typedef int I; struct UsingInt { -using I::I; // expected-error {{'I' (aka 'int') is not a class, namespace, or enumeration}} +using I::I; // expected-error {{'InhCtor::I' (aka 'int') is not a class, namespace, or enumeration}} }; template struct UsingIntTemplate { using T::T; // expected-error {{type 'int' cannot be used prior to '::' because it has no members}} Modified: cfe/trunk/test/CXX/drs/dr2xx.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr2xx.cpp?rev=297465&r1=297464&r2=297465&view=diff == --- cfe/trunk/test/CXX/drs/dr2xx.cpp (original) +++ cfe/trunk/test/CXX/drs/dr2xx.cpp Fri Mar 10 09:04:58 2017 @@ -1014,7 +1014,7 @@ namespace dr294 { // dr294: no namespace dr295 { // dr295: 3.7 typedef int f(); - const f g; // expected-warning {{'const' qualifier on function type 'f' (aka 'int ()') has no effect}} + const f g; // expected-warning {{'const' qualifier on function type 'dr295::f' (aka 'int ()') has no effect}} f &r = g; template struct X { const T &f; @@ -1022,10 +1022,10 @@ namespace dr295 { // dr295: 3.7 X x = {g}; typedef int U(); - typedef const U U; // expected-warning {{'const' qualifier on function type 'U' (aka 'int ()') has no effect}} + typedef const U U; // expected-warning {{'const' qualifier on function type 'dr295::U' (aka 'int ()') has no effect}}
[PATCH] D29944: libclang: Print namespaces for typedefs and type aliases
This revision was automatically updated to reflect the committed changes. Closed by commit rL297465: Print nested name specifiers for typedefs and type aliases (authored by arphaman). Changed prior to commit: https://reviews.llvm.org/D29944?vs=88376&id=91342#toc Repository: rL LLVM https://reviews.llvm.org/D29944 Files: cfe/trunk/lib/AST/TypePrinter.cpp cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp cfe/trunk/test/CXX/drs/dr2xx.cpp cfe/trunk/test/CXX/drs/dr5xx.cpp cfe/trunk/test/Index/annotate-nested-name-specifier.cpp cfe/trunk/test/Index/file-refs.cpp cfe/trunk/test/Index/print-type.cpp cfe/trunk/test/Index/recursive-cxx-member-calls.cpp cfe/trunk/test/Layout/ms-x86-basic-layout.cpp cfe/trunk/test/Misc/diag-template-diffing.cpp cfe/trunk/test/Modules/odr_hash.cpp cfe/trunk/test/SemaCXX/attr-noreturn.cpp cfe/trunk/test/SemaCXX/calling-conv-compat.cpp cfe/trunk/test/SemaCXX/cxx0x-initializer-aggregates.cpp cfe/trunk/test/SemaCXX/cxx1y-contextual-conversion-tweaks.cpp cfe/trunk/test/SemaCXX/enum-scoped.cpp cfe/trunk/test/SemaCXX/nested-name-spec.cpp cfe/trunk/test/SemaCXX/pseudo-destructors.cpp cfe/trunk/test/SemaObjCXX/arc-templates.mm cfe/trunk/test/SemaTemplate/member-access-ambig.cpp cfe/trunk/test/SemaTemplate/typename-specifier.cpp Index: cfe/trunk/test/SemaTemplate/member-access-ambig.cpp === --- cfe/trunk/test/SemaTemplate/member-access-ambig.cpp +++ cfe/trunk/test/SemaTemplate/member-access-ambig.cpp @@ -48,7 +48,7 @@ typedef int (A::*P); template struct S : T { void f() { - P(&T::X) // expected-error {{cannot cast from type 'int *' to member pointer type 'P'}} + P(&T::X) // expected-error {{cannot cast from type 'int *' to member pointer type 'AddrOfMember::P'}} == &A::X; } }; Index: cfe/trunk/test/SemaTemplate/typename-specifier.cpp === --- cfe/trunk/test/SemaTemplate/typename-specifier.cpp +++ cfe/trunk/test/SemaTemplate/typename-specifier.cpp @@ -102,7 +102,7 @@ template struct E { typedef typename T::foo foo; - typedef typename foo::bar bar; // expected-error {{type 'foo' (aka 'double') cannot be used prior to '::' because it has no members}} + typedef typename foo::bar bar; // expected-error {{type 'E::foo' (aka 'double') cannot be used prior to '::' because it has no members}} }; struct F { Index: cfe/trunk/test/Index/print-type.cpp === --- cfe/trunk/test/Index/print-type.cpp +++ cfe/trunk/test/Index/print-type.cpp @@ -17,15 +17,16 @@ Bar(outer::Foo* foo) { } typedef int FooType; + using AliasType = double; int *p; int *f(int *p, char *x, FooType z) { const FooType w = z; return p + z; } typedef double OtherType; typedef int ArrayType[5]; Baz baz; - Qux> qux; + Qux, FooType> qux; }; } @@ -87,91 +88,92 @@ // CHECK: NamespaceRef=outer:1:11 [type=] [typekind=Invalid] [isPOD=0] // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0] // CHECK: CompoundStmt= [type=] [typekind=Invalid] [isPOD=0] -// CHECK: TypedefDecl=FooType:19:15 (Definition) [type=FooType] [typekind=Typedef] [canonicaltype=int] [canonicaltypekind=Int] [isPOD=1] -// CHECK: FieldDecl=p:20:8 (Definition) [type=int *] [typekind=Pointer] [isPOD=1] [pointeetype=int] [pointeekind=Int] -// CHECK: CXXMethod=f:21:8 (Definition) [type=int *(int *, char *, FooType){{.*}}] [typekind=FunctionProto] [canonicaltype=int *(int *, char *, int){{.*}}] [canonicaltypekind=FunctionProto] [resulttype=int *] [resulttypekind=Pointer] [args= [int *] [Pointer] [char *] [Pointer] [FooType] [Typedef]] [isPOD=0] -// CHECK: ParmDecl=p:21:15 (Definition) [type=int *] [typekind=Pointer] [isPOD=1] [pointeetype=int] [pointeekind=Int] -// CHECK: ParmDecl=x:21:24 (Definition) [type=char *] [typekind=Pointer] [isPOD=1] [pointeetype=char] [pointeekind=Char_{{[US]}}] -// CHECK: ParmDecl=z:21:35 (Definition) [type=FooType] [typekind=Typedef] [canonicaltype=int] [canonicaltypekind=Int] [isPOD=1] -// CHECK: TypeRef=FooType:19:15 [type=FooType] [typekind=Typedef] [canonicaltype=int] [canonicaltypekind=Int] [isPOD=1] +// CHECK: TypedefDecl=FooType:19:15 (Definition) [type=outer::inner::Bar::FooType] [typekind=Typedef] [canonicaltype=int] [canonicaltypekind=Int] [isPOD=1] +// CHECK: TypeAliasDecl=AliasType:20:9 (Definition) [type=outer::inner::Bar::AliasType] [typekind=Typedef] [canonicaltype=double] [canonicaltypekind=Double] [isPOD=1] +// CHECK: FieldDecl=p:21:8 (Definition) [type=int *] [typekind=Pointer] [isPOD=1] [pointeetype=int] [pointeekind=Int] +// CHECK: CXXMethod=f:22:8 (Definition) [type=int *(int *, char *, outer::inner::Bar::FooType){{.*}}] [typekind=FunctionProto] [canonicaltype=int *(int *, char *, int){{.*}}] [canonicaltypekind=FunctionProto] [resulttype=int *] [resulttypekind=Pointe
[PATCH] D30643: [OpenCL] Extended diagnostics for atomic initialization
Anastasia added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8263 +def err_atomic_init_addressspace : Error< + "initialization of atomic variables is restricted to variables in global address space">; def err_atomic_init_constant : Error< echuraev wrote: > Anastasia wrote: > > Could we combine this error diag with the one below? I guess they are > > semantically very similar apart from one is about initialization and > > another is about assignment? > I'm not sure that it is a good idea to combine these errors. For example, if > developer had declared a variable non-constant and not in global address > space he would have got the same message for both errors. And it can be > difficult to determine what the exact problem is. He can fix one of the > problems but he will still get the same error. Well, I don't actually see that we check for constant anywhere so it's also OK if you want to drop this bit. Although I think the original intension of this message as I understood was to provide the most complete hint. My concern is that these two errors seem to be reporting nearly the same issue and ideally we would like to keep diagnostic list as small as possible. This also makes the file more concise and messages more consistent. https://reviews.llvm.org/D30643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration
This revision was automatically updated to reflect the committed changes. Closed by commit rL297467: [clang-format] Add option to break before inheritance separation operator in… (authored by Abpostelnicu). Changed prior to commit: https://reviews.llvm.org/D30487?vs=91335&id=91344#toc Repository: rL LLVM https://reviews.llvm.org/D30487 Files: cfe/trunk/docs/ClangFormatStyleOptions.rst cfe/trunk/include/clang/Format/Format.h cfe/trunk/lib/Format/ContinuationIndenter.cpp cfe/trunk/lib/Format/Format.cpp cfe/trunk/lib/Format/FormatToken.h cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTest.cpp Index: cfe/trunk/unittests/Format/FormatTest.cpp === --- cfe/trunk/unittests/Format/FormatTest.cpp +++ cfe/trunk/unittests/Format/FormatTest.cpp @@ -1029,6 +1029,17 @@ verifyFormat("class ::A::B {};"); } +TEST_F(FormatTest, BreakBeforeInheritanceComma) { + FormatStyle StyleWithInheritanceBreak = getLLVMStyle(); + StyleWithInheritanceBreak.BreakBeforeInheritanceComma = true; + + verifyFormat("class MyClass : public X {};", StyleWithInheritanceBreak); + verifyFormat("class MyClass\n" + ": public X\n" + ", public Y {};", + StyleWithInheritanceBreak); +} + TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) { verifyFormat("class A {\n} a, b;"); verifyFormat("struct A {\n} a, b;"); @@ -8582,6 +8593,7 @@ CHECK_PARSE_BOOL(BreakBeforeTernaryOperators); CHECK_PARSE_BOOL(BreakConstructorInitializersBeforeComma); CHECK_PARSE_BOOL(BreakStringLiterals); + CHECK_PARSE_BOOL(BreakBeforeInheritanceComma) CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine); CHECK_PARSE_BOOL(DerivePointerAlignment); CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding"); Index: cfe/trunk/docs/ClangFormatStyleOptions.rst === --- cfe/trunk/docs/ClangFormatStyleOptions.rst +++ cfe/trunk/docs/ClangFormatStyleOptions.rst @@ -528,6 +528,10 @@ +**BreakBeforeInheritanceComma** (``bool``) + If ``true``, in the class inheritance expression clang-format will + break before ``:`` and ``,`` if there is multiple inheritance. + **BreakBeforeTernaryOperators** (``bool``) If ``true``, ternary operators will be placed after line breaks. Index: cfe/trunk/include/clang/Format/Format.h === --- cfe/trunk/include/clang/Format/Format.h +++ cfe/trunk/include/clang/Format/Format.h @@ -422,6 +422,10 @@ /// which should not be split into lines or otherwise changed. std::string CommentPragmas; + /// \brief If ``true``, in the class inheritance expression clang-format will + /// break before ``:`` and ``,`` if there is multiple inheritance. + bool BreakBeforeInheritanceComma; + /// \brief If the constructor initializers don't fit on a line, put each /// initializer on its own line. bool ConstructorInitializerAllOnOneLineOrOnePerLine; @@ -844,6 +848,7 @@ BreakAfterJavaFieldAnnotations == R.BreakAfterJavaFieldAnnotations && BreakStringLiterals == R.BreakStringLiterals && ColumnLimit == R.ColumnLimit && CommentPragmas == R.CommentPragmas && + BreakBeforeInheritanceComma == R.BreakBeforeInheritanceComma && ConstructorInitializerAllOnOneLineOrOnePerLine == R.ConstructorInitializerAllOnOneLineOrOnePerLine && ConstructorInitializerIndentWidth == Index: cfe/trunk/lib/Format/TokenAnnotator.cpp === --- cfe/trunk/lib/Format/TokenAnnotator.cpp +++ cfe/trunk/lib/Format/TokenAnnotator.cpp @@ -676,6 +676,8 @@ case tok::comma: if (Contexts.back().InCtorInitializer) Tok->Type = TT_CtorInitializerComma; + else if (Contexts.back().InInheritanceList) +Tok->Type = TT_InheritanceComma; else if (Contexts.back().FirstStartOfName && (Contexts.size() == 1 || Line.startsWith(tok::kw_for))) { Contexts.back().FirstStartOfName->PartOfMultiVariableDeclStmt = true; @@ -945,6 +947,7 @@ bool CanBeExpression = true; bool InTemplateArgument = false; bool InCtorInitializer = false; +bool InInheritanceList = false; bool CaretFound = false; bool IsForEachMacro = false; }; @@ -1004,6 +1007,9 @@ Current.Previous->is(TT_CtorInitializerColon)) { Contexts.back().IsExpression = true; Contexts.back().InCtorInitializer = true; +} else if (Current.Previous && + Current.Previous->is(TT_InheritanceColon)) { + Contexts.back().InInheritanceList = true; } else if (Current.isOneOf(tok::r_paren, tok::greater, tok::comma)) { for (FormatToken *Previous = Current.Previous; Previous && Previous->isOneOf(tok::star, tok::amp); @@
r297468 - [OpenCL] Fix type compatibility check and generic AS mangling.
Author: stulova Date: Fri Mar 10 09:23:07 2017 New Revision: 297468 URL: http://llvm.org/viewvc/llvm-project?rev=297468&view=rev Log: [OpenCL] Fix type compatibility check and generic AS mangling. 1. Reimplemented conditional operator so that it checks compatibility of unqualified pointees of the 2nd and the 3rd operands (C99, OpenCL v2.0 6.5.15). Define QualTypes compatibility for OpenCL as following: - corresponding types are compatible (C99 6.7.3) - CVR-qualifiers are equal (C99 6.7.3) - address spaces are equal (implementation defined) 2. Added generic address space to Itanium mangling. Review: D30037 Patch by Dmitry Borisenkov! Added: cfe/trunk/test/SemaOpenCL/overload_addrspace_resolution.cl Modified: cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/ItaniumMangle.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=297468&r1=297467&r2=297468&view=diff == --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Fri Mar 10 09:23:07 2017 @@ -8066,15 +8066,6 @@ QualType ASTContext::mergeTypes(QualType Qualifiers LQuals = LHSCan.getLocalQualifiers(); Qualifiers RQuals = RHSCan.getLocalQualifiers(); if (LQuals != RQuals) { -if (getLangOpts().OpenCL) { - if (LHSCan.getUnqualifiedType() != RHSCan.getUnqualifiedType() || - LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers()) -return QualType(); - if (LQuals.isAddressSpaceSupersetOf(RQuals)) -return LHS; - if (RQuals.isAddressSpaceSupersetOf(LQuals)) -return RHS; -} // If any of these qualifiers are different, we have a type // mismatch. if (LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers() || @@ -8200,6 +8191,20 @@ QualType ASTContext::mergeTypes(QualType LHSPointee = LHSPointee.getUnqualifiedType(); RHSPointee = RHSPointee.getUnqualifiedType(); } +if (getLangOpts().OpenCL) { + Qualifiers LHSPteeQual = LHSPointee.getQualifiers(); + Qualifiers RHSPteeQual = RHSPointee.getQualifiers(); + // Blocks can't be an expression in a ternary operator (OpenCL v2.0 + // 6.12.5) thus the following check is asymmetric. + if (!LHSPteeQual.isAddressSpaceSupersetOf(RHSPteeQual)) +return QualType(); + LHSPteeQual.removeAddressSpace(); + RHSPteeQual.removeAddressSpace(); + LHSPointee = + QualType(LHSPointee.getTypePtr(), LHSPteeQual.getAsOpaqueValue()); + RHSPointee = + QualType(RHSPointee.getTypePtr(), RHSPteeQual.getAsOpaqueValue()); +} QualType ResultType = mergeTypes(LHSPointee, RHSPointee, OfBlockPointer, Unqualified); if (ResultType.isNull()) return QualType(); Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=297468&r1=297467&r2=297468&view=diff == --- cfe/trunk/lib/AST/ItaniumMangle.cpp (original) +++ cfe/trunk/lib/AST/ItaniumMangle.cpp Fri Mar 10 09:23:07 2017 @@ -2159,10 +2159,12 @@ void CXXNameMangler::mangleQualifiers(Qu } else { switch (AS) { default: llvm_unreachable("Not a language specific address space"); - // ::= "CL" [ "global" | "local" | "constant" ] + // ::= "CL" [ "global" | "local" | "constant | + //"generic" ] case LangAS::opencl_global: ASString = "CLglobal"; break; case LangAS::opencl_local:ASString = "CLlocal";break; case LangAS::opencl_constant: ASString = "CLconstant"; break; + case LangAS::opencl_generic: ASString = "CLgeneric"; break; // ::= "CU" [ "device" | "constant" | "shared" ] case LangAS::cuda_device: ASString = "CUdevice"; break; case LangAS::cuda_constant: ASString = "CUconstant"; break; Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=297468&r1=297467&r2=297468&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Mar 10 09:23:07 2017 @@ -6335,92 +6335,98 @@ static QualType checkConditionalPointerC Qualifiers lhQual = lhptee.getQualifiers(); Qualifiers rhQual = rhptee.getQualifiers(); + unsigned ResultAddrSpace = 0; + unsigned LAddrSpace = lhQual.getAddressSpace(); + unsigned RAddrSpace = rhQual.getAddressSpace(); + if (S.getLangOpts().OpenCL) { +// OpenCL v1.1 s6.5 - Conversion between pointers to distinct address +// spaces is disallowed. +if (lhQual.isAddressSpaceSupersetOf(rhQual)) + Resul
[PATCH] D30810: Preserve vec3 type.
Anastasia added a comment. Could you please add your test here (probably goes to test/CodeGenOpenCL)? Comment at: include/clang/Driver/CC1Options.td:661 +def fpreserve_vec3_type : Flag<["-"], "fpreserve-vec3-type">, + HelpText<"Preserve 3-component vector type operations">; + Can we drop "operations"? https://reviews.llvm.org/D30810 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30733: [Driver] Add arch-specific rpath for libc++
jroelofs added a comment. In https://reviews.llvm.org/D30733#697313, @Hahnfeld wrote: > In https://reviews.llvm.org/D30733#697108, @jroelofs wrote: > > > As I said on https://reviews.llvm.org/D30214, it is inappropriate to be > > installing libc++ in the resource directory... please **do not** do that. > > > Can you give reason for that? libc++ is not version-locked to the compiler, however that directory is. I understand you want to solve your problem, but I think we (as a community) need to take a step back and look at the implications of decisions like this... and having thought through this, I think this is not a wise choice if we value long term support. Yes, this plan /could/ work for a given individual release, but I think it does not scale to use cases where the libs have been chosen by some external constraint. For example, user code built against an old version of libc++: sometimes it's ok to upgrade the compiler, but often you're stuck with a particular version of the libraries because some other software was built against them. > I can understand that header files are independent of the target architecture > but how do you handle multiple binary libraries for let's say 32 and 64 bit? Arch + multilib suffixed directories solves this problem. > This was the main motivation for the OpenMP runtime in > http://lists.llvm.org/pipermail/openmp-dev/2016-December/001612.html, please > also see My objection isn't to putting the libs in a directory that contains the arch name / multilib name, but rather it is to having that directory be a child of lib/clang/$version/{lib, include}. > https://bugs.llvm.org//show_bug.cgi?id=31300. I don't think `libc++` would be > any different here. > > Additionally, my main motiviation was for `libunwind` as explained here: > http://lists.llvm.org/pipermail/cfe-dev/2017-January/052512.html > On that thread multiple people suggested to use an extra directory for > runtime libraries, @rnk and @mgorny listed as reviewers for this patch. And I disagree. The only things that belong in clang's resource directory are the builtins, sanitizer libs, and maybe the OpenMP libs (assuming they're tied to a particular compiler version, and don't have a stable API/ABI). > If `libunwind` goes there and is added together with `libc++`, we need to add > the rpath here. And what's the reason against installing `libc++` in the same > path then? IMNSHO, libunwind does not belong in the resource directory either. Concrete suggestion (and maybe we ought to discus this more widely on cfe-dev in RFC form): create a new directory not tied to the compiler version, and place non version locked libraries there. One way that could look is something like: lib/clang/SDKs/$vendor/$platform/$abi/$arch/{lib/$multilib, include} with, for example: lib └── clang └── SDKs ├── apple │ └── darwin15 │ ├── fat │ ├── powerpc │ └── x86_64 └── ubuntu10 └── linux └── gnueabi ├── arm └── x86_64 ├── lib └── lib64 (I don't want to get in the weeds bike-shedding the specific details of this layout just yet, so take this as a general idea with room for flexibility, and a small amount of hand-waving) representing the layout for a cross compiler with SDKs for: - ppc darwin - x86_64 darwin - fat library containing several darwin targets - arm linux - x86_64 linux, with both -m32 and -m64 multilibs With this strategy, now you can have say clang-4.0 installed on your system, along with some libraries that came with it. Now if you've built things against those libs, and upgrade your clang version, you are not tied to the new libc++ that comes with it, as you would be with libc++ placed in the resource dir. https://reviews.llvm.org/D30733 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30830: [OpenCL] Fix extension guards for atomic functions
jprice created this revision. https://reviews.llvm.org/D30830 Files: lib/Headers/opencl-c.h Index: lib/Headers/opencl-c.h === --- lib/Headers/opencl-c.h +++ lib/Headers/opencl-c.h @@ -14395,10 +14395,10 @@ #if defined(cl_khr_global_int32_base_atomics) int __ovld atom_xchg(volatile __global int *p, int val); -int __ovld atom_xchg(volatile __local int *p, int val); +unsigned int __ovld atom_xchg(volatile __global unsigned int *p, unsigned int val); #endif #if defined(cl_khr_local_int32_base_atomics) -unsigned int __ovld atom_xchg(volatile __global unsigned int *p, unsigned int val); +int __ovld atom_xchg(volatile __local int *p, int val); unsigned int __ovld atom_xchg(volatile __local unsigned int *p, unsigned int val); #endif @@ -14515,8 +14515,6 @@ #if defined(cl_khr_int64_extended_atomics) long __ovld atom_min(volatile __global long *p, long val); unsigned long __ovld atom_min(volatile __global unsigned long *p, unsigned long val); -#endif -#if defined(cl_khr_local_int32_extended_atomics) long __ovld atom_min(volatile __local long *p, long val); unsigned long __ovld atom_min(volatile __local unsigned long *p, unsigned long val); #endif Index: lib/Headers/opencl-c.h === --- lib/Headers/opencl-c.h +++ lib/Headers/opencl-c.h @@ -14395,10 +14395,10 @@ #if defined(cl_khr_global_int32_base_atomics) int __ovld atom_xchg(volatile __global int *p, int val); -int __ovld atom_xchg(volatile __local int *p, int val); +unsigned int __ovld atom_xchg(volatile __global unsigned int *p, unsigned int val); #endif #if defined(cl_khr_local_int32_base_atomics) -unsigned int __ovld atom_xchg(volatile __global unsigned int *p, unsigned int val); +int __ovld atom_xchg(volatile __local int *p, int val); unsigned int __ovld atom_xchg(volatile __local unsigned int *p, unsigned int val); #endif @@ -14515,8 +14515,6 @@ #if defined(cl_khr_int64_extended_atomics) long __ovld atom_min(volatile __global long *p, long val); unsigned long __ovld atom_min(volatile __global unsigned long *p, unsigned long val); -#endif -#if defined(cl_khr_local_int32_extended_atomics) long __ovld atom_min(volatile __local long *p, long val); unsigned long __ovld atom_min(volatile __local unsigned long *p, unsigned long val); #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28136: [OpenCL] Implement as_type operator as alias of __builtin_astype.
Anastasia added a comment. In https://reviews.llvm.org/D28136#697673, @echuraev wrote: > In https://reviews.llvm.org/D28136#634356, @Anastasia wrote: > > > This has been discussed during the initial review for the header: > > > > http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160425/157187.html > > > > The main issue is after preprocessing the header the original function name > > is no longer available in diagnostics reported. The spec defines as_type as > > a builtin function and not a macro. Additionally your patch would allow > > as_type to be used with extra type (not only those defined in spec). Also I > > don't see the problem to implement as_type with just simply calling a > > builtin. It should be inlined later anyways. > > > I think that this patch is really necessary because in some cases previous > implementation doesn't give a diagnostic. Please see test case that I have > added to this review. With current implementation //char// variable will be > cast to //int//. You can see the following part of llvm ir: > > %0 = load i8, i8* %src, align 1 > %conv = sext i8 %0 to i32 > %call = call i32 @_Z6as_inti(i32 %conv) #2 > > > So there is a bug and we didn't get error that the size of char isn't equal > to size of int. Program is compiled without any problems. > If as_type functions will be defined in macro then we will have the > following message: > > error: invalid reinterpretation: sizes of 'float' and 'char' must match > int dst = as_int( src ); > ^~~ > ././llvm/tools/clang/lib/Headers/opencl-c-common.h:6615:21: note: expanded > from macro 'as_int' > #define as_int(x) __builtin_astype((x), int) > ^~~~ > Why do you think this is a bug? It seems to follow standard behavior in C to promote char to int if required. Just like if you would have a C code: int as_int(int i); void foo() { char src = 1; int dst = as_int(src); } This code would complie and the same exactly IR would be generated. https://reviews.llvm.org/D28136 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30830: [OpenCL] Fix extension guards for atomic functions
Anastasia accepted this revision. Anastasia added a comment. This revision is now accepted and ready to land. LGTM! This bit was poorly tested initially as there were simply too many things. I am wondering if we could improve these bits slowly by extending further lib/Headers/opencl-c.h. https://reviews.llvm.org/D30830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30733: [Driver] Add arch-specific rpath for libc++
jroelofs added a comment. I'll also add that we had a BOF at EuroLLVM 2014, where this got support from the community and people generally thought it was a good plan... Just needed someone to follow through with it. We (wearing my CodeSourcery hat) said we would do so, but have been making slow progress on it since then. Now that we've got more time to work on our arm bare-metal toolchain, I expect that to pick up... sorry it has taken so long :/ https://reviews.llvm.org/D30733 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30792: Use callback for internalizing linked symbols.
mehdi_amini added a comment. Off topic, but since this is a rev lock change with LLVM, you can to all of in a single revision with: http://llvm.org/docs/GettingStarted.html#for-developers-to-work-with-a-git-monorepo Repository: rL LLVM https://reviews.llvm.org/D30792 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30831: [ASTImporter] Import fix of GCCAsmStmts w/ missing symbolic operands
gerazo created this revision. Do not drop the import of the whole function just because an asm statement in it has some missing symbolic names. https://reviews.llvm.org/D30831 Files: lib/AST/ASTImporter.cpp test/ASTMerge/asm/Inputs/asm-function.cpp test/ASTMerge/asm/test.cpp Index: test/ASTMerge/asm/test.cpp === --- test/ASTMerge/asm/test.cpp +++ test/ASTMerge/asm/test.cpp @@ -4,4 +4,5 @@ void testAsmImport() { asmFunc(12, 42); + asmFunc2(42); } Index: test/ASTMerge/asm/Inputs/asm-function.cpp === --- test/ASTMerge/asm/Inputs/asm-function.cpp +++ test/ASTMerge/asm/Inputs/asm-function.cpp @@ -9,3 +9,13 @@ res = bigres; return res; } + +int asmFunc2(int i) { + int res; + asm ("mov %1, %0 \t\n" + "inc %0 " + : "=r" (res) + : "r" (i) + : "cc"); + return res; +} Index: lib/AST/ASTImporter.cpp === --- lib/AST/ASTImporter.cpp +++ lib/AST/ASTImporter.cpp @@ -5218,14 +5218,14 @@ SmallVector Names; for (unsigned I = 0, E = S->getNumOutputs(); I != E; I++) { IdentifierInfo *ToII = Importer.Import(S->getOutputIdentifier(I)); -if (!ToII) - return nullptr; +// ToII is nullptr when no symbolic name is given for output operand +// see ParseStmtAsm::ParseAsmOperandsOpt Names.push_back(ToII); } for (unsigned I = 0, E = S->getNumInputs(); I != E; I++) { IdentifierInfo *ToII = Importer.Import(S->getInputIdentifier(I)); -if (!ToII) - return nullptr; +// ToII is nullptr when no symbolic name is given for input operand +// see ParseStmtAsm::ParseAsmOperandsOpt Names.push_back(ToII); } Index: test/ASTMerge/asm/test.cpp === --- test/ASTMerge/asm/test.cpp +++ test/ASTMerge/asm/test.cpp @@ -4,4 +4,5 @@ void testAsmImport() { asmFunc(12, 42); + asmFunc2(42); } Index: test/ASTMerge/asm/Inputs/asm-function.cpp === --- test/ASTMerge/asm/Inputs/asm-function.cpp +++ test/ASTMerge/asm/Inputs/asm-function.cpp @@ -9,3 +9,13 @@ res = bigres; return res; } + +int asmFunc2(int i) { + int res; + asm ("mov %1, %0 \t\n" + "inc %0 " + : "=r" (res) + : "r" (i) + : "cc"); + return res; +} Index: lib/AST/ASTImporter.cpp === --- lib/AST/ASTImporter.cpp +++ lib/AST/ASTImporter.cpp @@ -5218,14 +5218,14 @@ SmallVector Names; for (unsigned I = 0, E = S->getNumOutputs(); I != E; I++) { IdentifierInfo *ToII = Importer.Import(S->getOutputIdentifier(I)); -if (!ToII) - return nullptr; +// ToII is nullptr when no symbolic name is given for output operand +// see ParseStmtAsm::ParseAsmOperandsOpt Names.push_back(ToII); } for (unsigned I = 0, E = S->getNumInputs(); I != E; I++) { IdentifierInfo *ToII = Importer.Import(S->getInputIdentifier(I)); -if (!ToII) - return nullptr; +// ToII is nullptr when no symbolic name is given for input operand +// see ParseStmtAsm::ParseAsmOperandsOpt Names.push_back(ToII); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30810: Preserve vec3 type.
jaykang10 updated this revision to Diff 91355. jaykang10 added a comment. Changed help text for option and Added test file. https://reviews.llvm.org/D30810 Files: include/clang/Driver/CC1Options.td include/clang/Frontend/CodeGenOptions.def lib/CodeGen/CGExpr.cpp lib/Frontend/CompilerInvocation.cpp test/CodeGenOpenCL/preserve_vec3.cl Index: test/CodeGenOpenCL/preserve_vec3.cl === --- /dev/null +++ test/CodeGenOpenCL/preserve_vec3.cl @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown -preserve-vec3-type | FileCheck %s + +typedef float float3 __attribute__((ext_vector_type(3))); +typedef float float4 __attribute__((ext_vector_type(4))); + +void kernel foo(global float3 *a, global float3 *b) { + // CHECK: %[[LOAD_A:.*]] = load <3 x float>, <3 x float> addrspace(1)* %a + // CHECK: store <3 x float> %[[LOAD_A]], <3 x float> addrspace(1)* %b + *b = *a; +} Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -713,6 +713,7 @@ } } + Opts.PreserveVec3Type = Args.hasArg(OPT_fpreserve_vec3_type); Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions); Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument); Opts.XRayInstructionThreshold = Index: lib/CodeGen/CGExpr.cpp === --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -1368,26 +1368,28 @@ QualType TBAABaseType, uint64_t TBAAOffset, bool isNontemporal) { - // For better performance, handle vector loads differently. - if (Ty->isVectorType()) { -const llvm::Type *EltTy = Addr.getElementType(); - -const auto *VTy = cast(EltTy); - -// Handle vectors of size 3 like size 4 for better performance. -if (VTy->getNumElements() == 3) { - - // Bitcast to vec4 type. - llvm::VectorType *vec4Ty = llvm::VectorType::get(VTy->getElementType(), - 4); - Address Cast = Builder.CreateElementBitCast(Addr, vec4Ty, "castToVec4"); - // Now load value. - llvm::Value *V = Builder.CreateLoad(Cast, Volatile, "loadVec4"); - - // Shuffle vector to get vec3. - V = Builder.CreateShuffleVector(V, llvm::UndefValue::get(vec4Ty), - {0, 1, 2}, "extractVec"); - return EmitFromMemory(V, Ty); + if (!CGM.getCodeGenOpts().PreserveVec3Type) { +// For better performance, handle vector loads differently. +if (Ty->isVectorType()) { + const llvm::Type *EltTy = Addr.getElementType(); + + const auto *VTy = cast(EltTy); + + // Handle vectors of size 3 like size 4 for better performance. + if (VTy->getNumElements() == 3) { + +// Bitcast to vec4 type. +llvm::VectorType *vec4Ty = +llvm::VectorType::get(VTy->getElementType(), 4); +Address Cast = Builder.CreateElementBitCast(Addr, vec4Ty, "castToVec4"); +// Now load value. +llvm::Value *V = Builder.CreateLoad(Cast, Volatile, "loadVec4"); + +// Shuffle vector to get vec3. +V = Builder.CreateShuffleVector(V, llvm::UndefValue::get(vec4Ty), +{0, 1, 2}, "extractVec"); +return EmitFromMemory(V, Ty); + } } } @@ -1456,23 +1458,24 @@ bool isNontemporal) { // Handle vectors differently to get better performance. - if (Ty->isVectorType()) { -llvm::Type *SrcTy = Value->getType(); -auto *VecTy = cast(SrcTy); -// Handle vec3 special. -if (VecTy->getNumElements() == 3) { - // Our source is a vec3, do a shuffle vector to make it a vec4. - llvm::Constant *Mask[] = {Builder.getInt32(0), Builder.getInt32(1), -Builder.getInt32(2), -llvm::UndefValue::get(Builder.getInt32Ty())}; - llvm::Value *MaskV = llvm::ConstantVector::get(Mask); - Value = Builder.CreateShuffleVector(Value, - llvm::UndefValue::get(VecTy), - MaskV, "extractVec"); - SrcTy = llvm::VectorType::get(VecTy->getElementType(), 4); -} -if (Addr.getElementType() != SrcTy) { - Addr = Builder.CreateElementBitCast(Addr, SrcTy, "storetmp"); + if (!CGM.getCodeGenOpts().PreserveVec3Type) { +if (Ty->isVectorType()) { + llvm::Type *SrcTy = Value->getType(); + auto *VecTy = cast(SrcTy); + // Handle vec3 special. + if (VecTy->getNumElements() == 3) { +// Our source is a vec3, do a shuffle vector to make it a vec4. +llvm::Constant *Mask[] = {Builder.getIn
[PATCH] D30810: Preserve vec3 type.
jaykang10 added a comment. In https://reviews.llvm.org/D30810#697760, @Anastasia wrote: > Could you please add your test here (probably goes to test/CodeGenOpenCL)? Oops! I am so sorry. I missed it. I have updated it. https://reviews.llvm.org/D30810 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28136: [OpenCL] Implement as_type operator as alias of __builtin_astype.
bader added a comment. > Why do you think this is a bug? It seems to follow standard behavior in C to > promote char to int if required. Just like if you would have a C code: > > int as_int(int i); > void foo() { > char src = 1; > int dst = as_int(src); > } > > > This code would complie and the same exactly IR would be generated. as_type is defined to be used for bit re-interpretation. (see 6.2.4.2 Reinterpreting Types Using as_type() and as_typen()). In this sense, it's exactly matches __bultin_astype built-in function. Here are a few relevant OpenCL C language specification quotes from 6.2.4 section: > All data types described in tables 6.1 and 6.2 (except bool, half and void) > may be also reinterpreted as another data type of **the same size** using the > as_type() operator for scalar data types and the as_typen() operator for > vector data types. > The usual type promotion for function arguments shall not be performed. > It is an error to use as_type() or as_typen() operator to reinterpret data to > a type of a different number of bytes. So, aliasing as_type to __builtin_astype provides these checks, whereas we can't do it for overloadable as_type function declarations. I also would like to address your original concerns: > The main issue is after preprocessing the header the original function name > is no longer available in diagnostics reported. Actually diagnostics is able to provide a hint to exact code location in the header file where as_ is defined as macro, so user gets correct name of the operator in diagnostics as far as I know. > The spec defines as_type as a builtin function and not a macro. To be precise, spec defines as_type as an operator. So, the best way to implement it would be to add a language support of such operator, but AFAIK aliasing to __bulitin_astype via macro is sufficient enough for OpenCL use cases. > Additionally your patch would allow as_type to be used with extra type (not > only those defined in spec). Not sure I get this. We defined limited set of as_* functions - only for types from tables 6.1 and 6.2 as specified by specification, so if OpenCL developer will try to call as_(type2), which is not defined in the header, compiler will report en error about calling undeclared function. > Also I don't see the problem to implement as_type with just simply calling a > builtin. It should be inlined later anyways. Yes, but this solution will not give us error checking as pre-processor solution. Does it make sense? https://reviews.llvm.org/D28136 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30834: [x86] these aren't the undefs you're looking for (PR32176)
spatel created this revision. Herald added a subscriber: mcrosier. x86 has undef SSE/AVX intrinsics that should represent a bogus register operand. This is not the same as LLVM's undef value which can take on multiple bit patterns. There are better solutions / follow-ups to this discussed here: https://bugs.llvm.org/show_bug.cgi?id=32176 ...but this should prevent miscompiles with a one-line code change. https://reviews.llvm.org/D30834 Files: lib/CodeGen/CGBuiltin.cpp test/CodeGen/avx-builtins.c test/CodeGen/avx2-builtins.c test/CodeGen/avx512bw-builtins.c test/CodeGen/avx512dq-builtins.c test/CodeGen/avx512f-builtins.c test/CodeGen/avx512vl-builtins.c test/CodeGen/avx512vldq-builtins.c test/CodeGen/sse-builtins.c test/CodeGen/sse2-builtins.c Index: test/CodeGen/sse2-builtins.c === --- test/CodeGen/sse2-builtins.c +++ test/CodeGen/sse2-builtins.c @@ -1455,13 +1455,13 @@ __m128d test_mm_undefined_pd() { // CHECK-LABEL: @test_mm_undefined_pd - // CHECK: ret <2 x double> undef + // CHECK: ret <2 x double> zeroinitializer return _mm_undefined_pd(); } __m128i test_mm_undefined_si128() { // CHECK-LABEL: @test_mm_undefined_si128 - // CHECK: ret <2 x i64> undef + // CHECK: ret <2 x i64> zeroinitializer return _mm_undefined_si128(); } Index: test/CodeGen/sse-builtins.c === --- test/CodeGen/sse-builtins.c +++ test/CodeGen/sse-builtins.c @@ -802,7 +802,7 @@ __m128 test_mm_undefined_ps() { // CHECK-LABEL: @test_mm_undefined_ps - // CHECK: ret <4 x float> undef + // CHECK: ret <4 x float> zeroinitializer return _mm_undefined_ps(); } Index: test/CodeGen/avx512vldq-builtins.c === --- test/CodeGen/avx512vldq-builtins.c +++ test/CodeGen/avx512vldq-builtins.c @@ -996,40 +996,40 @@ __m128d test_mm256_extractf64x2_pd(__m256d __A) { // CHECK-LABEL: @test_mm256_extractf64x2_pd - // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> undef, <2 x i32> + // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> zeroinitializer, <2 x i32> return _mm256_extractf64x2_pd(__A, 1); } __m128d test_mm256_mask_extractf64x2_pd(__m128d __W, __mmask8 __U, __m256d __A) { // CHECK-LABEL: @test_mm256_mask_extractf64x2_pd - // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> undef, <2 x i32> + // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> zeroinitializer, <2 x i32> // CHECK: select <2 x i1> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}} return _mm256_mask_extractf64x2_pd(__W, __U, __A, 1); } __m128d test_mm256_maskz_extractf64x2_pd(__mmask8 __U, __m256d __A) { // CHECK-LABEL: @test_mm256_maskz_extractf64x2_pd - // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> undef, <2 x i32> + // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> zeroinitializer, <2 x i32> // CHECK: select <2 x i1> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}} return _mm256_maskz_extractf64x2_pd(__U, __A, 1); } __m128i test_mm256_extracti64x2_epi64(__m256i __A) { // CHECK-LABEL: @test_mm256_extracti64x2_epi64 - // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> undef, <2 x i32> + // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> zeroinitializer, <2 x i32> return _mm256_extracti64x2_epi64(__A, 1); } __m128i test_mm256_mask_extracti64x2_epi64(__m128i __W, __mmask8 __U, __m256i __A) { // CHECK-LABEL: @test_mm256_mask_extracti64x2_epi64 - // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> undef, <2 x i32> + // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> zeroinitializer, <2 x i32> // CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}} return _mm256_mask_extracti64x2_epi64(__W, __U, __A, 1); } __m128i test_mm256_maskz_extracti64x2_epi64(__mmask8 __U, __m256i __A) { // CHECK-LABEL: @test_mm256_maskz_extracti64x2_epi64 - // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> undef, <2 x i32> + // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> zeroinitializer, <2 x i32> // CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}} return _mm256_maskz_extracti64x2_epi64(__U, __A, 1); } Index: test/CodeGen/avx512vl-builtins.c === --- test/CodeGen/avx512vl-builtins.c +++ test/CodeGen/avx512vl-builtins.c @@ -5008,56 +5008,56 @@ __m128d test_mm_mask_permute_pd(__m128d __W, __mmask8 __U, __m128d __X) { // CHECK-LABEL: @test_mm_mask_permute_pd - // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> undef, <2 x i32> + // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> zeroinitializer, <2 x i32> // CHECK: select <2 x i1> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}} return _mm_mask_permute_pd(__W, __U, __X, 1); } __m128d test_mm_maskz_permute_pd(__m
[PATCH] D30768: [PATCH][VFS] Ignore broken symlinks in the directory iterator.
ributzka updated this revision to Diff 91371. ributzka added a comment. Remove the EC check completely. https://reviews.llvm.org/D30768 Files: include/clang/Basic/VirtualFileSystem.h lib/Basic/VirtualFileSystem.cpp unittests/Basic/VirtualFileSystemTest.cpp Index: unittests/Basic/VirtualFileSystemTest.cpp === --- unittests/Basic/VirtualFileSystemTest.cpp +++ unittests/Basic/VirtualFileSystemTest.cpp @@ -305,6 +305,22 @@ } operator StringRef() { return Path.str(); } }; + +struct ScopedLink { + SmallString<128> Path; + ScopedLink(const Twine &To, const Twine &From) { +Path = From.str(); +std::error_code EC = sys::fs::create_link(To, From); +if (EC) + Path = ""; +EXPECT_FALSE(EC); + } + ~ScopedLink() { +if (Path != "") + EXPECT_FALSE(llvm::sys::fs::remove(Path.str())); + } + operator StringRef() { return Path.str(); } +}; } // end anonymous namespace TEST(VirtualFileSystemTest, BasicRealFSIteration) { @@ -334,6 +350,35 @@ EXPECT_EQ(vfs::directory_iterator(), I); } +TEST(VirtualFileSystemTest, BrokenSymlinkRealFSIteration) { + ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/ true); + IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); + + ScopedLink _a("no_such_file", TestDirectory + "/a"); + ScopedDir _b(TestDirectory + "/b"); + ScopedLink _c("no_such_file", TestDirectory + "/c"); + + std::error_code EC; + vfs::directory_iterator I = FS->dir_begin(Twine(TestDirectory), EC); + EXPECT_TRUE(EC); + EXPECT_NE(vfs::directory_iterator(), I); + EC = std::error_code(); + EXPECT_TRUE(I->getName() == _a); + I.increment(EC); + EXPECT_FALSE(EC); + EXPECT_NE(vfs::directory_iterator(), I); + EXPECT_TRUE(I->getName() == _b); + I.increment(EC); + EXPECT_TRUE(EC); + EXPECT_NE(vfs::directory_iterator(), I); + EC = std::error_code(); + EXPECT_NE(vfs::directory_iterator(), I); + EXPECT_TRUE(I->getName() == _c); + I.increment(EC); + EXPECT_FALSE(EC); + EXPECT_EQ(vfs::directory_iterator(), I); +} + TEST(VirtualFileSystemTest, BasicRealFSRecursiveIteration) { ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/true); IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); @@ -373,6 +418,44 @@ EXPECT_EQ(1, Counts[3]); // d } +TEST(VirtualFileSystemTest, BrokenSymlinkRealFSRecursiveIteration) { + ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/ true); + IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); + + ScopedLink _a("no_such_file", TestDirectory + "/a"); + ScopedDir _b(TestDirectory + "/b"); + ScopedLink _ba("no_such_file", TestDirectory + "/b/a"); + ScopedDir _bb(TestDirectory + "/b/b"); + ScopedLink _bc("no_such_file", TestDirectory + "/b/c"); + ScopedLink _c("no_such_file", TestDirectory + "/c"); + ScopedDir _d(TestDirectory + "/d"); + ScopedDir _dd(TestDirectory + "/d/d"); + ScopedDir _ddd(TestDirectory + "/d/d/d"); + ScopedLink _e("no_such_file", TestDirectory + "/e"); + + std::vector Contents; + std::error_code EC; + for (vfs::recursive_directory_iterator I(*FS, Twine(TestDirectory), EC), E; + I != E; I.increment(EC)) { +// Skip broken symlinks. +if (EC == std::errc::no_such_file_or_directory) { + EC = std::error_code(); + continue; +} else if (EC) { + break; +} +Contents.push_back(I->getName()); + } + + // Check contents. + EXPECT_EQ(5U, Contents.size()); + EXPECT_TRUE(Contents[0] == _b); + EXPECT_TRUE(Contents[1] == _bb); + EXPECT_TRUE(Contents[2] == _d); + EXPECT_TRUE(Contents[3] == _dd); + EXPECT_TRUE(Contents[4] == _ddd); +} + template static void checkContents(DirIter I, ArrayRef ExpectedOut) { std::error_code EC; Index: lib/Basic/VirtualFileSystem.cpp === --- lib/Basic/VirtualFileSystem.cpp +++ lib/Basic/VirtualFileSystem.cpp @@ -246,8 +246,7 @@ if (!EC && Iter != llvm::sys::fs::directory_iterator()) { llvm::sys::fs::file_status S; EC = Iter->status(S); - if (!EC) -CurrentEntry = Status::copyWithNewName(S, Iter->path()); + CurrentEntry = Status::copyWithNewName(S, Iter->path()); } } @@ -1858,7 +1857,7 @@ std::error_code &EC) : FS(&FS_) { directory_iterator I = FS->dir_begin(Path, EC); - if (!EC && I != directory_iterator()) { + if (I != directory_iterator()) { State = std::make_shared(); State->push(I); } @@ -1871,8 +1870,6 @@ vfs::directory_iterator End; if (State->top()->isDirectory()) { vfs::directory_iterator I = FS->dir_begin(State->top()->getName(), EC); -if (EC) - return *this; if (I != End) { State->push(I); return *this; Index: include/clang/Basic/VirtualFileSystem.h === --- include/clang/Basic/VirtualFileSystem.h +++ include/clang/Basic/VirtualFileSystem.h @
r297485 - [mips][msa] Remove range checks for non-immediate sld.[bhwd] instructions
Author: petarj Date: Fri Mar 10 11:51:01 2017 New Revision: 297485 URL: http://llvm.org/viewvc/llvm-project?rev=297485&view=rev Log: [mips][msa] Remove range checks for non-immediate sld.[bhwd] instructions Removes immediate range checks for these instructions, since they have GPR rt as their input operand. Patch by Stefan Maksimovic. Differential Revision: https://reviews.llvm.org/D30693 Modified: cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/CodeGen/builtins-mips-msa-error.c cfe/trunk/test/CodeGen/builtins-mips-msa.c Modified: cfe/trunk/lib/Sema/SemaChecking.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=297485&r1=297484&r2=297485&view=diff == --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) +++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Mar 10 11:51:01 2017 @@ -1619,28 +1619,24 @@ bool Sema::CheckMipsBuiltinFunctionCall( case Mips::BI__builtin_msa_copy_u_b: case Mips::BI__builtin_msa_insve_b: case Mips::BI__builtin_msa_splati_b: i = 1; l = 0; u = 15; break; - case Mips::BI__builtin_msa_sld_b: case Mips::BI__builtin_msa_sldi_b: i = 2; l = 0; u = 15; break; // These intrinsics take an unsigned 3 bit immediate. case Mips::BI__builtin_msa_copy_s_h: case Mips::BI__builtin_msa_copy_u_h: case Mips::BI__builtin_msa_insve_h: case Mips::BI__builtin_msa_splati_h: i = 1; l = 0; u = 7; break; - case Mips::BI__builtin_msa_sld_h: case Mips::BI__builtin_msa_sldi_h: i = 2; l = 0; u = 7; break; // These intrinsics take an unsigned 2 bit immediate. case Mips::BI__builtin_msa_copy_s_w: case Mips::BI__builtin_msa_copy_u_w: case Mips::BI__builtin_msa_insve_w: case Mips::BI__builtin_msa_splati_w: i = 1; l = 0; u = 3; break; - case Mips::BI__builtin_msa_sld_w: case Mips::BI__builtin_msa_sldi_w: i = 2; l = 0; u = 3; break; // These intrinsics take an unsigned 1 bit immediate. case Mips::BI__builtin_msa_copy_s_d: case Mips::BI__builtin_msa_copy_u_d: case Mips::BI__builtin_msa_insve_d: case Mips::BI__builtin_msa_splati_d: i = 1; l = 0; u = 1; break; - case Mips::BI__builtin_msa_sld_d: case Mips::BI__builtin_msa_sldi_d: i = 2; l = 0; u = 1; break; // Memory offsets and immediate loads. // These intrinsics take a signed 10 bit immediate. Modified: cfe/trunk/test/CodeGen/builtins-mips-msa-error.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-mips-msa-error.c?rev=297485&r1=297484&r2=297485&view=diff == --- cfe/trunk/test/CodeGen/builtins-mips-msa-error.c (original) +++ cfe/trunk/test/CodeGen/builtins-mips-msa-error.c Fri Mar 10 11:51:01 2017 @@ -162,11 +162,6 @@ void test(void) { v8i16_r = __msa_shf_h(v8i16_a, 256); // CHECK: warning: argument should be a value from 0 to 255}} v4i32_r = __msa_shf_w(v4i32_a, 256); // CHECK: warning: argument should be a value from 0 to 255}} - v16i8_r = __msa_sld_b(v16i8_r, v16i8_a, 16); // expected-error {{argument should be a value from 0 to 15}} - v8i16_r = __msa_sld_h(v8i16_r, v8i16_a, 8); // expected-error {{argument should be a value from 0 to 7}} - v4i32_r = __msa_sld_w(v4i32_r, v4i32_a, 4); // expected-error {{argument should be a value from 0 to 3}} - v2i64_r = __msa_sld_d(v2i64_r, v2i64_a, 2); // expected-error {{argument should be a value from 0 to 1}} - v16i8_r = __msa_sldi_b(v16i8_r, v16i8_a, 16); // expected-error {{argument should be a value from 0 to 15}} v8i16_r = __msa_sldi_h(v8i16_r, v8i16_a, 8); // expected-error {{argument should be a value from 0 to 7}} v4i32_r = __msa_sldi_w(v4i32_r, v4i32_a, 4); // expected-error {{argument should be a value from 0 to 3}} @@ -358,11 +353,6 @@ void test(void) { v8i16_r = __msa_shf_h(v8i16_a, -1);// CHECK: warning: argument should be a value from 0 to 255}} v4i32_r = __msa_shf_w(v4i32_a, -1);// CHECK: warning: argument should be a value from 0 to 255}} - v16i8_r = __msa_sld_b(v16i8_r, v16i8_a, -17); // expected-error {{argument should be a value from 0 to 15}} - v8i16_r = __msa_sld_h(v8i16_r, v8i16_a, -8); // expected-error {{argument should be a value from 0 to 7}} - v4i32_r = __msa_sld_w(v4i32_r, v4i32_a, -4); // expected-error {{argument should be a value from 0 to 3}} - v2i64_r = __msa_sld_d(v2i64_r, v2i64_a, -2); // expected-error {{argument should be a value from 0 to 1}} - v16i8_r = __msa_sldi_b(v16i8_r, v16i8_a, -17); // expected-error {{argument should be a value from 0 to 15}} v8i16_r = __msa_sldi_h(v8i16_r, v8i16_a, -8); // expected-error {{argument should be a value from 0 to 7}} v4i32_r = __msa_sldi_w(v4i32_r, v4i32_a, -4); // expected-error {{argument should be a value from 0 to 3}} Modified: cfe/trunk/test/CodeGen/builtins-mi
[PATCH] D30693: [mips][msa] Remove range checks for non-immediate sld.[bhwd] instructions
This revision was automatically updated to reflect the committed changes. Closed by commit rL297485: [mips][msa] Remove range checks for non-immediate sld.[bhwd] instructions (authored by petarj). Changed prior to commit: https://reviews.llvm.org/D30693?vs=91158&id=91372#toc Repository: rL LLVM https://reviews.llvm.org/D30693 Files: cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/CodeGen/builtins-mips-msa-error.c cfe/trunk/test/CodeGen/builtins-mips-msa.c Index: cfe/trunk/lib/Sema/SemaChecking.cpp === --- cfe/trunk/lib/Sema/SemaChecking.cpp +++ cfe/trunk/lib/Sema/SemaChecking.cpp @@ -1619,28 +1619,24 @@ case Mips::BI__builtin_msa_copy_u_b: case Mips::BI__builtin_msa_insve_b: case Mips::BI__builtin_msa_splati_b: i = 1; l = 0; u = 15; break; - case Mips::BI__builtin_msa_sld_b: case Mips::BI__builtin_msa_sldi_b: i = 2; l = 0; u = 15; break; // These intrinsics take an unsigned 3 bit immediate. case Mips::BI__builtin_msa_copy_s_h: case Mips::BI__builtin_msa_copy_u_h: case Mips::BI__builtin_msa_insve_h: case Mips::BI__builtin_msa_splati_h: i = 1; l = 0; u = 7; break; - case Mips::BI__builtin_msa_sld_h: case Mips::BI__builtin_msa_sldi_h: i = 2; l = 0; u = 7; break; // These intrinsics take an unsigned 2 bit immediate. case Mips::BI__builtin_msa_copy_s_w: case Mips::BI__builtin_msa_copy_u_w: case Mips::BI__builtin_msa_insve_w: case Mips::BI__builtin_msa_splati_w: i = 1; l = 0; u = 3; break; - case Mips::BI__builtin_msa_sld_w: case Mips::BI__builtin_msa_sldi_w: i = 2; l = 0; u = 3; break; // These intrinsics take an unsigned 1 bit immediate. case Mips::BI__builtin_msa_copy_s_d: case Mips::BI__builtin_msa_copy_u_d: case Mips::BI__builtin_msa_insve_d: case Mips::BI__builtin_msa_splati_d: i = 1; l = 0; u = 1; break; - case Mips::BI__builtin_msa_sld_d: case Mips::BI__builtin_msa_sldi_d: i = 2; l = 0; u = 1; break; // Memory offsets and immediate loads. // These intrinsics take a signed 10 bit immediate. Index: cfe/trunk/test/CodeGen/builtins-mips-msa.c === --- cfe/trunk/test/CodeGen/builtins-mips-msa.c +++ cfe/trunk/test/CodeGen/builtins-mips-msa.c @@ -699,6 +699,11 @@ v4i32_r = __msa_sld_w(v4i32_r, v4i32_a, 3); // CHECK: call <4 x i32> @llvm.mips.sld.w( v2i64_r = __msa_sld_d(v2i64_r, v2i64_a, 1); // CHECK: call <2 x i64> @llvm.mips.sld.d( + v16i8_r = __msa_sld_b(v16i8_r, v16i8_a, 16); // CHECK: call <16 x i8> @llvm.mips.sld.b( + v8i16_r = __msa_sld_h(v8i16_r, v8i16_a, 8); // CHECK: call <8 x i16> @llvm.mips.sld.h( + v4i32_r = __msa_sld_w(v4i32_r, v4i32_a, 4); // CHECK: call <4 x i32> @llvm.mips.sld.w( + v2i64_r = __msa_sld_d(v2i64_r, v2i64_a, 2); // CHECK: call <2 x i64> @llvm.mips.sld.d( + v16i8_r = __msa_sldi_b(v16i8_r, v16i8_a, 7); // CHECK: call <16 x i8> @llvm.mips.sldi.b( v8i16_r = __msa_sldi_h(v8i16_r, v8i16_a, 3); // CHECK: call <8 x i16> @llvm.mips.sldi.h( v4i32_r = __msa_sldi_w(v4i32_r, v4i32_a, 2); // CHECK: call <4 x i32> @llvm.mips.sldi.w( Index: cfe/trunk/test/CodeGen/builtins-mips-msa-error.c === --- cfe/trunk/test/CodeGen/builtins-mips-msa-error.c +++ cfe/trunk/test/CodeGen/builtins-mips-msa-error.c @@ -162,11 +162,6 @@ v8i16_r = __msa_shf_h(v8i16_a, 256); // CHECK: warning: argument should be a value from 0 to 255}} v4i32_r = __msa_shf_w(v4i32_a, 256); // CHECK: warning: argument should be a value from 0 to 255}} - v16i8_r = __msa_sld_b(v16i8_r, v16i8_a, 16); // expected-error {{argument should be a value from 0 to 15}} - v8i16_r = __msa_sld_h(v8i16_r, v8i16_a, 8); // expected-error {{argument should be a value from 0 to 7}} - v4i32_r = __msa_sld_w(v4i32_r, v4i32_a, 4); // expected-error {{argument should be a value from 0 to 3}} - v2i64_r = __msa_sld_d(v2i64_r, v2i64_a, 2); // expected-error {{argument should be a value from 0 to 1}} - v16i8_r = __msa_sldi_b(v16i8_r, v16i8_a, 16); // expected-error {{argument should be a value from 0 to 15}} v8i16_r = __msa_sldi_h(v8i16_r, v8i16_a, 8); // expected-error {{argument should be a value from 0 to 7}} v4i32_r = __msa_sldi_w(v4i32_r, v4i32_a, 4); // expected-error {{argument should be a value from 0 to 3}} @@ -358,11 +353,6 @@ v8i16_r = __msa_shf_h(v8i16_a, -1);// CHECK: warning: argument should be a value from 0 to 255}} v4i32_r = __msa_shf_w(v4i32_a, -1);// CHECK: warning: argument should be a value from 0 to 255}} - v16i8_r = __msa_sld_b(v16i8_r, v16i8_a, -17); // expected-error {{argument should be a value from 0 to 15}} - v8i16_r = __msa_sld_h(v8i16_r, v8i16_a, -8); // expected-error {{argument should be a value from 0 to 7}} - v4i32_r = __msa_sld_w(v4i32_r, v4i32_a, -4);
[PATCH] D30830: [OpenCL] Fix extension guards for atomic functions
jprice added a comment. Thanks - could you commit this on my behalf please? https://reviews.llvm.org/D30830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30837: [libcxx] Support for shared_ptr
erik.pilkington created this revision. This patch adds support for `shared_ptr` types, so that the following works: void Func(); void Del(void (*)()) std::shared_ptr x(Func, Del); Where previously this would fail to compile. In PR27566, the use case described for this was a shared pointer to a dynamically loaded function, which seems reasonable enough to me. Both libstdc++ and MSVC support this use case as well, and I didn't notice any wording in the standard that disallowed it. This patch has 2 parts: 1. Don't try to instantiate an `allocator` 2. Fix `__enable_weak_this()` dummy overload to work with function pointers. Number 1 is accomplished by passing in `allocator` into `__shared_ptr_pointer` or `__shared_ptr_emplace` when no allocator was passed to the constructor of the `shared_ptr`, I believe this is correct because in this case the allocator is only used for a rebind, so any instantiation of std::allocator would work fine. This is my first libc++ patch, so take it with a grain of salt! Thanks for taking a look, Erik https://reviews.llvm.org/D30837 Files: include/memory test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp === --- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp +++ test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp @@ -45,6 +45,9 @@ virtual ~Foo() = default; }; +struct Result {}; +void resultDeletor(Result (*)()) {} +Result theFunction() { return Result(); } int main() { @@ -65,7 +68,9 @@ std::shared_ptr p2 = std::make_shared(); assert(p2.get()); } - +{ // https://bugs.llvm.org/show_bug.cgi?id=27566 + std::shared_ptr x(&theFunction, &resultDeletor); +} #if TEST_STD_VER >= 11 nc = globalMemCounter.outstanding_new; { Index: include/memory === --- include/memory +++ include/memory @@ -3884,8 +3884,7 @@ } } -_LIBCPP_INLINE_VISIBILITY -void __enable_weak_this(const volatile void*, const volatile void*) _NOEXCEPT {} +_LIBCPP_INLINE_VISIBILITY void __enable_weak_this(...) _NOEXCEPT {} template friend class _LIBCPP_TEMPLATE_VIS shared_ptr; template friend class _LIBCPP_TEMPLATE_VIS weak_ptr; @@ -3916,8 +3915,8 @@ : __ptr_(__p) { unique_ptr<_Yp> __hold(__p); -typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator<_Yp>()); +typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator()); __hold.release(); __enable_weak_this(__p, __p); } @@ -3932,8 +3931,8 @@ try { #endif // _LIBCPP_NO_EXCEPTIONS -typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__p, __d, allocator<_Yp>()); +typedef __shared_ptr_pointer<_Yp*, _Dp, allocator > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__p, __d, allocator()); __enable_weak_this(__p, __p); #ifndef _LIBCPP_NO_EXCEPTIONS } @@ -3954,8 +3953,8 @@ try { #endif // _LIBCPP_NO_EXCEPTIONS -typedef __shared_ptr_pointer > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__p, __d, allocator<_Tp>()); +typedef __shared_ptr_pointer > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__p, __d, allocator()); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) @@ -4094,8 +4093,8 @@ typename enable_if::value, __nat>::type) : __ptr_(__r.get()) { -typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>()); +typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator()); __enable_weak_this(__r.get(), __r.get()); __r.release(); } @@ -4123,8 +4122,8 @@ else #endif { -typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>()); +typedef __shared_ptr_pointer<_Yp*, _Dp, allocator > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator()); __enable_weak_this(__r.get(), __r.get()); } __r.release(); @@ -4154,8 +4153,8 @@ { typedef __shared_ptr_pointer<_Yp*, reference_wrapper::type>, - allocator<_Yp> > _CntrlBlk; -
[PATCH] D15031: CFG: Add CFGElement for automatic variables that leave the scope
mgehre updated this revision to Diff 91378. mgehre marked an inline comment as done. mgehre added a comment. Handle back-patches gotos and add test case Turned LocalScope::const_iterator::shared_parent from O(N^2) into O(N) time The combination with AddImplicitDtors will be added in a separate patch https://reviews.llvm.org/D15031 Files: include/clang/Analysis/AnalysisContext.h include/clang/Analysis/CFG.h include/clang/StaticAnalyzer/Core/AnalyzerOptions.h lib/Analysis/AnalysisDeclContext.cpp lib/Analysis/CFG.cpp lib/StaticAnalyzer/Core/AnalysisManager.cpp lib/StaticAnalyzer/Core/AnalyzerOptions.cpp lib/StaticAnalyzer/Core/ExprEngine.cpp lib/StaticAnalyzer/Core/PathDiagnostic.cpp test/Analysis/analyzer-config.c test/Analysis/analyzer-config.cpp test/Analysis/lifetime-cfg-output.cpp Index: test/Analysis/lifetime-cfg-output.cpp === --- /dev/null +++ test/Analysis/lifetime-cfg-output.cpp @@ -0,0 +1,783 @@ +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-lifetime=true -analyzer-config cfg-implicit-dtors=false %s > %t 2>&1 +// RUN: FileCheck --input-file=%t %s + +extern bool UV; +class A { +public: + // CHECK: [B2 (ENTRY)] + // CHECK-NEXT:Succs (1): B1 + // CHECK: [B1] + // CHECK-NEXT:1: true + // CHECK-NEXT:2: UV + // CHECK-NEXT:3: [B1.2] = [B1.1] + // CHECK-NEXT:Preds (1): B2 + // CHECK-NEXT:Succs (1): B0 + // CHECK: [B0 (EXIT)] + // CHECK-NEXT:Preds (1): B1 + A() { +UV = true; + } + // CHECK: [B3 (ENTRY)] + // CHECK-NEXT:Succs (1): B2 + // CHECK: [B1] + // CHECK-NEXT:1: 0 + // CHECK-NEXT:2: this + // CHECK-NEXT:3: [B1.2]->p + // CHECK-NEXT:4: [B1.3] (ImplicitCastExpr, LValueToRValue, int *) + // CHECK-NEXT:5: *[B1.4] + // CHECK-NEXT:6: [B1.5] = [B1.1] + // CHECK-NEXT:Preds (1): B2 + // CHECK-NEXT:Succs (1): B0 + // CHECK: [B2] + // CHECK-NEXT:1: this + // CHECK-NEXT:2: [B2.1]->p + // CHECK-NEXT:3: [B2.2] (ImplicitCastExpr, LValueToRValue, int *) + // CHECK-NEXT:4: [B2.3] (ImplicitCastExpr, PointerToBoolean, _Bool) + // CHECK-NEXT:T: if [B2.4] + // CHECK-NEXT:Preds (1): B3 + // CHECK-NEXT:Succs (2): B1 B0 + // CHECK: [B0 (EXIT)] + // CHECK-NEXT:Preds (2): B1 B2 + ~A() { +if (p) + *p = 0; + } + // CHECK: [B2 (ENTRY)] + // CHECK-NEXT:Succs (1): B1 + // CHECK: [B1] + // CHECK-NEXT:1: 1 + // CHECK-NEXT:2: return [B1.1]; + // CHECK-NEXT:Preds (1): B2 + // CHECK-NEXT:Succs (1): B0 + // CHECK: [B0 (EXIT)] + // CHECK-NEXT:Preds (1): B1 + operator int() const { return 1; } + int *p; +}; + +// CHECK: [B2 (ENTRY)] +// CHECK-NEXT:Succs (1): B1 +// CHECK: [B1] +// CHECK-NEXT:1: (CXXConstructExpr, class A) +// CHECK-NEXT:2: A a; +// CHECK-NEXT:3: a +// CHECK-NEXT:4: [B1.3] (ImplicitCastExpr, NoOp, const class A) +// CHECK-NEXT:5: const A &b = a; +// CHECK-NEXT:6: A() (CXXConstructExpr, class A) +// CHECK-NEXT:7: [B1.6] (BindTemporary) +// CHECK-NEXT:8: [B1.7] (ImplicitCastExpr, NoOp, const class A) +// CHECK-NEXT:9: [B1.8] +// CHECK-NEXT: 10: const A &c = A(); +// CHECK-NEXT: 11: [B1.10] (Lifetime ends) +// CHECK-NEXT: 12: [B1.2] (Lifetime ends) +// CHECK-NEXT: 13: [B1.5] (Lifetime ends) +// CHECK-NEXT:Preds (1): B2 +// CHECK-NEXT:Succs (1): B0 +// CHECK: [B0 (EXIT)] +// CHECK-NEXT:Preds (1): B1 +void test_const_ref() { + A a; + const A &b = a; + const A &c = A(); +} + +// CHECK: [B2 (ENTRY)] +// CHECK-NEXT: Succs (1): B1 +// CHECK: [B1] +// CHECK-NEXT:1: (CXXConstructExpr, class A [2]) +// CHECK-NEXT:2: A a[2]; +// CHECK-NEXT:3: (CXXConstructExpr, class A [0]) +// CHECK-NEXT:4: A b[0]; +// lifetime of a ends when its destructors are run +// CHECK-NEXT:5: [B1.2] (Lifetime ends) +// lifetime of b ends when its storage duration ends +// CHECK-NEXT:6: [B1.4] (Lifetime ends) +// CHECK-NEXT:Preds (1): B2 +// CHECK-NEXT:Succs (1): B0 +// CHECK: [B0 (EXIT)] +// CHECK-NEXT: Preds (1): B1 +void test_array() { + A a[2]; + A b[0]; +} + +// CHECK: [B2 (ENTRY)] +// CHECK-NEXT: Succs (1): B1 +// CHECK: [B1] +// CHECK-NEXT:1: (CXXConstructExpr, class A) +// CHECK-NEXT:2: A a; +// CHECK-NEXT:3: (CXXConstructExpr, class A) +// CHECK-NEXT:4: A c; +// CHECK-NEXT:5: (CXXConstructExpr, class A) +// CHECK-NEXT:6: A d; +// CHECK-NEXT:7: [B1.6] (Lifetime ends) +// CHECK-NEXT:8: [B1.4] (Lifetime ends) +// CHECK-NEXT:9: (CXXConstructExpr, class A) +// CHECK-NEXT: 10: A b; +// CHECK-NEXT: 11: [B1.10] (Lifetime ends) +// CHECK-NEXT: 12: [B1.2] (Lifetime ends) +// CHECK-NEXT:Preds (1): B2 +// CHECK-NEXT:Succs (1): B0 +// CHECK: [B0 (EXIT)] +// CHECK-NEXT:
[PATCH] D15031: CFG: Add CFGElement for automatic variables that leave the scope
mgehre added a comment. I'm sorry for the long delay! Regarding " I think it would also be good to (eventually) add CFGElements marking when the storage duration for underlying storage ends.": From what I understand, this only differs from the end of lifetime in case of objects with non-trivial destructors, where the lifetime ends before the destructor is called and the storage duration ends afterwards. In which case is this difference important to the static analyzer? Accessing an object after its lifetime ended is already UB, so the static analyzer could warn on this, even before the storage duration for underlying storage ends. https://reviews.llvm.org/D15031 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30183: Add -iframeworkwithsysroot compiler option
bruno accepted this revision. bruno added a comment. This revision is now accepted and ready to land. Hi Alex, Thanks for taking a look a this. LGTM Repository: rL LLVM https://reviews.llvm.org/D30183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30837: [libcxx] Support for shared_ptr
halyavin added a comment. But std::allocator is deprecated in C++17. I don't know a good solution, I just used int as an arbitrary type when I faced similar problem. https://reviews.llvm.org/D30837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30762: [ubsan] Add a nullability sanitizer
vsk marked 9 inline comments as done. vsk added a comment. The plan is to start off with -fsanitize=nullability, and then create a nullability-pedantic group later if it's really necessary. I think I've addressed all of the inline comments, and will upload a new diff shortly. Comment at: docs/UndefinedBehaviorSanitizer.rst:101 + ``-fsanitize=nullability-assign``, and the argument check with + ``-fsanitize=nullability-arg``. While violating nullability rules does + not result in undefined behavior, it is often unintentional, so UBSan zaks.anna wrote: > vsk wrote: > > zaks.anna wrote: > > > Have you investigated if -fsanitize=nullability-arg is too noisy? I think > > > we should somehow "recommend" return and assignment check to most users. > > > This is not clear from the help and options provided. The main concern > > > here is that someone would try -fsanitize=nullability, see a ton of > > > warnings they don't care about and think that the whole check is too > > > noisy. > > > > > > I cannot come up with a great solution. Options that come into mind are: > > > - Drop "arg" check completely. > > > - Remove arg from the nullability group. > > > - Have 2 groups for nullability. > > > > > > We can also wait for concrete data before making a decision here and > > > address this in subsequent commits. > > The nullability-arg check was not noisy on a small sample (n=4) of > > Apple-internal projects. I only collected 11 diagnostics in total, all of > > which seemed actionable. I.e the issues were not isolated to system > > headers: the project code actually did violate arg nullability. Based on > > what I've seen so far, I'd like to start off with including the arg check > > in a "nullability-full" group. If arg check noisiness becomes an issue, > > then I'd like to create a new "nullability-partial" group with just the > > return/assignment checks. > > > > TL;DR: let's rename -fsanitize=nullability to -fsanitize=nullability-full, > > keep the arg check, and introduce a nullability-partial group later if we > > need to. Wdyt? > > > > > Keeping things as is and introducing a new group if this becomes a problem > sounds good to me. You could use "nullability" and "nullability-pedantic". > That way you do not need to change the name and get to use "nullability". Sgtm. Comment at: docs/UndefinedBehaviorSanitizer.rst:141 - ``-fsanitize=undefined``: All of the checks listed above other than - ``unsigned-integer-overflow``. + ``unsigned-integer-overflow`` and ``nullability``. - ``-fsanitize=undefined-trap``: Deprecated alias of filcab wrote: > ```... and the ``nullability`` group.``` I define the group after the 'undefined' group, so I used a slightly different spelling. Comment at: lib/CodeGen/CGDecl.cpp:1907 + + // Skip the return value nullability check if the nullability preconditions + // are broken. zaks.anna wrote: > I would add a comment explaining why this is needed, similar to what you > included in the commit message: > "One point of note is that the nullability-return check is only allowed > to kick in if all arguments to the function satisfy their nullability > preconditions. This makes it necessary to emit some null checks in the > function body itself." > > Maybe even rename CanCheckRetValNullability into > RetValNullabilityPrecondition. I like this more than "CanCheck" because it's > just a precondition value. You check if it is satisfied (evaluates to true or > false) later when it's used in a branch. I added the comment and did the rename. I like 'RetValNullabilityPrecondition'. Comment at: test/CodeGenObjC/ubsan-nullability.m:114 + // CHECK: [[NONULL]]: + // CHECK: ret i32* +} filcab wrote: > `CHECK-NEXT`? I've promoted all the existing 'CHECK' lines to 'CHECK-NEXT's where possible. https://reviews.llvm.org/D30762 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30762: [ubsan] Add a nullability sanitizer
vsk updated this revision to Diff 91382. vsk marked 4 inline comments as done. vsk added a comment. - Rework documentation, add better code comments, and tighten up some check lines. https://reviews.llvm.org/D30762 Files: docs/UndefinedBehaviorSanitizer.rst include/clang/Basic/Sanitizers.def lib/CodeGen/CGCall.cpp lib/CodeGen/CGDecl.cpp lib/CodeGen/CGExprScalar.cpp lib/CodeGen/CodeGenFunction.cpp lib/CodeGen/CodeGenFunction.h lib/Driver/SanitizerArgs.cpp lib/Driver/ToolChain.cpp test/CodeGenObjC/ubsan-nonnull-and-nullability.m test/CodeGenObjC/ubsan-nullability.m Index: test/CodeGenObjC/ubsan-nullability.m === --- /dev/null +++ test/CodeGenObjC/ubsan-nullability.m @@ -0,0 +1,182 @@ +// REQUIRES: asserts +// RUN: %clang_cc1 -x objective-c -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=nullability-arg,nullability-assign,nullability-return -w %s -o - | FileCheck %s + +// CHECK: [[NONNULL_RV_LOC1:@.*]] = private unnamed_addr global {{.*}} i32 109, i32 1 {{.*}} i32 100, i32 6 +// CHECK: [[NONNULL_ARG_LOC:@.*]] = private unnamed_addr global {{.*}} i32 204, i32 15 {{.*}} i32 190, i32 23 +// CHECK: [[NONNULL_ASSIGN1_LOC:@.*]] = private unnamed_addr global {{.*}} i32 305, i32 9 +// CHECK: [[NONNULL_ASSIGN2_LOC:@.*]] = private unnamed_addr global {{.*}} i32 405, i32 10 +// CHECK: [[NONNULL_ASSIGN3_LOC:@.*]] = private unnamed_addr global {{.*}} i32 505, i32 10 +// CHECK: [[NONNULL_INIT1_LOC:@.*]] = private unnamed_addr global {{.*}} i32 604, i32 25 +// CHECK: [[NONNULL_INIT2_LOC1:@.*]] = private unnamed_addr global {{.*}} i32 707, i32 26 +// CHECK: [[NONNULL_INIT2_LOC2:@.*]] = private unnamed_addr global {{.*}} i32 707, i32 29 +// CHECK: [[NONNULL_RV_LOC2:@.*]] = private unnamed_addr global {{.*}} i32 817, i32 1 {{.*}} i32 800, i32 6 + +#define NULL ((void *)0) + +// CHECK-LABEL: define i32* @nonnull_retval1 +#line 100 +int *_Nonnull nonnull_retval1(int *p) { + // CHECK: br i1 true, label %[[NULL:.*]], label %[[NONULL:.*]], !nosanitize + // CHECK: [[NULL]]: + // CHECK: [[ICMP:%.*]] = icmp ne i32* {{.*}}, null, !nosanitize + // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize + // CHECK: call void @__ubsan_handle_nonnull_return{{.*}}[[NONNULL_RV_LOC1]] + return p; + // CHECK: [[NONULL]]: + // CHECK-NEXT: ret i32* +} + +#line 190 +void nonnull_arg(int *_Nonnull p) {} + +// CHECK-LABEL: define void @call_func_with_nonnull_arg +#line 200 +void call_func_with_nonnull_arg(int *_Nonnull p) { + // CHECK: [[ICMP:%.*]] = icmp ne i32* {{.*}}, null, !nosanitize + // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize + // CHECK: call void @__ubsan_handle_nonnull_arg{{.*}}[[NONNULL_ARG_LOC]] + nonnull_arg(p); +} + +// CHECK-LABEL: define void @nonnull_assign1 +#line 300 +void nonnull_assign1(int *p) { + // CHECK: [[ICMP:%.*]] = icmp ne i32* {{.*}}, null, !nosanitize + // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize + // CHECK: call void @__ubsan_handle_type_mismatch{{.*}}[[NONNULL_ASSIGN1_LOC]] + int *_Nonnull local; + local = p; +} + +// CHECK-LABEL: define void @nonnull_assign2 +#line 400 +void nonnull_assign2(int *p) { + // CHECK: [[ICMP:%.*]] = icmp ne i32* %{{.*}}, null, !nosanitize + // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize + // CHECK: call void @__ubsan_handle_type_mismatch{{.*}}[[NONNULL_ASSIGN2_LOC]] + int *_Nonnull arr[1]; + arr[0] = p; +} + +struct S1 { + int *_Nonnull mptr; +}; + +// CHECK-LABEL: define void @nonnull_assign3 +#line 500 +void nonnull_assign3(int *p) { + // CHECK: [[ICMP:%.*]] = icmp ne i32* %{{.*}}, null, !nosanitize + // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize + // CHECK: call void @__ubsan_handle_type_mismatch{{.*}}[[NONNULL_ASSIGN3_LOC]] + struct S1 s; + s.mptr = p; +} + +// CHECK-LABEL: define void @nonnull_init1 +#line 600 +void nonnull_init1(int *p) { + // CHECK: [[ICMP:%.*]] = icmp ne i32* %{{.*}}, null, !nosanitize + // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize + // CHECK: call void @__ubsan_handle_type_mismatch{{.*}}[[NONNULL_INIT1_LOC]] + int *_Nonnull local = p; +} + +// CHECK-LABEL: define void @nonnull_init2 +#line 700 +void nonnull_init2(int *p) { + // CHECK: [[ICMP:%.*]] = icmp ne i32* %{{.*}}, null, !nosanitize + // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize + // CHECK: call void @__ubsan_handle_type_mismatch{{.*}}[[NONNULL_INIT2_LOC1]] + // CHECK: [[ICMP:%.*]] = icmp ne i32* %{{.*}}, null, !nosanitize + // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize + // CHECK: call void @__ubsan_handle_type_mismatch{{.*}}[[NONNULL_INIT2_LOC2]] + int *_Nonnull arr[] = {p, p}; +} + +// CHECK-LABEL: define i32* @nonnull_retval2 +#line 800 +int *_Nonnull nonnull_retval2(int *_Nonnull arg1, //< Test this. + int *_Nonnull arg2, //< Test this. + int *_Nullable arg3, //< Don't test the rest. + int *arg4, + int arg5, ...) { +
[PATCH] D26796: [Driver] Use arch type to find compiler-rt libraries (on Linux)
mgorny added a comment. Another ping. Since 4.0.0 final has been tagged, I think we should get back to working on this. @compnerd, any suggestion how to proceed here? https://reviews.llvm.org/D26796 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29851: [clang-tools-extra] [test] Fix test dependencies when using installed tools
mgorny added a comment. PIng. Repository: rL LLVM https://reviews.llvm.org/D29851 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30155: [clang-tools-extra] [test] Fix clang library dir in LD_LIBRARY_PATH For stand-alone build
mgorny added a comment. Ping. Repository: rL LLVM https://reviews.llvm.org/D30155 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used
mgorny marked 5 inline comments as done. mgorny added a comment. A gentle ping. https://reviews.llvm.org/D29542 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24921: [cfe] [Headers] Fix inttypes.h macros visibility in C++ with C99-compliant libc
mgorny added a comment. Ping II. https://reviews.llvm.org/D24921 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r297497 - Attempt to fix Windows buildbot.
Author: gkistanova Date: Fri Mar 10 13:34:15 2017 New Revision: 297497 URL: http://llvm.org/viewvc/llvm-project?rev=297497&view=rev Log: Attempt to fix Windows buildbot. Modified: cfe/trunk/test/Modules/dependency-dump-dependent-module.m cfe/trunk/test/Modules/dependency-dump.m Modified: cfe/trunk/test/Modules/dependency-dump-dependent-module.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-dump-dependent-module.m?rev=297497&r1=297496&r2=297497&view=diff == --- cfe/trunk/test/Modules/dependency-dump-dependent-module.m (original) +++ cfe/trunk/test/Modules/dependency-dump-dependent-module.m Fri Mar 10 13:34:15 2017 @@ -1,6 +1,8 @@ // When a module depends on another, check that we dump the dependency header // files for both. +// REQUIRES: shell + // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -module-dependency-dir %t/vfs -F %S/Inputs -I %S/Inputs -verify %s // expected-no-diagnostics Modified: cfe/trunk/test/Modules/dependency-dump.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-dump.m?rev=297497&r1=297496&r2=297497&view=diff == --- cfe/trunk/test/Modules/dependency-dump.m (original) +++ cfe/trunk/test/Modules/dependency-dump.m Fri Mar 10 13:34:15 2017 @@ -1,6 +1,8 @@ // Check that we can dump all of the headers a module depends on, and a VFS map // for the same. +// REQUIRES: shell + // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -module-dependency-dir %t/vfs -F %S/Inputs -I %S/Inputs -verify %s // expected-no-diagnostics ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30841: [clang-tidy] readability-misleading-indentation: fix chained if
fgross created this revision. Herald added a subscriber: JDevlieghere. Fixed erroneously flagging of chained if statements when styled like this: if (cond) { } else if (cond) { } else { } https://reviews.llvm.org/D30841 Files: clang-tidy/readability/MisleadingIndentationCheck.cpp clang-tidy/readability/MisleadingIndentationCheck.h test/clang-tidy/readability-misleading-indentation.cpp Index: test/clang-tidy/readability-misleading-indentation.cpp === --- test/clang-tidy/readability-misleading-indentation.cpp +++ test/clang-tidy/readability-misleading-indentation.cpp @@ -76,5 +76,31 @@ { } + if(cond1) { + } + else if (cond2) { + } + else { + } + + if(cond1) { + } + else if (cond2) { + } + else { + } + // CHECK-MESSAGES: :[[@LINE-2]]:8: warning: different indentation for 'if' and corresponding 'else' [readability-misleading-indentation] + + if (cond1) { +if (cond1) { +} +else if (cond2) { +} +else { +} + } + else if (cond2) { + } + BLOCK } Index: clang-tidy/readability/MisleadingIndentationCheck.h === --- clang-tidy/readability/MisleadingIndentationCheck.h +++ clang-tidy/readability/MisleadingIndentationCheck.h @@ -11,6 +11,7 @@ #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_MISLEADING_INDENTATION_H #include "../ClangTidy.h" +#include namespace clang { namespace tidy { @@ -32,6 +33,10 @@ private: void danglingElseCheck(const SourceManager &SM, const IfStmt *If); void missingBracesCheck(const SourceManager &SM, const CompoundStmt *CStmt); + + /// Key: Chained If + /// Value: Preceding If + std::map ChainedIfs; }; } // namespace readability Index: clang-tidy/readability/MisleadingIndentationCheck.cpp === --- clang-tidy/readability/MisleadingIndentationCheck.cpp +++ clang-tidy/readability/MisleadingIndentationCheck.cpp @@ -25,10 +25,20 @@ if (IfLoc.isMacroID() || ElseLoc.isMacroID()) return; + if (const auto *ChainedIf = dyn_cast(If->getElse())) { +if (SM.getExpansionLineNumber(ElseLoc) == +SM.getExpansionLineNumber(ChainedIf->getIfLoc())) + ChainedIfs.emplace(ChainedIf, If); + } + if (SM.getExpansionLineNumber(If->getThen()->getLocEnd()) == SM.getExpansionLineNumber(ElseLoc)) return; + for (auto Iter = ChainedIfs.find(If); Iter != ChainedIfs.end(); + Iter = ChainedIfs.find(Iter->second)) +IfLoc = Iter->second->getIfLoc(); + if (SM.getExpansionColumnNumber(IfLoc) != SM.getExpansionColumnNumber(ElseLoc)) diag(ElseLoc, "different indentation for 'if' and corresponding 'else'"); Index: test/clang-tidy/readability-misleading-indentation.cpp === --- test/clang-tidy/readability-misleading-indentation.cpp +++ test/clang-tidy/readability-misleading-indentation.cpp @@ -76,5 +76,31 @@ { } + if(cond1) { + } + else if (cond2) { + } + else { + } + + if(cond1) { + } + else if (cond2) { + } + else { + } + // CHECK-MESSAGES: :[[@LINE-2]]:8: warning: different indentation for 'if' and corresponding 'else' [readability-misleading-indentation] + + if (cond1) { +if (cond1) { +} +else if (cond2) { +} +else { +} + } + else if (cond2) { + } + BLOCK } Index: clang-tidy/readability/MisleadingIndentationCheck.h === --- clang-tidy/readability/MisleadingIndentationCheck.h +++ clang-tidy/readability/MisleadingIndentationCheck.h @@ -11,6 +11,7 @@ #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_MISLEADING_INDENTATION_H #include "../ClangTidy.h" +#include namespace clang { namespace tidy { @@ -32,6 +33,10 @@ private: void danglingElseCheck(const SourceManager &SM, const IfStmt *If); void missingBracesCheck(const SourceManager &SM, const CompoundStmt *CStmt); + + /// Key: Chained If + /// Value: Preceding If + std::map ChainedIfs; }; } // namespace readability Index: clang-tidy/readability/MisleadingIndentationCheck.cpp === --- clang-tidy/readability/MisleadingIndentationCheck.cpp +++ clang-tidy/readability/MisleadingIndentationCheck.cpp @@ -25,10 +25,20 @@ if (IfLoc.isMacroID() || ElseLoc.isMacroID()) return; + if (const auto *ChainedIf = dyn_cast(If->getElse())) { +if (SM.getExpansionLineNumber(ElseLoc) == +SM.getExpansionLineNumber(ChainedIf->getIfLoc())) + ChainedIfs.emplace(ChainedIf, If); + } + if (SM.getExpansionLineNumber(If->getThen()->getLocEnd()) == SM.getExpansionLineNumber(ElseLoc)) return; + for (auto Iter = ChainedIfs.find(If); Iter != ChainedIfs.end(); + Iter = ChainedIfs.find(Iter->second)) +IfLoc = Iter->second->
[PATCH] D30283: [ubsan] Reduce alignment checking of C++ object pointers
vsk added a reviewer: rsmith. vsk added a comment. Ping. I appreciate that there are a lot of test changes to sift through here -- please let me know if I can make the patch easier to review in any way. https://reviews.llvm.org/D30283 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30837: [libcxx] Support for shared_ptr
erik.pilkington updated this revision to Diff 91385. erik.pilkington added a comment. This new patch replaces the allocator from `allocator` to `allocator`, I didn't realize `allocator` was deprecated. Thanks, Erik https://reviews.llvm.org/D30837 Files: include/memory test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp === --- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp +++ test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp @@ -45,6 +45,9 @@ virtual ~Foo() = default; }; +struct Result {}; +void resultDeletor(Result (*)()) {} +Result theFunction() { return Result(); } int main() { @@ -65,7 +68,9 @@ std::shared_ptr p2 = std::make_shared(); assert(p2.get()); } - +{ // https://bugs.llvm.org/show_bug.cgi?id=27566 + std::shared_ptr x(&theFunction, &resultDeletor); +} #if TEST_STD_VER >= 11 nc = globalMemCounter.outstanding_new; { Index: include/memory === --- include/memory +++ include/memory @@ -3884,8 +3884,7 @@ } } -_LIBCPP_INLINE_VISIBILITY -void __enable_weak_this(const volatile void*, const volatile void*) _NOEXCEPT {} +_LIBCPP_INLINE_VISIBILITY void __enable_weak_this(...) _NOEXCEPT {} template friend class _LIBCPP_TEMPLATE_VIS shared_ptr; template friend class _LIBCPP_TEMPLATE_VIS weak_ptr; @@ -3916,8 +3915,8 @@ : __ptr_(__p) { unique_ptr<_Yp> __hold(__p); -typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator<_Yp>()); +typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator()); __hold.release(); __enable_weak_this(__p, __p); } @@ -3932,8 +3931,8 @@ try { #endif // _LIBCPP_NO_EXCEPTIONS -typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__p, __d, allocator<_Yp>()); +typedef __shared_ptr_pointer<_Yp*, _Dp, allocator > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__p, __d, allocator()); __enable_weak_this(__p, __p); #ifndef _LIBCPP_NO_EXCEPTIONS } @@ -3954,8 +3953,8 @@ try { #endif // _LIBCPP_NO_EXCEPTIONS -typedef __shared_ptr_pointer > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__p, __d, allocator<_Tp>()); +typedef __shared_ptr_pointer > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__p, __d, allocator()); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) @@ -4094,8 +4093,8 @@ typename enable_if::value, __nat>::type) : __ptr_(__r.get()) { -typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>()); +typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator()); __enable_weak_this(__r.get(), __r.get()); __r.release(); } @@ -4123,8 +4122,8 @@ else #endif { -typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>()); +typedef __shared_ptr_pointer<_Yp*, _Dp, allocator > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator()); __enable_weak_this(__r.get(), __r.get()); } __r.release(); @@ -4154,8 +4153,8 @@ { typedef __shared_ptr_pointer<_Yp*, reference_wrapper::type>, - allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator<_Yp>()); + allocator > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator()); __enable_weak_this(__r.get(), __r.get()); } __r.release(); @@ -4168,12 +4167,13 @@ shared_ptr<_Tp> shared_ptr<_Tp>::make_shared(_Args&& ...__args) { -typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; +typedef __shared_ptr_emplace<_Tp, allocator > _CntrlBlk; typedef allocator<_CntrlBlk> _A2; typedef __allocator_destructor<_A2> _D2; _A2 __a2; unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); -::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...); +::new(__hold2.get()) _CntrlBlk(allocator(), +
[PATCH] D27387: [libc++] Add a key function for bad_function_call
smeenai added a comment. Ping. https://reviews.llvm.org/D27387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r297468 - [OpenCL] Fix type compatibility check and generic AS mangling.
Hello Anastasia, Added test fails on one of our new builders: Failing Tests (1): Clang :: SemaOpenCL/overload_addrspace_resolution.cl http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/23/steps/test-check-all/logs/stdio Please have a look at it? Thanks Galina On Fri, Mar 10, 2017 at 7:23 AM, Anastasia Stulova via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: stulova > Date: Fri Mar 10 09:23:07 2017 > New Revision: 297468 > > URL: http://llvm.org/viewvc/llvm-project?rev=297468&view=rev > Log: > [OpenCL] Fix type compatibility check and generic AS mangling. > > 1. Reimplemented conditional operator so that it checks > compatibility of unqualified pointees of the 2nd and > the 3rd operands (C99, OpenCL v2.0 6.5.15). > > Define QualTypes compatibility for OpenCL as following: > >- corresponding types are compatible (C99 6.7.3) >- CVR-qualifiers are equal (C99 6.7.3) >- address spaces are equal (implementation defined) > > 2. Added generic address space to Itanium mangling. > > Review: D30037 > > Patch by Dmitry Borisenkov! > > > Added: > cfe/trunk/test/SemaOpenCL/overload_addrspace_resolution.cl > Modified: > cfe/trunk/lib/AST/ASTContext.cpp > cfe/trunk/lib/AST/ItaniumMangle.cpp > cfe/trunk/lib/Sema/SemaExpr.cpp > cfe/trunk/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl > > Modified: cfe/trunk/lib/AST/ASTContext.cpp > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ > ASTContext.cpp?rev=297468&r1=297467&r2=297468&view=diff > > == > --- cfe/trunk/lib/AST/ASTContext.cpp (original) > +++ cfe/trunk/lib/AST/ASTContext.cpp Fri Mar 10 09:23:07 2017 > @@ -8066,15 +8066,6 @@ QualType ASTContext::mergeTypes(QualType >Qualifiers LQuals = LHSCan.getLocalQualifiers(); >Qualifiers RQuals = RHSCan.getLocalQualifiers(); >if (LQuals != RQuals) { > -if (getLangOpts().OpenCL) { > - if (LHSCan.getUnqualifiedType() != RHSCan.getUnqualifiedType() || > - LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers()) > -return QualType(); > - if (LQuals.isAddressSpaceSupersetOf(RQuals)) > -return LHS; > - if (RQuals.isAddressSpaceSupersetOf(LQuals)) > -return RHS; > -} > // If any of these qualifiers are different, we have a type > // mismatch. > if (LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers() || > @@ -8200,6 +8191,20 @@ QualType ASTContext::mergeTypes(QualType >LHSPointee = LHSPointee.getUnqualifiedType(); >RHSPointee = RHSPointee.getUnqualifiedType(); > } > +if (getLangOpts().OpenCL) { > + Qualifiers LHSPteeQual = LHSPointee.getQualifiers(); > + Qualifiers RHSPteeQual = RHSPointee.getQualifiers(); > + // Blocks can't be an expression in a ternary operator (OpenCL v2.0 > + // 6.12.5) thus the following check is asymmetric. > + if (!LHSPteeQual.isAddressSpaceSupersetOf(RHSPteeQual)) > +return QualType(); > + LHSPteeQual.removeAddressSpace(); > + RHSPteeQual.removeAddressSpace(); > + LHSPointee = > + QualType(LHSPointee.getTypePtr(), > LHSPteeQual.getAsOpaqueValue()); > + RHSPointee = > + QualType(RHSPointee.getTypePtr(), > RHSPteeQual.getAsOpaqueValue()); > +} > QualType ResultType = mergeTypes(LHSPointee, RHSPointee, > OfBlockPointer, > Unqualified); > if (ResultType.isNull()) return QualType(); > > Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ > ItaniumMangle.cpp?rev=297468&r1=297467&r2=297468&view=diff > > == > --- cfe/trunk/lib/AST/ItaniumMangle.cpp (original) > +++ cfe/trunk/lib/AST/ItaniumMangle.cpp Fri Mar 10 09:23:07 2017 > @@ -2159,10 +2159,12 @@ void CXXNameMangler::mangleQualifiers(Qu > } else { >switch (AS) { >default: llvm_unreachable("Not a language specific address space"); > - // ::= "CL" [ "global" | "local" | "constant" ] > + // ::= "CL" [ "global" | "local" | "constant | > + //"generic" ] >case LangAS::opencl_global: ASString = "CLglobal"; break; >case LangAS::opencl_local:ASString = "CLlocal";break; >case LangAS::opencl_constant: ASString = "CLconstant"; break; > + case LangAS::opencl_generic: ASString = "CLgeneric"; break; >// ::= "CU" [ "device" | "constant" | "shared" ] >case LangAS::cuda_device: ASString = "CUdevice"; break; >case LangAS::cuda_constant: ASString = "CUconstant"; break; > > Modified: cfe/trunk/lib/Sema/SemaExpr.cpp > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ > SemaExpr.cpp?rev=297468&r1=297467&r2=297468&view=diff > > ===
[PATCH] D30768: [PATCH][VFS] Ignore broken symlinks in the directory iterator.
bruno accepted this revision. bruno added inline comments. This revision is now accepted and ready to land. Comment at: lib/Basic/VirtualFileSystem.cpp:1873 vfs::directory_iterator I = FS->dir_begin(State->top()->getName(), EC); -if (EC) +if (EC && EC != std::errc::no_such_file_or_directory) return *this; ributzka wrote: > bruno wrote: > > Can you add a comment explaining why you are doing it? I would prefer if we > > reset the `EC` state here than having the callers ignoring `EC` results. > If we reset the EC here, then the caller won't know that there was an issue. > The idea is that we still want the caller to check EC. It should be up to the > caller to decide how to act on this particular error. > > I guess since the caller has to check for the error anyway I could even > remove this check completely and not check EC at all here. Right, this should be fine with the latest changes and per discussions offline. LGTM https://reviews.llvm.org/D30768 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30768: [PATCH][VFS] Ignore broken symlinks in the directory iterator.
This revision was automatically updated to reflect the committed changes. Closed by commit rL297510: [VFS] Ignore broken symlinks in the directory iterator. (authored by ributzka). Changed prior to commit: https://reviews.llvm.org/D30768?vs=91371&id=91403#toc Repository: rL LLVM https://reviews.llvm.org/D30768 Files: cfe/trunk/include/clang/Basic/VirtualFileSystem.h cfe/trunk/lib/Basic/VirtualFileSystem.cpp cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Index: cfe/trunk/include/clang/Basic/VirtualFileSystem.h === --- cfe/trunk/include/clang/Basic/VirtualFileSystem.h +++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h @@ -161,7 +161,7 @@ directory_iterator &increment(std::error_code &EC) { assert(Impl && "attempting to increment past end"); EC = Impl->increment(); -if (EC || !Impl->CurrentEntry.isStatusKnown()) +if (!Impl->CurrentEntry.isStatusKnown()) Impl.reset(); // Normalize the end iterator to Impl == nullptr. return *this; } Index: cfe/trunk/lib/Basic/VirtualFileSystem.cpp === --- cfe/trunk/lib/Basic/VirtualFileSystem.cpp +++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp @@ -246,8 +246,7 @@ if (!EC && Iter != llvm::sys::fs::directory_iterator()) { llvm::sys::fs::file_status S; EC = Iter->status(S); - if (!EC) -CurrentEntry = Status::copyWithNewName(S, Iter->path()); + CurrentEntry = Status::copyWithNewName(S, Iter->path()); } } @@ -1858,7 +1857,7 @@ std::error_code &EC) : FS(&FS_) { directory_iterator I = FS->dir_begin(Path, EC); - if (!EC && I != directory_iterator()) { + if (I != directory_iterator()) { State = std::make_shared(); State->push(I); } @@ -1871,8 +1870,6 @@ vfs::directory_iterator End; if (State->top()->isDirectory()) { vfs::directory_iterator I = FS->dir_begin(State->top()->getName(), EC); -if (EC) - return *this; if (I != End) { State->push(I); return *this; Index: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp === --- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp +++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp @@ -305,6 +305,22 @@ } operator StringRef() { return Path.str(); } }; + +struct ScopedLink { + SmallString<128> Path; + ScopedLink(const Twine &To, const Twine &From) { +Path = From.str(); +std::error_code EC = sys::fs::create_link(To, From); +if (EC) + Path = ""; +EXPECT_FALSE(EC); + } + ~ScopedLink() { +if (Path != "") + EXPECT_FALSE(llvm::sys::fs::remove(Path.str())); + } + operator StringRef() { return Path.str(); } +}; } // end anonymous namespace TEST(VirtualFileSystemTest, BasicRealFSIteration) { @@ -334,6 +350,35 @@ EXPECT_EQ(vfs::directory_iterator(), I); } +TEST(VirtualFileSystemTest, BrokenSymlinkRealFSIteration) { + ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/ true); + IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); + + ScopedLink _a("no_such_file", TestDirectory + "/a"); + ScopedDir _b(TestDirectory + "/b"); + ScopedLink _c("no_such_file", TestDirectory + "/c"); + + std::error_code EC; + vfs::directory_iterator I = FS->dir_begin(Twine(TestDirectory), EC); + EXPECT_TRUE(EC); + EXPECT_NE(vfs::directory_iterator(), I); + EC = std::error_code(); + EXPECT_TRUE(I->getName() == _a); + I.increment(EC); + EXPECT_FALSE(EC); + EXPECT_NE(vfs::directory_iterator(), I); + EXPECT_TRUE(I->getName() == _b); + I.increment(EC); + EXPECT_TRUE(EC); + EXPECT_NE(vfs::directory_iterator(), I); + EC = std::error_code(); + EXPECT_NE(vfs::directory_iterator(), I); + EXPECT_TRUE(I->getName() == _c); + I.increment(EC); + EXPECT_FALSE(EC); + EXPECT_EQ(vfs::directory_iterator(), I); +} + TEST(VirtualFileSystemTest, BasicRealFSRecursiveIteration) { ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/true); IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); @@ -373,6 +418,44 @@ EXPECT_EQ(1, Counts[3]); // d } +TEST(VirtualFileSystemTest, BrokenSymlinkRealFSRecursiveIteration) { + ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/ true); + IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); + + ScopedLink _a("no_such_file", TestDirectory + "/a"); + ScopedDir _b(TestDirectory + "/b"); + ScopedLink _ba("no_such_file", TestDirectory + "/b/a"); + ScopedDir _bb(TestDirectory + "/b/b"); + ScopedLink _bc("no_such_file", TestDirectory + "/b/c"); + ScopedLink _c("no_such_file", TestDirectory + "/c"); + ScopedDir _d(TestDirectory + "/d"); + ScopedDir _dd(TestDirectory + "/d/d"); + ScopedDir _ddd(TestDirectory + "/d/d/d"); + ScopedLink _e("no_such_file", TestDirectory + "/e"); + + std::vector Contents; + std::error_code EC; + for (vfs::recur
[PATCH] D30768: [PATCH][VFS] Ignore broken symlinks in the directory iterator.
ributzka added a comment. Thanks Bruno. Committed in r297510. Repository: rL LLVM https://reviews.llvm.org/D30768 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30845: Fix array sizes where address space is not yet known
kzhuravl created this revision. Herald added a subscriber: wdng. For variables in generic address spaces, for example: unsigned char V[6442450944]; ... the address space is not yet known when we get into *getConstantArrayType*, it is 0. AMDGCN target's address space 0 has 32 bits pointers, so when we call *getPointerWidth* with 0, the array size is trimmed to 32 bits, which is not right. https://reviews.llvm.org/D30845 Files: include/clang/Basic/TargetInfo.h lib/AST/ASTContext.cpp lib/Basic/Targets.cpp test/CodeGenOpenCL/amdgcn-large-globals.cl Index: test/CodeGenOpenCL/amdgcn-large-globals.cl === --- test/CodeGenOpenCL/amdgcn-large-globals.cl +++ test/CodeGenOpenCL/amdgcn-large-globals.cl @@ -0,0 +1,12 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -cl-std=CL2.0 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s + +// CHECK: @One = common local_unnamed_addr addrspace(1) global [6442450944 x i8] zeroinitializer, align 1 +unsigned char One[6442450944]; +// CHECK: @Two = common local_unnamed_addr addrspace(1) global [6442450944 x i32] zeroinitializer, align 4 +global unsigned int Two[6442450944]; + +kernel void large_globals(unsigned int id) { + One[id] = id; + Two[id + 1] = id + 1; +} Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -2084,6 +2084,10 @@ } } + uint64_t getPreferredPointerWidth(unsigned AddrSpace) const override { +return 64; + } + uint64_t getMaxPointerWidth() const override { return getTriple().getArch() == llvm::Triple::amdgcn ? 64 : 32; } Index: lib/AST/ASTContext.cpp === --- lib/AST/ASTContext.cpp +++ lib/AST/ASTContext.cpp @@ -2692,8 +2692,8 @@ // Convert the array size into a canonical width matching the pointer size for // the target. llvm::APInt ArySize(ArySizeIn); - ArySize = -ArySize.zextOrTrunc(Target->getPointerWidth(getTargetAddressSpace(EltTy))); + ArySize = ArySize.zextOrTrunc( + Target->getPreferredPointerWidth(getTargetAddressSpace(EltTy))); llvm::FoldingSetNodeID ID; ConstantArrayType::Profile(ID, EltTy, ArySize, ASM, IndexTypeQuals); Index: include/clang/Basic/TargetInfo.h === --- include/clang/Basic/TargetInfo.h +++ include/clang/Basic/TargetInfo.h @@ -296,6 +296,13 @@ return AddrSpace == 0 ? PointerAlign : getPointerAlignV(AddrSpace); } + /// \brief Return the "preferred" width of pointers on this target, for the + /// specified address space. This can be different from "getPointerWidth" in + /// cases where the final address space is not yet known. + virtual uint64_t getPreferredPointerWidth(unsigned AddrSpace) const { +return getPointerWidth(AddrSpace); + } + /// \brief Return the maximum width of pointers on this target. virtual uint64_t getMaxPointerWidth() const { return PointerWidth; Index: test/CodeGenOpenCL/amdgcn-large-globals.cl === --- test/CodeGenOpenCL/amdgcn-large-globals.cl +++ test/CodeGenOpenCL/amdgcn-large-globals.cl @@ -0,0 +1,12 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -cl-std=CL2.0 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s + +// CHECK: @One = common local_unnamed_addr addrspace(1) global [6442450944 x i8] zeroinitializer, align 1 +unsigned char One[6442450944]; +// CHECK: @Two = common local_unnamed_addr addrspace(1) global [6442450944 x i32] zeroinitializer, align 4 +global unsigned int Two[6442450944]; + +kernel void large_globals(unsigned int id) { + One[id] = id; + Two[id + 1] = id + 1; +} Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -2084,6 +2084,10 @@ } } + uint64_t getPreferredPointerWidth(unsigned AddrSpace) const override { +return 64; + } + uint64_t getMaxPointerWidth() const override { return getTriple().getArch() == llvm::Triple::amdgcn ? 64 : 32; } Index: lib/AST/ASTContext.cpp === --- lib/AST/ASTContext.cpp +++ lib/AST/ASTContext.cpp @@ -2692,8 +2692,8 @@ // Convert the array size into a canonical width matching the pointer size for // the target. llvm::APInt ArySize(ArySizeIn); - ArySize = -ArySize.zextOrTrunc(Target->getPointerWidth(getTargetAddressSpace(EltTy))); + ArySize = ArySize.zextOrTrunc( + Target->getPreferredPointerWidth(getTargetAddressSpace(EltTy))); llvm::FoldingSetNodeID ID; ConstantArrayType::Profile(ID, EltTy, ArySize, ASM, IndexTypeQuals); Index: include/clang/Basic/TargetInfo.h === ---
[PATCH] D30845: Fix array sizes where address space is not yet known
kzhuravl added a comment. I am not sure if this is the right way to fix it. https://reviews.llvm.org/D30845 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26953: clang-format: handle formatting on constexpr if
outcoldman added a comment. The actual problem is with that clang-format does not know anything about c++17 features, because it does not set it in lang options. Not sure if that will fix constexpr problem as well, but I could solve some other problems with tools/clang ✓ 13:45:12 ╰─ svn diff Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp (revision 297506) +++ lib/Format/Format.cpp (working copy) @@ -1893,6 +1893,7 @@ LangOpts.CPlusPlus = 1; LangOpts.CPlusPlus11 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1; LangOpts.CPlusPlus14 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1; + LangOpts.CPlusPlus1z = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1; LangOpts.LineComment = 1; bool AlternativeOperators = Style.IsCpp(); LangOpts.CXXOperatorNames = AlternativeOperators ? 1 : 0; https://reviews.llvm.org/D26953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30837: [libcxx] Support for shared_ptr
Quuxplusone added a comment. I notice that the Standard implies that std::unique_ptr will work only with *object types* T, and yet the "object" wording is missing from shared_ptr. > A unique pointer is an object that owns another *object* and manages that > other *object* through a pointer. > The shared_ptr class template stores a *pointer*, usually obtained via new. > shared_ptr implements semantics of shared ownership; the last remaining owner > of the pointer is responsible for destroying the object, *or otherwise > releasing the resources associated with the stored pointer.* So it does seem like shared_ptr should work and should store a T(*)(). And it does seem that unique_ptr should continue to not-work... but maybe there's a useful vendor extension or standards proposal to be made in that area. Comment at: include/memory:4209 { -typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; +typedef __shared_ptr_emplace<_Tp, allocator > _CntrlBlk; typedef allocator<_CntrlBlk> _Alloc2; IIUC, you don't need to touch make_shared. I doubt these changes are truly harmful, but I don't understand what meaning we're trying to assign to things like auto a = std::make_shared(); auto b = std::make_shared(myFunction); It seems like the effect of this change is just to mess with anyone who's explicitly specializing std::allocator to make its ::rebind member do something wacky. In which case I'd say they've got it coming to them... but the effect of this change doesn't seem relevant to the purpose described in your commit message. :) Comment at: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp:49 +struct Result {}; +void resultDeletor(Result (*)()) {} +Result theFunction() { return Result(); } Could you plausibly make this void resultDeleter(Result (*f)()) { assert(f == theFunction); } for extra sanity checking? For super-duper checking, touch a global variable in `resultDeleter` so that you can verify that the deleter was actually called. This might reasonably be perceived as overkill. :) Comment at: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp:72 +{ // https://bugs.llvm.org/show_bug.cgi?id=27566 + std::shared_ptr x(&theFunction, &resultDeletor); +} Presumably this should also compile without the explicit `&`s, right? Might be worth adding std::shared_ptr y(theFunction, resultDeleter); in addition to your existing test case, just to make sure that omitting the `&` doesn't mess up the template deduction somehow. IIUC, it would never make sense to write something like auto z = std::make_shared(theFunction); so that part doesn't need testing, right? https://reviews.llvm.org/D30837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30848: Implement DR 373 "Lookup on namespace qualified name in using-directive"
mgehre created this revision. 3.4.6 [basic.lookup.udir] paragraph 1: In a using-directive or namespace-alias-definition, during the lookup for a namespace-name or for a name in a nested-name-specifier, only namespace names are considered. https://reviews.llvm.org/D30848 Files: include/clang/Parse/Parser.h include/clang/Sema/Sema.h lib/Parse/ParseDeclCXX.cpp lib/Parse/ParseExprCXX.cpp lib/Sema/SemaCXXScopeSpec.cpp test/CXX/drs/dr3xx.cpp www/cxx_dr_status.html Index: www/cxx_dr_status.html === --- www/cxx_dr_status.html +++ www/cxx_dr_status.html @@ -2279,7 +2279,7 @@ http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#373";>373 C++11 Lookup on namespace qualified name in using-directive -No +Yes http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#374";>374 Index: test/CXX/drs/dr3xx.cpp === --- test/CXX/drs/dr3xx.cpp +++ test/CXX/drs/dr3xx.cpp @@ -908,15 +908,14 @@ } } -namespace dr373 { // dr373: no - // FIXME: This is valid. - namespace X { int dr373; } // expected-note 2{{here}} +namespace dr373 { // dr373: yes + namespace X { int dr373; } struct dr373 { // expected-note {{here}} void f() { - using namespace dr373::X; // expected-error {{no namespace named 'X' in 'dr373::dr373'}} + using namespace dr373::X; int k = dr373; // expected-error {{does not refer to a value}} - namespace Y = dr373::X; // expected-error {{no namespace named 'X' in 'dr373::dr373'}} + namespace Y = dr373::X; k = Y::dr373; } }; Index: lib/Sema/SemaCXXScopeSpec.cpp === --- lib/Sema/SemaCXXScopeSpec.cpp +++ lib/Sema/SemaCXXScopeSpec.cpp @@ -461,6 +461,7 @@ ///are allowed. The bool value pointed by this parameter is set to /// 'true' if the identifier is treated as if it was followed by ':', ///not '::'. +/// \param OnlyNamespace If true, only considers namespaces in lookup. /// /// This routine differs only slightly from ActOnCXXNestedNameSpecifier, in /// that it contains an extra parameter \p ScopeLookupResult, which provides @@ -479,9 +480,15 @@ CXXScopeSpec &SS, NamedDecl *ScopeLookupResult, bool ErrorRecoveryLookup, - bool *IsCorrectedToColon) { + bool *IsCorrectedToColon, + bool OnlyNamespace) { + + Sema::LookupNameKind LNameKind = LookupNestedNameSpecifierName; + if (OnlyNamespace) +LNameKind = LookupNamespaceName; + LookupResult Found(*this, IdInfo.Identifier, IdInfo.IdentifierLoc, - LookupNestedNameSpecifierName); + LNameKind); QualType ObjectType = GetTypeFromParser(IdInfo.ObjectType); // Determine where to perform name lookup @@ -824,14 +831,16 @@ bool EnteringContext, CXXScopeSpec &SS, bool ErrorRecoveryLookup, - bool *IsCorrectedToColon) { + bool *IsCorrectedToColon, + bool OnlyNamespace) { if (SS.isInvalid()) return true; return BuildCXXNestedNameSpecifier(S, IdInfo, EnteringContext, SS, /*ScopeLookupResult=*/nullptr, false, - IsCorrectedToColon); + IsCorrectedToColon, + OnlyNamespace); } bool Sema::ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS, Index: lib/Parse/ParseExprCXX.cpp === --- lib/Parse/ParseExprCXX.cpp +++ lib/Parse/ParseExprCXX.cpp @@ -141,13 +141,16 @@ /// filled in with the leading identifier in the last component of the /// nested-name-specifier, if any. /// +/// \param OnlyNamespace If true, only considers namespaces in lookup. +/// /// \returns true if there was an error parsing a scope specifier bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, ParsedType ObjectType, bool EnteringContext, bool *MayBePseudoDestructor, bool IsTypename, -IdentifierInfo **LastII) { +IdentifierInfo **LastII, +bool OnlyNamespace) { assert(getLangOpts().CPlusPlus && "Call si
[PATCH] D30848: Implement DR 373 "Lookup on namespace qualified name in using-directive"
mgehre updated this revision to Diff 91418. mgehre added a comment. clang-format https://reviews.llvm.org/D30848 Files: include/clang/Parse/Parser.h include/clang/Sema/Sema.h lib/Parse/ParseDeclCXX.cpp lib/Parse/ParseExprCXX.cpp lib/Sema/SemaCXXScopeSpec.cpp test/CXX/drs/dr3xx.cpp www/cxx_dr_status.html Index: www/cxx_dr_status.html === --- www/cxx_dr_status.html +++ www/cxx_dr_status.html @@ -2279,7 +2279,7 @@ http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#373";>373 C++11 Lookup on namespace qualified name in using-directive -No +Yes http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#374";>374 Index: test/CXX/drs/dr3xx.cpp === --- test/CXX/drs/dr3xx.cpp +++ test/CXX/drs/dr3xx.cpp @@ -908,15 +908,14 @@ } } -namespace dr373 { // dr373: no - // FIXME: This is valid. - namespace X { int dr373; } // expected-note 2{{here}} +namespace dr373 { // dr373: yes + namespace X { int dr373; } struct dr373 { // expected-note {{here}} void f() { - using namespace dr373::X; // expected-error {{no namespace named 'X' in 'dr373::dr373'}} + using namespace dr373::X; int k = dr373; // expected-error {{does not refer to a value}} - namespace Y = dr373::X; // expected-error {{no namespace named 'X' in 'dr373::dr373'}} + namespace Y = dr373::X; k = Y::dr373; } }; Index: lib/Sema/SemaCXXScopeSpec.cpp === --- lib/Sema/SemaCXXScopeSpec.cpp +++ lib/Sema/SemaCXXScopeSpec.cpp @@ -461,6 +461,7 @@ ///are allowed. The bool value pointed by this parameter is set to /// 'true' if the identifier is treated as if it was followed by ':', ///not '::'. +/// \param OnlyNamespace If true, only considers namespaces in lookup. /// /// This routine differs only slightly from ActOnCXXNestedNameSpecifier, in /// that it contains an extra parameter \p ScopeLookupResult, which provides @@ -473,15 +474,15 @@ /// scope if it *knows* that the result is correct. It should not return in a /// dependent context, for example. Nor will it extend \p SS with the scope /// specifier. -bool Sema::BuildCXXNestedNameSpecifier(Scope *S, - NestedNameSpecInfo &IdInfo, - bool EnteringContext, - CXXScopeSpec &SS, +bool Sema::BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, + bool EnteringContext, CXXScopeSpec &SS, NamedDecl *ScopeLookupResult, bool ErrorRecoveryLookup, - bool *IsCorrectedToColon) { + bool *IsCorrectedToColon, + bool OnlyNamespace) { LookupResult Found(*this, IdInfo.Identifier, IdInfo.IdentifierLoc, - LookupNestedNameSpecifierName); + OnlyNamespace ? LookupNamespaceName + : LookupNestedNameSpecifierName); QualType ObjectType = GetTypeFromParser(IdInfo.ObjectType); // Determine where to perform name lookup @@ -819,19 +820,17 @@ return true; } -bool Sema::ActOnCXXNestedNameSpecifier(Scope *S, - NestedNameSpecInfo &IdInfo, - bool EnteringContext, - CXXScopeSpec &SS, +bool Sema::ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, + bool EnteringContext, CXXScopeSpec &SS, bool ErrorRecoveryLookup, - bool *IsCorrectedToColon) { + bool *IsCorrectedToColon, + bool OnlyNamespace) { if (SS.isInvalid()) return true; - return BuildCXXNestedNameSpecifier(S, IdInfo, - EnteringContext, SS, + return BuildCXXNestedNameSpecifier(S, IdInfo, EnteringContext, SS, /*ScopeLookupResult=*/nullptr, false, - IsCorrectedToColon); + IsCorrectedToColon, OnlyNamespace); } bool Sema::ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS, Index: lib/Parse/ParseExprCXX.cpp === --- lib/Parse/ParseExprCXX.cpp +++ lib/Parse/ParseExprCXX.cpp @@ -141,13 +141,16 @@ /// filled in with the leading identifier in the last component of the /// nested-name-specifier, if any. /// +/// \param OnlyNamespace If true, only considers namespaces in lookup. +/// /// \
[PATCH] D30848: Implement DR 373 "Lookup on namespace qualified name in using-directive"
rsmith added inline comments. Comment at: test/CXX/drs/dr3xx.cpp:911 -namespace dr373 { // dr373: no - // FIXME: This is valid. - namespace X { int dr373; } // expected-note 2{{here}} +namespace dr373 { // dr373: yes + namespace X { int dr373; } This should say "dr373: 5" to indicate the first version of Clang with the fix. Comment at: www/cxx_dr_status.html:2282 Lookup on namespace qualified name in using-directive -No +Yes ... and this file should be regenerated so it lists the version. https://reviews.llvm.org/D30848 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30593: Add correct "-isystem"/"-isysroot" warning handling to static analysis' BugReporter.
kmarshall added a comment. NP, Anna. I filed a number of bugs for the false positives: - https://bugs.llvm.org/show_bug.cgi?id=32229 - https://bugs.llvm.org/show_bug.cgi?id=32232 - https://bugs.llvm.org/show_bug.cgi?id=32233 - https://bugs.llvm.org/show_bug.cgi?id=32234 - https://bugs.llvm.org/show_bug.cgi?id=32235 Repository: rL LLVM https://reviews.llvm.org/D30593 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30848: Implement DR 373 "Lookup on namespace qualified name in using-directive"
mgehre updated this revision to Diff 91424. mgehre added a comment. Added clang version to test and regenerated cxx_dr_status.html https://reviews.llvm.org/D30848 Files: include/clang/Parse/Parser.h include/clang/Sema/Sema.h lib/Parse/ParseDeclCXX.cpp lib/Parse/ParseExprCXX.cpp lib/Sema/SemaCXXScopeSpec.cpp test/CXX/drs/dr3xx.cpp www/cxx_dr_status.html Index: www/cxx_dr_status.html === --- www/cxx_dr_status.html +++ www/cxx_dr_status.html @@ -2279,7 +2279,7 @@ http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#373";>373 C++11 Lookup on namespace qualified name in using-directive -No +SVN http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#374";>374 Index: test/CXX/drs/dr3xx.cpp === --- test/CXX/drs/dr3xx.cpp +++ test/CXX/drs/dr3xx.cpp @@ -908,15 +908,14 @@ } } -namespace dr373 { // dr373: no - // FIXME: This is valid. - namespace X { int dr373; } // expected-note 2{{here}} +namespace dr373 { // dr373: 5 + namespace X { int dr373; } struct dr373 { // expected-note {{here}} void f() { - using namespace dr373::X; // expected-error {{no namespace named 'X' in 'dr373::dr373'}} + using namespace dr373::X; int k = dr373; // expected-error {{does not refer to a value}} - namespace Y = dr373::X; // expected-error {{no namespace named 'X' in 'dr373::dr373'}} + namespace Y = dr373::X; k = Y::dr373; } }; Index: lib/Sema/SemaCXXScopeSpec.cpp === --- lib/Sema/SemaCXXScopeSpec.cpp +++ lib/Sema/SemaCXXScopeSpec.cpp @@ -461,6 +461,7 @@ ///are allowed. The bool value pointed by this parameter is set to /// 'true' if the identifier is treated as if it was followed by ':', ///not '::'. +/// \param OnlyNamespace If true, only considers namespaces in lookup. /// /// This routine differs only slightly from ActOnCXXNestedNameSpecifier, in /// that it contains an extra parameter \p ScopeLookupResult, which provides @@ -473,15 +474,15 @@ /// scope if it *knows* that the result is correct. It should not return in a /// dependent context, for example. Nor will it extend \p SS with the scope /// specifier. -bool Sema::BuildCXXNestedNameSpecifier(Scope *S, - NestedNameSpecInfo &IdInfo, - bool EnteringContext, - CXXScopeSpec &SS, +bool Sema::BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, + bool EnteringContext, CXXScopeSpec &SS, NamedDecl *ScopeLookupResult, bool ErrorRecoveryLookup, - bool *IsCorrectedToColon) { + bool *IsCorrectedToColon, + bool OnlyNamespace) { LookupResult Found(*this, IdInfo.Identifier, IdInfo.IdentifierLoc, - LookupNestedNameSpecifierName); + OnlyNamespace ? LookupNamespaceName + : LookupNestedNameSpecifierName); QualType ObjectType = GetTypeFromParser(IdInfo.ObjectType); // Determine where to perform name lookup @@ -819,19 +820,17 @@ return true; } -bool Sema::ActOnCXXNestedNameSpecifier(Scope *S, - NestedNameSpecInfo &IdInfo, - bool EnteringContext, - CXXScopeSpec &SS, +bool Sema::ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, + bool EnteringContext, CXXScopeSpec &SS, bool ErrorRecoveryLookup, - bool *IsCorrectedToColon) { + bool *IsCorrectedToColon, + bool OnlyNamespace) { if (SS.isInvalid()) return true; - return BuildCXXNestedNameSpecifier(S, IdInfo, - EnteringContext, SS, + return BuildCXXNestedNameSpecifier(S, IdInfo, EnteringContext, SS, /*ScopeLookupResult=*/nullptr, false, - IsCorrectedToColon); + IsCorrectedToColon, OnlyNamespace); } bool Sema::ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS, Index: lib/Parse/ParseExprCXX.cpp === --- lib/Parse/ParseExprCXX.cpp +++ lib/Parse/ParseExprCXX.cpp @@ -141,13 +141,16 @@ /// filled in with the leading identifier in the last component of the /// nested-name-specifier, if any. /// +/// \param OnlyNamespace If true,
[PATCH] D30837: [libcxx] Support for shared_ptr
EricWF requested changes to this revision. EricWF added a comment. This revision now requires changes to proceed. We can't just use an arbitrary allocator type for a number of reasons: - You just changed the type of the control block. That's ABI breaking. - `allocator` allocates ints, nothing else. - It may mean we don't select a valid user specialization of `allocator`. I'll play around to see if I can come up with another path forward to fix this. https://reviews.llvm.org/D30837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r297530 - clang/test/SemaOpenCL/overload_addrspace_resolution.cl: Appease MS mangler to specify triple=x86_64-unknown.
Author: chapuni Date: Fri Mar 10 17:06:34 2017 New Revision: 297530 URL: http://llvm.org/viewvc/llvm-project?rev=297530&view=rev Log: clang/test/SemaOpenCL/overload_addrspace_resolution.cl: Appease MS mangler to specify triple=x86_64-unknown. Modified: cfe/trunk/test/SemaOpenCL/overload_addrspace_resolution.cl Modified: cfe/trunk/test/SemaOpenCL/overload_addrspace_resolution.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/overload_addrspace_resolution.cl?rev=297530&r1=297529&r2=297530&view=diff == --- cfe/trunk/test/SemaOpenCL/overload_addrspace_resolution.cl (original) +++ cfe/trunk/test/SemaOpenCL/overload_addrspace_resolution.cl Fri Mar 10 17:06:34 2017 @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -cl-std=CL2.0 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -cl-std=CL2.0 -emit-llvm -o - -triple x86_64-unknown-unknown %s | FileCheck %s void __attribute__((overloadable)) foo(global int *a, global int *b); void __attribute__((overloadable)) foo(generic int *a, generic int *b); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D30768: [PATCH][VFS] Ignore broken symlinks in the directory iterator.
Looks like this is failing on a number of bots... On Fri, Mar 10, 2017 at 1:37 PM Juergen Ributzka via Phabricator via cfe-commits wrote: > ributzka added a comment. > > Thanks Bruno. Committed in r297510. > > > Repository: > rL LLVM > > https://reviews.llvm.org/D30768 > > > > ___ > 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] D30776: [coroutines] Fix diagnostics depending on the first coroutine statement.
EricWF added a comment. In https://reviews.llvm.org/D30776#697258, @GorNishanov wrote: > In https://reviews.llvm.org/D30776#697233, @EricWF wrote: > > > Good to know. I'll update this tomorrow. > > > Well, that is just the thought. Possibly we can check for the types of > await_ready and await_suspend in BuildResolvedCoawaitExpr. Then, we don't > have to keep the vector of await/yield-expressions. I guess it depends on when we want the diagnostics to be issued. And I think emitting them as they are built makes the most sense. If we attempt to issue the diagnostics at the end of the body it may be too late. Do you still want me to put the vector back in now or when the need actually arises? https://reviews.llvm.org/D30776 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D30768: [PATCH][VFS] Ignore broken symlinks in the directory iterator.
Nevermind, I see you've fixed. Thanks :) On Fri, Mar 10, 2017 at 3:21 PM Eric Christopher wrote: > Looks like this is failing on a number of bots... > > On Fri, Mar 10, 2017 at 1:37 PM Juergen Ributzka via Phabricator via > cfe-commits wrote: > > ributzka added a comment. > > Thanks Bruno. Committed in r297510. > > > Repository: > rL LLVM > > https://reviews.llvm.org/D30768 > > > > ___ > 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] D30775: [coroutines] Refactor SuspendExpr to create just one OpaqueValue (almost NFC)
EricWF accepted this revision. EricWF added a comment. This revision is now accepted and ready to land. This LGTM. https://reviews.llvm.org/D30775 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r297511 - [VFS] Remove the Path variable from RealFSDirIter. NFC.
Author: ributzka Date: Fri Mar 10 15:23:29 2017 New Revision: 297511 URL: http://llvm.org/viewvc/llvm-project?rev=297511&view=rev Log: [VFS] Remove the Path variable from RealFSDirIter. NFC. This variable is set, but never used. Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=297511&r1=297510&r2=297511&view=diff == --- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original) +++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Fri Mar 10 15:23:29 2017 @@ -238,11 +238,9 @@ IntrusiveRefCntPtr vfs::getR namespace { class RealFSDirIter : public clang::vfs::detail::DirIterImpl { - std::string Path; llvm::sys::fs::directory_iterator Iter; public: - RealFSDirIter(const Twine &_Path, std::error_code &EC) - : Path(_Path.str()), Iter(Path, EC) { + RealFSDirIter(const Twine &Path, std::error_code &EC) : Iter(Path, EC) { if (!EC && Iter != llvm::sys::fs::directory_iterator()) { llvm::sys::fs::file_status S; EC = Iter->status(S); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits