[PATCH] D26511: [clang-tidy] Rename modernize-use-default to modernize-use-equals-default
malcolm.parsons added a comment. In https://reviews.llvm.org/D26511#592665, @Prazek wrote: > It is introduced because of "modernize-use-delete" was too ambiguous because > of operator delete, so it was changed to "modernize-use-equals-delete". But > this case is not ambiguous at all, so I don't see point changing that. default can also be used in a switch. https://reviews.llvm.org/D26511 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D21298: [Clang-tidy] delete null check
Prazek added inline comments. Comment at: test/clang-tidy/misc-delete-null-pointer.cpp:11 + } + // CHECK-FIXES: delete p; + int *p3 = new int[3]; Is there check-fixes-not? This seems to be required here, because even if the fixit won't happen here, the test will pass. https://reviews.llvm.org/D21298 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26511: [clang-tidy] Rename modernize-use-default to modernize-use-equals-default
Prazek added a comment. I think this change is not required at first place. It is introduced because of "modernize-use-delete" was too ambiguous because of operator delete, so it was changed to "modernize-use-equals-delete". But this case is not ambiguous at all, so I don't see point changing that. Maybe it would be better to find better name for the modernize-use-equals-delete to be modernize-delete-function or something before 4.0 is released. https://reviews.llvm.org/D26511 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26410: [CodeGen] Don't emit the same global block multiple times.
rjmccall added a comment. This looks great. One minor tweak and then it's ready. Comment at: lib/CodeGen/CGBlocks.cpp:1057 +void CodeGenModule::putAddrOfGlobalBlock(const BlockExpr *BE, + llvm::Constant *Addr) { + bool Ok = EmittedGlobalBlocks.insert(std::make_pair(BE, Addr)).second; We conventionally name these things "set" rather than "put". https://reviews.llvm.org/D26410 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286567 - Mirror the llvm changes that split Bitcode/ReaderWriter.h
Author: tejohnson Date: Thu Nov 10 23:35:12 2016 New Revision: 286567 URL: http://llvm.org/viewvc/llvm-project?rev=286567&view=rev Log: Mirror the llvm changes that split Bitcode/ReaderWriter.h The change in D26502 splits ReaderWriter.h, which contains the APIs into both the BitReader and BitWriter libraries, into BitcodeReader.h and BitcodeWriter.h. Change clang uses to the appropriate split header(s). Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp cfe/trunk/lib/CodeGen/CodeGenAction.cpp cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=286567&r1=286566&r2=286567&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Nov 10 23:35:12 2016 @@ -20,7 +20,8 @@ #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/Bitcode/BitcodeWriterPass.h" -#include "llvm/Bitcode/ReaderWriter.h" +#include "llvm/Bitcode/BitcodeWriter.h" +#include "llvm/Bitcode/BitcodeReader.h" #include "llvm/CodeGen/RegAllocRegistry.h" #include "llvm/CodeGen/SchedulerRegistry.h" #include "llvm/IR/DataLayout.h" Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=286567&r1=286566&r2=286567&view=diff == --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original) +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Nov 10 23:35:12 2016 @@ -18,7 +18,7 @@ #include "clang/AST/Decl.h" #include "clang/AST/StmtOpenMP.h" #include "llvm/ADT/ArrayRef.h" -#include "llvm/Bitcode/ReaderWriter.h" +#include "llvm/Bitcode/BitcodeReader.h" #include "llvm/IR/CallSite.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/GlobalValue.h" Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=286567&r1=286566&r2=286567&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Thu Nov 10 23:35:12 2016 @@ -21,7 +21,7 @@ #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/FrontendDiagnostic.h" #include "clang/Lex/Preprocessor.h" -#include "llvm/Bitcode/ReaderWriter.h" +#include "llvm/Bitcode/BitcodeReader.h" #include "llvm/IR/DebugInfo.h" #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/DiagnosticPrinter.h" Modified: cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp?rev=286567&r1=286566&r2=286567&view=diff == --- cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp (original) +++ cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp Thu Nov 10 23:35:12 2016 @@ -22,7 +22,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Triple.h" -#include "llvm/Bitcode/ReaderWriter.h" +#include "llvm/Bitcode/BitcodeWriter.h" #include "llvm/IR/Constant.h" #include "llvm/IR/Constants.h" #include "llvm/IR/GlobalVariable.h" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D25816: Use descriptive message if list initializer is incorrectly parenthesized.
Is it OK to commit this patch? Thanks, --Serge 2016-10-21 18:21 GMT+07:00 Alex Lorenz : > arphaman added a subscriber: rsmith. > arphaman added a comment. > > LGTM, I added Richard in case he has something to add. > > > I chose to retain current clang behavior and reject questionable code. > GCC patch that introduced this message explains using warning by some > uncertainty, 5 years passed, I think the standard is stable in viewpoint on > such usage. > > Thanks for the detailed explanation, I wasn't sure if GCC's was behaving > according to the standard or not. > > > https://reviews.llvm.org/D25816 > > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25857: [tsan][clang] Introduce a function attribute to disable TSan checking at run time
dvyukov accepted this revision. dvyukov added a comment. This revision is now accepted and ready to land. > Alternatively, I could drop this aspect of the test altogether since I have > an assert in the llvm pass. Dropping the check is fine in this case. https://reviews.llvm.org/D25857 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24933: Enable configuration files in clang
sepavloff added a comment. >> Config file set by environment variable is similar to default config file as >> user does not specify anything in command line. But the user must explicitly >> specify the file, it is not made automatically. > > Sorry, I don't understand this part. If a user specifies `clang foo.c`, the compiler driver "magically" gets additional options in both cases, whether default config file is used or the config is specified by environment variable. So both scenarios are evil to some extent. But the latter case is the lesser evil, as the user must previously define proper variable. Sorry for unclear wording. >> Ability to append compiler options via environment variable is important >> feature, I think, because: >> ... >> >> - Build systems provided by software components are not perfect. Some do not >> honor CFLAGS, some require setting options inside makefiles etc. Changing >> compiler options might be a challenge. Environment variable solves this >> problem easily and effectively. > > But now you seem to be serving the goal about letting the user set flags > without using the build system, which I thought wasn't a goal anymore? Strictly speaking, you are right. Setting config by environment variable has the same effect as using default config file, with the exception that compiler user deliberately sets the variable and can chose what options to set in a particular case. By allowing this "lesser evil" we provide the user with a way to work around complex cases. https://reviews.llvm.org/D24933 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r286534 - PR30937: don't devirtualize if we find that the callee is a pure virtual
On Thu, Nov 10, 2016 at 6:12 PM, Mehdi Amini via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Thinking again, the method “can” be implemented I think. Forget it… > It can be, but the context is a virtual dispatch, so an overrider won't actually be used, and you do get undefined behavior. Emitting a direct call to __cxa_pure_virtual (or the MS ABI equivalent) would likely be a more "polite" option than going straight to @llvm.unreachable (after all, that's what would be in the vtable slot)... but see PR30937: doing so would cause a Clang-compiled Firefox to stop working. It sounds like they're fixing the problem, though, so maybe we can do this at some point. If we go that way (and probably even if we don't), we should teach Sema to detect this case and issue a warning. > — > Mehdi > > > On Nov 10, 2016, at 6:11 PM, Mehdi Amini wrote: > > > > Could we emit llvm.unreachable in this case? > > > > — > > Mehdi > > > >> On Nov 10, 2016, at 5:01 PM, Richard Smith via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> > >> Author: rsmith > >> Date: Thu Nov 10 19:01:31 2016 > >> New Revision: 286534 > >> > >> URL: http://llvm.org/viewvc/llvm-project?rev=286534&view=rev > >> Log: > >> PR30937: don't devirtualize if we find that the callee is a pure virtual > >> function. In that case, there is no requirement that the callee is > actually > >> defined, and the code may in fact be valid and have defined behavior if > the > >> virtual call is unreachable. > >> > >> Modified: > >> cfe/trunk/lib/CodeGen/CGClass.cpp > >> cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp > >> > >> Modified: cfe/trunk/lib/CodeGen/CGClass.cpp > >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ > CGClass.cpp?rev=286534&r1=286533&r2=286534&view=diff > >> > == > >> --- cfe/trunk/lib/CodeGen/CGClass.cpp (original) > >> +++ cfe/trunk/lib/CodeGen/CGClass.cpp Thu Nov 10 19:01:31 2016 > >> @@ -2851,9 +2851,9 @@ CodeGenFunction::CanDevirtualizeMemberFu > >>return false; > >> > >> // If the member function is marked 'final', we know that it can't be > >> - // overridden and can therefore devirtualize it. > >> + // overridden and can therefore devirtualize it unless it's pure > virtual. > >> if (MD->hasAttr()) > >> -return true; > >> +return !MD->isPure(); > >> > >> // If the base expression (after skipping derived-to-base conversions) > is a > >> // class prvalue, then we can devirtualize. > >> @@ -2861,31 +2861,28 @@ CodeGenFunction::CanDevirtualizeMemberFu > >> if (Base->isRValue() && Base->getType()->isRecordType()) > >>return true; > >> > >> - // If the most derived class is marked final, we know that no > subclass can > >> - // override this member function and so we can devirtualize it. For > example: > >> - // > >> - // struct A { virtual void f(); } > >> - // struct B final : A { }; > >> - // > >> - // void f(B *b) { > >> - // b->f(); > >> - // } > >> - // > >> - if (const CXXRecordDecl *BestDynamicDecl = > Base->getBestDynamicClassType()) { > >> -if (BestDynamicDecl->hasAttr()) > >> - return true; > >> - > >> -// There may be a method corresponding to MD in a derived class. > If that > >> -// method is marked final, we can devirtualize it. > >> -const CXXMethodDecl *DevirtualizedMethod = > >> -MD->getCorrespondingMethodInClass(BestDynamicDecl); > >> -if (DevirtualizedMethod->hasAttr()) > >> - return true; > >> - } > >> + // If we don't even know what we would call, we can't devirtualize. > >> + const CXXRecordDecl *BestDynamicDecl = Base->getBestDynamicClassType( > ); > >> + if (!BestDynamicDecl) > >> +return false; > >> + > >> + // There may be a method corresponding to MD in a derived class. > >> + const CXXMethodDecl *DevirtualizedMethod = > >> + MD->getCorrespondingMethodInClass(BestDynamicDecl); > >> + > >> + // If that method is pure virtual, we can't devirtualize. If this > code is > >> + // reached, the result would be UB, not a direct call to the derived > class > >> + // function, and we can't assume the derived class function is > defined. > >> + if (DevirtualizedMethod->isPure()) > >> +return false; > >> + > >> + // If that method is marked final, we can devirtualize it. > >> + if (DevirtualizedMethod->hasAttr()) > >> +return true; > >> > >> // Similarly, if the class itself is marked 'final' it can't be > overridden > >> // and we can therefore devirtualize the member function call. > >> - if (MD->getParent()->hasAttr()) > >> + if (BestDynamicDecl->hasAttr()) > >>return true; > >> > >> if (const DeclRefExpr *DRE = dyn_cast(Base)) { > >> > >> Modified: cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function- > calls.cpp > >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ > CodeGenCXX/devirtualize-virtual-function-calls.cpp? > rev=286534&r1=286533&r2=286534&view=diff > >> ===
[PATCH] D26540: [Sema] Accept and ignore the leaf attribute
phosek created this revision. phosek added a subscriber: cfe-commits. phosek set the repository for this revision to rL LLVM. This is a GCC extension, Clang should accept the attribute without a warning for compatibility with GCC. https://llvm.org/bugs/show_bug.cgi?id=30980 Repository: rL LLVM https://reviews.llvm.org/D26540 Files: include/clang/Basic/Attr.td test/Sema/attr-leaf.c Index: test/Sema/attr-leaf.c === --- /dev/null +++ test/Sema/attr-leaf.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -verify -fsyntax-only %s +// expected-no-diagnostics + +void f(void) __attribute__((leaf)); Index: include/clang/Basic/Attr.td === --- include/clang/Basic/Attr.td +++ include/clang/Basic/Attr.td @@ -915,6 +915,11 @@ let Documentation = [LayoutVersionDocs]; } +def Leaf : IgnoredAttr { + let Spellings = [GNU<"leaf">]; + let Subjects = SubjectList<[Function]>; +} + def MaxFieldAlignment : InheritableAttr { // This attribute has no spellings as it is only ever created implicitly. let Spellings = []; Index: test/Sema/attr-leaf.c === --- /dev/null +++ test/Sema/attr-leaf.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -verify -fsyntax-only %s +// expected-no-diagnostics + +void f(void) __attribute__((leaf)); Index: include/clang/Basic/Attr.td === --- include/clang/Basic/Attr.td +++ include/clang/Basic/Attr.td @@ -915,6 +915,11 @@ let Documentation = [LayoutVersionDocs]; } +def Leaf : IgnoredAttr { + let Spellings = [GNU<"leaf">]; + let Subjects = SubjectList<[Function]>; +} + def MaxFieldAlignment : InheritableAttr { // This attribute has no spellings as it is only ever created implicitly. let Spellings = []; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type
mehdi_amini added a comment. > So when this modification tells the developer to add 'unsigned' to their > enum, they are subsequently causing a warning to occur in GCC. > > I have commented on the bug on GCC for this > (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51242#c28), but it looks > unlikely to be fixed. > > Should we go ahead and add this warning when following its instructions will > cause a warning in the GCC compiler? Even though GCC is at fault here, I'm > not sure what the right thing is to do. GCC seems to agree that they should fix it: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61414 ; so I wouldn't consider it a blocker. But I'm not using GCC either, and I don't know what is our usual policy, so it'd be nice to have another opinion here. https://reviews.llvm.org/D24289 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type
sashab added a comment. Sorry, had this discussion elsewhere (https://bugs.chromium.org/p/chromium/issues/detail?id=648462). I'm uncertain at this point. There is currently a bug in GCC that means enums with an explicit underlying type (or enum classes, although the latter is to be fixed) are given the size of their underlying type. For example: enum Foo { A, B }; can be stored in a bitfield of size 1, but: enum Foo : unsigned char { A, B }; will error in a bitfield of any size smaller than 8. So when this modification tells the developer to add 'unsigned' to their enum, they are subsequently causing a warning to occur in GCC. I have commented on the bug on GCC for this (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51242#c28), but it looks unlikely to be fixed. Should we go ahead and add this warning when following its instructions will cause a warning in the GCC compiler? Even though GCC is at fault here, I'm not sure what the right thing is to do. https://reviews.llvm.org/D24289 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r286534 - PR30937: don't devirtualize if we find that the callee is a pure virtual
Thinking again, the method “can” be implemented I think. Forget it… — Mehdi > On Nov 10, 2016, at 6:11 PM, Mehdi Amini wrote: > > Could we emit llvm.unreachable in this case? > > — > Mehdi > >> On Nov 10, 2016, at 5:01 PM, Richard Smith via cfe-commits >> wrote: >> >> Author: rsmith >> Date: Thu Nov 10 19:01:31 2016 >> New Revision: 286534 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=286534&view=rev >> Log: >> PR30937: don't devirtualize if we find that the callee is a pure virtual >> function. In that case, there is no requirement that the callee is actually >> defined, and the code may in fact be valid and have defined behavior if the >> virtual call is unreachable. >> >> Modified: >> cfe/trunk/lib/CodeGen/CGClass.cpp >> cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp >> >> Modified: cfe/trunk/lib/CodeGen/CGClass.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=286534&r1=286533&r2=286534&view=diff >> == >> --- cfe/trunk/lib/CodeGen/CGClass.cpp (original) >> +++ cfe/trunk/lib/CodeGen/CGClass.cpp Thu Nov 10 19:01:31 2016 >> @@ -2851,9 +2851,9 @@ CodeGenFunction::CanDevirtualizeMemberFu >>return false; >> >> // If the member function is marked 'final', we know that it can't be >> - // overridden and can therefore devirtualize it. >> + // overridden and can therefore devirtualize it unless it's pure virtual. >> if (MD->hasAttr()) >> -return true; >> +return !MD->isPure(); >> >> // If the base expression (after skipping derived-to-base conversions) is a >> // class prvalue, then we can devirtualize. >> @@ -2861,31 +2861,28 @@ CodeGenFunction::CanDevirtualizeMemberFu >> if (Base->isRValue() && Base->getType()->isRecordType()) >>return true; >> >> - // If the most derived class is marked final, we know that no subclass can >> - // override this member function and so we can devirtualize it. For >> example: >> - // >> - // struct A { virtual void f(); } >> - // struct B final : A { }; >> - // >> - // void f(B *b) { >> - // b->f(); >> - // } >> - // >> - if (const CXXRecordDecl *BestDynamicDecl = >> Base->getBestDynamicClassType()) { >> -if (BestDynamicDecl->hasAttr()) >> - return true; >> - >> -// There may be a method corresponding to MD in a derived class. If that >> -// method is marked final, we can devirtualize it. >> -const CXXMethodDecl *DevirtualizedMethod = >> -MD->getCorrespondingMethodInClass(BestDynamicDecl); >> -if (DevirtualizedMethod->hasAttr()) >> - return true; >> - } >> + // If we don't even know what we would call, we can't devirtualize. >> + const CXXRecordDecl *BestDynamicDecl = Base->getBestDynamicClassType(); >> + if (!BestDynamicDecl) >> +return false; >> + >> + // There may be a method corresponding to MD in a derived class. >> + const CXXMethodDecl *DevirtualizedMethod = >> + MD->getCorrespondingMethodInClass(BestDynamicDecl); >> + >> + // If that method is pure virtual, we can't devirtualize. If this code is >> + // reached, the result would be UB, not a direct call to the derived class >> + // function, and we can't assume the derived class function is defined. >> + if (DevirtualizedMethod->isPure()) >> +return false; >> + >> + // If that method is marked final, we can devirtualize it. >> + if (DevirtualizedMethod->hasAttr()) >> +return true; >> >> // Similarly, if the class itself is marked 'final' it can't be overridden >> // and we can therefore devirtualize the member function call. >> - if (MD->getParent()->hasAttr()) >> + if (BestDynamicDecl->hasAttr()) >>return true; >> >> if (const DeclRefExpr *DRE = dyn_cast(Base)) { >> >> Modified: cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp?rev=286534&r1=286533&r2=286534&view=diff >> == >> --- cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp >> (original) >> +++ cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp Thu >> Nov 10 19:01:31 2016 >> @@ -161,3 +161,37 @@ namespace test4 { >>p->fish.eat(); >> } >> } >> + >> +// Do not devirtualize to pure virtual function calls. >> +namespace test5 { >> + struct X { >> +virtual void f() = 0; >> + }; >> + struct Y {}; >> + // CHECK-LABEL: define {{.*}} @_ZN5test51f >> + void f(Y &y, X Y::*p) { >> +// CHECK-NOT: call {{.*}} @_ZN5test51X1fEv >> +// CHECK: call void % >> +(y.*p).f(); >> + }; >> + >> + struct Z final { >> +virtual void f() = 0; >> + }; >> + // CHECK-LABEL: define {{.*}} @_ZN5test51g >> + void g(Z &z) { >> +// CHECK-NOT: call {{.*}} @_ZN5test51Z1fEv >> +// CHECK: call void % >> +z.f(); >> + } >> + >> + struct Q { >> +virt
Re: r286534 - PR30937: don't devirtualize if we find that the callee is a pure virtual
Could we emit llvm.unreachable in this case? — Mehdi > On Nov 10, 2016, at 5:01 PM, Richard Smith via cfe-commits > wrote: > > Author: rsmith > Date: Thu Nov 10 19:01:31 2016 > New Revision: 286534 > > URL: http://llvm.org/viewvc/llvm-project?rev=286534&view=rev > Log: > PR30937: don't devirtualize if we find that the callee is a pure virtual > function. In that case, there is no requirement that the callee is actually > defined, and the code may in fact be valid and have defined behavior if the > virtual call is unreachable. > > Modified: >cfe/trunk/lib/CodeGen/CGClass.cpp >cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp > > Modified: cfe/trunk/lib/CodeGen/CGClass.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=286534&r1=286533&r2=286534&view=diff > == > --- cfe/trunk/lib/CodeGen/CGClass.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGClass.cpp Thu Nov 10 19:01:31 2016 > @@ -2851,9 +2851,9 @@ CodeGenFunction::CanDevirtualizeMemberFu > return false; > > // If the member function is marked 'final', we know that it can't be > - // overridden and can therefore devirtualize it. > + // overridden and can therefore devirtualize it unless it's pure virtual. > if (MD->hasAttr()) > -return true; > +return !MD->isPure(); > > // If the base expression (after skipping derived-to-base conversions) is a > // class prvalue, then we can devirtualize. > @@ -2861,31 +2861,28 @@ CodeGenFunction::CanDevirtualizeMemberFu > if (Base->isRValue() && Base->getType()->isRecordType()) > return true; > > - // If the most derived class is marked final, we know that no subclass can > - // override this member function and so we can devirtualize it. For > example: > - // > - // struct A { virtual void f(); } > - // struct B final : A { }; > - // > - // void f(B *b) { > - // b->f(); > - // } > - // > - if (const CXXRecordDecl *BestDynamicDecl = > Base->getBestDynamicClassType()) { > -if (BestDynamicDecl->hasAttr()) > - return true; > - > -// There may be a method corresponding to MD in a derived class. If that > -// method is marked final, we can devirtualize it. > -const CXXMethodDecl *DevirtualizedMethod = > -MD->getCorrespondingMethodInClass(BestDynamicDecl); > -if (DevirtualizedMethod->hasAttr()) > - return true; > - } > + // If we don't even know what we would call, we can't devirtualize. > + const CXXRecordDecl *BestDynamicDecl = Base->getBestDynamicClassType(); > + if (!BestDynamicDecl) > +return false; > + > + // There may be a method corresponding to MD in a derived class. > + const CXXMethodDecl *DevirtualizedMethod = > + MD->getCorrespondingMethodInClass(BestDynamicDecl); > + > + // If that method is pure virtual, we can't devirtualize. If this code is > + // reached, the result would be UB, not a direct call to the derived class > + // function, and we can't assume the derived class function is defined. > + if (DevirtualizedMethod->isPure()) > +return false; > + > + // If that method is marked final, we can devirtualize it. > + if (DevirtualizedMethod->hasAttr()) > +return true; > > // Similarly, if the class itself is marked 'final' it can't be overridden > // and we can therefore devirtualize the member function call. > - if (MD->getParent()->hasAttr()) > + if (BestDynamicDecl->hasAttr()) > return true; > > if (const DeclRefExpr *DRE = dyn_cast(Base)) { > > Modified: cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp?rev=286534&r1=286533&r2=286534&view=diff > == > --- cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp > (original) > +++ cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp Thu Nov > 10 19:01:31 2016 > @@ -161,3 +161,37 @@ namespace test4 { > p->fish.eat(); > } > } > + > +// Do not devirtualize to pure virtual function calls. > +namespace test5 { > + struct X { > +virtual void f() = 0; > + }; > + struct Y {}; > + // CHECK-LABEL: define {{.*}} @_ZN5test51f > + void f(Y &y, X Y::*p) { > +// CHECK-NOT: call {{.*}} @_ZN5test51X1fEv > +// CHECK: call void % > +(y.*p).f(); > + }; > + > + struct Z final { > +virtual void f() = 0; > + }; > + // CHECK-LABEL: define {{.*}} @_ZN5test51g > + void g(Z &z) { > +// CHECK-NOT: call {{.*}} @_ZN5test51Z1fEv > +// CHECK: call void % > +z.f(); > + } > + > + struct Q { > +virtual void f() final = 0; > + }; > + // CHECK-LABEL: define {{.*}} @_ZN5test51h > + void h(Q &q) { > +// CHECK-NOT: call {{.*}} @_ZN5test51Q1fEv > +// CHECK: call void % > +q.f(); > + } > +} > > > ___
[PATCH] D26534: [PPC] add altivec.h functions for converting a vector of half precision to a vector of single precision
sfertile created this revision. sfertile added reviewers: nemanjai, amehsan, kbarton, syzaara, jtony, lei. sfertile added subscribers: cfe-commits, echristo. sfertile set the repository for this revision to rL LLVM. Change adds 2 functions to altivec.h vector float vec_extract_fp32_from_shorth (vector unsigned short); Purpose: Extracts four single-precision floating-point numbers from the high elements of a vector of eight 16-bit elements, interpreting each element as a 16-bit floating-point number in IEEE format. Result value: The first four elements are interpreted as 16-bit floating-point numbers in IEEE format, and extended to single-precision format, returning a vector with four single-precision IEEE numbers. vector float vec_extract_fp32_from_shortl (vector unsigned short); Purpose Extracts four single-precision floating-point numbers from the low elements of a vector of eight 16-bit elements, interpreting each element as a 16-bit floating-point number in IEEE format. Result value: The last four elements are interpreted as 16-bit floating-point numbers in IEEE format, and extended to single-precision format, returning a vector with four single-precision IEEE numbers. Adds a builtin that gets mapped to the xscvhpsp instruction. (VSX Scalar Convert Half-Precision to Double-Precision) Repository: rL LLVM https://reviews.llvm.org/D26534 Files: include/clang/Basic/BuiltinsPPC.def lib/Headers/altivec.h test/CodeGen/builtins-ppc-p9vector.c Index: test/CodeGen/builtins-ppc-p9vector.c === --- test/CodeGen/builtins-ppc-p9vector.c +++ test/CodeGen/builtins-ppc-p9vector.c @@ -827,4 +827,21 @@ // CHECK-NEXT: ret <16 x i8> return vec_srv (vuca, vucb); } - +vector float test74(void) { +// CHECK-BE: shufflevector <8 x i16> {{.+}}, <8 x i16> {{.+}}, <8 x i32> +// CHECK-BE: @llvm.ppc.vsx.xvcvhpsp(<8 x i16> {{.+}}) +// CHECK-BE-NEXT: ret <4 x float> +// CHECK-LE: shufflevector <8 x i16> {{.+}}, <8 x i16> {{.+}}, <8 x i32> +// CHECK-LE: @llvm.ppc.vsx.xvcvhpsp(<8 x i16> {{.+}}) +// CHECK-LE-NEXT: ret <4 x float> + return vec_extract_fp32_from_shorth(vusa); +} +vector float test75(void) { +// CHECK-BE: shufflevector <8 x i16> {{.+}}, <8 x i16> {{.+}}, <8 x i32> +// CHECK-BE: @llvm.ppc.vsx.xvcvhpsp(<8 x i16> {{.+}}) +// CHECK-BE-NEXT: ret <4 x float> +// CHECK-LE: shufflevector <8 x i16> {{.+}}, <8 x i16> {{.+}}, <8 x i32> +// CHECK-LE: @llvm.ppc.vsx.xvcvhpsp(<8 x i16> {{.+}}) +// CHECK-LE-NEXT: ret <4 x float> + return vec_extract_fp32_from_shortl(vusa); +} Index: lib/Headers/altivec.h === --- lib/Headers/altivec.h +++ lib/Headers/altivec.h @@ -11902,6 +11902,30 @@ return __a[__b]; } +#if defined(__POWER9_VECTOR__) +static __inline__ vector float __ATTRS_o_ai +vec_extract_fp32_from_shorth(vector unsigned short __a) { + vector unsigned short __b = +#ifdef __LITTLE_ENDIAN__ +__builtin_shufflevector(__a, __a, 0, -1, 1, -1, 2, -1, 3, -1); +#else +__builtin_shufflevector(__a, __a, -1, 0, -1, 1, -1, 2, -1, 3); +#endif + return __builtin_vsx_xvcvhpsp(__b); +} + +static __inline__ vector float __ATTRS_o_ai +vec_extract_fp32_from_shortl(vector unsigned short __a) { + vector unsigned short __b = +#ifdef __LITTLE_ENDIAN__ +__builtin_shufflevector(__a, __a, 4, -1, 5, -1, 6, -1, 7, -1); +#else +__builtin_shufflevector(__a, __a, -1, 4, -1, 5, -1, 6, -1, 7); +#endif + return __builtin_vsx_xvcvhpsp(__b); +} +#endif /* __POWER9_VECTOR__ */ + /* vec_insert */ static __inline__ vector signed char __ATTRS_o_ai Index: include/clang/Basic/BuiltinsPPC.def === --- include/clang/Basic/BuiltinsPPC.def +++ include/clang/Basic/BuiltinsPPC.def @@ -380,6 +380,8 @@ BUILTIN(__builtin_vsx_xviexpdp, "V2dV2ULLiV2ULLi", "") BUILTIN(__builtin_vsx_xviexpsp, "V4fV4UiV4Ui", "") +BUILTIN(__builtin_vsx_xvcvhpsp, "V4fV8Us", "") + // HTM builtins BUILTIN(__builtin_tbegin, "UiUIi", "") BUILTIN(__builtin_tend, "UiUIi", "") Index: test/CodeGen/builtins-ppc-p9vector.c === --- test/CodeGen/builtins-ppc-p9vector.c +++ test/CodeGen/builtins-ppc-p9vector.c @@ -827,4 +827,21 @@ // CHECK-NEXT: ret <16 x i8> return vec_srv (vuca, vucb); } - +vector float test74(void) { +// CHECK-BE: shufflevector <8 x i16> {{.+}}, <8 x i16> {{.+}}, <8 x i32> +// CHECK-BE: @llvm.ppc.vsx.xvcvhpsp(<8 x i16> {{.+}}) +// CHECK-BE-NEXT: ret <4 x float> +// CHECK-LE: shufflevector <8 x i16> {{.+}}, <8 x i16> {{.+}}, <8 x i32> +// CHECK-LE: @llvm.ppc.vsx.xvcvhpsp(<8 x i16> {{.+}}) +// CHECK-LE-NEXT: ret <4 x float> + return vec_extract_fp32_from_shorth(vusa); +} +vector float test75(void) { +// CHECK-BE: shufflevector <8 x i16> {{.+}}, <8 x i16> {{.+}}, <8 x i32> +// CHECK-BE: @llvm.ppc.vsx.xvcvhpsp(<8 x i16> {{.+}}) +// CHECK-BE-NEX
[PATCH] D26227: Don't require nullability on 'va_list'.
jordan_rose added a comment. One more fix-up in https://reviews.llvm.org/rL286542. Hopefully the last one. Repository: rL LLVM https://reviews.llvm.org/D26227 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26491: Define __ANDROID_API__ when specified as part of an Android target.
This revision was automatically updated to reflect the committed changes. Closed by commit rL286543: Define __ANDROID_API__ when specified as part of an Android target. (authored by srhines). Changed prior to commit: https://reviews.llvm.org/D26491?vs=77446&id=77578#toc Repository: rL LLVM https://reviews.llvm.org/D26491 Files: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/test/Preprocessor/init.c Index: cfe/trunk/lib/Basic/Targets.cpp === --- cfe/trunk/lib/Basic/Targets.cpp +++ cfe/trunk/lib/Basic/Targets.cpp @@ -465,6 +465,8 @@ Triple.getEnvironmentVersion(Maj, Min, Rev); this->PlatformName = "android"; this->PlatformMinVersion = VersionTuple(Maj, Min, Rev); + if (Maj) +Builder.defineMacro("__ANDROID_API__", Twine(Maj)); } if (Opts.POSIXThreads) Builder.defineMacro("_REENTRANT"); Index: cfe/trunk/test/Preprocessor/init.c === --- cfe/trunk/test/Preprocessor/init.c +++ cfe/trunk/test/Preprocessor/init.c @@ -8497,14 +8497,19 @@ // NORTTI:#define __STDC__ 1 // // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID %s +// ANDROID-NOT:#define __ANDROID_API__ // ANDROID:#define __ANDROID__ 1 // // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s // I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 4U // // RUN: %clang_cc1 -x c++ -triple x86_64-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix X86_64-ANDROID-CXX %s // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL // +// RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID20 %s +// ANDROID20:#define __ANDROID_API__ 20 +// ANDROID20:#define __ANDROID__ 1 +// // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix LANAI %s // LANAI: #define __lanai__ 1 // Index: cfe/trunk/lib/Basic/Targets.cpp === --- cfe/trunk/lib/Basic/Targets.cpp +++ cfe/trunk/lib/Basic/Targets.cpp @@ -465,6 +465,8 @@ Triple.getEnvironmentVersion(Maj, Min, Rev); this->PlatformName = "android"; this->PlatformMinVersion = VersionTuple(Maj, Min, Rev); + if (Maj) +Builder.defineMacro("__ANDROID_API__", Twine(Maj)); } if (Opts.POSIXThreads) Builder.defineMacro("_REENTRANT"); Index: cfe/trunk/test/Preprocessor/init.c === --- cfe/trunk/test/Preprocessor/init.c +++ cfe/trunk/test/Preprocessor/init.c @@ -8497,14 +8497,19 @@ // NORTTI:#define __STDC__ 1 // // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID %s +// ANDROID-NOT:#define __ANDROID_API__ // ANDROID:#define __ANDROID__ 1 // // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s // I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 4U // // RUN: %clang_cc1 -x c++ -triple x86_64-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix X86_64-ANDROID-CXX %s // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL // +// RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID20 %s +// ANDROID20:#define __ANDROID_API__ 20 +// ANDROID20:#define __ANDROID__ 1 +// // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix LANAI %s // LANAI: #define __lanai__ 1 // ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286543 - Define __ANDROID_API__ when specified as part of an Android target.
Author: srhines Date: Thu Nov 10 19:29:39 2016 New Revision: 286543 URL: http://llvm.org/viewvc/llvm-project?rev=286543&view=rev Log: Define __ANDROID_API__ when specified as part of an Android target. Summary: This macro should be defined only when the user directly specifies an API level as part of an Android target. For any regular Android target, we leave this macro undefined. Bug: https://llvm.org/bugs/show_bug.cgi?id=30940 Reviewers: eugenis, pirama Subscribers: tberghammer, cfe-commits, pirama, eugenis, danalbert Differential Revision: https://reviews.llvm.org/D26491 Modified: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/test/Preprocessor/init.c Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=286543&r1=286542&r2=286543&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Thu Nov 10 19:29:39 2016 @@ -465,6 +465,8 @@ protected: Triple.getEnvironmentVersion(Maj, Min, Rev); this->PlatformName = "android"; this->PlatformMinVersion = VersionTuple(Maj, Min, Rev); + if (Maj) +Builder.defineMacro("__ANDROID_API__", Twine(Maj)); } if (Opts.POSIXThreads) Builder.defineMacro("_REENTRANT"); Modified: cfe/trunk/test/Preprocessor/init.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=286543&r1=286542&r2=286543&view=diff == --- cfe/trunk/test/Preprocessor/init.c (original) +++ cfe/trunk/test/Preprocessor/init.c Thu Nov 10 19:29:39 2016 @@ -8497,6 +8497,7 @@ // NORTTI:#define __STDC__ 1 // // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID %s +// ANDROID-NOT:#define __ANDROID_API__ // ANDROID:#define __ANDROID__ 1 // // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s @@ -8505,6 +8506,10 @@ // RUN: %clang_cc1 -x c++ -triple x86_64-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix X86_64-ANDROID-CXX %s // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL // +// RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID20 %s +// ANDROID20:#define __ANDROID_API__ 20 +// ANDROID20:#define __ANDROID__ 1 +// // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix LANAI %s // LANAI: #define __lanai__ 1 // ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286542 - Don't require nullability on 'va_list', even when it's a pointer.
Author: jrose Date: Thu Nov 10 19:29:18 2016 New Revision: 286542 URL: http://llvm.org/viewvc/llvm-project?rev=286542&view=rev Log: Don't require nullability on 'va_list', even when it's a pointer. Take 3! This should finally fix the Hexagon, PPC, and Windows bots. rdar://problem/25846421 Modified: cfe/trunk/lib/Sema/SemaType.cpp Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=286542&r1=286541&r2=286542&view=diff == --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Thu Nov 10 19:29:18 2016 @@ -3827,6 +3827,23 @@ static TypeSourceInfo *GetFullTypeForDec } } + // Local function that returns true if its argument looks like a va_list. + auto isVaList = [&S](QualType T) -> bool { +auto *typedefTy = T->getAs(); +if (!typedefTy) + return false; +TypedefDecl *vaListTypedef = S.Context.getBuiltinVaListDecl(); +do { + if (typedefTy->getDecl() == vaListTypedef) +return true; + if (auto *name = typedefTy->getDecl()->getIdentifier()) +if (name->isStr("va_list")) + return true; + typedefTy = typedefTy->desugar()->getAs(); +} while (typedefTy); +return false; + }; + // Local function that checks the nullability for a given pointer declarator. // Returns true if _Nonnull was inferred. auto inferPointerNullability = [&](SimplePointerKind pointerKind, @@ -3905,37 +3922,27 @@ static TypeSourceInfo *GetFullTypeForDec // nullability and perform consistency checking. if (S.ActiveTemplateInstantiations.empty()) { if (T->canHaveNullability() && !T->getNullability(S.Context)) { - SimplePointerKind pointerKind = SimplePointerKind::Pointer; - if (T->isBlockPointerType()) -pointerKind = SimplePointerKind::BlockPointer; - else if (T->isMemberPointerType()) -pointerKind = SimplePointerKind::MemberPointer; - - if (auto *attr = inferPointerNullability( - pointerKind, D.getDeclSpec().getTypeSpecTypeLoc(), - D.getMutableDeclSpec().getAttributes().getListRef())) { -T = Context.getAttributedType( - AttributedType::getNullabilityAttrKind(*inferNullability), T, T); -attr->setUsedAsTypeAttr(); + if (isVaList(T)) { +// Record that we've seen a pointer, but do nothing else. +if (NumPointersRemaining > 0) + --NumPointersRemaining; + } else { +SimplePointerKind pointerKind = SimplePointerKind::Pointer; +if (T->isBlockPointerType()) + pointerKind = SimplePointerKind::BlockPointer; +else if (T->isMemberPointerType()) + pointerKind = SimplePointerKind::MemberPointer; + +if (auto *attr = inferPointerNullability( + pointerKind, D.getDeclSpec().getTypeSpecTypeLoc(), + D.getMutableDeclSpec().getAttributes().getListRef())) { + T = Context.getAttributedType( +AttributedType::getNullabilityAttrKind(*inferNullability),T,T); + attr->setUsedAsTypeAttr(); +} } } -auto isVaList = [&S](QualType T) -> bool { - auto *typedefTy = T->getAs(); - if (!typedefTy) -return false; - TypedefDecl *vaListTypedef = S.Context.getBuiltinVaListDecl(); - do { -if (typedefTy->getDecl() == vaListTypedef) - return true; -if (auto *name = typedefTy->getDecl()->getIdentifier()) - if (name->isStr("va_list")) -return true; -typedefTy = typedefTy->desugar()->getAs(); - } while (typedefTy); - return false; -}; - if (complainAboutMissingNullability == CAMN_Yes && T->isArrayType() && !T->getNullability(S.Context) && !isVaList(T) && D.isPrototypeContext() && ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286541 - Revert "Speculative fix for va_list/nullability test on Hexagon and PPC."
Author: jrose Date: Thu Nov 10 19:29:15 2016 New Revision: 286541 URL: http://llvm.org/viewvc/llvm-project?rev=286541&view=rev Log: Revert "Speculative fix for va_list/nullability test on Hexagon and PPC." This reverts commit r286533. At this point an array really is still an array, but the problem is with /non-/array va_lists anyway. Modified: cfe/trunk/lib/Sema/SemaType.cpp Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=286541&r1=286540&r2=286541&view=diff == --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Thu Nov 10 19:29:15 2016 @@ -3921,10 +3921,6 @@ static TypeSourceInfo *GetFullTypeForDec } auto isVaList = [&S](QualType T) -> bool { - // Handle array va_list parameters that decayed to pointers. - if (auto *decayedTy = T->getAs()) -T = decayedTy->getOriginalType(); - auto *typedefTy = T->getAs(); if (!typedefTy) return false; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286534 - PR30937: don't devirtualize if we find that the callee is a pure virtual
Author: rsmith Date: Thu Nov 10 19:01:31 2016 New Revision: 286534 URL: http://llvm.org/viewvc/llvm-project?rev=286534&view=rev Log: PR30937: don't devirtualize if we find that the callee is a pure virtual function. In that case, there is no requirement that the callee is actually defined, and the code may in fact be valid and have defined behavior if the virtual call is unreachable. Modified: cfe/trunk/lib/CodeGen/CGClass.cpp cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp Modified: cfe/trunk/lib/CodeGen/CGClass.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=286534&r1=286533&r2=286534&view=diff == --- cfe/trunk/lib/CodeGen/CGClass.cpp (original) +++ cfe/trunk/lib/CodeGen/CGClass.cpp Thu Nov 10 19:01:31 2016 @@ -2851,9 +2851,9 @@ CodeGenFunction::CanDevirtualizeMemberFu return false; // If the member function is marked 'final', we know that it can't be - // overridden and can therefore devirtualize it. + // overridden and can therefore devirtualize it unless it's pure virtual. if (MD->hasAttr()) -return true; +return !MD->isPure(); // If the base expression (after skipping derived-to-base conversions) is a // class prvalue, then we can devirtualize. @@ -2861,31 +2861,28 @@ CodeGenFunction::CanDevirtualizeMemberFu if (Base->isRValue() && Base->getType()->isRecordType()) return true; - // If the most derived class is marked final, we know that no subclass can - // override this member function and so we can devirtualize it. For example: - // - // struct A { virtual void f(); } - // struct B final : A { }; - // - // void f(B *b) { - // b->f(); - // } - // - if (const CXXRecordDecl *BestDynamicDecl = Base->getBestDynamicClassType()) { -if (BestDynamicDecl->hasAttr()) - return true; - -// There may be a method corresponding to MD in a derived class. If that -// method is marked final, we can devirtualize it. -const CXXMethodDecl *DevirtualizedMethod = -MD->getCorrespondingMethodInClass(BestDynamicDecl); -if (DevirtualizedMethod->hasAttr()) - return true; - } + // If we don't even know what we would call, we can't devirtualize. + const CXXRecordDecl *BestDynamicDecl = Base->getBestDynamicClassType(); + if (!BestDynamicDecl) +return false; + + // There may be a method corresponding to MD in a derived class. + const CXXMethodDecl *DevirtualizedMethod = + MD->getCorrespondingMethodInClass(BestDynamicDecl); + + // If that method is pure virtual, we can't devirtualize. If this code is + // reached, the result would be UB, not a direct call to the derived class + // function, and we can't assume the derived class function is defined. + if (DevirtualizedMethod->isPure()) +return false; + + // If that method is marked final, we can devirtualize it. + if (DevirtualizedMethod->hasAttr()) +return true; // Similarly, if the class itself is marked 'final' it can't be overridden // and we can therefore devirtualize the member function call. - if (MD->getParent()->hasAttr()) + if (BestDynamicDecl->hasAttr()) return true; if (const DeclRefExpr *DRE = dyn_cast(Base)) { Modified: cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp?rev=286534&r1=286533&r2=286534&view=diff == --- cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp (original) +++ cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp Thu Nov 10 19:01:31 2016 @@ -161,3 +161,37 @@ namespace test4 { p->fish.eat(); } } + +// Do not devirtualize to pure virtual function calls. +namespace test5 { + struct X { +virtual void f() = 0; + }; + struct Y {}; + // CHECK-LABEL: define {{.*}} @_ZN5test51f + void f(Y &y, X Y::*p) { +// CHECK-NOT: call {{.*}} @_ZN5test51X1fEv +// CHECK: call void % +(y.*p).f(); + }; + + struct Z final { +virtual void f() = 0; + }; + // CHECK-LABEL: define {{.*}} @_ZN5test51g + void g(Z &z) { +// CHECK-NOT: call {{.*}} @_ZN5test51Z1fEv +// CHECK: call void % +z.f(); + } + + struct Q { +virtual void f() final = 0; + }; + // CHECK-LABEL: define {{.*}} @_ZN5test51h + void h(Q &q) { +// CHECK-NOT: call {{.*}} @_ZN5test51Q1fEv +// CHECK: call void % +q.f(); + } +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286533 - Speculative fix for va_list/nullability test on Hexagon and PPC.
Author: jrose Date: Thu Nov 10 18:55:14 2016 New Revision: 286533 URL: http://llvm.org/viewvc/llvm-project?rev=286533&view=rev Log: Speculative fix for va_list/nullability test on Hexagon and PPC. PowerPC's va_list, at least, is a typedef for an array, which means it decays to a pointer in parameter position. Since the decayed type is built from the array element type, the typedef sugar is lost. More rdar://problem/25846421. Modified: cfe/trunk/lib/Sema/SemaType.cpp Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=286533&r1=286532&r2=286533&view=diff == --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Thu Nov 10 18:55:14 2016 @@ -3921,6 +3921,10 @@ static TypeSourceInfo *GetFullTypeForDec } auto isVaList = [&S](QualType T) -> bool { + // Handle array va_list parameters that decayed to pointers. + if (auto *decayedTy = T->getAs()) +T = decayedTy->getOriginalType(); + auto *typedefTy = T->getAs(); if (!typedefTy) return false; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26227: Don't require nullability on 'va_list'.
jordan_rose closed this revision. jordan_rose added a comment. Committed in https://reviews.llvm.org/rL286522, with a fix-up to make the check for va_lists more conservative in https://reviews.llvm.org/rL286531. Repository: rL LLVM https://reviews.llvm.org/D26227 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26109: Warn when 'assume_nonnull' infers nullability within an array.
jordan_rose closed this revision. jordan_rose added a comment. Committed as https://reviews.llvm.org/rL286521. Repository: rL LLVM https://reviews.llvm.org/D26109 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26108: Add -Wnullability-completeness-on-arrays.
jordan_rose closed this revision. jordan_rose added a comment. Committed as https://reviews.llvm.org/rL286520, with a slight fix-up for MSVC in https://reviews.llvm.org/rL286525. Repository: rL LLVM https://reviews.llvm.org/D26108 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25850: Accept nullability annotations (_Nullable) on array parameters
jordan_rose closed this revision. jordan_rose added a comment. Committed as https://reviews.llvm.org/rL286519. Repository: rL LLVM https://reviews.llvm.org/D25850 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286531 - Don't require nullability on 'va_list' harder.
Author: jrose Date: Thu Nov 10 18:23:59 2016 New Revision: 286531 URL: http://llvm.org/viewvc/llvm-project?rev=286531&view=rev Log: Don't require nullability on 'va_list' harder. Platform headers don't always define 'va_list' in terms of Clang's '__builtin_va_list', so in addition to checking for our own synthesized decl, also just look for typedefs literally named 'va_list'. Better to err on the side of false negatives here. Fix-up for rdar://problem/25846421. Modified: cfe/trunk/lib/Sema/SemaType.cpp Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=286531&r1=286530&r2=286531&view=diff == --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Thu Nov 10 18:23:59 2016 @@ -3928,6 +3928,9 @@ static TypeSourceInfo *GetFullTypeForDec do { if (typedefTy->getDecl() == vaListTypedef) return true; +if (auto *name = typedefTy->getDecl()->getIdentifier()) + if (name->isStr("va_list")) +return true; typedefTy = typedefTy->desugar()->getAs(); } while (typedefTy); return false; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26530: Fix the spelling of 'bitfield' in diagnostics to be consistently 'bit-field'.
chandlerc updated this revision to Diff 77574. chandlerc added a comment. Update the tests accordingly. https://reviews.llvm.org/D26530 Files: include/clang/Basic/DiagnosticParseKinds.td include/clang/Basic/DiagnosticSemaKinds.td test/Parser/objc-property-syntax.m test/Sema/constant-conversion.c test/SemaCXX/conversion.cpp test/SemaCXX/member-init.cpp test/SemaOpenCL/unsupported.cl Index: test/SemaOpenCL/unsupported.cl === --- test/SemaOpenCL/unsupported.cl +++ test/SemaOpenCL/unsupported.cl @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -verify %s struct { - int a : 1; // expected-error {{bitfields are not supported in OpenCL}} + int a : 1; // expected-error {{bit-fields are not supported in OpenCL}} }; void no_vla(int n) { Index: test/SemaCXX/member-init.cpp === --- test/SemaCXX/member-init.cpp +++ test/SemaCXX/member-init.cpp @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify -std=c++11 -Wall %s struct Bitfield { - int n : 3 = 7; // expected-error {{bitfield member cannot have an in-class initializer}} + int n : 3 = 7; // expected-error {{bit-field member cannot have an in-class initializer}} }; int a; Index: test/SemaCXX/conversion.cpp === --- test/SemaCXX/conversion.cpp +++ test/SemaCXX/conversion.cpp @@ -50,7 +50,7 @@ namespace test2 { struct A { unsigned int x : 2; -A() : x(10) {} // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}} +A() : x(10) {} // expected-warning {{implicit truncation from 'int' to bit-field changes value from 10 to 2}} }; } Index: test/Sema/constant-conversion.c === --- test/Sema/constant-conversion.c +++ test/Sema/constant-conversion.c @@ -11,7 +11,7 @@ void test_7809123(void) { struct { int i5 : 5; } a; - a.i5 = 36; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 36 to 4}} + a.i5 = 36; // expected-warning {{implicit truncation from 'int' to bit-field changes value from 36 to 4}} } void test() { @@ -31,28 +31,28 @@ int bar : 2; }; - struct A a = { 0, 10 };// expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to -2}} - struct A b[] = { 0, 10, 0, 0 };// expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to -2}} - struct A c[] = {{10, 0}}; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}} - struct A d = (struct A) { 10, 0 }; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}} - struct A e = { .foo = 10 };// expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}} + struct A a = { 0, 10 };// expected-warning {{implicit truncation from 'int' to bit-field changes value from 10 to -2}} + struct A b[] = { 0, 10, 0, 0 };// expected-warning {{implicit truncation from 'int' to bit-field changes value from 10 to -2}} + struct A c[] = {{10, 0}}; // expected-warning {{implicit truncation from 'int' to bit-field changes value from 10 to 2}} + struct A d = (struct A) { 10, 0 }; // expected-warning {{implicit truncation from 'int' to bit-field changes value from 10 to 2}} + struct A e = { .foo = 10 };// expected-warning {{implicit truncation from 'int' to bit-field changes value from 10 to 2}} } void test4() { struct A { char c : 2; } a; - a.c = 0x101; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 257 to 1}} + a.c = 0x101; // expected-warning {{implicit truncation from 'int' to bit-field changes value from 257 to 1}} } void test5() { struct A { _Bool b : 1; } a; // Don't warn about this implicit conversion to bool, or at least - // don't warn about it just because it's a bitfield. + // don't warn about it just because it's a bit-field. a.b = 100; } @@ -71,15 +71,15 @@ f.twoBits1 = ~0; // no-warning f.twoBits1 = ~1; // no-warning - f.twoBits2 = ~2; // expected-warning {{implicit truncation from 'int' to bitfield changes value from -3 to 1}} + f.twoBits2 = ~2; // expected-warning {{implicit truncation from 'int' to bit-field changes value from -3 to 1}} f.twoBits1 &= ~1; // no-warning f.twoBits2 &= ~2; // no-warning } void test8() { enum E { A, B, C }; struct { enum E x : 1; } f; - f.x = C; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 2 to 0}} + f.x = C; // expected-warning {{implicit truncation from 'int' to bit-field changes value from 2 to 0}} } void test9() { @@ -128,6 +128,6 @@ s.a = ~0U; s.a = ~(1<, InGroup; def warn_impcast_bitfield_precision_constant :
[PATCH] D26530: Fix the spelling of 'bitfield' in diagnostics to be consistently 'bit-field'.
chandlerc created this revision. chandlerc added a reviewer: rsmith. chandlerc added a subscriber: cfe-commits. Herald added a subscriber: mcrosier. The latter agrees with most existing diagnostics and the C and C++ standards. https://reviews.llvm.org/D26530 Files: include/clang/Basic/DiagnosticParseKinds.td include/clang/Basic/DiagnosticSemaKinds.td Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -2914,7 +2914,7 @@ "implicit conversion from %2 to %3 changes value from %0 to %1">, InGroup; def warn_impcast_bitfield_precision_constant : Warning< - "implicit truncation from %2 to bitfield changes value from %0 to %1">, + "implicit truncation from %2 to bit-field changes value from %0 to %1">, InGroup; def warn_impcast_literal_float_to_integer : Warning< @@ -8053,7 +8053,7 @@ def err_static_function_scope : Error< "variables in function scope cannot be declared static">; def err_opencl_bitfields : Error< - "bitfields are not supported in OpenCL">; + "bit-fields are not supported in OpenCL">; def err_opencl_vla : Error< "variable length arrays are not supported in OpenCL">; def err_bad_kernel_param_type : Error< Index: include/clang/Basic/DiagnosticParseKinds.td === --- include/clang/Basic/DiagnosticParseKinds.td +++ include/clang/Basic/DiagnosticParseKinds.td @@ -399,7 +399,7 @@ "expected selector for Objective-C %select{setter|getter}0">; def err_objc_property_requires_field_name : Error< "property requires fields to be named">; -def err_objc_property_bitfield : Error<"property name cannot be a bitfield">; +def err_objc_property_bitfield : Error<"property name cannot be a bit-field">; def err_objc_expected_property_attr : Error<"unknown property attribute %0">; def err_objc_properties_require_objc2 : Error< "properties are an Objective-C 2 feature">; @@ -729,7 +729,7 @@ "in-class initialization of non-static data members is incompatible with C++98">, InGroup, DefaultIgnore; def err_bitfield_member_init: Error< - "bitfield member cannot have an in-class initializer">; + "bit-field member cannot have an in-class initializer">; def err_incomplete_array_member_init: Error< "array bound cannot be deduced from an in-class initializer">; Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -2914,7 +2914,7 @@ "implicit conversion from %2 to %3 changes value from %0 to %1">, InGroup; def warn_impcast_bitfield_precision_constant : Warning< - "implicit truncation from %2 to bitfield changes value from %0 to %1">, + "implicit truncation from %2 to bit-field changes value from %0 to %1">, InGroup; def warn_impcast_literal_float_to_integer : Warning< @@ -8053,7 +8053,7 @@ def err_static_function_scope : Error< "variables in function scope cannot be declared static">; def err_opencl_bitfields : Error< - "bitfields are not supported in OpenCL">; + "bit-fields are not supported in OpenCL">; def err_opencl_vla : Error< "variable length arrays are not supported in OpenCL">; def err_bad_kernel_param_type : Error< Index: include/clang/Basic/DiagnosticParseKinds.td === --- include/clang/Basic/DiagnosticParseKinds.td +++ include/clang/Basic/DiagnosticParseKinds.td @@ -399,7 +399,7 @@ "expected selector for Objective-C %select{setter|getter}0">; def err_objc_property_requires_field_name : Error< "property requires fields to be named">; -def err_objc_property_bitfield : Error<"property name cannot be a bitfield">; +def err_objc_property_bitfield : Error<"property name cannot be a bit-field">; def err_objc_expected_property_attr : Error<"unknown property attribute %0">; def err_objc_properties_require_objc2 : Error< "properties are an Objective-C 2 feature">; @@ -729,7 +729,7 @@ "in-class initialization of non-static data members is incompatible with C++98">, InGroup, DefaultIgnore; def err_bitfield_member_init: Error< - "bitfield member cannot have an in-class initializer">; + "bit-field member cannot have an in-class initializer">; def err_incomplete_array_member_init: Error< "array bound cannot be deduced from an in-class initializer">; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286525 - [Sema] Fix-up for MSVC, which is stricter about template types.
Author: jrose Date: Thu Nov 10 17:41:18 2016 New Revision: 286525 URL: http://llvm.org/viewvc/llvm-project?rev=286525&view=rev Log: [Sema] Fix-up for MSVC, which is stricter about template types. Modified: cfe/trunk/lib/Sema/SemaType.cpp Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=286525&r1=286524&r2=286525&view=diff == --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Thu Nov 10 17:41:18 2016 @@ -3545,7 +3545,7 @@ static void recordNullabilitySeen(Sema & S.Diag(fileNullability.PointerLoc, diag::warn_nullability_missing_array); } else { S.Diag(fileNullability.PointerLoc, diag::warn_nullability_missing) - << fileNullability.PointerKind; + << static_cast(fileNullability.PointerKind); } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26415: [XRay] Support AArch64 in Clang
dberris added inline comments. Comment at: lib/Driver/Tools.cpp:4903-4906 +if (Triple.getOS() != llvm::Triple::Linux) + D.Diag(diag::err_drv_clang_unsupported) + << (std::string(XRayInstrumentOption) + " on non-Linux target OS."); +switch (Triple.getArch()) { Did you need to put an `else` before the switch? I don't know what happens when you're on Windows non-supported platform -- will this cause two diagnostics to be printed? https://reviews.llvm.org/D26415 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286521 - Warn when 'assume_nonnull' infers nullability within an array.
Author: jrose Date: Thu Nov 10 17:28:30 2016 New Revision: 286521 URL: http://llvm.org/viewvc/llvm-project?rev=286521&view=rev Log: Warn when 'assume_nonnull' infers nullability within an array. ...or within a reference. Both of these add an extra level of indirection that make us less certain that the pointer really was supposed to be non-nullable. However, changing the default behavior would be a breaking change, so we'll just make it a warning instead. Part of rdar://problem/25846421 Added: cfe/trunk/test/FixIt/nullability.mm Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/test/SemaObjCXX/nullability-consistency-arrays.mm Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=286521&r1=286520&r2=286521&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Nov 10 17:28:30 2016 @@ -277,6 +277,7 @@ def ModuleFileExtension : DiagGroup<"mod def NewlineEOF : DiagGroup<"newline-eof">; def Nullability : DiagGroup<"nullability">; def NullabilityDeclSpec : DiagGroup<"nullability-declspec">; +def NullabilityInferredOnNestedType : DiagGroup<"nullability-inferred-on-nested-type">; def NullableToNonNullConversion : DiagGroup<"nullable-to-nonnull-conversion">; def NullabilityCompletenessOnArrays : DiagGroup<"nullability-completeness-on-arrays">; def NullabilityCompleteness : DiagGroup<"nullability-completeness", Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=286521&r1=286520&r2=286521&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Nov 10 17:28:30 2016 @@ -8737,6 +8737,11 @@ def warn_nullability_missing_array : War "_Nullable, or _Null_unspecified)">, InGroup; +def warn_nullability_inferred_on_nested_type : Warning< + "inferring '_Nonnull' for pointer type within %select{array|reference}0 is " + "deprecated">, + InGroup; + def err_objc_type_arg_explicit_nullability : Error< "type argument %0 cannot explicitly specify nullability">; Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=286521&r1=286520&r2=286521&view=diff == --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Thu Nov 10 17:28:30 2016 @@ -3274,15 +3274,27 @@ namespace { // NSError** NSErrorPointerPointer, }; + + /// Describes a declarator chunk wrapping a pointer that marks inference as + /// unexpected. + // These values must be kept in sync with diagnostics. + enum class PointerWrappingDeclaratorKind { +/// Pointer is top-level. +None = -1, +/// Pointer is an array element. +Array = 0, +/// Pointer is the referent type of a C++ reference. +Reference = 1 + }; } // end anonymous namespace /// Classify the given declarator, whose type-specified is \c type, based on /// what kind of pointer it refers to. /// /// This is used to determine the default nullability. -static PointerDeclaratorKind classifyPointerDeclarator(Sema &S, - QualType type, - Declarator &declarator) { +static PointerDeclaratorKind +classifyPointerDeclarator(Sema &S, QualType type, Declarator &declarator, + PointerWrappingDeclaratorKind &wrappingKind) { unsigned numNormalPointers = 0; // For any dependent type, we consider it a non-pointer. @@ -3294,6 +3306,10 @@ static PointerDeclaratorKind classifyPoi DeclaratorChunk &chunk = declarator.getTypeObject(i); switch (chunk.Kind) { case DeclaratorChunk::Array: + if (numNormalPointers == 0) +wrappingKind = PointerWrappingDeclaratorKind::Array; + break; + case DeclaratorChunk::Function: case DeclaratorChunk::Pipe: break; @@ -3304,14 +3320,18 @@ static PointerDeclaratorKind classifyPoi : PointerDeclaratorKind::SingleLevelPointer; case DeclaratorChunk::Paren: + break; + case DeclaratorChunk::Reference: - continue; + if (numNormalPointers == 0) +wrappingKind = PointerWrappingDeclaratorKind::Reference; + break; case DeclaratorChunk::Pointer: ++numNormalPointers; if (numNormalPointers > 2) return PointerDeclaratorKind::MultiLevelPointer; - con
r286520 - Add -Wnullability-completeness-on-arrays.
Author: jrose Date: Thu Nov 10 17:28:26 2016 New Revision: 286520 URL: http://llvm.org/viewvc/llvm-project?rev=286520&view=rev Log: Add -Wnullability-completeness-on-arrays. This is an addition to (and sub-warning of) -Wnullability-completeness that warns when an array parameter is missing nullability. When the specific warning is switched off, the compiler falls back to only warning on pointer types written as pointer types. Note that use of nullability /within/ an array triggers the completeness checks regardless of whether or not the array-specific warning is enabled; the intent there is simply to determine whether a particular header is trying to be nullability-aware at all. Part of rdar://problem/25846421. Added: cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-arrays.h cfe/trunk/test/SemaObjCXX/nullability-consistency-arrays.mm Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaType.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=286520&r1=286519&r2=286520&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Nov 10 17:28:26 2016 @@ -278,7 +278,9 @@ def NewlineEOF : DiagGroup<"newline-eof" def Nullability : DiagGroup<"nullability">; def NullabilityDeclSpec : DiagGroup<"nullability-declspec">; def NullableToNonNullConversion : DiagGroup<"nullable-to-nonnull-conversion">; -def NullabilityCompleteness : DiagGroup<"nullability-completeness">; +def NullabilityCompletenessOnArrays : DiagGroup<"nullability-completeness-on-arrays">; +def NullabilityCompleteness : DiagGroup<"nullability-completeness", +[NullabilityCompletenessOnArrays]>; def NullArithmetic : DiagGroup<"null-arithmetic">; def NullCharacter : DiagGroup<"null-character">; def NullDereference : DiagGroup<"null-dereference">; Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=286520&r1=286519&r2=286520&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Nov 10 17:28:26 2016 @@ -8732,6 +8732,10 @@ def warn_nullability_missing : Warning< "%select{pointer|block pointer|member pointer}0 is missing a nullability " "type specifier (_Nonnull, _Nullable, or _Null_unspecified)">, InGroup; +def warn_nullability_missing_array : Warning< + "array parameter is missing a nullability type specifier (_Nonnull, " + "_Nullable, or _Null_unspecified)">, + InGroup; def err_objc_type_arg_explicit_nullability : Error< "type argument %0 cannot explicitly specify nullability">; Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=286520&r1=286519&r2=286520&view=diff == --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Thu Nov 10 17:28:26 2016 @@ -3212,6 +3212,7 @@ namespace { Pointer, BlockPointer, MemberPointer, +Array, }; } // end anonymous namespace @@ -3453,12 +3454,15 @@ static FileID getNullabilityCompleteness return file; } -/// Check for consistent use of nullability. -static void checkNullabilityConsistency(TypeProcessingState &state, +/// Complains about missing nullability if the file containing \p pointerLoc +/// has other uses of nullability (either the keywords or the \c assume_nonnull +/// pragma). +/// +/// If the file has \e not seen other uses of nullability, this particular +/// pointer is saved for possible later diagnosis. See recordNullabilitySeen(). +static void checkNullabilityConsistency(Sema &S, SimplePointerKind pointerKind, SourceLocation pointerLoc) { - Sema &S = state.getSema(); - // Determine which file we're performing consistency checking for. FileID file = getNullabilityCompletenessCheckFileID(S, pointerLoc); if (file.isInvalid()) @@ -3468,10 +3472,16 @@ static void checkNullabilityConsistency( // about anything. FileNullability &fileNullability = S.NullabilityMap[file]; if (!fileNullability.SawTypeNullability) { -// If this is the first pointer declarator in the file, record it. +// If this is the first pointer declarator in the file, and the appropriate +// warning is on, record it in case we need to diagnose it retroactively. +diag::kind diagKind; +if (pointerKind == SimplePointerKind::Array)
r286519 - Accept nullability qualifiers on array parameters.
Author: jrose Date: Thu Nov 10 17:28:17 2016 New Revision: 286519 URL: http://llvm.org/viewvc/llvm-project?rev=286519&view=rev Log: Accept nullability qualifiers on array parameters. Since array parameters decay to pointers, '_Nullable' and friends should be available for use there as well. This is especially important for parameters that are typedefs of arrays. The unsugared syntax for this follows the syntax for 'static'-sized arrays in C: void test(int values[_Nullable]); This syntax was previously accepted but the '_Nullable' (and any other attributes) were silently discarded. However, applying '_Nullable' to a typedef was previously rejected and is now accepted; therefore, it may be necessary to test for the presence of this feature: #if __has_feature(nullability_on_arrays) One important change here is that DecayedTypes don't always immediately contain PointerTypes anymore; they may contain an AttributedType instead. This only affected one place in-tree, so I would guess it's not likely to cause problems elsewhere. This commit does not change -Wnullability-completeness just yet. I want to think about whether it's worth doing something special to avoid breaking existing clients that compile with -Werror. It also doesn't change '#pragma clang assume_nonnull' behavior, which currently treats the following two declarations as equivalent: #pragma clang assume_nonnull begin void test(void *pointers[]); #pragma clang assume_nonnull end void test(void * _Nonnull pointers[]); This is not the desired behavior, but changing it would break backwards-compatibility. Most likely the best answer is going to be adding a new warning. Part of rdar://problem/25846421 Modified: cfe/trunk/include/clang/AST/Type.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/Lex/PPMacroExpansion.cpp cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/test/Parser/nullability.c cfe/trunk/test/Sema/nullability.c cfe/trunk/test/SemaCXX/nullability.cpp cfe/trunk/test/SemaObjC/nullability.m Modified: cfe/trunk/include/clang/AST/Type.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=286519&r1=286518&r2=286519&view=diff == --- cfe/trunk/include/clang/AST/Type.h (original) +++ cfe/trunk/include/clang/AST/Type.h Thu Nov 10 17:28:17 2016 @@ -2266,19 +2266,15 @@ public: /// Represents a pointer type decayed from an array or function type. class DecayedType : public AdjustedType { - DecayedType(QualType OriginalType, QualType DecayedPtr, QualType CanonicalPtr) - : AdjustedType(Decayed, OriginalType, DecayedPtr, CanonicalPtr) { -assert(isa(getAdjustedType())); - } + inline + DecayedType(QualType OriginalType, QualType Decayed, QualType Canonical); friend class ASTContext; // ASTContext creates these. public: QualType getDecayedType() const { return getAdjustedType(); } - QualType getPointeeType() const { -return cast(getDecayedType())->getPointeeType(); - } + inline QualType getPointeeType() const; static bool classof(const Type *T) { return T->getTypeClass() == Decayed; } }; @@ -5962,6 +5958,23 @@ inline const ArrayType *Type::castAsArra return cast(getUnqualifiedDesugaredType()); } +DecayedType::DecayedType(QualType OriginalType, QualType DecayedPtr, + QualType CanonicalPtr) +: AdjustedType(Decayed, OriginalType, DecayedPtr, CanonicalPtr) { +#ifndef NDEBUG + QualType Adjusted = getAdjustedType(); + (void)AttributedType::stripOuterNullability(Adjusted); + assert(isa(Adjusted)); +#endif +} + +QualType DecayedType::getPointeeType() const { + QualType Decayed = getDecayedType(); + (void)AttributedType::stripOuterNullability(Decayed); + return cast(Decayed)->getPointeeType(); +} + + } // end namespace clang #endif Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=286519&r1=286518&r2=286519&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Thu Nov 10 17:28:17 2016 @@ -3122,10 +3122,14 @@ public: /// method) or an Objective-C property attribute, rather than as an /// underscored type specifier. /// + /// \param allowArrayTypes Whether to accept nullability specifiers on an + /// array type (e.g., because it will decay to a pointer). + /// /// \returns true if nullability cannot be applied, false otherwise. bool checkNullabilityTypeSpecifier(QualType &type, NullabilityKind nullability, SourceLocation nullabilityLoc, - bool isContextSensitive); + bool isContextSensitiv
r286522 - Don't require nullability on 'va_list'.
Author: jrose Date: Thu Nov 10 17:28:34 2016 New Revision: 286522 URL: http://llvm.org/viewvc/llvm-project?rev=286522&view=rev Log: Don't require nullability on 'va_list'. There are many non-portable typedefs, but va_list is one that nobody ever thinks of as a pointer or an array. (When's the last time you saw someone check for a NULL va_list?) Make an exception for this one special type. Part of rdar://problem/25846421. Modified: cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-arrays.h Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=286522&r1=286521&r2=286522&view=diff == --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Thu Nov 10 17:28:34 2016 @@ -3919,8 +3919,22 @@ static TypeSourceInfo *GetFullTypeForDec attr->setUsedAsTypeAttr(); } } + +auto isVaList = [&S](QualType T) -> bool { + auto *typedefTy = T->getAs(); + if (!typedefTy) +return false; + TypedefDecl *vaListTypedef = S.Context.getBuiltinVaListDecl(); + do { +if (typedefTy->getDecl() == vaListTypedef) + return true; +typedefTy = typedefTy->desugar()->getAs(); + } while (typedefTy); + return false; +}; + if (complainAboutMissingNullability == CAMN_Yes && -T->isArrayType() && !T->getNullability(S.Context) && +T->isArrayType() && !T->getNullability(S.Context) && !isVaList(T) && D.isPrototypeContext() && !hasOuterPointerLikeChunk(D, D.getNumTypeObjects())) { checkNullabilityConsistency(S, SimplePointerKind::Array, Modified: cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-arrays.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-arrays.h?rev=286522&r1=286521&r2=286522&view=diff == --- cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-arrays.h (original) +++ cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-arrays.h Thu Nov 10 17:28:34 2016 @@ -1,3 +1,5 @@ +#include + void firstThingInTheFileThatNeedsNullabilityIsAnArray(int ints[]); #if ARRAYS_CHECKED // expected-warning@-2 {{array parameter is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)}} @@ -33,6 +35,26 @@ void testAllOK( void * _Nullable ptrs[_Nonnull], void * _Nullable * _Nullable nestedPtrs[_Nonnull]); +void testVAList(va_list ok); // no warning + +#if __cplusplus +// Carefully construct a test case such that if a platform's va_list is an array +// or pointer type, it gets tested, but otherwise it does not. +template +struct pointer_like_or { typedef F type; }; +template +struct pointer_like_or { typedef T *type; }; +template +struct pointer_like_or { typedef T * const type; }; +template +struct pointer_like_or { typedef T type[]; }; +template +struct pointer_like_or { typedef T type[size]; }; + +void testVAListWithNullability( + pointer_like_or::type _Nonnull x); // no errors +#endif + void nestedArrays(int x[5][1]) {} #if ARRAYS_CHECKED // expected-warning@-2 {{array parameter is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286518 - [index] Add SymbolSubKind for the GKInspectable annotation.
Author: akirtzidis Date: Thu Nov 10 17:27:11 2016 New Revision: 286518 URL: http://llvm.org/viewvc/llvm-project?rev=286518&view=rev Log: [index] Add SymbolSubKind for the GKInspectable annotation. Modified: cfe/trunk/include/clang/Index/IndexSymbol.h cfe/trunk/lib/Index/IndexSymbol.cpp cfe/trunk/test/Index/Core/index-subkinds.m Modified: cfe/trunk/include/clang/Index/IndexSymbol.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/IndexSymbol.h?rev=286518&r1=286517&r2=286518&view=diff == --- cfe/trunk/include/clang/Index/IndexSymbol.h (original) +++ cfe/trunk/include/clang/Index/IndexSymbol.h Thu Nov 10 17:27:11 2016 @@ -66,8 +66,9 @@ enum class SymbolSubKind : uint8_t { UnitTest = 1 << 3, IBAnnotated = 1 << 4, IBOutletCollection= 1 << 5, + GKInspectable = 1 << 6, }; -static const unsigned SymbolSubKindBitNum = 6; +static const unsigned SymbolSubKindBitNum = 7; typedef unsigned SymbolSubKindSet; /// Set of roles that are attributed to symbol occurrences. Modified: cfe/trunk/lib/Index/IndexSymbol.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=286518&r1=286517&r2=286518&view=diff == --- cfe/trunk/lib/Index/IndexSymbol.cpp (original) +++ cfe/trunk/lib/Index/IndexSymbol.cpp Thu Nov 10 17:27:11 2016 @@ -165,6 +165,10 @@ SymbolInfo index::getSymbolInfo(const De Info.Kind = SymbolKind::InstanceProperty; Info.Lang = SymbolLanguage::ObjC; checkForIBOutlets(D, Info.SubKinds); + if (auto *Annot = D->getAttr()) { +if (Annot->getAnnotation() == "gk_inspectable") + Info.SubKinds |= (unsigned)SymbolSubKind::GKInspectable; + } break; case Decl::ObjCIvar: Info.Kind = SymbolKind::Field; @@ -380,6 +384,7 @@ void index::applyForEachSymbolSubKind(Sy APPLY_FOR_SUBKIND(UnitTest); APPLY_FOR_SUBKIND(IBAnnotated); APPLY_FOR_SUBKIND(IBOutletCollection); + APPLY_FOR_SUBKIND(GKInspectable); #undef APPLY_FOR_SUBKIND } @@ -398,6 +403,7 @@ void index::printSymbolSubKinds(SymbolSu case SymbolSubKind::UnitTest: OS << "test"; break; case SymbolSubKind::IBAnnotated: OS << "IB"; break; case SymbolSubKind::IBOutletCollection: OS << "IBColl"; break; +case SymbolSubKind::GKInspectable: OS << "GKI"; break; } }); } Modified: cfe/trunk/test/Index/Core/index-subkinds.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-subkinds.m?rev=286518&r1=286517&r2=286518&view=diff == --- cfe/trunk/test/Index/Core/index-subkinds.m (original) +++ cfe/trunk/test/Index/Core/index-subkinds.m Thu Nov 10 17:27:11 2016 @@ -50,3 +50,11 @@ // CHECK: [[@LINE+1]]:1 | instance-method(IB)/ObjC | doIt | c:objc(cs)IBCls(im)doIt | -[IBCls doIt] | Decl,Dyn,RelChild | rel: 1 -(IBAction)doIt; @end + + +#define GKInspectable __attribute__((annotate("gk_inspectable"))) + +@interface GKI +// CHECK: [[@LINE+1]]:40 | instance-property(GKI)/ObjC | gkIntProp | c:objc(cs)GKI(py)gkIntProp | | Decl,RelChild | rel: 1 +@property (readonly) GKInspectable int gkIntProp; +@end ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286512 - [test] Remove implicit deps on libLTO.dylib on Darwin (NFC)
Author: vedantk Date: Thu Nov 10 16:31:06 2016 New Revision: 286512 URL: http://llvm.org/viewvc/llvm-project?rev=286512&view=rev Log: [test] Remove implicit deps on libLTO.dylib on Darwin (NFC) This un-breaks the `check-clang` target. Modified: cfe/trunk/test/Driver/nostdlib.c cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp Modified: cfe/trunk/test/Driver/nostdlib.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/nostdlib.c?rev=286512&r1=286511&r2=286512&view=diff == --- cfe/trunk/test/Driver/nostdlib.c (original) +++ cfe/trunk/test/Driver/nostdlib.c Thu Nov 10 16:31:06 2016 @@ -6,24 +6,24 @@ // Most of the toolchains would check for -nostartfiles and -nostdlib // in a short-circuiting boolean expression, so if both of the preceding // options were present, the second would warn about being unused. -// RUN: %clang -### -nostartfiles -nostdlib -target i386-apple-darwin %s \ +// RUN: %clang -### -Wno-liblto -nostartfiles -nostdlib -target i386-apple-darwin %s \ // RUN: 2>&1 | FileCheck %s -check-prefix=ARGSCLAIMED // ARGSCLAIMED-NOT: warning: // In the presence of -nostdlib, the standard libraries should not be // passed down to link line -// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: %clang -no-canonical-prefixes %s -### -Wno-liblto -o %t.o 2>&1 \ // RUN: -target i686-pc-linux-gnu -nostdlib --rtlib=compiler-rt \ // RUN: -resource-dir=%S/Inputs/resource_dir -lclang_rt.builtins-i686 \ // RUN: | FileCheck --check-prefix=CHECK-LINUX-NOSTDLIB %s // -// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: %clang -no-canonical-prefixes %s -### -Wno-liblto -o %t.o 2>&1 \ // RUN: -target i686-pc-linux-gnu --rtlib=compiler-rt -nostdlib \ // RUN: -resource-dir=%S/Inputs/resource_dir -lclang_rt.builtins-i686 \ // RUN: | FileCheck --check-prefix=CHECK-LINUX-NOSTDLIB %s // -// RUN: %clang -target x86_64-pc-windows-msvc -nostdlib --rtlib=compiler-rt -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MSVC-NOSTDLIB -// RUN: %clang -target x86_64-pc-windows-msvc --rtlib=compiler-rt -nostdlib -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MSVC-NOSTDLIB +// RUN: %clang -target x86_64-pc-windows-msvc -nostdlib --rtlib=compiler-rt -### -Wno-liblto %s 2>&1 | FileCheck %s -check-prefix CHECK-MSVC-NOSTDLIB +// RUN: %clang -target x86_64-pc-windows-msvc --rtlib=compiler-rt -nostdlib -### -Wno-liblto %s 2>&1 | FileCheck %s -check-prefix CHECK-MSVC-NOSTDLIB // // CHECK-LINUX-NOSTDLIB: warning: argument unused during compilation: '--rtlib=compiler-rt' // CHECK-LINUX-NOSTDLIB: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}" Modified: cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp?rev=286512&r1=286511&r2=286512&view=diff == --- cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp (original) +++ cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp Thu Nov 10 16:31:06 2016 @@ -8,7 +8,7 @@ // Test that link invocations don't emit an "argument unused during compilation" diagnostic. // RUN: touch %t.o -// RUN: %clang -Werror -Wframe-larger-than=0 %t.o -### 2>&1 | not grep ' error: ' +// RUN: %clang -Werror -Wno-liblto -Wframe-larger-than=0 %t.o -### 2>&1 | not grep ' error: ' // TODO: Support rich backend diagnostics for Objective-C methods. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286507 - [clang-format] Fix PR30527: Regression when clang-format insert spaces in [] when in template
Author: nico Date: Thu Nov 10 15:49:25 2016 New Revision: 286507 URL: http://llvm.org/viewvc/llvm-project?rev=286507&view=rev Log: [clang-format] Fix PR30527: Regression when clang-format insert spaces in [] when in template Actual regression was introduced in r272668. This revision fixes JS script, but also regress Cpp case. It manifests with spaces added when template is followed with array. Bug 30527 mentions case of array as a nested template type (foo[]>). Fix is to detect such case and to prevent treating it as array initialization, but as a subscript case. However, before r272668, this case was treated simple because we were detecting it as a StartsObjCMethodExpr. Same was true for other similar case - array of templates (foo[]). This patch tries to address two problems: 1) fixing regression 2) making sure both cases (array as a nested type, array of templates) which were entering StartsObjCMethodExpr branch are handled now appropriately. https://reviews.llvm.org/D26163 Patch from Branko Kokanovic ! Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTest.cpp Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=286507&r1=286506&r2=286507&view=diff == --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Nov 10 15:49:25 2016 @@ -306,7 +306,17 @@ private: FormatToken *Left = CurrentToken->Previous; Left->ParentBracket = Contexts.back().ContextKind; FormatToken *Parent = Left->getPreviousNonComment(); -bool StartsObjCMethodExpr = + +// Cases where '>' is followed by '['. +// In C++, this can happen either in array of templates (foo[10]) +// or when array is a nested template type (unique_ptr[]>). +bool CppArrayTemplates = +Style.Language == FormatStyle::LK_Cpp && Parent && +Parent->is(TT_TemplateCloser) && +(Contexts.back().CanBeExpression || Contexts.back().IsExpression || + Contexts.back().InTemplateArgument); + +bool StartsObjCMethodExpr = !CppArrayTemplates && Style.Language == FormatStyle::LK_Cpp && Contexts.back().CanBeExpression && Left->isNot(TT_LambdaLSquare) && CurrentToken->isNot(tok::l_brace) && @@ -327,7 +337,7 @@ private: Parent->isOneOf(tok::l_brace, tok::comma)) { Left->Type = TT_JsComputedPropertyName; } else if (Style.Language == FormatStyle::LK_Proto || - (Parent && + (!CppArrayTemplates && Parent && Parent->isOneOf(TT_BinaryOperator, TT_TemplateCloser, tok::at, tok::comma, tok::l_paren, tok::l_square, tok::question, tok::colon, tok::kw_return, Modified: cfe/trunk/unittests/Format/FormatTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=286507&r1=286506&r2=286507&view=diff == --- cfe/trunk/unittests/Format/FormatTest.cpp (original) +++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Nov 10 15:49:25 2016 @@ -11544,6 +11544,26 @@ TEST_F(FormatTest, FormatsTableGenCode) verifyFormat("include \"a.td\"\ninclude \"b.td\"", Style); } +TEST_F(FormatTest, ArrayOfTemplates) { + EXPECT_EQ("auto a = new unique_ptr[10];", +format("auto a = new unique_ptr [ 10];")); + + FormatStyle Spaces = getLLVMStyle(); + Spaces.SpacesInSquareBrackets = true; + EXPECT_EQ("auto a = new unique_ptr[ 10 ];", +format("auto a = new unique_ptr [10];", Spaces)); +} + +TEST_F(FormatTest, ArrayAsTemplateType) { + EXPECT_EQ("auto a = unique_ptr[10]>;", +format("auto a = unique_ptr < Foo < Bar>[ 10]> ;")); + + FormatStyle Spaces = getLLVMStyle(); + Spaces.SpacesInSquareBrackets = true; + EXPECT_EQ("auto a = unique_ptr[ 10 ]>;", +format("auto a = unique_ptr < Foo < Bar>[10]> ;", Spaces)); +} + // Since this test case uses UNIX-style file path. We disable it for MS // compiler. #if !defined(_MSC_VER) && !defined(__MINGW32__) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26163: [clang-format] Fix PR30527: Regression when clang-format insert spaces in [] when in template
thakis closed this revision. thakis added a comment. Landed in r286507. Thanks! https://reviews.llvm.org/D26163 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286506 - [Sema] Range-ify for loop, add period to comment. NFC.
Author: gbiv Date: Thu Nov 10 15:47:12 2016 New Revision: 286506 URL: http://llvm.org/viewvc/llvm-project?rev=286506&view=rev Log: [Sema] Range-ify for loop, add period to comment. NFC. Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/lib/Sema/SemaOverload.cpp Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=286506&r1=286505&r2=286506&view=diff == --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Nov 10 15:47:12 2016 @@ -825,8 +825,8 @@ static void handleEnableIfAttr(Sema &S, !Expr::isPotentialConstantExprUnevaluated(Cond, cast(D), Diags)) { S.Diag(Attr.getLoc(), diag::err_enable_if_never_constant_expr); -for (int I = 0, N = Diags.size(); I != N; ++I) - S.Diag(Diags[I].first, Diags[I].second); +for (const PartialDiagnosticAt &PDiag : Diags) + S.Diag(PDiag.first, PDiag.second); return; } Modified: cfe/trunk/lib/Sema/SemaOverload.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=286506&r1=286505&r2=286506&view=diff == --- cfe/trunk/lib/Sema/SemaOverload.cpp (original) +++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Nov 10 15:47:12 2016 @@ -12498,7 +12498,7 @@ Sema::BuildCallToMemberFunction(Scope *S // In the case the method to call was not selected by the overloading // resolution process, we still need to handle the enable_if attribute. Do - // that here, so it will not hide previous -- and more relevant -- errors + // that here, so it will not hide previous -- and more relevant -- errors. if (isa(NakedMemExpr)) { if (const EnableIfAttr *Attr = CheckEnableIf(Method, Args, true)) { Diag(MemExprE->getLocStart(), ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26196: Add support for non-zero null pointers
rjmccall added inline comments. Comment at: lib/CodeGen/TargetInfo.cpp:7040 + auto AS = PT->getAddressSpace(); + return AS != Ctx.getTargetAddressSpace(LangAS::opencl_local) && AS != 0; +} yaxunl wrote: > rjmccall wrote: > > This check is definitely not correct; this function needs to return true > > when AS == 0, right? > > > > Also, you should really just be checking QT.getAddressSpace(). > The null pointer of amdgpu target in addr space 0 does not have zero value. > > I will change it use QT.getAddressSpace() though. Oh, if the *default* address space — the address space of the stack — has a non-zero null pointer value, that will definitely change a lot of things, and LLVM will probably be deeply unhappy with you. I feel like that's a much bigger and more problematic change. This is still the right approach for working around it in Clang, but... it's concerning. And that does mean you'll have to fix a bunch of the other languages that in principle you could otherwise have avoided. https://reviews.llvm.org/D26196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26522: Improve handling of __FUNCTION__ and other predefined expression for Objective-C Blocks
mehdi_amini created this revision. mehdi_amini added a reviewer: arphaman. mehdi_amini added a subscriber: cfe-commits. Instead of always displaying the mangled name, try to do better and get something closer to regular functions. https://reviews.llvm.org/D26522 Files: clang/lib/AST/Expr.cpp clang/lib/CodeGen/CGExpr.cpp clang/test/CodeGen/block-with-perdefinedexpr.cpp clang/test/CodeGenCXX/predefined-expr-cxx14.cpp Index: clang/test/CodeGenCXX/predefined-expr-cxx14.cpp === --- clang/test/CodeGenCXX/predefined-expr-cxx14.cpp +++ clang/test/CodeGenCXX/predefined-expr-cxx14.cpp @@ -17,8 +17,8 @@ // CHECK-DAG: @__func__._ZN24ClassInTopLevelNamespace25topLevelNamespaceFunctionEv = private unnamed_addr constant [26 x i8] c"topLevelNamespaceFunction\00" // CHECK-DAG: @__PRETTY_FUNCTION__._ZN24ClassInTopLevelNamespace25topLevelNamespaceFunctionEv = private unnamed_addr constant [60 x i8] c"auto *ClassInTopLevelNamespace::topLevelNamespaceFunction()\00" -// CHECK-DAG: @__func__.___ZN16ClassBlockConstrD2Ev_block_invoke = private unnamed_addr constant [41 x i8] c"___ZN16ClassBlockConstrD2Ev_block_invoke\00" -// CHECK-DAG: @__func__.___ZN16ClassBlockConstrC2Ev_block_invoke = private unnamed_addr constant [41 x i8] c"___ZN16ClassBlockConstrC2Ev_block_invoke\00" +// CHECK-DAG: @__func__.___ZN16ClassBlockConstrD2Ev_block_invoke = private unnamed_addr constant [31 x i8] c"~ClassBlockConstr_block_invoke\00" +// CHECK-DAG: @__func__.___ZN16ClassBlockConstrC2Ev_block_invoke = private unnamed_addr constant [30 x i8] c"ClassBlockConstr_block_invoke\00" int printf(const char * _Format, ...); Index: clang/test/CodeGen/block-with-perdefinedexpr.cpp === --- /dev/null +++ clang/test/CodeGen/block-with-perdefinedexpr.cpp @@ -0,0 +1,69 @@ +// RUN: %clang_cc1 %s -emit-llvm -o - -fblocks -triple x86_64-apple-darwin10 | FileCheck %s + +void bar() { + // CHECK-DAG: @__FUNCTION__.___Z3barv_block_invoke = private unnamed_addr constant [17 x i8] c"bar_block_invoke\00", align 1 + const char * (^block1)() = ^() { +return __FUNCTION__; + }; + // CHECK-DAG: @__FUNCTION__.___Z3barv_block_invoke_2 = private unnamed_addr constant [19 x i8] c"bar_block_invoke_2\00", align 1 + const char * (^block2)() = ^() { +return __FUNCTION__; + }; +} + +void baz() { + // CHECK-DAG: @__PRETTY_FUNCTION__.___Z3bazv_block_invoke = private unnamed_addr constant [24 x i8] c"void baz()_block_invoke\00", align 1 + const char * (^block1)() = ^() { +return __PRETTY_FUNCTION__; + }; + // CHECK-DAG: @__PRETTY_FUNCTION__.___Z3bazv_block_invoke_2 = private unnamed_addr constant [26 x i8] c"void baz()_block_invoke_2\00", align 1 + const char * (^block2)() = ^() { +return __PRETTY_FUNCTION__; + }; +} + +namespace foonamespace { +class Foo { +public: + Foo() { +// CHECK-DAG: @__PRETTY_FUNCTION__.___ZN12foonamespace3FooC2Ev_block_invoke = private unnamed_addr constant [38 x i8] c"foonamespace::Foo::Foo()_block_invoke\00", align 1 +const char * (^block1)() = ^() { + return __PRETTY_FUNCTION__; +}; +// CHECK-DAG: @__PRETTY_FUNCTION__.___ZN12foonamespace3FooC2Ev_block_invoke_2 = private unnamed_addr constant [40 x i8] c"foonamespace::Foo::Foo()_block_invoke_2\00", align 1 +const char * (^block2)() = ^() { + return __PRETTY_FUNCTION__; +}; +// CHECK-DAG: @__func__.___ZN12foonamespace3FooC2Ev_block_invoke_3 = private unnamed_addr constant [19 x i8] c"Foo_block_invoke_3\00", align 1 +const char * (^block3)() = ^() { + return __func__; +}; +bar(); + } + ~Foo() { +// CHECK-DAG: @__func__.___ZN12foonamespace3FooD2Ev_block_invoke = private unnamed_addr constant [18 x i8] c"~Foo_block_invoke\00", align 1 +const char * (^block1)() = ^() { + return __func__; +}; +// CHECK-DAG: @__PRETTY_FUNCTION__.___ZN12foonamespace3FooD2Ev_block_invoke_2 = private unnamed_addr constant [41 x i8] c"foonamespace::Foo::~Foo()_block_invoke_2\00", align 1 +const char * (^block2)() = ^() { + return __PRETTY_FUNCTION__; +}; + } + void bar() { +// CHECK-DAG: @__PRETTY_FUNCTION__.___ZN12foonamespace3Foo3barEv_block_invoke = private unnamed_addr constant [43 x i8] c"void foonamespace::Foo::bar()_block_invoke\00", align 1 +const char * (^block1)() = ^() { + return __PRETTY_FUNCTION__; +}; +// CHECK-DAG: @__PRETTY_FUNCTION__.___ZN12foonamespace3Foo3barEv_block_invoke_2 = private unnamed_addr constant [45 x i8] c"void foonamespace::Foo::bar()_block_invoke_2\00", align 1 +const char * (^block2)() = ^() { + return __PRETTY_FUNCTION__; +}; +// CHECK-DAG: @__func__.___ZN12foonamespace3Foo3barEv_block_invoke_3 = private unnamed_addr constant [19 x i8] c"bar_block_invoke_3\00", align 1 +const char * (^block3)() = ^() { + return __func__; +}; + } +}; +Foo f; +} Index: clang/lib/CodeGen/CGExpr.cpp ===
[PATCH] D26431: [WebAssembly] Define __unix__ as part of the wasm target
jgravelle-google abandoned this revision. jgravelle-google added a comment. Abandoning in favor of https://github.com/kripken/emscripten/pull/4718 https://reviews.llvm.org/D26431 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24933: Enable configuration files in clang
hans added a comment. In https://reviews.llvm.org/D24933#591943, @sepavloff wrote: > >> Default config file is searched for only in the directory where clang > >> executable resides. It allows SDK suppliers to customize compiler, for > >> instance by turning off unneeded warnings, by providing their own > >> clang.cfg. On the other hand developers cannot by accident override > >> default setting because clang.cfg is placed in system directory. > > > > I thought one of the stated goals for this patch would be to allow users to > > set default flags without touching the project's build system. > > Yes, that's true. Initially it was supposed that a user can override compiler > defaults by putting `clang.cfg` into well-knows places, including `~/llvm`, > in particular. Then this idea was rejected as a result of feedback, and > default config file now is allowed only in the directory where `clang` > executable resides. It still allows to override default settings by SDK > suppliers but limit this possibility to powerful users. I see. The SDK use case seems quite reasonable to me. >> What about this line? >> >> static const ArrayRef SearchDirs({ "~/.llvm", "/etc/llvm" }); >> >> That sounds like you'll be searching the home directory for a default config >> file. > > These are directories where config files specified by option `--config` are > searched for. There is a big difference between default config files and > those specified explicitly. Default file adds option silently, user does not > specify anything in the command line. Due to this point it can represent a > source of troubles, such as problems with bug reports. In contrast the named > config files are specified explicitly in clang invocation. A user may set the > same set of option by listing them in command line. Such config file does not > represents any dander, it is only a convenience feature. Oh, I misunderstood then. Thanks for clarifying. >> And even if we ignore that, the CLANGCFG environment variable presents the >> same problem. >> >> Let's say a developer uses that to point to a config file with their >> favourite compiler flags for compiling on their x86_64 machine. >> >> But then they want to build something using the Android NDK, whose Clang >> will now pull in that config file and start passing flags which doesn't >> apply to the target, e.g. ARM. The user might not even be invoking the NDK >> directly; it might be through Android Studio which certainly doesn't expect >> other flags to be used than the ones it passes. > > If a user forget to update LIBRARY_PATH or C_INCLUDE_PATH the result would be > the same. I don't like those either :-) > Config file set by environment variable is similar to default config file as > user does not specify anything in command line. But the user must explicitly > specify the file, it is not made automatically. Sorry, I don't understand this part. > Ability to append compiler options via environment variable is important > feature, I think, because: > > - This feature implemented by Intel compiles has proven its convenience. > - Build systems provided by software components are not perfect. Some do not > honor CFLAGS, some require setting options inside makefiles etc. Changing > compiler options might be a challenge. Environment variable solves this > problem easily and effectively. But now you seem to be serving the goal about letting the user set flags without using the build system, which I thought wasn't a goal anymore? Again, allowing SDKs to configure the compiler (such as setting the default target) without actually changing it in the source seems somewhat reasonable, but this other part worries me. https://reviews.llvm.org/D24933 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26520: [PowerPC] Implement BE VSX load/store builtins - llvm portion.
jtony created this revision. jtony added reviewers: nemanjai, sfertile, syzaara, lei, kbarton, amehsan. jtony added subscribers: llvm-commits, cfe-commits, echristo. This patch implements all the overloads for vec_xl_be and vec_xst_be. On BE, they behaves exactly the same with vec_xl and vec_xst, therefore they are simply implemented by defining a matching macro. On LE, they are implemented by defining new builtins and intrinsics. For int/float/long long/double, it is just a load (lxvw4x/lxvd2x) or store(stxvw4x/stxvd2x). For char/char/short, we also need some extra shuffling before or after call the builtins to get the desired BE order. For int128, simply call vec_xl or vec_xst. Signatures: vector signed char vec_xl_be (signed long long, signed char *); vector unsigned char vec_xl_be (signed long long, unsigned char *); vector signed int vec_xl_be (signed long long, signed int *); vector unsigned int vec_xl_be (signed long long, unsigned int *); vector signed int128 vec_xl_be (signed long long, signed int128 *); vector unsigned int128 vec_xl_be (signed long long, unsigned int128 *); vector signed long long vec_xl_be (signed long long, signed long long *); vector unsigned long long vec_xl_be (signed long long, unsigned long long *); vector signed short vec_xl_be (signed long long, signed short *); vector unsigned short vec_xl_be (signed long long, unsigned short *); vector double vec_xl_be (signed long long, double *); vector float vec_xl_be (signed long long, float *); void vec_xst_be (vector signed char, signed long long, signed char *); void vec_xst_be (vector unsigned char, signed long long, unsigned char *); void vec_xst_be (vector signed int, signed long long, signed int *); void vec_xst_be (vector unsigned int, signed long long, unsigned int *); void vec_xst_be (vector signed int128, signed long long, signed int128 *); void vec_xst_be (vector unsigned int128, signed long long, unsigned int128 *); void vec_xst_be (vector signed long long, signed long long, signed long long *); void vec_xst_be (vector unsigned long long, signed long long, unsigned long long *); void vec_xst_be (vector signed short, signed long long, signed short *); void vec_xst_be (vector unsigned short, signed long long, unsigned short *); void vec_xst_be (vector double, signed long long, double *); void vec_xst_be (vector float, signed long long, float *); https://reviews.llvm.org/D26520 Files: include/llvm/IR/IntrinsicsPowerPC.td lib/Target/PowerPC/PPCISelLowering.cpp lib/Target/PowerPC/PPCInstrVSX.td test/CodeGen/PowerPC/vsx.ll Index: test/CodeGen/PowerPC/vsx.ll === --- test/CodeGen/PowerPC/vsx.ll +++ test/CodeGen/PowerPC/vsx.ll @@ -1190,3 +1190,51 @@ ; CHECK-LE: xscmpudp [[REG:[0-9]+]], 3, 4 ; CHECK-LE: beqlr [[REG]] } + +; Function Attrs: nounwind readnone +define <4 x i32> @test83(i8* %a) { + entry: +%0 = tail call <4 x i32> @llvm.ppc.vsx.lxvw4x.be(i8* %a) + ret <4 x i32> %0 + ; CHECK-LABEL: test83 + ; CHECK: lxvw4x 34, 0, 3 + ; CHECK: blr +} +; Function Attrs: nounwind readnone +declare <4 x i32> @llvm.ppc.vsx.lxvw4x.be(i8*) + +; Function Attrs: nounwind readnone +define <2 x double> @test84(i8* %a) { + entry: +%0 = tail call <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8* %a) + ret <2 x double> %0 + ; CHECK-LABEL: test84 + ; CHECK: lxvd2x 34, 0, 3 + ; CHECK: blr +} +; Function Attrs: nounwind readnone +declare <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8*) + +; Function Attrs: nounwind readnone +define void @test85(<4 x i32> %a, i8* %b) { + entry: +tail call void @llvm.ppc.vsx.stxvw4x.be(<4 x i32> %a, i8* %b) +ret void + ; CHECK-LABEL: test85 + ; CHECK: stxvw4x 34, 0, 5 + ; CHECK: blr +} +; Function Attrs: nounwind readnone +declare void @llvm.ppc.vsx.stxvw4x.be(<4 x i32>, i8*) + +; Function Attrs: nounwind readnone +define void @test86(<2 x double> %a, i8* %b) { + entry: +tail call void @llvm.ppc.vsx.stxvd2x.be(<2 x double> %a, i8* %b) +ret void + ; CHECK-LABEL: test86 + ; CHECK: stxvd2x 34, 0, 5 + ; CHECK: blr +} +; Function Attrs: nounwind readnone +declare void @llvm.ppc.vsx.stxvd2x.be(<2 x double>, i8*) Index: lib/Target/PowerPC/PPCInstrVSX.td === --- lib/Target/PowerPC/PPCInstrVSX.td +++ lib/Target/PowerPC/PPCInstrVSX.td @@ -1012,6 +1012,10 @@ (STXVD2X $rS, xoaddr:$dst)>; def : Pat<(int_ppc_vsx_stxvw4x v4i32:$rS, xoaddr:$dst), (STXVW4X $rS, xoaddr:$dst)>; + def : Pat<(int_ppc_vsx_stxvd2x_be v2f64:$rS, xoaddr:$dst), +(STXVD2X $rS, xoaddr:$dst)>; + def : Pat<(int_ppc_vsx_stxvw4x_be v4i32:$rS, xoaddr:$dst), +(STXVW4X $rS, xoaddr:$dst)>; def : Pat<(PPCstxvd2x v2f64:$rS, xoaddr:$dst), (STXVD2X $rS, xoaddr:$dst)>; } let Predicates = [IsBigEndian, HasVSX, HasOnlySwappingMemOps] in { @@ -1840,6 +1844,9 @@ def : Pat<(f64 (vector_extract v
[PATCH] D26163: [clang-format] Fix PR30527: Regression when clang-format insert spaces in [] when in template
branko added a comment. Thanks. @djasper - can you commit this for me, please? https://reviews.llvm.org/D26163 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286500 - Clean up uses of unique_ptr for RAII objects. NFC.
Author: gbiv Date: Thu Nov 10 14:43:52 2016 New Revision: 286500 URL: http://llvm.org/viewvc/llvm-project?rev=286500&view=rev Log: Clean up uses of unique_ptr for RAII objects. NFC. - EnterExpressionEvaluationContext allows you to specify whether you *actually* want to enter an evaluation context. - For types that don't allow that, llvm::Optional should do the same thing as std::unique_ptr, but with 100% less heap allocations. Modified: cfe/trunk/lib/Parse/ParseDecl.cpp Modified: cfe/trunk/lib/Parse/ParseDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=286500&r1=286499&r2=286500&view=diff == --- cfe/trunk/lib/Parse/ParseDecl.cpp (original) +++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Nov 10 14:43:52 2016 @@ -25,6 +25,7 @@ #include "clang/Sema/PrettyDeclStackTrace.h" #include "clang/Sema/Scope.h" #include "clang/Sema/SemaDiagnostic.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringSwitch.h" @@ -301,10 +302,10 @@ unsigned Parser::ParseAttributeArgsCommo // Parse the non-empty comma-separated list of expressions. do { - std::unique_ptr Unevaluated; - if (attributeParsedArgsUnevaluated(*AttrName)) -Unevaluated.reset( -new EnterExpressionEvaluationContext(Actions, Sema::Unevaluated)); + bool ShouldEnter = attributeParsedArgsUnevaluated(*AttrName); + EnterExpressionEvaluationContext Unevaluated( + Actions, Sema::Unevaluated, /*LambdaContextDecl=*/nullptr, + /*IsDecltype=*/false, ShouldEnter); ExprResult ArgExpr( Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression())); @@ -366,13 +367,13 @@ void Parser::ParseGNUAttributeArgs(Ident // These may refer to the function arguments, but need to be parsed early to // participate in determining whether it's a redeclaration. - std::unique_ptr PrototypeScope; + llvm::Optional PrototypeScope; if (normalizeAttrName(AttrName->getName()) == "enable_if" && D && D->isFunctionDeclarator()) { DeclaratorChunk::FunctionTypeInfo FTI = D->getFunctionTypeInfo(); -PrototypeScope.reset(new ParseScope(this, Scope::FunctionPrototypeScope | -Scope::FunctionDeclarationScope | -Scope::DeclScope)); +PrototypeScope.emplace(this, Scope::FunctionPrototypeScope | + Scope::FunctionDeclarationScope | + Scope::DeclScope); for (unsigned i = 0; i != FTI.NumParams; ++i) { ParmVarDecl *Param = cast(FTI.Params[i].Param); Actions.ActOnReenterCXXMethodParameter(getCurScope(), Param); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26519: [PowerPC] Implement BE VSX load/store builtins - clang portion.
jtony created this revision. jtony added reviewers: nemanjai, amehsan, kbarton, sfertile, syzaara, lei. jtony added subscribers: cfe-commits, echristo, llvm-commits. This patch implements all the overloads for vec_xl_be and vec_xst_be. On BE, they behaves exactly the same with vec_xl and vec_xst, therefore they are simply implemented by defining a matching macro. On LE, they are implemented by defining new builtins and intrinsics. For int/float/long long/double, it is just a load (lxvw4x/lxvd2x) or store(stxvw4x/stxvd2x). For char/char/short, we also need some extra shuffling before or after call the builtins to get the desired BE order. For int128, simply call vec_xl or vec_xst. Signatures: vector signed char vec_xl_be (signed long long, signed char *); vector unsigned char vec_xl_be (signed long long, unsigned char *); vector signed int vec_xl_be (signed long long, signed int *); vector unsigned int vec_xl_be (signed long long, unsigned int *); vector signed __int128 vec_xl_be (signed long long, signed __int128 *); vector unsigned __int128 vec_xl_be (signed long long, unsigned __int128 *); vector signed long long vec_xl_be (signed long long, signed long long *); vector unsigned long long vec_xl_be (signed long long, unsigned long long *); vector signed short vec_xl_be (signed long long, signed short *); vector unsigned short vec_xl_be (signed long long, unsigned short *); vector double vec_xl_be (signed long long, double *); vector float vec_xl_be (signed long long, float *); void vec_xst_be (vector signed char, signed long long, signed char *); void vec_xst_be (vector unsigned char, signed long long, unsigned char *); void vec_xst_be (vector signed int, signed long long, signed int *); void vec_xst_be (vector unsigned int, signed long long, unsigned int *); void vec_xst_be (vector signed __int128, signed long long, signed __int128 *); void vec_xst_be (vector unsigned __int128, signed long long, unsigned __int128 *); void vec_xst_be (vector signed long long, signed long long, signed long long *); void vec_xst_be (vector unsigned long long, signed long long, unsigned long long *); void vec_xst_be (vector signed short, signed long long, signed short *); void vec_xst_be (vector unsigned short, signed long long, unsigned short *); void vec_xst_be (vector double, signed long long, double *); void vec_xst_be (vector float, signed long long, float *); https://reviews.llvm.org/D26519 Files: include/clang/Basic/BuiltinsPPC.def lib/CodeGen/CGBuiltin.cpp lib/Headers/altivec.h test/CodeGen/builtins-ppc-altivec.c test/CodeGen/builtins-ppc-quadword.c test/CodeGen/builtins-ppc-vsx.c Index: test/CodeGen/builtins-ppc-vsx.c === --- test/CodeGen/builtins-ppc-vsx.c +++ test/CodeGen/builtins-ppc-vsx.c @@ -1273,4 +1273,28 @@ vec_xst(vd, sll, ad); // CHECK: store <2 x double> %{{[0-9]+}}, <2 x double>* %{{[0-9]+}}, align 16 // CHECK-LE: store <2 x double> %{{[0-9]+}}, <2 x double>* %{{[0-9]+}}, align 16 + +res_vsll = vec_xl_be(sll, asll); +// CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16 +// CHECK-LE: call <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8* %{{[0-9]+}}) + +res_vull = vec_xl_be(sll, aull); +// CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16 +// CHECK-LE: call <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8* %{{[0-9]+}}) + +res_vd = vec_xl_be(sll, ad); +// CHECK: load <2 x double>, <2 x double>* %{{[0-9]+}}, align 16 +// CHECK-LE: call <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8* %{{[0-9]+}}) + +vec_xst_be(vsll, sll, asll); +// CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16 +// CHECK-LE: call void @llvm.ppc.vsx.stxvd2x.be(<2 x double> %{{[0-9]+}}, i8* %{{[0-9]+}}) + +vec_xst_be(vull, sll, aull); +// CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16 +// CHECK-LE: call void @llvm.ppc.vsx.stxvd2x.be(<2 x double> %{{[0-9]+}}, i8* %{{[0-9]+}}) + +vec_xst_be(vd, sll, ad); +// CHECK: store <2 x double> %{{[0-9]+}}, <2 x double>* %{{[0-9]+}}, align 16 +// CHECK-LE: call void @llvm.ppc.vsx.stxvd2x.be(<2 x double> %{{[0-9]+}}, i8* %{{[0-9]+}}) } Index: test/CodeGen/builtins-ppc-quadword.c === --- test/CodeGen/builtins-ppc-quadword.c +++ test/CodeGen/builtins-ppc-quadword.c @@ -193,4 +193,26 @@ // CHECK: store <1 x i128> %{{[0-9]+}}, <1 x i128>* %{{[0-9]+}}, align 16 // CHECK-LE: store <1 x i128> %{{[0-9]+}}, <1 x i128>* %{{[0-9]+}}, align 16 // CHECK-PPC: error: call to 'vec_xst' is ambiguous + + /* vec_xl_be */ + res_vlll = vec_xl_be(param_sll, ¶m_lll); + // CHECK: load <1 x i128>, <1 x i128>* %{{[0-9]+}}, align 16 + // CHECK-LE: load <1 x i128>, <1 x i128>* %{{[0-9]+}}, align 16 + // CHECK-PPC: error: call to 'vec_xl' is ambiguous + + res_vulll = vec_xl_be(param_sll, ¶m_ulll); + // CHECK: load <1 x i128>, <1 x i128>* %{{[0-9]+}}, align 16 + // CHECK-LE: load <1 x i128>, <1 x i128>* %{{[0-9]+}}, align 16 + // CHECK-PPC
[PATCH] D26415: [XRay] Support AArch64 in Clang
rSerge marked 5 inline comments as done. rSerge added inline comments. Comment at: lib/Driver/Tools.cpp:4903-4906 if (Triple.getOS() == llvm::Triple::Linux && (Triple.getArch() == llvm::Triple::arm || - Triple.getArch() == llvm::Triple::x86_64)) { + Triple.getArch() == llvm::Triple::x86_64 || + Triple.getArch() == llvm::Triple::aarch64)) { dberris wrote: > rSerge wrote: > > dberris wrote: > > > rSerge wrote: > > > > dberris wrote: > > > > > I'm wondering whether it's worth turning this into a `switch` > > > > > statement now that we have more than two supported architectures? > > > > I think that would lead to more awkward code: there wouldn't be a > > > > single decision outcome point (like the current `else` block), so to > > > > avoid duplicating the code which currently prints the message, a `bool` > > > > variable would be needed. I think it's more neat to just enumerate all > > > > the OS&CPU combinations in the `if` condition for now. > > > > This place is not performance-critical and the compiler should convert > > > > appropriate `if`s into `switch`es anyway. > > > This is an issue of making it more readable, something like: > > > > > > ``` > > > if (Triple.getOS() != llvm::Triple::Linux) > > > D.Diag(...) << ...; // Unsupported OS. > > > switch (Triple.getArch()) { > > > case llvm::Triple::arm: > > > case llvm::Triple::x86_64: > > > case llvm::Tripe::aarch64: > > > // Supported. > > > break; > > > default: > > > D.Diag(...) << ...; > > > } > > > ``` > > > > > > This way any new architectures become supported, they just get added to > > > the list of cases that short-circuit. > > We can't say that an OS is supported or unsupported unless all CPU > > architectures for this OS support or don't support XRay, and this is not > > going to happen in the near future. So it is more accurate to say about the > > triple: some triples are supported and some are not. So in coding it is > > natural to check for the triple with `||` and `&&`. > > We can't say that an OS is supported or unsupported unless all CPU > > architectures for this OS support or don't support XRay, and this is not > > going to happen in the near future. > > I don't get it. Right now, as written, it doesn't matter what OS it is -- any > OS other than Linux wouldn't be supported anyway. Maybe I mis-wrote, but: > > ``` > if (Triple.getOS() != llvm::Triple::Linux) > D.Diag(...) << ...; > else switch(Triple.getArch()) { > ... > default: > D.Diag(...) << ...; > } > ``` > > Is a direct translation that's more readable than the current complex if > statement conditional. > > > So it is more accurate to say about the triple: some triples are supported > > and some are not. So in coding it is natural to check for the triple with > > || and &&. > > Sure, but conditional is already unwieldy with just three supported platforms. Changed. https://reviews.llvm.org/D26415 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26415: [XRay] Support AArch64 in Clang
rSerge updated this revision to Diff 77537. https://reviews.llvm.org/D26415 Files: lib/Driver/Tools.cpp test/Driver/XRay/xray-instrument-cpu.c test/Driver/XRay/xray-instrument-os.c Index: test/Driver/XRay/xray-instrument-os.c === --- test/Driver/XRay/xray-instrument-os.c +++ test/Driver/XRay/xray-instrument-os.c @@ -1,4 +1,4 @@ // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s // XFAIL: -linux- -// REQUIRES-ANY: amd64, x86_64, x86_64h, arm +// REQUIRES-ANY: amd64, x86_64, x86_64h, arm, aarch64, arm64 typedef int a; Index: test/Driver/XRay/xray-instrument-cpu.c === --- test/Driver/XRay/xray-instrument-cpu.c +++ test/Driver/XRay/xray-instrument-cpu.c @@ -1,4 +1,4 @@ // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s -// XFAIL: amd64-, x86_64-, x86_64h-, arm +// XFAIL: amd64-, x86_64-, x86_64h-, arm, aarch64, arm64 // REQUIRES: linux typedef int a; Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -4900,11 +4900,16 @@ if (Args.hasFlag(options::OPT_fxray_instrument, options::OPT_fnoxray_instrument, false)) { const char *const XRayInstrumentOption = "-fxray-instrument"; -if (Triple.getOS() == llvm::Triple::Linux && -(Triple.getArch() == llvm::Triple::arm || - Triple.getArch() == llvm::Triple::x86_64)) { +if (Triple.getOS() != llvm::Triple::Linux) + D.Diag(diag::err_drv_clang_unsupported) + << (std::string(XRayInstrumentOption) + " on non-Linux target OS."); +switch (Triple.getArch()) { +case llvm::Triple::x86_64: +case llvm::Triple::arm: +case llvm::Triple::aarch64: // Supported. -} else { + break; +default: D.Diag(diag::err_drv_clang_unsupported) << (std::string(XRayInstrumentOption) + " on " + Triple.str()); } Index: test/Driver/XRay/xray-instrument-os.c === --- test/Driver/XRay/xray-instrument-os.c +++ test/Driver/XRay/xray-instrument-os.c @@ -1,4 +1,4 @@ // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s // XFAIL: -linux- -// REQUIRES-ANY: amd64, x86_64, x86_64h, arm +// REQUIRES-ANY: amd64, x86_64, x86_64h, arm, aarch64, arm64 typedef int a; Index: test/Driver/XRay/xray-instrument-cpu.c === --- test/Driver/XRay/xray-instrument-cpu.c +++ test/Driver/XRay/xray-instrument-cpu.c @@ -1,4 +1,4 @@ // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s -// XFAIL: amd64-, x86_64-, x86_64h-, arm +// XFAIL: amd64-, x86_64-, x86_64h-, arm, aarch64, arm64 // REQUIRES: linux typedef int a; Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -4900,11 +4900,16 @@ if (Args.hasFlag(options::OPT_fxray_instrument, options::OPT_fnoxray_instrument, false)) { const char *const XRayInstrumentOption = "-fxray-instrument"; -if (Triple.getOS() == llvm::Triple::Linux && -(Triple.getArch() == llvm::Triple::arm || - Triple.getArch() == llvm::Triple::x86_64)) { +if (Triple.getOS() != llvm::Triple::Linux) + D.Diag(diag::err_drv_clang_unsupported) + << (std::string(XRayInstrumentOption) + " on non-Linux target OS."); +switch (Triple.getArch()) { +case llvm::Triple::x86_64: +case llvm::Triple::arm: +case llvm::Triple::aarch64: // Supported. -} else { + break; +default: D.Diag(diag::err_drv_clang_unsupported) << (std::string(XRayInstrumentOption) + " on " + Triple.str()); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26196: Add support for non-zero null pointers
yaxunl updated this revision to Diff 77525. yaxunl marked an inline comment as done. yaxunl added a comment. Changed APValue to differentiate with null pointer and pointers casted from integer. Fixed casting integer to pointer. Refactored isNullPtrZero to use just QualType as parameter. Added tests for casting integer to pointer, initialization of static and function-scope variable, and cast pointer to bool. https://reviews.llvm.org/D26196 Files: include/clang/AST/APValue.h lib/AST/APValue.cpp lib/AST/ExprConstant.cpp lib/CodeGen/CGDecl.cpp lib/CodeGen/CGExprAgg.cpp lib/CodeGen/CGExprConstant.cpp lib/CodeGen/CGExprScalar.cpp lib/CodeGen/CodeGenModule.h lib/CodeGen/CodeGenTypes.cpp lib/CodeGen/TargetInfo.cpp lib/CodeGen/TargetInfo.h test/CodeGenOpenCL/amdgpu-nullptr.cl Index: test/CodeGenOpenCL/amdgpu-nullptr.cl === --- /dev/null +++ test/CodeGenOpenCL/amdgpu-nullptr.cl @@ -0,0 +1,487 @@ +// RUN: %clang_cc1 %s -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -fno-common -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -O0 -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -fno-common -emit-llvm -o - | FileCheck --check-prefix=NOOPT %s + +// LLVM requests global variable with common linkage to be initialized with zeroinitializer, therefore use -fno-common +// to suppress common linkage for tentative definition. + +// Test 0 as initializer. + +// CHECK: @private_p = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4 +private char *private_p = 0; + +// CHECK: @local_p = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4 +local char *local_p = 0; + +// CHECK: @global_p = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4 +global char *global_p = 0; + +// CHECK: @constant_p = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4 +constant char *constant_p = 0; + +// CHECK: @generic_p = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4 +generic char *generic_p = 0; + +// Test NULL as initializer. + +// CHECK: @private_p_NULL = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4 +private char *private_p_NULL = NULL; + +// CHECK: @local_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4 +local char *local_p_NULL = NULL; + +// CHECK: @global_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4 +global char *global_p_NULL = NULL; + +// CHECK: @constant_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4 +constant char *constant_p_NULL = NULL; + +// CHECK: @generic_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4 +generic char *generic_p_NULL = NULL; + +// Test default initialization of pointers. + +// CHECK: @p1 = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4 +private char *p1; + +// CHECK: @p2 = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4 +local char *p2; + +// CHECK: @p3 = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4 +constant char *p3; + +// CHECK: @p4 = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4 +global char *p4; + +// CHECK: @p5 = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4 +generic char *p5; + +// Test default initialization of sturcture. +typedef struct { + private char *p1; + local char *p2; + constant char *p3; + global char *p4; + generic char *p5; +} StructTy1; + +// CHECK: @S1 = local_unnamed_addr addrspace(1) global %struct.StructTy1 { i8* addrspacecast (i8 addrspace(4)* null to i8*), i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), i8 addrspace(2)* null, i8 addrspace(1)* null, i8 addrspace(4)* null }, align 4 +StructTy1 S1; + +typedef struct { + constant char *p3; + global char *p4; + generic char *p5; +} StructTy2; + + +// CHECK: @S2 = local_unnamed_addr addrspace(1) global %struct.StructTy2 zeroinitializer, align 4 +StructTy2 S2; + +// Test default initialization of array. +// CHECK: @A1 = local_unnamed_addr addrspace(1) global [2 x %struct.StructTy1] [%struct.StructTy1 { i8* addrspacecast (i8 addrspace(4)* null to i8*), i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), i8 addrspace(2)* null, i8 addrspace(1)* null, i8 addrspace(4)* null }, %struct.StructTy1 { i8* addrspacecast (i8 addrspace(4)* null to i8*), i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), i8 addrspace(2)* null, i8 addrspace(1)* null, i8 addrspace(4)* null }], align 4 +StructTy1 A1[2]; + +// CHECK: @A2 = local_unnamed_addr addrspace(1) global [2 x %struct.StructTy2] zeroi
r286494 - Correcting a documentation formatting bug; NFC.
Author: aaronballman Date: Thu Nov 10 13:45:49 2016 New Revision: 286494 URL: http://llvm.org/viewvc/llvm-project?rev=286494&view=rev Log: Correcting a documentation formatting bug; NFC. Modified: cfe/trunk/include/clang/Basic/AttrDocs.td Modified: cfe/trunk/include/clang/Basic/AttrDocs.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=286494&r1=286493&r2=286494&view=diff == --- cfe/trunk/include/clang/Basic/AttrDocs.td (original) +++ cfe/trunk/include/clang/Basic/AttrDocs.td Thu Nov 10 13:45:49 2016 @@ -2697,11 +2697,11 @@ functions that have an argument with a t behaviour is changed in the following manner: - A value whose type is any member of the transparent union can be passed as an -argument without the need to cast that value. + argument without the need to cast that value. - The argument is passed to the function using the calling convention of the -first member of the transparent union. Consequently, all the members of the -transparent union should have the same calling convention as its first member. + first member of the transparent union. Consequently, all the members of the + transparent union should have the same calling convention as its first member. Transparent unions are not supported in C++. }]; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26515: [clang-move] Abstract a ClassMather for matching class declarations.
ioeric added inline comments. Comment at: clang-move/ClangMove.cpp:144 + void run(const ast_matchers::MatchFinder::MatchResult &Result) override { +if (const auto *CMD = +Result.Nodes.getNodeAs("class_method")) { hokein wrote: > ioeric wrote: > > It'd be more readable if you pull each case below into a helper function. > hmm, I'd prefer current way. Because I don't see significant advantage by > pulling each case into a helper function, since the code for each condition > is used only once. > Generally, we prefer short functions to long functions. Comment at: clang-move/ClangMove.cpp:139 +class ClassDeclarationMatcher : public MatchFinder::MatchCallback { +public: Why is this called a Matcher? https://reviews.llvm.org/D26515 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26491: Define __ANDROID_API__ when specified as part of an Android target.
eugenis accepted this revision. eugenis added a reviewer: eugenis. eugenis added a comment. Looks great! https://reviews.llvm.org/D26491 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26442: [analyzer] Fix crash on getSVal: handle case of CompoundVal
NoQ added a comment. Wow, this crash must have been hard to notice! I think we shouldn't be default-binding non-lazy compound values. Normally we unpack them into field bindings right away, but it seems that nobody cared to implement this for unions. The current crash goes through `RegionStoreManager::bind()`, 2000 if (Ty->isVectorType()) 2001 return bindVector(B, TR, V); 2002 if (Ty->isUnionType()) -> 2003 return bindAggregate(B, TR, V); I think that instead of doing `bindAggregate()`, we should do something similar to what `RegionStoreManager::bindStruct()` does (the code that handles compound values should probably be factored out). It should be even easier because unions hold only one value. I'm not sure if my suggestion has any immediate benefits to overweight its complexity, but it should make improving support for unions easier in the future. Also, the code for the lazy compound value is really out of place here. All it does is works around the huge and famous FIXME in `getBindingForFieldOrElementCommon()`. But i don't think we should grow this FIXME into unions. Repository: rL LLVM https://reviews.llvm.org/D26442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26515: [clang-move] Abstract a ClassMather for matching class declarations.
hokein added inline comments. Comment at: clang-move/ClangMove.cpp:144 + void run(const ast_matchers::MatchFinder::MatchResult &Result) override { +if (const auto *CMD = +Result.Nodes.getNodeAs("class_method")) { ioeric wrote: > It'd be more readable if you pull each case below into a helper function. hmm, I'd prefer current way. Because I don't see significant advantage by pulling each case into a helper function, since the code for each condition is used only once. https://reviews.llvm.org/D26515 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26515: [clang-move] Abstract a ClassMather for matching class declarations.
hokein updated this revision to Diff 77521. hokein marked 3 inline comments as done. hokein added a comment. Address comments. https://reviews.llvm.org/D26515 Files: clang-move/ClangMove.cpp clang-move/ClangMove.h Index: clang-move/ClangMove.h === --- clang-move/ClangMove.h +++ clang-move/ClangMove.h @@ -16,6 +16,7 @@ #include "clang/Tooling/Tooling.h" #include "llvm/ADT/SmallPtrSet.h" #include +#include #include #include @@ -80,6 +81,14 @@ clang::CharSourceRange IncludeFilenameRange, const SourceManager &SM); + std::vector &getMovedDecls() { return MovedDecls; } + + std::vector &getRemovedDecls() { return RemovedDecls; } + + llvm::SmallPtrSet &getUnremovedDeclsInOldHeader() { +return UnremovedDeclsInOldHeader; + } + private: // Make the Path absolute using the OrignalRunningDirectory if the Path is not // an absolute path. An empty Path will result in an empty string. @@ -90,6 +99,9 @@ void moveAll(SourceManager& SM, StringRef OldFile, StringRef NewFile); MoveDefinitionSpec Spec; + // Stores all MatchCallbacks created by this tool. + std::vector> + MatchCallbacks; // The Key is file path, value is the replacements being applied to the file. std::map &FileToReplacements; // All declarations (the class decl being moved, forward decls) that need to Index: clang-move/ClangMove.cpp === --- clang-move/ClangMove.cpp +++ clang-move/ClangMove.cpp @@ -136,6 +136,54 @@ ClangMoveTool *const MoveTool; }; +class ClassDeclarationMatcher : public MatchFinder::MatchCallback { +public: + explicit ClassDeclarationMatcher(ClangMoveTool *MoveTool) + : MoveTool(MoveTool) {} + void run(const ast_matchers::MatchFinder::MatchResult &Result) override { +if (const auto *CMD = +Result.Nodes.getNodeAs("class_method")) { + // Skip inline class methods. isInline() ast matcher doesn't ignore this + // case. + if (!CMD->isInlined()) { +MoveTool->getMovedDecls().emplace_back( +CMD, &Result.Context->getSourceManager()); +MoveTool->getRemovedDecls().push_back(MoveTool->getMovedDecls().back()); +// Get template class method from its method declaration as +// UnremovedDecls stores template class method. +if (const auto *FTD = CMD->getDescribedFunctionTemplate()) { + MoveTool->getUnremovedDeclsInOldHeader().erase(FTD); +} else { + MoveTool->getUnremovedDeclsInOldHeader().erase(CMD); +} + } +} else if (const auto *VD = Result.Nodes.getNodeAs( + "class_static_var_decl")) { + MoveTool->getMovedDecls().emplace_back( + VD, &Result.Context->getSourceManager()); + MoveTool->getRemovedDecls().push_back(MoveTool->getMovedDecls().back()); + MoveTool->getUnremovedDeclsInOldHeader().erase(VD); +} else if (const auto *CD = Result.Nodes.getNodeAs( + "moved_class")) { + // Get class template from its class declaration as UnremovedDecls stores + // class template. + if (const auto *TC = CD->getDescribedClassTemplate()) { +MoveTool->getMovedDecls().emplace_back( +TC, &Result.Context->getSourceManager()); + } else { +MoveTool->getMovedDecls().emplace_back( +CD, &Result.Context->getSourceManager()); + } + MoveTool->getRemovedDecls().push_back(MoveTool->getMovedDecls().back()); + MoveTool->getUnremovedDeclsInOldHeader().erase( + MoveTool->getMovedDecls().back().Decl); +} + } + +private: + ClangMoveTool *MoveTool; +}; + // Expand to get the end location of the line where the EndLoc of the given // Decl. SourceLocation @@ -352,23 +400,27 @@ // // Matchers for old files, including old.h/old.cc // + // Create a MatchCallback for class declarations. + MatchCallbacks.push_back(llvm::make_unique(this)); // Match moved class declarations. - auto MovedClass = cxxRecordDecl( - InOldFiles, *InMovedClassNames, isDefinition(), - hasDeclContext(anyOf(namespaceDecl(), translationUnitDecl(; - Finder->addMatcher(MovedClass.bind("moved_class"), this); + auto MovedClass = + cxxRecordDecl( + InOldFiles, *InMovedClassNames, isDefinition(), + hasDeclContext(anyOf(namespaceDecl(), translationUnitDecl( + .bind("moved_class"); + Finder->addMatcher(MovedClass, MatchCallbacks.back().get()); // Match moved class methods (static methods included) which are defined // outside moved class declaration. Finder->addMatcher( cxxMethodDecl(InOldFiles, ofOutermostEnclosingClass(*InMovedClassNames), isDefinition()) .bind("
[PATCH] D25660: [Analyzer] Checker for iterators dereferenced beyond their range.
zaks.anna added inline comments. Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:219 + + assert(LCtx->getKind() == LocationContext::StackFrame && + "Function does not begin with stack frame context"); a.sidorin wrote: > `isa(LCtx)`? > And `cast<>` below already does the same check with an assertion. At least one advantage of the assert is that it provides an error message. I'd not try to minimize the number of asserts. Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:423 + +void IteratorPastEndChecker::handleComparison(CheckerContext &C, + const SVal &LVal, baloghadamsoftware wrote: > baloghadamsoftware wrote: > > NoQ wrote: > > > baloghadamsoftware wrote: > > > > NoQ wrote: > > > > > a.sidorin wrote: > > > > > > What will happen if we write something like this: > > > > > > ``` > > > > > > bool Eq1 = it1 == it2; > > > > > > bool Eq2 = it3 == it4; > > > > > > if (Eq1) {...}? > > > > > > ``` > > > > > > > > > > > > As I understand, we'll assume the second condition instead of first. > > > > > Had a look. So the problem is, we obtain the result of the comparison > > > > > as a symbol, from which it is too hard to recover the operands in > > > > > order to move iterator position data from one value to another. > > > > > > > > > > Normally we obtain a simple SymbolConjured for the return value of > > > > > the `operator==()` call (or, similarly, `operator!=()`). For > > > > > plain-value iterators (eg. `typedef T *iterator`) we might be > > > > > obtaining an actual binary symbolic expression, but even then it's > > > > > not quite clear how to obtain operands (the structure of the > > > > > expression might have changed due to algebraic simplifications). > > > > > Additionally, LHS and RHS aren't necessarily symbols (they might be > > > > > semi-concrete), so composing symbolic expressions from them in > > > > > general is problematic with our symbol hierarchy, which is rarely a > > > > > problem for numbers but for structural symbols it'd be a mess. > > > > > > > > > > For now i suggest, instead of storing only the last LHS and RHS, to > > > > > save a map from symbols (which are results of comparisons) to (LHS > > > > > value, RHS value) pairs. This map should, apart from the obvious, be > > > > > cleaned up whenever one of the iterators in the pair gets mutated > > > > > (incremented or decremented). This should take care of the problem > > > > > Alexey points out, and should work with semi-concrete stuff. > > > > > > > > > > For the future i suggest to let users construct their own symbols and > > > > > symbolic expressions more easily. In fact, if only we had all > > > > > iterators as regions, we should have probably used SymbolMetadata for > > > > > this purpose: it's easy to both recover the parent region from it and > > > > > use it in symbolic expressions. We could also deprecate the confusing > > > > > structural symbols (provide default-bound lazy compound values for > > > > > conjured structures instead), and then it'd be possible to transition > > > > > to SymbolMetadata entirely. > > > > Thank you for the suggestion. I am not sure if I fully understand you. > > > > If I create a map where the key is the resulting symbol of the > > > > comparison, it will not work because evalAssume is called for the > > > > innermost comparison. So if the body of operator== (or operator!=) is > > > > inlined, then I get a binary symbolic expression in evalAssume, not the > > > > SymbolConjured. This binary Symbolic expression is a comparison of the > > > > internals of the iterators, e.g. the internal pointer. So the key will > > > > not match any LHS and RHS value pair in the map. I also thought on such > > > > solution earlier but I dismissed it because of this. > > > Well, even if the body of the comparison operator is inlined, > > > PreStmt/PostStmt callbacks should still work, and it doesn't really > > > matter if there's a `SymbolConjured` or not, we can still add the > > > symbolic expression to our map as a key. > > > > > > Essentially, you ignore whatever happens in the iterator's operator==() > > > when it's inlined (including any evalAssume events), then in PostStmt of > > > operator==() you map the return-value symbol of the operator to the > > > operator's arguments (operands), then whenever an assumption is being > > > made against the return-value symbol, you carry over this assumption to > > > the operands. I think it shouldn't really matter if the operator call was > > > inlined. > > > > > > The only unexpected thing that may happen due to inlining is if the > > > inlined operator returns a concrete value (plain true or plain false) > > > instead of the symbol, but in this case what we need to do is to just > > > carry over the assumption to the operands instantly. > > Maybe if I evalua
[PATCH] D26196: Add support for non-zero null pointers
yaxunl marked 12 inline comments as done. yaxunl added inline comments. Comment at: lib/CodeGen/TargetInfo.cpp:7040 + auto AS = PT->getAddressSpace(); + return AS != Ctx.getTargetAddressSpace(LangAS::opencl_local) && AS != 0; +} rjmccall wrote: > This check is definitely not correct; this function needs to return true when > AS == 0, right? > > Also, you should really just be checking QT.getAddressSpace(). The null pointer of amdgpu target in addr space 0 does not have zero value. I will change it use QT.getAddressSpace() though. https://reviews.llvm.org/D26196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26515: [clang-move] Abstract a ClassMather for matching class declarations.
ioeric added inline comments. Comment at: clang-move/ClangMove.cpp:144 + void run(const ast_matchers::MatchFinder::MatchResult &Result) override { +if (const auto *CMD = +Result.Nodes.getNodeAs("class_method")) { It'd be more readable if you pull each case below into a helper function. Comment at: clang-move/ClangMove.cpp:403 // + auto ClassMatchCallback = llvm::make_unique(this); // Match moved class declarations. `push_back` and then use `back()` would save you a variable. Comment at: clang-move/ClangMove.cpp:424 + // Extend the MatchCallback lifetime. + MatchCallbacksHolder.push_back(std::move(ClassMatchCallback)); I'd first move `push_back` to the top, and then use `MatchCallbacksHolder.back()`. Comment at: clang-move/ClangMove.h:104 + std::vector> + MatchCallbacksHolder; // The Key is file path, value is the replacements being applied to the file. Simply `MatchCallbacks` would be a better name IMO. https://reviews.llvm.org/D26515 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26515: [clang-move] Abstract a ClassMather for matching class declarations.
hokein created this revision. hokein added a reviewer: ioeric. hokein added a subscriber: cfe-commits. No functionality change. This is a refactoring patch, which makes the code more readable and easy to extend it to support more types. https://reviews.llvm.org/D26515 Files: clang-move/ClangMove.cpp clang-move/ClangMove.h Index: clang-move/ClangMove.h === --- clang-move/ClangMove.h +++ clang-move/ClangMove.h @@ -16,6 +16,7 @@ #include "clang/Tooling/Tooling.h" #include "llvm/ADT/SmallPtrSet.h" #include +#include #include #include @@ -80,6 +81,14 @@ clang::CharSourceRange IncludeFilenameRange, const SourceManager &SM); + std::vector &getMovedDecls() { return MovedDecls; } + + std::vector &getRemovedDecls() { return RemovedDecls; } + + llvm::SmallPtrSet &getUnremovedDeclsInOldHeader() { +return UnremovedDeclsInOldHeader; + } + private: // Make the Path absolute using the OrignalRunningDirectory if the Path is not // an absolute path. An empty Path will result in an empty string. @@ -90,6 +99,9 @@ void moveAll(SourceManager& SM, StringRef OldFile, StringRef NewFile); MoveDefinitionSpec Spec; + // Stores all MatchCallbacks created by this tool. + std::vector> + MatchCallbacksHolder; // The Key is file path, value is the replacements being applied to the file. std::map &FileToReplacements; // All declarations (the class decl being moved, forward decls) that need to Index: clang-move/ClangMove.cpp === --- clang-move/ClangMove.cpp +++ clang-move/ClangMove.cpp @@ -136,6 +136,54 @@ ClangMoveTool *const MoveTool; }; +class ClassDeclarationMatcher : public MatchFinder::MatchCallback { +public: + explicit ClassDeclarationMatcher(ClangMoveTool *MoveTool) + : MoveTool(MoveTool) {} + void run(const ast_matchers::MatchFinder::MatchResult &Result) override { +if (const auto *CMD = +Result.Nodes.getNodeAs("class_method")) { + // Skip inline class methods. isInline() ast matcher doesn't ignore this + // case. + if (!CMD->isInlined()) { +MoveTool->getMovedDecls().emplace_back( +CMD, &Result.Context->getSourceManager()); +MoveTool->getRemovedDecls().push_back(MoveTool->getMovedDecls().back()); +// Get template class method from its method declaration as +// UnremovedDecls stores template class method. +if (const auto *FTD = CMD->getDescribedFunctionTemplate()) { + MoveTool->getUnremovedDeclsInOldHeader().erase(FTD); +} else { + MoveTool->getUnremovedDeclsInOldHeader().erase(CMD); +} + } +} else if (const auto *VD = Result.Nodes.getNodeAs( + "class_static_var_decl")) { + MoveTool->getMovedDecls().emplace_back( + VD, &Result.Context->getSourceManager()); + MoveTool->getRemovedDecls().push_back(MoveTool->getMovedDecls().back()); + MoveTool->getUnremovedDeclsInOldHeader().erase(VD); +} else if (const auto *CD = Result.Nodes.getNodeAs( + "moved_class")) { + // Get class template from its class declaration as UnremovedDecls stores + // class template. + if (const auto *TC = CD->getDescribedClassTemplate()) { +MoveTool->getMovedDecls().emplace_back( +TC, &Result.Context->getSourceManager()); + } else { +MoveTool->getMovedDecls().emplace_back( +CD, &Result.Context->getSourceManager()); + } + MoveTool->getRemovedDecls().push_back(MoveTool->getMovedDecls().back()); + MoveTool->getUnremovedDeclsInOldHeader().erase( + MoveTool->getMovedDecls().back().Decl); +} + } + +private: + ClangMoveTool *MoveTool; +}; + // Expand to get the end location of the line where the EndLoc of the given // Decl. SourceLocation @@ -352,23 +400,28 @@ // // Matchers for old files, including old.h/old.cc // + auto ClassMatchCallback = llvm::make_unique(this); // Match moved class declarations. - auto MovedClass = cxxRecordDecl( - InOldFiles, *InMovedClassNames, isDefinition(), - hasDeclContext(anyOf(namespaceDecl(), translationUnitDecl(; - Finder->addMatcher(MovedClass.bind("moved_class"), this); + auto MovedClass = + cxxRecordDecl( + InOldFiles, *InMovedClassNames, isDefinition(), + hasDeclContext(anyOf(namespaceDecl(), translationUnitDecl( + .bind("moved_class"); + Finder->addMatcher(MovedClass, ClassMatchCallback.get()); // Match moved class methods (static methods included) which are defined // outside moved class declaration. Finder->addMatcher( cxxMethodDecl(InOldFiles, ofOutermostEnclosingClass(*InMovedClassNa
[PATCH] D26479: [PowerPC] Implement remaining permute builtins in altivec.h - Clang portion
kbarton accepted this revision. kbarton added a comment. This revision is now accepted and ready to land. LGTM Repository: rL LLVM https://reviews.llvm.org/D26479 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26491: Define __ANDROID_API__ when specified as part of an Android target.
pirama accepted this revision. pirama added a reviewer: pirama. pirama added a comment. This revision is now accepted and ready to land. The bug points back to this Phab page instead of a bug. LGTM otherwise. https://reviews.llvm.org/D26491 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25985: [analyzer] Export coverage information from the analyzer.
NoQ added a comment. Maybe you could instead make a checker that subscribes for `checkEndAnalysis` and scans the provided `ExplodedGraph`'s `nodes_begin()..nodes_end()` for visited statement-based program points (as in `PathDiagnosticLocation::getStmt(N)`)? This should give you per-statement precision, and you'd avoid dealing with the CFG element kinds. That sounds more straightforward and that's essentially how our deadcode checker works (but it suppresses its positives for incomplete analyses - you don't need even that). https://reviews.llvm.org/D25985 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26493: [clang-move] Make the output code look more pretty.
ioeric added inline comments. Comment at: clang-move/ClangMove.cpp:273 } +bool IsNamespaceStart = false; while (DeclIt != DeclNamespaces.end()) { It's been a while since the last time I reviewed this, and I need to struggle to understand what CurrentNamespaces, NextNamespaces, and IsNamespaceStart are... some comments for them are really appreciated. https://reviews.llvm.org/D26493 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26456: Handle adding new nested namespace in old namespace.
This revision was automatically updated to reflect the committed changes. Closed by commit rL286486: Handle adding new nested namespace in old namespace. (authored by ioeric). Changed prior to commit: https://reviews.llvm.org/D26456?vs=77511&id=77513#toc Repository: rL LLVM https://reviews.llvm.org/D26456 Files: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp === --- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp +++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp @@ -57,16 +57,19 @@ } // Returns the containing namespace of `InnerNs` by skipping `PartialNsName`. -// If the `InnerNs` does not have `PartialNsName` as suffix, nullptr is -// returned. +// If the `InnerNs` does not have `PartialNsName` as suffix, or `PartialNsName` +// is empty, nullptr is returned. // For example, if `InnerNs` is "a::b::c" and `PartialNsName` is "b::c", then // the NamespaceDecl of namespace "a" will be returned. const NamespaceDecl *getOuterNamespace(const NamespaceDecl *InnerNs, llvm::StringRef PartialNsName) { + if (!InnerNs || PartialNsName.empty()) +return nullptr; const auto *CurrentContext = llvm::cast(InnerNs); const auto *CurrentNs = InnerNs; llvm::SmallVector PartialNsNameSplitted; - PartialNsName.split(PartialNsNameSplitted, "::"); + PartialNsName.split(PartialNsNameSplitted, "::", /*MaxSplit=*/-1, + /*KeepEmpty=*/false); while (!PartialNsNameSplitted.empty()) { // Get the inner-most namespace in CurrentContext. while (CurrentContext && !llvm::isa(CurrentContext)) @@ -468,16 +471,20 @@ // "x::y" will be inserted inside the existing namespace "a" and after "a::b". // `OuterNs` is the first namespace in `DiffOldNamespace`, e.g. "namespace b" // in the above example. - // FIXME: consider the case where DiffOldNamespace is empty. + // If there is no outer namespace (i.e. DiffOldNamespace is empty), the new + // namespace will be a nested namespace in the old namespace. const NamespaceDecl *OuterNs = getOuterNamespace(NsDecl, DiffOldNamespace); - SourceLocation LocAfterNs = - getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager, - Result.Context->getLangOpts()); - assert(LocAfterNs.isValid() && - "Failed to get location after DiffOldNamespace"); + SourceLocation InsertionLoc = Start; + if (OuterNs) { +SourceLocation LocAfterNs = +getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager, + Result.Context->getLangOpts()); +assert(LocAfterNs.isValid() && + "Failed to get location after DiffOldNamespace"); +InsertionLoc = LocAfterNs; + } MoveNs.InsertionOffset = Result.SourceManager->getFileOffset( - Result.SourceManager->getSpellingLoc(LocAfterNs)); - + Result.SourceManager->getSpellingLoc(InsertionLoc)); MoveNs.FID = Result.SourceManager->getFileID(Start); MoveNs.SourceMgr = Result.SourceManager; MoveNamespaces[R.getFilePath()].push_back(MoveNs); Index: clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp === --- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp +++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp @@ -97,6 +97,48 @@ EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); } +TEST_F(ChangeNamespaceTest, NewNsNestedInOldNs) { + NewNamespace = "na::nb::nc"; + std::string Code = "namespace na {\n" + "namespace nb {\n" + "class A {};\n" + "} // namespace nb\n" + "} // namespace na\n"; + std::string Expected = "namespace na {\n" + "namespace nb {\n" + "namespace nc {\n" + "class A {};\n" + "} // namespace nc\n" + "\n" + "} // namespace nb\n" + "} // namespace na\n"; + EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); +} + +TEST_F(ChangeNamespaceTest, NewNsNestedInOldNsWithRefs) { + NewNamespace = "na::nb::nc"; + std::string Code = "namespace na {\n" + "class A {};\n" + "namespace nb {\n" + "class B {};\n" + "class C {};\n" + "void f() { A a; B b; }\n" + "} // namespace nb\n" + "} // namespace na\n"; + std::string Expected = "namespace na {\n" + "class A {};\n" + "namespace nb {\n" + "namesp
[PATCH] D26406: Add -Wduplicate-protocol for existing diagnostic
This revision was automatically updated to reflect the committed changes. Closed by commit rL286487: Add -Wduplicate-protocol for existing diagnostic (authored by arphaman). Changed prior to commit: https://reviews.llvm.org/D26406?vs=77232&id=77514#toc Repository: rL LLVM https://reviews.llvm.org/D26406 Files: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/test/Misc/warning-flags.c cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td === --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td @@ -742,7 +742,9 @@ "trying to recursively use %0 as superclass of %1">; def err_conflicting_aliasing_type : Error<"conflicting types for alias %0">; def warn_undef_interface : Warning<"cannot find interface declaration for %0">; -def warn_duplicate_protocol_def : Warning<"duplicate protocol definition of %0 is ignored">; +def warn_duplicate_protocol_def : Warning< + "duplicate protocol definition of %0 is ignored">, + InGroup>; def err_protocol_has_circular_dependency : Error< "protocol has circular dependency">; def err_undeclared_protocol : Error<"cannot find protocol declaration for %0">; Index: cfe/trunk/test/Misc/warning-flags.c === --- cfe/trunk/test/Misc/warning-flags.c +++ cfe/trunk/test/Misc/warning-flags.c @@ -18,7 +18,7 @@ The list of warnings below should NEVER grow. It should gradually shrink to 0. -CHECK: Warnings without flags (83): +CHECK: Warnings without flags (82): CHECK-NEXT: ext_excess_initializers CHECK-NEXT: ext_excess_initializers_in_char_array_initializer CHECK-NEXT: ext_expected_semi_decl_list @@ -58,7 +58,6 @@ CHECK-NEXT: warn_drv_objc_gc_unsupported CHECK-NEXT: warn_drv_pch_not_first_include CHECK-NEXT: warn_dup_category_def -CHECK-NEXT: warn_duplicate_protocol_def CHECK-NEXT: warn_enum_value_overflow CHECK-NEXT: warn_expected_qualified_after_typename CHECK-NEXT: warn_extraneous_char_constant Index: cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m === --- cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m +++ cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m @@ -35,6 +35,12 @@ @protocol PP @end // expected-note {{previous definition is here}} @protocol PP @end // expected-warning {{duplicate protocol definition of 'PP'}} +@protocol DP @end +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wduplicate-protocol" +@protocol DP @end +#pragma clang diagnostic pop + @interface A(Cat) @end // expected-note {{previous definition is here}} @interface A(Cat) @end // expected-warning {{duplicate definition of category 'Cat' on interface 'A'}} Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td === --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td @@ -742,7 +742,9 @@ "trying to recursively use %0 as superclass of %1">; def err_conflicting_aliasing_type : Error<"conflicting types for alias %0">; def warn_undef_interface : Warning<"cannot find interface declaration for %0">; -def warn_duplicate_protocol_def : Warning<"duplicate protocol definition of %0 is ignored">; +def warn_duplicate_protocol_def : Warning< + "duplicate protocol definition of %0 is ignored">, + InGroup>; def err_protocol_has_circular_dependency : Error< "protocol has circular dependency">; def err_undeclared_protocol : Error<"cannot find protocol declaration for %0">; Index: cfe/trunk/test/Misc/warning-flags.c === --- cfe/trunk/test/Misc/warning-flags.c +++ cfe/trunk/test/Misc/warning-flags.c @@ -18,7 +18,7 @@ The list of warnings below should NEVER grow. It should gradually shrink to 0. -CHECK: Warnings without flags (83): +CHECK: Warnings without flags (82): CHECK-NEXT: ext_excess_initializers CHECK-NEXT: ext_excess_initializers_in_char_array_initializer CHECK-NEXT: ext_expected_semi_decl_list @@ -58,7 +58,6 @@ CHECK-NEXT: warn_drv_objc_gc_unsupported CHECK-NEXT: warn_drv_pch_not_first_include CHECK-NEXT: warn_dup_category_def -CHECK-NEXT: warn_duplicate_protocol_def CHECK-NEXT: warn_enum_value_overflow CHECK-NEXT: warn_expected_qualified_after_typename CHECK-NEXT: warn_extraneous_char_constant Index: cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m === --- cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m +++ cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m @@ -35,6 +35,12 @@ @protocol PP @end // expected-note {{previous definition is here}} @protocol PP @end // expected-warning {{duplicate protocol definition of 'PP
r286487 - Add -Wduplicate-protocol for existing diagnostic
Author: arphaman Date: Thu Nov 10 12:30:26 2016 New Revision: 286487 URL: http://llvm.org/viewvc/llvm-project?rev=286487&view=rev Log: Add -Wduplicate-protocol for existing diagnostic Expose a warning flag for warn_duplicate_protocol_def. This allows control over the severity of duplicate protocol definitions. For example -Werror=duplicate-protocol or #pragma clang diagnostic ignored "-Wduplicate-protocol". Patch provided by Dave Lee! Differential Revision: https://reviews.llvm.org/D26406 Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/test/Misc/warning-flags.c cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=286487&r1=286486&r2=286487&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Nov 10 12:30:26 2016 @@ -742,7 +742,9 @@ def err_recursive_superclass : Error< "trying to recursively use %0 as superclass of %1">; def err_conflicting_aliasing_type : Error<"conflicting types for alias %0">; def warn_undef_interface : Warning<"cannot find interface declaration for %0">; -def warn_duplicate_protocol_def : Warning<"duplicate protocol definition of %0 is ignored">; +def warn_duplicate_protocol_def : Warning< + "duplicate protocol definition of %0 is ignored">, + InGroup>; def err_protocol_has_circular_dependency : Error< "protocol has circular dependency">; def err_undeclared_protocol : Error<"cannot find protocol declaration for %0">; Modified: cfe/trunk/test/Misc/warning-flags.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/warning-flags.c?rev=286487&r1=286486&r2=286487&view=diff == --- cfe/trunk/test/Misc/warning-flags.c (original) +++ cfe/trunk/test/Misc/warning-flags.c Thu Nov 10 12:30:26 2016 @@ -18,7 +18,7 @@ This test serves two purposes: The list of warnings below should NEVER grow. It should gradually shrink to 0. -CHECK: Warnings without flags (83): +CHECK: Warnings without flags (82): CHECK-NEXT: ext_excess_initializers CHECK-NEXT: ext_excess_initializers_in_char_array_initializer CHECK-NEXT: ext_expected_semi_decl_list @@ -58,7 +58,6 @@ CHECK-NEXT: warn_drv_clang_unsupported CHECK-NEXT: warn_drv_objc_gc_unsupported CHECK-NEXT: warn_drv_pch_not_first_include CHECK-NEXT: warn_dup_category_def -CHECK-NEXT: warn_duplicate_protocol_def CHECK-NEXT: warn_enum_value_overflow CHECK-NEXT: warn_expected_qualified_after_typename CHECK-NEXT: warn_extraneous_char_constant Modified: cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m?rev=286487&r1=286486&r2=286487&view=diff == --- cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m (original) +++ cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m Thu Nov 10 12:30:26 2016 @@ -35,6 +35,12 @@ void Gorf() // expected-error {{redefini @protocol PP @end // expected-note {{previous definition is here}} @protocol PP @end // expected-warning {{duplicate protocol definition of 'PP'}} +@protocol DP @end +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wduplicate-protocol" +@protocol DP @end +#pragma clang diagnostic pop + @interface A(Cat) @end // expected-note {{previous definition is here}} @interface A(Cat) @end // expected-warning {{duplicate definition of category 'Cat' on interface 'A'}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r286486 - Handle adding new nested namespace in old namespace.
Author: ioeric Date: Thu Nov 10 12:29:01 2016 New Revision: 286486 URL: http://llvm.org/viewvc/llvm-project?rev=286486&view=rev Log: Handle adding new nested namespace in old namespace. Reviewers: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26456 Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=286486&r1=286485&r2=286486&view=diff == --- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original) +++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Thu Nov 10 12:29:01 2016 @@ -57,16 +57,19 @@ SourceLocation EndLocationForType(TypeLo } // Returns the containing namespace of `InnerNs` by skipping `PartialNsName`. -// If the `InnerNs` does not have `PartialNsName` as suffix, nullptr is -// returned. +// If the `InnerNs` does not have `PartialNsName` as suffix, or `PartialNsName` +// is empty, nullptr is returned. // For example, if `InnerNs` is "a::b::c" and `PartialNsName` is "b::c", then // the NamespaceDecl of namespace "a" will be returned. const NamespaceDecl *getOuterNamespace(const NamespaceDecl *InnerNs, llvm::StringRef PartialNsName) { + if (!InnerNs || PartialNsName.empty()) +return nullptr; const auto *CurrentContext = llvm::cast(InnerNs); const auto *CurrentNs = InnerNs; llvm::SmallVector PartialNsNameSplitted; - PartialNsName.split(PartialNsNameSplitted, "::"); + PartialNsName.split(PartialNsNameSplitted, "::", /*MaxSplit=*/-1, + /*KeepEmpty=*/false); while (!PartialNsNameSplitted.empty()) { // Get the inner-most namespace in CurrentContext. while (CurrentContext && !llvm::isa(CurrentContext)) @@ -468,16 +471,20 @@ void ChangeNamespaceTool::moveOldNamespa // "x::y" will be inserted inside the existing namespace "a" and after "a::b". // `OuterNs` is the first namespace in `DiffOldNamespace`, e.g. "namespace b" // in the above example. - // FIXME: consider the case where DiffOldNamespace is empty. + // If there is no outer namespace (i.e. DiffOldNamespace is empty), the new + // namespace will be a nested namespace in the old namespace. const NamespaceDecl *OuterNs = getOuterNamespace(NsDecl, DiffOldNamespace); - SourceLocation LocAfterNs = - getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager, - Result.Context->getLangOpts()); - assert(LocAfterNs.isValid() && - "Failed to get location after DiffOldNamespace"); + SourceLocation InsertionLoc = Start; + if (OuterNs) { +SourceLocation LocAfterNs = +getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager, + Result.Context->getLangOpts()); +assert(LocAfterNs.isValid() && + "Failed to get location after DiffOldNamespace"); +InsertionLoc = LocAfterNs; + } MoveNs.InsertionOffset = Result.SourceManager->getFileOffset( - Result.SourceManager->getSpellingLoc(LocAfterNs)); - + Result.SourceManager->getSpellingLoc(InsertionLoc)); MoveNs.FID = Result.SourceManager->getFileID(Start); MoveNs.SourceMgr = Result.SourceManager; MoveNamespaces[R.getFilePath()].push_back(MoveNs); Modified: clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp?rev=286486&r1=286485&r2=286486&view=diff == --- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp (original) +++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp Thu Nov 10 12:29:01 2016 @@ -97,6 +97,48 @@ TEST_F(ChangeNamespaceTest, SimpleMoveWi EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); } +TEST_F(ChangeNamespaceTest, NewNsNestedInOldNs) { + NewNamespace = "na::nb::nc"; + std::string Code = "namespace na {\n" + "namespace nb {\n" + "class A {};\n" + "} // namespace nb\n" + "} // namespace na\n"; + std::string Expected = "namespace na {\n" + "namespace nb {\n" + "namespace nc {\n" + "class A {};\n" + "} // namespace nc\n" + "\n" + "} // namespace nb\n" + "} // namespace na\n"; + EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); +} + +TEST_F(ChangeNamespaceTest, NewNsNestedInOldNsWithRefs) { + NewNamespace = "
[PATCH] D26456: Handle adding new nested namespace in old namespace.
ioeric updated this revision to Diff 77511. ioeric added a comment. - Merged origin/master https://reviews.llvm.org/D26456 Files: change-namespace/ChangeNamespace.cpp unittests/change-namespace/ChangeNamespaceTests.cpp Index: unittests/change-namespace/ChangeNamespaceTests.cpp === --- unittests/change-namespace/ChangeNamespaceTests.cpp +++ unittests/change-namespace/ChangeNamespaceTests.cpp @@ -97,6 +97,48 @@ EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); } +TEST_F(ChangeNamespaceTest, NewNsNestedInOldNs) { + NewNamespace = "na::nb::nc"; + std::string Code = "namespace na {\n" + "namespace nb {\n" + "class A {};\n" + "} // namespace nb\n" + "} // namespace na\n"; + std::string Expected = "namespace na {\n" + "namespace nb {\n" + "namespace nc {\n" + "class A {};\n" + "} // namespace nc\n" + "\n" + "} // namespace nb\n" + "} // namespace na\n"; + EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); +} + +TEST_F(ChangeNamespaceTest, NewNsNestedInOldNsWithRefs) { + NewNamespace = "na::nb::nc"; + std::string Code = "namespace na {\n" + "class A {};\n" + "namespace nb {\n" + "class B {};\n" + "class C {};\n" + "void f() { A a; B b; }\n" + "} // namespace nb\n" + "} // namespace na\n"; + std::string Expected = "namespace na {\n" + "class A {};\n" + "namespace nb {\n" + "namespace nc {\n" + "class B {};\n" + "class C {};\n" + "void f() { A a; B b; }\n" + "} // namespace nc\n" + "\n" + "} // namespace nb\n" + "} // namespace na\n"; + EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); +} + TEST_F(ChangeNamespaceTest, SimpleMoveIntoAnotherNestedNamespace) { NewNamespace = "na::nc"; std::string Code = "namespace na {\n" Index: change-namespace/ChangeNamespace.cpp === --- change-namespace/ChangeNamespace.cpp +++ change-namespace/ChangeNamespace.cpp @@ -57,16 +57,19 @@ } // Returns the containing namespace of `InnerNs` by skipping `PartialNsName`. -// If the `InnerNs` does not have `PartialNsName` as suffix, nullptr is -// returned. +// If the `InnerNs` does not have `PartialNsName` as suffix, or `PartialNsName` +// is empty, nullptr is returned. // For example, if `InnerNs` is "a::b::c" and `PartialNsName` is "b::c", then // the NamespaceDecl of namespace "a" will be returned. const NamespaceDecl *getOuterNamespace(const NamespaceDecl *InnerNs, llvm::StringRef PartialNsName) { + if (!InnerNs || PartialNsName.empty()) +return nullptr; const auto *CurrentContext = llvm::cast(InnerNs); const auto *CurrentNs = InnerNs; llvm::SmallVector PartialNsNameSplitted; - PartialNsName.split(PartialNsNameSplitted, "::"); + PartialNsName.split(PartialNsNameSplitted, "::", /*MaxSplit=*/-1, + /*KeepEmpty=*/false); while (!PartialNsNameSplitted.empty()) { // Get the inner-most namespace in CurrentContext. while (CurrentContext && !llvm::isa(CurrentContext)) @@ -468,16 +471,20 @@ // "x::y" will be inserted inside the existing namespace "a" and after "a::b". // `OuterNs` is the first namespace in `DiffOldNamespace`, e.g. "namespace b" // in the above example. - // FIXME: consider the case where DiffOldNamespace is empty. + // If there is no outer namespace (i.e. DiffOldNamespace is empty), the new + // namespace will be a nested namespace in the old namespace. const NamespaceDecl *OuterNs = getOuterNamespace(NsDecl, DiffOldNamespace); - SourceLocation LocAfterNs = - getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager, - Result.Context->getLangOpts()); - assert(LocAfterNs.isValid() && - "Failed to get location after DiffOldNamespace"); + SourceLocation InsertionLoc = Start; + if (OuterNs) { +SourceLocation LocAfterNs = +getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager, + Result.Context->getLangOpts()); +assert(LocAfterNs.isValid() && + "Failed to get location after DiffOldNamespace"); +InsertionLoc = LocAfterNs; + } MoveNs.InsertionOffset = Result.SourceManager->getFileOffset( - Result.SourceManager->getSpellingLoc(LocAfterNs)); - + Result.SourceManager->getSpellingLoc(InsertionLoc));
[PATCH] D26456: Handle adding new nested namespace in old namespace.
ioeric updated this revision to Diff 77509. ioeric added a comment. - Address comments. https://reviews.llvm.org/D26456 Files: change-namespace/ChangeNamespace.cpp unittests/change-namespace/ChangeNamespaceTests.cpp Index: unittests/change-namespace/ChangeNamespaceTests.cpp === --- unittests/change-namespace/ChangeNamespaceTests.cpp +++ unittests/change-namespace/ChangeNamespaceTests.cpp @@ -97,6 +97,48 @@ EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); } +TEST_F(ChangeNamespaceTest, NewNsNestedInOldNs) { + NewNamespace = "na::nb::nc"; + std::string Code = "namespace na {\n" + "namespace nb {\n" + "class A {};\n" + "} // namespace nb\n" + "} // namespace na\n"; + std::string Expected = "namespace na {\n" + "namespace nb {\n" + "namespace nc {\n" + "class A {};\n" + "} // namespace nc\n" + "\n" + "} // namespace nb\n" + "} // namespace na\n"; + EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); +} + +TEST_F(ChangeNamespaceTest, NewNsNestedInOldNsWithRefs) { + NewNamespace = "na::nb::nc"; + std::string Code = "namespace na {\n" + "class A {};\n" + "namespace nb {\n" + "class B {};\n" + "class C {};\n" + "void f() { A a; B b; }\n" + "} // namespace nb\n" + "} // namespace na\n"; + std::string Expected = "namespace na {\n" + "class A {};\n" + "namespace nb {\n" + "namespace nc {\n" + "class B {};\n" + "class C {};\n" + "void f() { A a; B b; }\n" + "} // namespace nc\n" + "\n" + "} // namespace nb\n" + "} // namespace na\n"; + EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); +} + TEST_F(ChangeNamespaceTest, SimpleMoveIntoAnotherNestedNamespace) { NewNamespace = "na::nc"; std::string Code = "namespace na {\n" Index: change-namespace/ChangeNamespace.cpp === --- change-namespace/ChangeNamespace.cpp +++ change-namespace/ChangeNamespace.cpp @@ -57,16 +57,19 @@ } // Returns the containing namespace of `InnerNs` by skipping `PartialNsName`. -// If the `InnerNs` does not have `PartialNsName` as suffix, nullptr is -// returned. +// If the `InnerNs` does not have `PartialNsName` as suffix, or `PartialNsName` +// is empty, nullptr is returned. // For example, if `InnerNs` is "a::b::c" and `PartialNsName` is "b::c", then // the NamespaceDecl of namespace "a" will be returned. const NamespaceDecl *getOuterNamespace(const NamespaceDecl *InnerNs, llvm::StringRef PartialNsName) { + if (!InnerNs || PartialNsName.empty()) +return nullptr; const auto *CurrentContext = llvm::cast(InnerNs); const auto *CurrentNs = InnerNs; llvm::SmallVector PartialNsNameSplitted; - PartialNsName.split(PartialNsNameSplitted, "::"); + PartialNsName.split(PartialNsNameSplitted, "::", /*MaxSplit=*/-1, + /*KeepEmpty=*/false); while (!PartialNsNameSplitted.empty()) { // Get the inner-most namespace in CurrentContext. while (CurrentContext && !llvm::isa(CurrentContext)) @@ -468,16 +471,20 @@ // "x::y" will be inserted inside the existing namespace "a" and after "a::b". // `OuterNs` is the first namespace in `DiffOldNamespace`, e.g. "namespace b" // in the above example. - // FIXME: consider the case where DiffOldNamespace is empty. + // If there is no outer namespace (i.e. DiffOldNamespace is empty), the new + // namespace will be a nested namespace in the old namespace. const NamespaceDecl *OuterNs = getOuterNamespace(NsDecl, DiffOldNamespace); - SourceLocation LocAfterNs = - getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager, - Result.Context->getLangOpts()); - assert(LocAfterNs.isValid() && - "Failed to get location after DiffOldNamespace"); + SourceLocation InsertionLoc = Start; + if (OuterNs) { +SourceLocation LocAfterNs = +getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager, + Result.Context->getLangOpts()); +assert(LocAfterNs.isValid() && + "Failed to get location after DiffOldNamespace"); +InsertionLoc = LocAfterNs; + } MoveNs.InsertionOffset = Result.SourceManager->getFileOffset( - Result.SourceManager->getSpellingLoc(LocAfterNs)); - + Result.SourceManager->getSpellingLoc(InsertionLoc)); Mov
[PATCH] D24933: Enable configuration files in clang
sepavloff added a comment. >> Default config file is searched for only in the directory where clang >> executable resides. It allows SDK suppliers to customize compiler, for >> instance by turning off unneeded warnings, by providing their own clang.cfg. >> On the other hand developers cannot by accident override default setting >> because clang.cfg is placed in system directory. > > I thought one of the stated goals for this patch would be to allow users to > set default flags without touching the project's build system. Yes, that's true. Initially it was supposed that a user can override compiler defaults by putting `clang.cfg` into well-knows places, including `~/llvm`, in particular. Then this idea was rejected as a result of feedback, and default config file now is allowed only in the directory where `clang` executable resides. It still allows to override default settings by SDK suppliers but limit this possibility to powerful users. > What about this line? > > static const ArrayRef SearchDirs({ "~/.llvm", "/etc/llvm" }); > > That sounds like you'll be searching the home directory for a default config > file. These are directories where config files specified by option `--config` are searched for. There is a big difference between default config files and those specified explicitly. Default file adds option silently, user does not specify anything in the command line. Due to this point it can represent a source of troubles, such as problems with bug reports. In contrast the named config files are specified explicitly in clang invocation. A user may set the same set of option by listing them in command line. Such config file does not represents any dander, it is only a convenience feature. > And even if we ignore that, the CLANGCFG environment variable presents the > same problem. > > Let's say a developer uses that to point to a config file with their > favourite compiler flags for compiling on their x86_64 machine. > > But then they want to build something using the Android NDK, whose Clang will > now pull in that config file and start passing flags which doesn't apply to > the target, e.g. ARM. The user might not even be invoking the NDK directly; > it might be through Android Studio which certainly doesn't expect other flags > to be used than the ones it passes. If a user forget to update LIBRARY_PATH or C_INCLUDE_PATH the result would be the same. Config file set by environment variable is similar to default config file as user does not specify anything in command line. But the user must explicitly specify the file, it is not made automatically. Ability to append compiler options via environment variable is important feature, I think, because: - This feature implemented by Intel compiles has proven its convenience. - Build systems provided by software components are not perfect. Some do not honor CFLAGS, some require setting options inside makefiles etc. Changing compiler options might be a challenge. Environment variable solves this problem easily and effectively. - most compilers support it, in particular: - Intel compiler: ICCCFG (https://software.intel.com/en-us/node/522775), - Keil C compilers: ARMCOMPILER6_CLANGOPT (http://www.keil.com/support/man/docs/armclang_intro/armclang_intro_chr1374139991387.htm) - Visual C: CL (https://msdn.microsoft.com/en-us/library/kezkeayy.aspx) - IBM XL C/C++: XLC_USR_CONFIG (http://www.ibm.com/support/knowledgecenter/en/SSGH3R_13.1.3/com.ibm.xlcpp1313.aix.doc/compiler_ref/tusetenv1.html) https://reviews.llvm.org/D24933 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24183: A clang tool for changing surrouding namespaces of class/function definitions.
ioeric added inline comments. Comment at: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp:396 + // Calculate the name of the `NsDecl` after it is moved to new namespace. + std::string OldNs = NsDecl->getQualifiedNameAsString(); + llvm::StringRef Postfix = OldNs; mehdi_amini wrote: > You shouldn't dereference after a `dyn_cast`. Either null-check or use `cast`. Thanks! Fixed by rL286485 Repository: rL LLVM https://reviews.llvm.org/D24183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26456: Handle adding new nested namespace in old namespace.
hokein accepted this revision. hokein added a comment. This revision is now accepted and ready to land. LGTM with two nits. Comment at: change-namespace/ChangeNamespace.cpp:475 + // If there is no outer namespace (i.e. DiffOldNamespace is empty), the new + // namespace will be a nested namespace in the old namespace const NamespaceDecl *OuterNs = getOuterNamespace(NsDecl, DiffOldNamespace); missing a trailing `.`. Comment at: change-namespace/ChangeNamespace.cpp:477 const NamespaceDecl *OuterNs = getOuterNamespace(NsDecl, DiffOldNamespace); - SourceLocation LocAfterNs = - getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager, - Result.Context->getLangOpts()); - assert(LocAfterNs.isValid() && - "Failed to get location after DiffOldNamespace"); + SourceLocation InsertionLoc; + if (OuterNs) { How about `SourceLocation InsertionLoc = Start;` so that you don't need else statement below? https://reviews.llvm.org/D26456 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r286485 - [change-namespace] dyn_cast -> cast.
Author: ioeric Date: Thu Nov 10 12:15:34 2016 New Revision: 286485 URL: http://llvm.org/viewvc/llvm-project?rev=286485&view=rev Log: [change-namespace] dyn_cast -> cast. Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=286485&r1=286484&r2=286485&view=diff == --- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original) +++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Thu Nov 10 12:15:34 2016 @@ -404,7 +404,7 @@ void ChangeNamespaceTool::run( clang::SourceRange VarRefRange = VarRef->getSourceRange(); replaceQualifiedSymbolInDeclContext( Result, Context->getDeclContext(), VarRefRange.getBegin(), -VarRefRange.getEnd(), llvm::dyn_cast(Var)); +VarRefRange.getEnd(), llvm::cast(Var)); } else { const auto *Call = Result.Nodes.getNodeAs("call"); assert(Call != nullptr && "Expecting callback for CallExpr."); @@ -421,7 +421,7 @@ void ChangeNamespaceTool::run( clang::SourceRange CalleeRange = Call->getCallee()->getSourceRange(); replaceQualifiedSymbolInDeclContext( Result, Context->getDeclContext(), CalleeRange.getBegin(), -CalleeRange.getEnd(), llvm::dyn_cast(Func)); +CalleeRange.getEnd(), llvm::cast(Func)); } } @@ -543,7 +543,7 @@ void ChangeNamespaceTool::replaceQualifi const DeclContext *DeclCtx, SourceLocation Start, SourceLocation End, const NamedDecl *FromDecl) { const auto *NsDeclContext = DeclCtx->getEnclosingNamespaceContext(); - const auto *NsDecl = llvm::dyn_cast(NsDeclContext); + const auto *NsDecl = llvm::cast(NsDeclContext); // Calculate the name of the `NsDecl` after it is moved to new namespace. std::string OldNs = NsDecl->getQualifiedNameAsString(); llvm::StringRef Postfix = OldNs; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26406: Add -Wduplicate-protocol for existing diagnostic
arphaman added a comment. It seems sufficient enough, I will commit it with the summary. Thanks! https://reviews.llvm.org/D26406 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24183: A clang tool for changing surrouding namespaces of class/function definitions.
mehdi_amini added inline comments. Comment at: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp:396 + // Calculate the name of the `NsDecl` after it is moved to new namespace. + std::string OldNs = NsDecl->getQualifiedNameAsString(); + llvm::StringRef Postfix = OldNs; You shouldn't dereference after a `dyn_cast`. Either null-check or use `cast`. Repository: rL LLVM https://reviews.llvm.org/D24183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26406: Add -Wduplicate-protocol for existing diagnostic
kastiglione added a comment. @arphaman Is the summary here sufficient, or should I elaborate in some way? I'm fine with this summary if you are. https://reviews.llvm.org/D26406 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25985: [analyzer] Export coverage information from the analyzer.
zaks.anna added inline comments. Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:262 + +static void dumpCoverageInfo(llvm::SmallVectorImpl &Path, + SourceManager &SM) { xazax.hun wrote: > zaks.anna wrote: > > xazax.hun wrote: > > > zaks.anna wrote: > > > > Can this be a debug checker? > > > You mean the dumping part or also collecting the coverage? It can be a > > > debug checker if we add a new callback like "checkBasicBlockBegin". I did > > > not want to add such callback just for a debug check. However, it is > > > possible to move only the dumping part to a separate checker. What would > > > you prefer? > > I would prefer to add a "checkBasicBlockBegin" callback and move all of > > this diagnostic code into a debug checker. > Do you think the checkers should be able to add state transitions from > BeginBasicBlock callback? Would you prefer to have an EndBasicBlock callback > for symmetry? I cannot think of any right now. The main advantages of having this as a debug checker are: - Not having this code in ExprEngine.cpp - it's not related to the core engine functionality. - More importantly, discoverability of this functionality. On the downside, we would not want to add a checker API if it has no useful users. https://reviews.llvm.org/D25985 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26511: [clang-tidy] Rename modernize-use-default to modernize-use-equals-default
aaron.ballman added inline comments. Comment at: clang-tidy/modernize/ModernizeTidyModule.cpp:58 "modernize-use-bool-literals"); -CheckFactories.registerCheck("modernize-use-default"); + CheckFactories.registerCheck("modernize-use-equals-default"); CheckFactories.registerCheck("modernize-use-emplace"); malcolm.parsons wrote: > aaron.ballman wrote: > > What do we want to do, if anything, for people who have scripts using the > > old name? Do we want to keep the old name as an alias to the new name for > > some period of time? > An alias helps if the check was enabled by name, but not if it was disabled > by name. > If the alias is temporary, would you want a deprecation warning? > I wouldn't want to warn about `-checks=modernize*`, but maybe warning for > `-checks=modernize-use-default` would be useful. > An alias helps if the check was enabled by name, but not if it was disabled > by name. Oye, this is true and unfortunate. > If the alias is temporary, would you want a deprecation warning? > I wouldn't want to warn about -checks=modernize*, but maybe warning for > -checks=modernize-use-default would be useful. I think a deprecation warning would be a helpful feature, but not required. I do agree that I would not want a warning for wildcard matches. I would also be fine if we simply had the documentation for `modernize-use-default` forward to the documentation for `modernize-use-equals-default` and put a note in there about the old name being deprecated and leave in an alias to the old name. To be complete, I would also be fine if we remove the old name as in this patch. I am mostly thinking about what default policy we want to have when this situation arises. FWIW, the check was exposed under this name around Oct 2015, so it's been in the wild for over a year, and in a public release. https://reviews.llvm.org/D26511 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26511: [clang-tidy] Rename modernize-use-default to modernize-use-equals-default
malcolm.parsons added inline comments. Comment at: clang-tidy/modernize/ModernizeTidyModule.cpp:58 "modernize-use-bool-literals"); -CheckFactories.registerCheck("modernize-use-default"); + CheckFactories.registerCheck("modernize-use-equals-default"); CheckFactories.registerCheck("modernize-use-emplace"); aaron.ballman wrote: > What do we want to do, if anything, for people who have scripts using the old > name? Do we want to keep the old name as an alias to the new name for some > period of time? An alias helps if the check was enabled by name, but not if it was disabled by name. If the alias is temporary, would you want a deprecation warning? I wouldn't want to warn about `-checks=modernize*`, but maybe warning for `-checks=modernize-use-default` would be useful. https://reviews.llvm.org/D26511 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26512: Protect std::ios tests under libcpp-no-exceptions
rogfer01 added inline comments. Comment at: test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp:171-173 +#else +ios1.copyfmt(ios2); +#endif This is a bit unexpected. It looks like if the copyfmt, even if it throws, were able to copy part of the information. Is this reasonable? https://reviews.llvm.org/D26512 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26512: Protect std::ios tests under libcpp-no-exceptions
rogfer01 created this revision. rogfer01 added reviewers: EricWF, mclow.lists, rmaprath. rogfer01 added a subscriber: cfe-commits. Skip tests that expect an exception be thrown. https://reviews.llvm.org/D26512 Files: test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp Index: test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp === --- test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp +++ test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp @@ -7,7 +7,6 @@ // //===--===// -// XFAIL: libcpp-no-exceptions // // template class basic_ios @@ -18,14 +17,17 @@ #include #include +#include "test_macros.h" + struct testbuf : public std::streambuf {}; int main() { { std::ios ios(0); ios.setstate(std::ios::goodbit); assert(ios.rdstate() == std::ios::badbit); +#ifndef TEST_HAS_NO_EXCEPTIONS try { ios.exceptions(std::ios::badbit); @@ -51,6 +53,7 @@ { assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit)); } +#endif } { testbuf sb; Index: test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp === --- test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp +++ test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp @@ -7,7 +7,6 @@ // //===--===// -// XFAIL: libcpp-no-exceptions // // template class basic_ios @@ -18,6 +17,8 @@ #include #include +#include "test_macros.h" + struct testbuf : public std::streambuf {}; int main() @@ -27,6 +28,7 @@ assert(ios.exceptions() == std::ios::goodbit); ios.exceptions(std::ios::eofbit); assert(ios.exceptions() == std::ios::eofbit); +#ifndef TEST_HAS_NO_EXCEPTIONS try { ios.exceptions(std::ios::badbit); @@ -36,6 +38,7 @@ { } assert(ios.exceptions() == std::ios::badbit); +#endif } { testbuf sb; Index: test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp === --- test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp +++ test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp @@ -7,7 +7,6 @@ // //===--===// -// XFAIL: libcpp-no-exceptions // // template class basic_ios @@ -18,14 +17,17 @@ #include #include +#include "test_macros.h" + struct testbuf : public std::streambuf {}; int main() { { std::ios ios(0); ios.clear(); assert(ios.rdstate() == std::ios::badbit); +#ifndef TEST_HAS_NO_EXCEPTIONS try { ios.exceptions(std::ios::badbit); @@ -51,6 +53,7 @@ { assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit)); } +#endif } { testbuf sb; Index: test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp === --- test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp +++ test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp @@ -7,7 +7,6 @@ // //===--===// -// XFAIL: libcpp-no-exceptions // // template class basic_ios @@ -18,6 +17,8 @@ #include #include +#include "test_macros.h" + struct testbuf : public std::streambuf { @@ -35,24 +36,28 @@ testbuf sb1; testbuf sb2; testios ios(&sb1); +#ifndef TEST_HAS_NO_EXCEPTIONS try { ios.setstate(std::ios::badbit); ios.exceptions(std::ios::badbit); } catch (...) { } +#endif ios.set_rdbuf(&sb2); assert(ios.rdbuf() == &sb2); +#ifndef TEST_HAS_NO_EXCEPTIONS try { ios.setstate(std::ios::badbit); ios.exceptions(std::ios::badbit); } catch (...) { } +#endif ios.set_rdbuf(0); assert(ios.rdbuf() == 0); } Index: test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp === --- test/std/input.output/iostreams.base/ios/basic.ios.member
[PATCH] D26511: [clang-tidy] Rename modernize-use-default to modernize-use-equals-default
aaron.ballman added inline comments. Comment at: clang-tidy/modernize/ModernizeTidyModule.cpp:58 "modernize-use-bool-literals"); -CheckFactories.registerCheck("modernize-use-default"); + CheckFactories.registerCheck("modernize-use-equals-default"); CheckFactories.registerCheck("modernize-use-emplace"); What do we want to do, if anything, for people who have scripts using the old name? Do we want to keep the old name as an alias to the new name for some period of time? https://reviews.llvm.org/D26511 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26511: [clang-tidy] Rename modernize-use-default to modernize-use-equals-default
malcolm.parsons created this revision. malcolm.parsons added reviewers: aaron.ballman, alexfh, angelgarcia. malcolm.parsons added a subscriber: cfe-commits. Herald added a subscriber: mgorny. https://reviews.llvm.org/D26511 Files: clang-tidy/modernize/CMakeLists.txt clang-tidy/modernize/ModernizeTidyModule.cpp clang-tidy/modernize/UseDefaultCheck.cpp clang-tidy/modernize/UseDefaultCheck.h clang-tidy/modernize/UseEqualsDefaultCheck.cpp clang-tidy/modernize/UseEqualsDefaultCheck.h docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/modernize-use-default.rst docs/clang-tidy/checks/modernize-use-equals-default.rst test/clang-tidy/modernize-use-default-copy.cpp test/clang-tidy/modernize-use-default-delayed.cpp test/clang-tidy/modernize-use-default.cpp test/clang-tidy/modernize-use-equals-default-copy.cpp test/clang-tidy/modernize-use-equals-default-delayed.cpp test/clang-tidy/modernize-use-equals-default.cpp Index: test/clang-tidy/modernize-use-equals-default.cpp === --- test/clang-tidy/modernize-use-equals-default.cpp +++ test/clang-tidy/modernize-use-equals-default.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s modernize-use-default %t -- -- -std=c++11 -fno-delayed-template-parsing -fexceptions +// RUN: %check_clang_tidy %s modernize-use-equals-default %t -- -- -std=c++11 -fno-delayed-template-parsing -fexceptions // Out of line definition. class OL { @@ -8,10 +8,10 @@ }; OL::OL() {} -// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial default constructor [modernize-use-default] +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial default constructor [modernize-use-equals-default] // CHECK-FIXES: OL::OL() = default; OL::~OL() {} -// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial destructor [modernize-use-default] +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial destructor [modernize-use-equals-default] // CHECK-FIXES: OL::~OL() = default; // Inline definitions. Index: test/clang-tidy/modernize-use-equals-default-delayed.cpp === --- test/clang-tidy/modernize-use-equals-default-delayed.cpp +++ test/clang-tidy/modernize-use-equals-default-delayed.cpp @@ -1,4 +1,4 @@ -// RUN: clang-tidy %s -checks=-*,modernize-use-default -- -std=c++11 -fdelayed-template-parsing -fexceptions | count 0 +// RUN: clang-tidy %s -checks=-*,modernize-use-equals-default -- -std=c++11 -fdelayed-template-parsing -fexceptions | count 0 // Note: this test expects no diagnostics, but FileCheck cannot handle that, // hence the use of | count 0. Index: test/clang-tidy/modernize-use-equals-default-copy.cpp === --- test/clang-tidy/modernize-use-equals-default-copy.cpp +++ test/clang-tidy/modernize-use-equals-default-copy.cpp @@ -1,19 +1,19 @@ -// RUN: %check_clang_tidy %s modernize-use-default %t -- -- -std=c++11 -fno-delayed-template-parsing -fexceptions +// RUN: %check_clang_tidy %s modernize-use-equals-default %t -- -- -std=c++11 -fno-delayed-template-parsing -fexceptions // Out of line definition. struct OL { OL(const OL &); OL &operator=(const OL &); int Field; }; OL::OL(const OL &Other) : Field(Other.Field) {} -// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial copy constructor [modernize-use-default] +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial copy constructor [modernize-use-equals-default] // CHECK-FIXES: OL::OL(const OL &Other) = default; OL &OL::operator=(const OL &Other) { Field = Other.Field; return *this; } -// CHECK-MESSAGES: :[[@LINE-4]]:1: warning: use '= default' to define a trivial copy-assignment operator [modernize-use-default] +// CHECK-MESSAGES: :[[@LINE-4]]:1: warning: use '= default' to define a trivial copy-assignment operator [modernize-use-equals-default] // CHECK-FIXES: OL &OL::operator=(const OL &Other) = default; // Inline. Index: docs/clang-tidy/checks/modernize-use-equals-default.rst === --- docs/clang-tidy/checks/modernize-use-equals-default.rst +++ docs/clang-tidy/checks/modernize-use-equals-default.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - modernize-use-default +.. title:: clang-tidy - modernize-use-equals-default -modernize-use-default -= +modernize-use-equals-default + This check replaces default bodies of special member functions with ``= default;``. The explicitly defaulted function declarations enable more Index: docs/clang-tidy/checks/list.rst === --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -109,7 +109,7 @@ modernize-shrink-to-fit
[PATCH] D26458: Protect nested-exceptions tests under no-exceptions
rogfer01 added a comment. @rmaprath well each case is testing a different special member: the assignment operator, the copy constructor and the default constructor. My feeling is that at least the non-throwing part must be tested under no-exceptions. But I understand, that this class is probably useless in the context of no-exceptions. https://reviews.llvm.org/D26458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r286474 - Protect bitset tests under libcpp-no-exceptions
Author: rogfer01 Date: Thu Nov 10 10:54:55 2016 New Revision: 286474 URL: http://llvm.org/viewvc/llvm-project?rev=286474&view=rev Log: Protect bitset tests under libcpp-no-exceptions Bitset tests feature a sequence of tests of increasing bitset sizes, but these tests rely on exceptions when the bitset size is less than 50 elements. This change adds a flag to tell whether a test should throw. If it must throw it will be skipped under no-exceptions. Differential Revision: https://reviews.llvm.org/D26140 Modified: libcxx/trunk/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp libcxx/trunk/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp libcxx/trunk/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp libcxx/trunk/test/std/utilities/template.bitset/bitset.members/test.pass.cpp Modified: libcxx/trunk/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp?rev=286474&r1=286473&r2=286474&view=diff == --- libcxx/trunk/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp Thu Nov 10 10:54:55 2016 @@ -7,13 +7,14 @@ // //===--===// -// XFAIL: libcpp-no-exceptions // test bitset& flip(size_t pos); #include #include #include +#include "test_macros.h" + template std::bitset make_bitset() @@ -25,11 +26,15 @@ make_bitset() } template -void test_flip_one() +void test_flip_one(bool test_throws) { std::bitset v = make_bitset(); +#ifdef TEST_HAS_NO_EXCEPTIONS +if (test_throws) return; +#else try { +#endif v.flip(50); bool b = v[50]; if (50 >= v.size()) @@ -39,21 +44,25 @@ void test_flip_one() assert(v[50] != b); v.flip(50); assert(v[50] == b); +assert(!test_throws); +#ifndef TEST_HAS_NO_EXCEPTIONS } catch (std::out_of_range&) { +assert(test_throws); } +#endif } int main() { -test_flip_one<0>(); -test_flip_one<1>(); -test_flip_one<31>(); -test_flip_one<32>(); -test_flip_one<33>(); -test_flip_one<63>(); -test_flip_one<64>(); -test_flip_one<65>(); -test_flip_one<1000>(); +test_flip_one<0>(true); +test_flip_one<1>(true); +test_flip_one<31>(true); +test_flip_one<32>(true); +test_flip_one<33>(true); +test_flip_one<63>(false); +test_flip_one<64>(false); +test_flip_one<65>(false); +test_flip_one<1000>(false); } Modified: libcxx/trunk/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp?rev=286474&r1=286473&r2=286474&view=diff == --- libcxx/trunk/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp Thu Nov 10 10:54:55 2016 @@ -7,18 +7,23 @@ // //===--===// -// XFAIL: libcpp-no-exceptions // test bitset& reset(size_t pos); #include #include +#include "test_macros.h" + template -void test_reset_one() +void test_reset_one(bool test_throws) { std::bitset v; +#ifdef TEST_HAS_NO_EXCEPTIONS +if (test_throws) return; +#else try { +#endif v.set(); v.reset(50); if (50 >= v.size()) @@ -28,21 +33,25 @@ void test_reset_one() assert(!v[i]); else assert(v[i]); +assert(!test_throws); +#ifndef TEST_HAS_NO_EXCEPTIONS } catch (std::out_of_range&) { +assert(test_throws); } +#endif } int main() { -test_reset_one<0>(); -test_reset_one<1>(); -test_reset_one<31>(); -test_reset_one<32>(); -test_reset_one<33>(); -test_reset_one<63>(); -test_reset_one<64>(); -test_reset_one<65>(); -test_reset_one<1000>(); +test_reset_one<0>(true); +test_reset_one<1>(true); +test_reset_one<31>(true); +test_reset_one<32>(true); +test_reset_one<33>(true); +test_reset_one<63>(false); +test_reset_one<64>(false); +test_reset_one<65>(false); +test_reset_one<1000>(false); } Modified: libcxx/trunk/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp?rev=286474&r1=286473&r2=286474&view=diff ===
[PATCH] D26138: [clang-tidy] Add modernize-use-equals-delete check
This revision was automatically updated to reflect the committed changes. Closed by commit rL286472: [clang-tidy] Add modernize-use-equals-delete check (authored by malcolm.parsons). Changed prior to commit: https://reviews.llvm.org/D26138?vs=76971&id=77500#toc Repository: rL LLVM https://reviews.llvm.org/D26138 Files: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.h clang-tools-extra/trunk/docs/ReleaseNotes.rst clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-delete.rst clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp === --- clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp +++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp @@ -0,0 +1,134 @@ +// RUN: %check_clang_tidy %s modernize-use-equals-delete %t + +struct PositivePrivate { +private: + PositivePrivate(); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete] + // CHECK-FIXES: PositivePrivate() = delete; + PositivePrivate(const PositivePrivate &); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete] + // CHECK-FIXES: PositivePrivate(const PositivePrivate &) = delete; + PositivePrivate &operator=(const PositivePrivate &); + // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete] + // CHECK-FIXES: PositivePrivate &operator=(const PositivePrivate &) = delete; + PositivePrivate(PositivePrivate &&); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete] + // CHECK-FIXES: PositivePrivate(PositivePrivate &&) = delete; + PositivePrivate &operator=(PositivePrivate &&); + // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete] + // CHECK-FIXES: PositivePrivate &operator=(PositivePrivate &&) = delete; + ~PositivePrivate(); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete] + // CHECK-FIXES: ~PositivePrivate() = delete; +}; + +struct NegativePublic { + NegativePublic(const NegativePublic &); +}; + +struct NegativeProtected { +protected: + NegativeProtected(const NegativeProtected &); +}; + +struct PositiveInlineMember { + int foo() { return 0; } + +private: + PositiveInlineMember(const PositiveInlineMember &); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete] + // CHECK-FIXES: PositiveInlineMember(const PositiveInlineMember &) = delete; +}; + +struct PositiveOutOfLineMember { + int foo(); + +private: + PositiveOutOfLineMember(const PositiveOutOfLineMember &); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete] + // CHECK-FIXES: PositiveOutOfLineMember(const PositiveOutOfLineMember &) = delete; +}; + +int PositiveOutOfLineMember::foo() { return 0; } + +struct PositiveAbstractMember { + virtual int foo() = 0; + +private: + PositiveAbstractMember(const PositiveAbstractMember &); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete] + // CHECK-FIXES: PositiveAbstractMember(const PositiveAbstractMember &) = delete; +}; + +struct NegativeMemberNotImpl { + int foo(); + +private: + NegativeMemberNotImpl(const NegativeMemberNotImpl &); +}; + +struct NegativeStaticMemberNotImpl { + static int foo(); + +private: + NegativeStaticMemberNotImpl(const NegativeStaticMemberNotImpl &); +}; + +struct NegativeInline { +private: + NegativeInline(const NegativeInline &) {} +}; + +struct NegativeOutOfLine { +private: + NegativeOutOfLine(const NegativeOutOfLine &); +}; + +NegativeOutOfLine::NegativeOutOfLine(const NegativeOutOfLine &) {} + +struct NegativeConstructNotImpl { + NegativeConstructNotImpl(); + +private: + NegativeConstructNotImpl(const NegativeConstructNotImpl &); +}; + +struct PositiveDefaultedConstruct { + PositiveDefaultedConstruct() = default; + +private: + PositiveDefaultedConstruct(const PositiveDefaultedConstruct &); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '=
[clang-tools-extra] r286472 - [clang-tidy] Add modernize-use-equals-delete check
Author: malcolm.parsons Date: Thu Nov 10 10:46:59 2016 New Revision: 286472 URL: http://llvm.org/viewvc/llvm-project?rev=286472&view=rev Log: [clang-tidy] Add modernize-use-equals-delete check Summary: Fixes PR27872 Reviewers: klimek, hokein, alexfh, aaron.ballman Subscribers: Prazek, Eugene.Zelenko, danielmarjamaki, cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D26138 Added: clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.h clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-delete.rst clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp clang-tools-extra/trunk/docs/ReleaseNotes.rst clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=286472&r1=286471&r2=286472&view=diff == --- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Thu Nov 10 10:46:59 2016 @@ -18,6 +18,7 @@ add_clang_library(clangTidyModernizeModu UseBoolLiteralsCheck.cpp UseDefaultCheck.cpp UseEmplaceCheck.cpp + UseEqualsDeleteCheck.cpp UseNullptrCheck.cpp UseOverrideCheck.cpp UseUsingCheck.cpp Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=286472&r1=286471&r2=286472&view=diff == --- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Thu Nov 10 10:46:59 2016 @@ -24,6 +24,7 @@ #include "UseBoolLiteralsCheck.h" #include "UseDefaultCheck.h" #include "UseEmplaceCheck.h" +#include "UseEqualsDeleteCheck.h" #include "UseNullptrCheck.h" #include "UseOverrideCheck.h" #include "UseUsingCheck.h" @@ -56,6 +57,8 @@ public: "modernize-use-bool-literals"); CheckFactories.registerCheck("modernize-use-default"); CheckFactories.registerCheck("modernize-use-emplace"); +CheckFactories.registerCheck( +"modernize-use-equals-delete"); CheckFactories.registerCheck("modernize-use-nullptr"); CheckFactories.registerCheck("modernize-use-override"); CheckFactories.registerCheck("modernize-use-using"); Added: clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp?rev=286472&view=auto == --- clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp (added) +++ clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp Thu Nov 10 10:46:59 2016 @@ -0,0 +1,69 @@ +//===--- UseEqualsDeleteCheck.cpp - clang-tidy-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "UseEqualsDeleteCheck.h" +#include "clang/AST/ASTContext.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/Lex/Lexer.h" + +using namespace clang::ast_matchers; + +namespace clang { +namespace tidy { +namespace modernize { + +static const char SpecialFunction[] = "SpecialFunction"; +static const char DeletedNotPublic[] = "DeletedNotPublic"; + +void UseEqualsDeleteCheck::registerMatchers(MatchFinder *Finder) { + auto PrivateSpecialFn = cxxMethodDecl( + isPrivate(), + anyOf(cxxConstructorDecl(anyOf(isDefaultConstructor(), + isCopyConstructor(), isMoveConstructor())), +cxxMethodDecl( +anyOf(isCopyAssignmentOperator(), isMoveAssignmentOperator())), +cxxDestructorDecl())); + + Finder->addMatcher( + cxxMethodDecl( + PrivateSpecialFn, + unless(anyOf(hasBody(stmt()), isDefaulted(), isDeleted(), + // Ensure that all methods except private special member + // functions are defined. + hasParent(cxxRecordDecl(hasMethod(unless( + anyOf(PrivateSpecialFn, hasBody(stmt()), isPure(), + isD
[PATCH] D23657: Remove some false positives when taking the address of packed members
rogfer01 updated this revision to Diff 77498. rogfer01 added a comment. - Address comments. - Rebase test with current trunk - Make the check resilient under errors If no comments arise from this change I will be commiting it Monday next week. https://reviews.llvm.org/D23657 Files: include/clang/Sema/Sema.h lib/Sema/SemaChecking.cpp test/Sema/address-packed.c Index: test/Sema/address-packed.c === --- test/Sema/address-packed.c +++ test/Sema/address-packed.c @@ -26,6 +26,7 @@ struct Arguable *get_arguable(); void to_void(void *); +void to_intptr(intptr_t); void g0(void) { { @@ -41,43 +42,48 @@ f1((int *)(void *)&arguable.x); // no-warning to_void(&arguable.x); // no-warning -void *p = &arguable.x; // no-warning; +void *p = &arguable.x; // no-warning to_void(p); +to_intptr((intptr_t)p); // no-warning } { union UnionArguable arguable; f2(&arguable.c); // no-warning f1(&arguable.x); // expected-warning {{packed member 'x' of class or structure 'UnionArguable'}} -f1((int *)(void *)&arguable.x); // no-warning -to_void(&arguable.x); // no-warning +f1((int *)(void *)&arguable.x); // no-warning +to_void(&arguable.x); // no-warning +to_intptr((intptr_t)&arguable.x); // no-warning } { ArguableT arguable; f2(&arguable.c0); // no-warning f1(&arguable.x); // expected-warning {{packed member 'x' of class or structure 'Arguable'}} f2(&arguable.c1); // no-warning -f1((int *)(void *)&arguable.x); // no-warning -to_void(&arguable.x); // no-warning +f1((int *)(void *)&arguable.x); // no-warning +to_void(&arguable.x); // no-warning +to_intptr((intptr_t)&arguable.x); // no-warning } { struct Arguable *arguable = get_arguable(); f2(&arguable->c0); // no-warning f1(&arguable->x); // expected-warning {{packed member 'x' of class or structure 'Arguable'}} f2(&arguable->c1); // no-warning -f1((int *)(void *)&arguable->x); // no-warning -to_void(&arguable->c1); // no-warning +f1((int *)(void *)&arguable->x);// no-warning +to_void(&arguable->c1); // no-warning +to_intptr((intptr_t)&arguable->c1); // no-warning } { ArguableT *arguable = get_arguable(); f2(&(arguable->c0)); // no-warning f1(&(arguable->x)); // expected-warning {{packed member 'x' of class or structure 'Arguable'}} f2(&(arguable->c1)); // no-warning -f1((int *)(void *)&(arguable->x)); // no-warning -to_void(&(arguable->c1)); // no-warning +f1((int *)(void *)&(arguable->x)); // no-warning +to_void(&(arguable->c1)); // no-warning +to_intptr((intptr_t)&(arguable->c1)); // no-warning } } @@ -196,3 +202,130 @@ int *anonymousInnerUnion(struct S6 *s) { return &s->x; // expected-warning {{packed member 'x' of class or structure 'S6::(anonymous)'}} } + +struct S6a { +int a; +int _; +int c; +char __; +int d; +} __attribute__((packed, aligned(16))) s6; + +void g8() +{ +f1(&s6.a); // no-warning +f1(&s6.c); // no-warning +f1(&s6.d); // expected-warning {{packed member 'd' of class or structure 'S6a'}} +} + +struct __attribute__((packed, aligned(1))) MisalignedContainee { double d; }; +struct __attribute__((aligned(8))) AlignedContainer { struct MisalignedContainee b; }; + +struct AlignedContainer *p; +double* g9() { + return &p->b.d; // no-warning +} + +union OneUnion +{ +uint32_t a; +uint32_t b:1; +}; + +struct __attribute__((packed)) S7 { +uint8_t length; +uint8_t stuff; +uint8_t padding[2]; +union OneUnion one_union; +}; + +union AnotherUnion { +long data; +struct S7 s; +} *au; + +union OneUnion* get_OneUnion(void) +{ +return &au->s.one_union; // no-warning +} + +struct __attribute__((packed)) S8 { +uint8_t data1; +uint8_t data2; + uint16_t wider_data; +}; + +#define LE_READ_2(p) \ + ((uint16_t) \ + const uint8_t *)(p))[0] ) | \ + (((const uint8_t *)(p))[1] << 8))) + +uint32_t get_wider_data(struct S8 *s) +{ +return LE_READ_2(&s->wider_data); // no-warning +} + +struct S9 { + uint32_t x; + uint8_t y[2]; + uint16_t z; +} __attribute__((__packed__)); + +typedef struct S9 __attribute__((__aligned__(16))) aligned_S9; + +void g10() { + struct S9 x; + struct S9 __attribute__((__aligned__(8))) y; + aligned_S9 z; + + uint32_t *p32; + p32 = &x.x; // expected-warning {{packed member 'x' of class or structure 'S9'}} + p32 = &y.x; // no-warning + p32 = &z.x; // no-warning +} + +typedef struct { + uint32_t msgh_bits; + uint32_t msgh_size; + int32_t msgh_voucher_port; + int32_t msgh_id; +} S10Header; + +typedef struct { + uint32_t t; + uint64_t m; + uint32_t p; + union { +struct { + uint32_t a; + double z; +} _
[PATCH] D26509: [OpenCL] Fix integer parameters of enqueue_kernel
Anastasia created this revision. Anastasia added a reviewer: yaxunl. Anastasia added a subscriber: cfe-commits. Parameters representing number of events as well as sizes of enqueued block arguments in enqueue_kernel function are specified as uint type. This prevents passing sizeof(int) type expressions on the 64 bit architectures because they return size_t which is a 64 bit wide in contrast to uint that is always 32 bits. The suggestion is to accept any integer type as soon as the compiler can prove that the range fits in the data width of uint for number of event or size_t for block argument sizes (and if not appropriate error is emitted). The proposed enqueue_kernel signature would be: int enqueue_kernel (queue_t queue, kernel_enqueue_flags_t flags, const ndrange_t ndrange, uint num_events_in_wait_list, const clk_event_t *event_wait_list, clk_event_t *event_ret, void (^block)(local void *, ...), size_t size0, ...) and therefore compiler should allow the call: enqueue_kernel(default_queue, flags, ndrange, sizeof(event_wait_list)/sizeof(event_wait_list[0]), event_wait_list2, &clk_event, ^(local void *p) { return; }, sizeof(int[2])); See tests for more examples. https://reviews.llvm.org/D26509 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/CodeGen/CGBuiltin.cpp lib/Sema/SemaChecking.cpp test/CodeGenOpenCL/cl20-device-side-enqueue.cl test/SemaOpenCL/cl20-device-side-enqueue.cl Index: test/SemaOpenCL/cl20-device-side-enqueue.cl === --- test/SemaOpenCL/cl20-device-side-enqueue.cl +++ test/SemaOpenCL/cl20-device-side-enqueue.cl @@ -1,5 +1,6 @@ // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only -// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only -Wconversion -DWCONV +// RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 +// RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir64-unknown-unknown" -verify -pedantic -fsyntax-only -Wconversion -DWCONV // Diagnostic tests for different overloads of enqueue_kernel from Table 6.13.17.1 of OpenCL 2.0 Spec. kernel void enqueue_kernel_tests() { @@ -39,6 +40,10 @@ return 0; }); + enqueue_kernel(default_queue, flags, ndrange, vptr, &event_wait_list, &evt, ^(void) { // expected-error{{illegal call to enqueue_kernel, parameter needs to be specified as integer type}} +return 0; + }); + enqueue_kernel(default_queue, flags, ndrange, 1, vptr, &evt, ^(void) // expected-error{{illegal call to enqueue_kernel, expected 'clk_event_t *' argument type}} { return 0; @@ -62,16 +67,35 @@ ^(local void *a, local void *b) { return 0; }, - 1024, 1024L); // expected-error{{local memory sizes need to be specified as uint}} + 1024L, 1024); + + enqueue_kernel(default_queue, flags, ndrange, + ^(local void *a, local void *b) { + return 0; + }, + 1024, 4294967296L); +#ifdef B32 +// expected-warning@-2{{implicit conversion from 'long' to 'unsigned int' changes value from 4294967296 to 0}} +#endif char c; enqueue_kernel(default_queue, flags, ndrange, ^(local void *a, local void *b) { return 0; }, - c, 1024); + c, 1024L); #ifdef WCONV -// expected-warning@-2{{implicit conversion changes signedness: 'char' to 'unsigned int'}} +// expected-warning-re@-2{{implicit conversion changes signedness: 'char' to 'unsigned {{int|long}}'}} +#endif +#define UINT_MAX 4294967295 + + enqueue_kernel(default_queue, flags, ndrange, + ^(local void *a, local void *b) { + return 0; + }, + sizeof(int), sizeof(int) * UINT_MAX); +#ifdef B32 +// expected-warning@-2{{implicit conversion from 'long' to 'unsigned int' changes value from 17179869180 to 4294967292}} #endif typedef void (^bl_A_t)(local void *); @@ -97,10 +121,13 @@ ^(local void *a, local void *b) { return 0; }, - illegal_mem_size, illegal_mem_size); // expected-error{{local memory sizes need to be specified as uint}} expected-error{{local memory sizes need to be specified as uint}} -#ifdef WCONV -// expected-warning@-2{{implicit conversion turns floating-point number into integer: 'float' to 'unsigned int'}} expected-warning@-2{{implicit conversion turns floating-point number into integer: 'float' to 'unsigned int'}} -#endif + illegal_mem_size, illegal_mem_size); // expected-error{{illegal call to enqueue_kernel, parameter needs to be specified as integer type}}
[PATCH] D26138: [clang-tidy] Add modernize-use-equals-delete check
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM, thank you! Comment at: clang-tidy/modernize/UseEqualsDeleteCheck.cpp:58 + << FixItHint::CreateInsertion(StartLoc, "public: ") + << FixItHint::CreateInsertion(AfterLoc, " private:"); +} malcolm.parsons wrote: > aaron.ballman wrote: > > malcolm.parsons wrote: > > > aaron.ballman wrote: > > > > I am on the fence about this fixit. On the one hand, the fix is a > > > > technical improvement because it means that implementations will > > > > consistently find the declaration and bark about it being explicitly > > > > deleted. On the other hand, the fixit suggests code that should never > > > > pass a reasonable code review. > > > > > > > > I'm wondering if it would make more sense to leave the access > > > > specifiers alone and just put a FIXME in the code to point the > > > > situation out. I am guessing that at some point we will have a > > > > refactoring tool that can help without resorting to making declarations > > > > like `public: C() = delete; private:`. > > > > > > > > What do you think? > > > I'm wondering whether no fixit would be better than a not-good-enough > > > fixit. > > Generally, no. Incremental improvements are almost always fine. However, > > the user is asking to have their code modernized, and the fixit results in > > code that looks more foreign than modern (at least, to me). > > > > I won't block the patch moving forward regardless of whether the fixit is > > in or out, but I am curious if @alexfh has an opinion, or if you have a > > strong preference one way or the other. > I'll change the check to warn about deleted methods that aren't public; the > user can fix those manually until a better fixit is possible. I think that's a good solution for now, thanks! https://reviews.llvm.org/D26138 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang-tools-extra] r286466 - [clang-tidy] Add missing meta refresh for cert-msc30-c doc. NFC
On Thu, Nov 10, 2016 at 11:19 AM, Malcolm Parsons via cfe-commits wrote: > Author: malcolm.parsons > Date: Thu Nov 10 10:19:17 2016 > New Revision: 286466 > > URL: http://llvm.org/viewvc/llvm-project?rev=286466&view=rev > Log: > [clang-tidy] Add missing meta refresh for cert-msc30-c doc. NFC Thank you for this! (Though I would claim it's not NFC since it definitely makes a functional improvement to the docs.) ~Aaron > > Modified: > clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc30-c.rst > > Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc30-c.rst > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc30-c.rst?rev=286466&r1=286465&r2=286466&view=diff > == > --- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc30-c.rst (original) > +++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-msc30-c.rst Thu Nov > 10 10:19:17 2016 > @@ -1,4 +1,6 @@ > .. title:: clang-tidy - cert-msc30-c > +.. meta:: > + :http-equiv=refresh: 5;URL=cert-msc50-cpp.html > > cert-msc30-c > > > > ___ > 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] D24894: [clang-tidy] Prefer transparent functors to non-transparent one.
aaron.ballman added inline comments. Comment at: clang-tidy/modernize/UseTransparentFunctorsCheck.cpp:71 + +static const StringRef Message = "prefer transparent functors (%0)"; + You should quote the %0 to clarify that you're referring to syntax. Comment at: clang-tidy/modernize/UseTransparentFunctorsCheck.cpp:89 +diag(FuncInst->getLocStart(), Message) +<< (FuncClass->getName() + "<>").str(); +return; Is the `.str()` required? (Same question applies below.) https://reviews.llvm.org/D24894 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26479: [PowerPC] Implement remaining permute builtins in altivec.h - Clang portion
nemanjai updated this revision to Diff 77494. nemanjai added a comment. Accidentally uploaded the wrong patch so it was missing full context. Repository: rL LLVM https://reviews.llvm.org/D26479 Files: include/clang/Basic/BuiltinsPPC.def lib/Headers/altivec.h test/CodeGen/builtins-ppc-crypto.c test/CodeGen/builtins-ppc-p8vector.c test/CodeGen/builtins-ppc-p9vector.c Index: test/CodeGen/builtins-ppc-p9vector.c === --- test/CodeGen/builtins-ppc-p9vector.c +++ test/CodeGen/builtins-ppc-p9vector.c @@ -827,4 +827,101 @@ // CHECK-NEXT: ret <16 x i8> return vec_srv (vuca, vucb); } - +vector unsigned short test74(void) { +// CHECK-BE: @llvm.ppc.vsx.xvcvsphp(<4 x float> +// CHECK-BE: @llvm.ppc.vsx.xvcvsphp(<4 x float> +// CHECK-BE: @llvm.ppc.altivec.vperm +// CHECK: @llvm.ppc.vsx.xvcvsphp(<4 x float> +// CHECK: @llvm.ppc.vsx.xvcvsphp(<4 x float> +// CHECK: @llvm.ppc.altivec.vperm + return vec_pack_to_short_fp32(vfa, vfb); +} +vector unsigned int test75(void) { +// CHECK-BE: @llvm.ppc.altivec.vrlwmi(<4 x i32 +// CHECK-BE-NEXT: ret <4 x i32> +// CHECK: @llvm.ppc.altivec.vrlwmi(<4 x i32 +// CHECK-NEXT: ret <4 x i32> + return vec_rlmi(vuia, vuia, vuia); +} +vector unsigned long long test76(void) { +// CHECK-BE: @llvm.ppc.altivec.vrldmi(<2 x i64 +// CHECK-BE-NEXT: ret <2 x i64> +// CHECK: @llvm.ppc.altivec.vrldmi(<2 x i64 +// CHECK-NEXT: ret <2 x i64> + return vec_rlmi(vula, vula, vula); +} +vector unsigned int test77(void) { +// CHECK-BE: @llvm.ppc.altivec.vrlwnm(<4 x i32 +// CHECK-BE: and <4 x i32 +// CHECK-BE: ret <4 x i32> +// CHECK: @llvm.ppc.altivec.vrlwnm(<4 x i32 +// CHECK: and <4 x i32 +// CHECK: ret <4 x i32> + return vec_rlnm(vuia, vuia, vuia); +} +vector unsigned long long test78(void) { +// CHECK-BE: @llvm.ppc.altivec.vrldnm(<2 x i64 +// CHECK-BE: and <2 x i64 +// CHECK-BE-NEXT: ret <2 x i64> +// CHECK: @llvm.ppc.altivec.vrldnm(<2 x i64 +// CHECK: and <2 x i64 +// CHECK-NEXT: ret <2 x i64> + return vec_rlnm(vula, vula, vula); +} +vector double test79(void) { +// CHECK-BE: extractelement <4 x float> +// CHECK-BE: fpext float +// CHECK-BE: insertelement <2 x double> +// CHECK-BE: extractelement <4 x float> +// CHECK-BE: fpext float +// CHECK-BE: insertelement <2 x double> +// CHECK: extractelement <4 x float> +// CHECK: fpext float +// CHECK: insertelement <2 x double> +// CHECK: extractelement <4 x float> +// CHECK: fpext float +// CHECK: insertelement <2 x double> + return vec_unpackh(vfa); +} +vector double test80(void) { +// CHECK-BE: extractelement <4 x float> +// CHECK-BE: fpext float +// CHECK-BE: insertelement <2 x double> +// CHECK-BE: extractelement <4 x float> +// CHECK-BE: fpext float +// CHECK-BE: insertelement <2 x double> +// CHECK: extractelement <4 x float> +// CHECK: fpext float +// CHECK: insertelement <2 x double> +// CHECK: extractelement <4 x float> +// CHECK: fpext float +// CHECK: insertelement <2 x double> + return vec_unpackl(vfa); +} +vector double test81(void) { + // CHECK: extractelement <2 x double> + // CHECK: fptrunc double + // CHECK: insertelement <4 x float> + // CHECK: extractelement <2 x double> + // CHECK: fptrunc double + // CHECK: insertelement <4 x float> + // CHECK: extractelement <2 x double> + // CHECK: fptrunc double + // CHECK: insertelement <4 x float> + // CHECK: extractelement <2 x double> + // CHECK: fptrunc double + // CHECK: insertelement <4 x float> + // CHECK-LE: extractelement <2 x double> + // CHECK-LE: fptrunc double + // CHECK-LE: insertelement <4 x float> + // CHECK-LE: extractelement <2 x double> + // CHECK-LE: fptrunc double + // CHECK-LE: insertelement <4 x float> + // CHECK-LE: extractelement <2 x double> + // CHECK-LE: fptrunc double + // CHECK-LE: insertelement <4 x float> + // CHECK-LE: extractelement <2 x double> + // CHECK-LE: fptrunc double + // CHECK-LE: insertelement <4 x float> + return vec_pack(vda, vdb); +} Index: test/CodeGen/builtins-ppc-p8vector.c === --- test/CodeGen/builtins-ppc-p8vector.c +++ test/CodeGen/builtins-ppc-p8vector.c @@ -136,6 +136,26 @@ // CHECK-LE: @llvm.ppc.altivec.vperm // CHECK-PPC: warning: implicit declaration of function 'vec_mergee' + res_vbll = vec_mergee(vbll, vbll); +// CHECK: @llvm.ppc.altivec.vperm +// CHECK-LE: @llvm.ppc.altivec.vperm + + res_vsll = vec_mergee(vsll, vsll); +// CHECK: @llvm.ppc.altivec.vperm +// CHECK-LE: @llvm.ppc.altivec.vperm + + res_vull = vec_mergee(vull, vull); +// CHECK: @llvm.ppc.altivec.vperm +// CHECK-LE: @llvm.ppc.altivec.vperm + + res_vf = vec_mergee(vfa, vfa); +// CHECK: @llvm.ppc.altivec.vperm +// CHECK-LE: @llvm.ppc.altivec.vperm + + res_vd = vec_mergee(vda, vda); +// CHECK: @llvm.ppc.altivec.vperm +// CHECK-LE: @llvm.ppc.altivec.vperm + /* vec_mergeo */ res_vbi = vec_mergeo(vbi, vbi); // CHECK: @llvm.ppc.altivec.vperm Index: test/CodeGen/builtins-ppc-crypto.c ===
[PATCH] D26274: clang-format: [JS] do not break after declare namespace.
This revision was automatically updated to reflect the committed changes. Closed by commit rL286468: clang-format: [JS] do not break after declare namespace. (authored by mprobst). Changed prior to commit: https://reviews.llvm.org/D26274?vs=76831&id=77493#toc Repository: rL LLVM https://reviews.llvm.org/D26274 Files: cfe/trunk/lib/Format/UnwrappedLineParser.cpp Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp === --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp @@ -669,14 +669,14 @@ // FIXME: This returns true for C/C++ keywords like 'struct'. return FormatTok->is(tok::identifier) && (FormatTok->Tok.getIdentifierInfo() == nullptr || - !FormatTok->isOneOf(Keywords.kw_in, Keywords.kw_of, Keywords.kw_as, - Keywords.kw_async, Keywords.kw_await, - Keywords.kw_yield, Keywords.kw_finally, - Keywords.kw_function, Keywords.kw_import, - Keywords.kw_is, Keywords.kw_let, Keywords.kw_var, - Keywords.kw_abstract, Keywords.kw_extends, - Keywords.kw_implements, Keywords.kw_instanceof, - Keywords.kw_interface, Keywords.kw_throws)); + !FormatTok->isOneOf( + Keywords.kw_in, Keywords.kw_of, Keywords.kw_as, Keywords.kw_async, + Keywords.kw_await, Keywords.kw_yield, Keywords.kw_finally, + Keywords.kw_function, Keywords.kw_import, Keywords.kw_is, + Keywords.kw_let, Keywords.kw_var, tok::kw_const, + Keywords.kw_abstract, Keywords.kw_extends, Keywords.kw_implements, + Keywords.kw_instanceof, Keywords.kw_interface, + Keywords.kw_throws)); } static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords, Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp === --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp @@ -669,14 +669,14 @@ // FIXME: This returns true for C/C++ keywords like 'struct'. return FormatTok->is(tok::identifier) && (FormatTok->Tok.getIdentifierInfo() == nullptr || - !FormatTok->isOneOf(Keywords.kw_in, Keywords.kw_of, Keywords.kw_as, - Keywords.kw_async, Keywords.kw_await, - Keywords.kw_yield, Keywords.kw_finally, - Keywords.kw_function, Keywords.kw_import, - Keywords.kw_is, Keywords.kw_let, Keywords.kw_var, - Keywords.kw_abstract, Keywords.kw_extends, - Keywords.kw_implements, Keywords.kw_instanceof, - Keywords.kw_interface, Keywords.kw_throws)); + !FormatTok->isOneOf( + Keywords.kw_in, Keywords.kw_of, Keywords.kw_as, Keywords.kw_async, + Keywords.kw_await, Keywords.kw_yield, Keywords.kw_finally, + Keywords.kw_function, Keywords.kw_import, Keywords.kw_is, + Keywords.kw_let, Keywords.kw_var, tok::kw_const, + Keywords.kw_abstract, Keywords.kw_extends, Keywords.kw_implements, + Keywords.kw_instanceof, Keywords.kw_interface, + Keywords.kw_throws)); } static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26479: [PowerPC] Implement remaining permute builtins in altivec.h - Clang portion
nemanjai added a comment. In https://reviews.llvm.org/D26479#591723, @amehsan wrote: > more context? Really sorry. It appears that I uploaded the wrong patch file. Updating now. Repository: rL LLVM https://reviews.llvm.org/D26479 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286467 - clang-format: [JS] do not break after declare namespace.
Author: mprobst Date: Thu Nov 10 10:20:58 2016 New Revision: 286467 URL: http://llvm.org/viewvc/llvm-project?rev=286467&view=rev Log: clang-format: [JS] do not break after declare namespace. See TypeScript grammar for tokens following 'declare': https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#A.10 Modified: cfe/trunk/lib/Format/FormatToken.h cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTestJS.cpp Modified: cfe/trunk/lib/Format/FormatToken.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=286467&r1=286466&r2=286467&view=diff == --- cfe/trunk/lib/Format/FormatToken.h (original) +++ cfe/trunk/lib/Format/FormatToken.h Thu Nov 10 10:20:58 2016 @@ -580,12 +580,14 @@ struct AdditionalKeywords { kw_as = &IdentTable.get("as"); kw_async = &IdentTable.get("async"); kw_await = &IdentTable.get("await"); +kw_declare = &IdentTable.get("declare"); kw_finally = &IdentTable.get("finally"); kw_from = &IdentTable.get("from"); kw_function = &IdentTable.get("function"); kw_import = &IdentTable.get("import"); kw_is = &IdentTable.get("is"); kw_let = &IdentTable.get("let"); +kw_module = &IdentTable.get("module"); kw_type = &IdentTable.get("type"); kw_var = &IdentTable.get("var"); kw_yield = &IdentTable.get("yield"); @@ -632,12 +634,14 @@ struct AdditionalKeywords { IdentifierInfo *kw_as; IdentifierInfo *kw_async; IdentifierInfo *kw_await; + IdentifierInfo *kw_declare; IdentifierInfo *kw_finally; IdentifierInfo *kw_from; IdentifierInfo *kw_function; IdentifierInfo *kw_import; IdentifierInfo *kw_is; IdentifierInfo *kw_let; + IdentifierInfo *kw_module; IdentifierInfo *kw_type; IdentifierInfo *kw_var; IdentifierInfo *kw_yield; Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=286467&r1=286466&r2=286467&view=diff == --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Nov 10 10:20:58 2016 @@ -2426,10 +2426,10 @@ bool TokenAnnotator::canBreakBefore(cons } else if (Style.Language == FormatStyle::LK_JavaScript) { const FormatToken *NonComment = Right.getPreviousNonComment(); if (Left.isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break, - tok::kw_throw) || + tok::kw_throw, Keywords.kw_module) || (NonComment && NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break, - tok::kw_throw))) + tok::kw_throw, Keywords.kw_module))) return false; // Otherwise a semicolon is inserted. if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace)) return false; @@ -2443,6 +2443,18 @@ bool TokenAnnotator::canBreakBefore(cons return Style.BreakBeforeBinaryOperators != FormatStyle::BOS_None; if (Right.is(Keywords.kw_as)) return false; // must not break before as in 'x as type' casts +if (Left.is(Keywords.kw_declare) && +Right.isOneOf(Keywords.kw_module, tok::kw_namespace, + Keywords.kw_function, tok::kw_class, tok::kw_enum, + Keywords.kw_interface, Keywords.kw_type, Keywords.kw_var, + Keywords.kw_let, tok::kw_const)) + // See grammar for 'declare' statements at: + // https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#A.10 + return false; +if (Left.isOneOf(Keywords.kw_module, tok::kw_namespace) && +Right.isOneOf(tok::identifier, tok::string_literal)) { + return false; // must not break in "module foo { ...}" +} } if (Left.is(tok::at)) Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=286467&r1=286466&r2=286467&view=diff == --- cfe/trunk/unittests/Format/FormatTestJS.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestJS.cpp Thu Nov 10 10:20:58 2016 @@ -349,6 +349,37 @@ TEST_F(FormatTestJS, FormatsNamespaces) "}\n"); } +TEST_F(FormatTestJS, NamespacesMayNotWrap) { + verifyFormat("declare namespace foobarbaz {\n" + "}\n", getGoogleJSStyleWithColumns(18)); + verifyFormat("declare module foobarbaz {\n" + "}\n", getGoogleJSStyleWithColumns(15)); + verifyFormat("namespace foobarbaz {\n" + "}\n", getGoogleJSStyleWithColumns(10)); + verifyFormat("module foobarbaz {\n" + "}\n", getGoogleJSStyleWithColumns(7)); +} + +TEST_F(FormatTestJS, AmbientDeclarations) { + FormatStyle NineCols = getGoogleJSStyleWithColumns(9); + verifyFormat( +
r286469 - drop kw_module from ASI protection block
Author: mprobst Date: Thu Nov 10 10:21:04 2016 New Revision: 286469 URL: http://llvm.org/viewvc/llvm-project?rev=286469&view=rev Log: drop kw_module from ASI protection block Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=286469&r1=286468&r2=286469&view=diff == --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Nov 10 10:21:04 2016 @@ -2426,10 +2426,10 @@ bool TokenAnnotator::canBreakBefore(cons } else if (Style.Language == FormatStyle::LK_JavaScript) { const FormatToken *NonComment = Right.getPreviousNonComment(); if (Left.isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break, - tok::kw_throw, Keywords.kw_module) || + tok::kw_throw) || (NonComment && NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break, - tok::kw_throw, Keywords.kw_module))) + tok::kw_throw))) return false; // Otherwise a semicolon is inserted. if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace)) return false; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r286468 - clang-format: [JS] do not break after declare namespace.
Author: mprobst Date: Thu Nov 10 10:21:02 2016 New Revision: 286468 URL: http://llvm.org/viewvc/llvm-project?rev=286468&view=rev Log: clang-format: [JS] do not break after declare namespace. Summary: See TypeScript grammar for tokens following 'declare': https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#A.10 Additional minor change: clang-format: [JS] Prevent ASI before const. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D26274 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=286468&r1=286467&r2=286468&view=diff == --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original) +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Thu Nov 10 10:21:02 2016 @@ -669,14 +669,14 @@ static bool mustBeJSIdent(const Addition // FIXME: This returns true for C/C++ keywords like 'struct'. return FormatTok->is(tok::identifier) && (FormatTok->Tok.getIdentifierInfo() == nullptr || - !FormatTok->isOneOf(Keywords.kw_in, Keywords.kw_of, Keywords.kw_as, - Keywords.kw_async, Keywords.kw_await, - Keywords.kw_yield, Keywords.kw_finally, - Keywords.kw_function, Keywords.kw_import, - Keywords.kw_is, Keywords.kw_let, Keywords.kw_var, - Keywords.kw_abstract, Keywords.kw_extends, - Keywords.kw_implements, Keywords.kw_instanceof, - Keywords.kw_interface, Keywords.kw_throws)); + !FormatTok->isOneOf( + Keywords.kw_in, Keywords.kw_of, Keywords.kw_as, Keywords.kw_async, + Keywords.kw_await, Keywords.kw_yield, Keywords.kw_finally, + Keywords.kw_function, Keywords.kw_import, Keywords.kw_is, + Keywords.kw_let, Keywords.kw_var, tok::kw_const, + Keywords.kw_abstract, Keywords.kw_extends, Keywords.kw_implements, + Keywords.kw_instanceof, Keywords.kw_interface, + Keywords.kw_throws)); } static bool mustBeJSIdentOrValue(const AdditionalKeywords &Keywords, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits