[PATCH] D68108: Redeclare Objective-C property accessors inside the ObjCImplDecl in which they are synthesized.

2019-09-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Also, I think it would be good if there was a more explicit method for asking 
whether a method is a synthesized definition.  Basically, there's a tri-state: 
there are pure declarations, user-provided definitions, and synthetic 
definitions.  IRGen should emit a function when it sees either of the latter 
two, but it might have to use special code for synthetic definitions.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68108/new/

https://reviews.llvm.org/D68108



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r373142 - [TimeProfiler] Fix "OptModule" section and add new "Backend" sections

2019-09-28 Thread Anton Afanasyev via cfe-commits
Author: anton-afanasyev
Date: Sat Sep 28 00:14:12 2019
New Revision: 373142

URL: http://llvm.org/viewvc/llvm-project?rev=373142&view=rev
Log:
[TimeProfiler] Fix "OptModule" section and add new "Backend" sections

Remove unnecessary "OptModule" section. Add "PerFunctionPasses",
"PerModulePasses" and "CodeGenPasses" sections under "Backend" section.

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=373142&r1=373141&r2=373142&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Sat Sep 28 00:14:12 2019
@@ -895,6 +895,7 @@ void EmitAssemblyHelper::EmitAssembly(Ba
 
   {
 PrettyStackTraceString CrashInfo("Per-function optimization");
+llvm::TimeTraceScope TimeScope("PerFunctionPasses", StringRef(""));
 
 PerFunctionPasses.doInitialization();
 for (Function &F : *TheModule)
@@ -905,11 +906,13 @@ void EmitAssemblyHelper::EmitAssembly(Ba
 
   {
 PrettyStackTraceString CrashInfo("Per-module optimization passes");
+llvm::TimeTraceScope TimeScope("PerModulePasses", StringRef(""));
 PerModulePasses.run(*TheModule);
   }
 
   {
 PrettyStackTraceString CrashInfo("Code generation");
+llvm::TimeTraceScope TimeScope("CodeGenPasses", StringRef(""));
 CodeGenPasses.run(*TheModule);
   }
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68117: [DWARF-5] Support for C++11 defaulted, deleted member functions.

2019-09-28 Thread Sourabh Singh Tomar via Phabricator via cfe-commits
SouraVX updated this revision to Diff 86.
SouraVX added a comment.

Minor refactor for context.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68117/new/

https://reviews.llvm.org/D68117

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
  llvm/include/llvm/BinaryFormat/Dwarf.h
  llvm/include/llvm/IR/DebugInfoFlags.def
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/BinaryFormat/Dwarf.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp

Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1296,6 +1296,19 @@
 addFlag(SPDie, dwarf::DW_AT_elemental);
   if (SP->isRecursive())
 addFlag(SPDie, dwarf::DW_AT_recursive);
+  if (DD->getDwarfVersion() >= 5) {
+if (SP->isDefaultedInClass())
+  addUInt(SPDie, dwarf::DW_AT_defaulted, dwarf::DW_FORM_data1,
+  dwarf::DW_DEFAULTED_in_class);
+if (SP->isDefaultedOutOfClass())
+  addUInt(SPDie, dwarf::DW_AT_defaulted, dwarf::DW_FORM_data1,
+  dwarf::DW_DEFAULTED_out_of_class);
+if (SP->isNotDefaulted())
+  addUInt(SPDie, dwarf::DW_AT_defaulted, dwarf::DW_FORM_data1,
+  dwarf::DW_DEFAULTED_no);
+if (SP->isDeleted())
+  addFlag(SPDie, dwarf::DW_AT_deleted);
+  }
 }
 
 void DwarfUnit::constructSubrangeDIE(DIE &Buffer, const DISubrange *SR,
Index: llvm/lib/BinaryFormat/Dwarf.cpp
===
--- llvm/lib/BinaryFormat/Dwarf.cpp
+++ llvm/lib/BinaryFormat/Dwarf.cpp
@@ -271,6 +271,19 @@
   return StringRef();
 }
 
+StringRef llvm::dwarf::DefaultedMemberString(unsigned DefaultedEncodings) {
+  switch (DefaultedEncodings) {
+  // Defaulted Member Encodings codes
+  case DW_DEFAULTED_no:
+return "DW_DEFAULTED_no";
+  case DW_DEFAULTED_in_class:
+return "DW_DEFAULTED_in_class";
+  case DW_DEFAULTED_out_of_class:
+return "DW_DEFAULTED_out_of_class";
+  }
+  return StringRef();
+}
+
 StringRef llvm::dwarf::VisibilityString(unsigned Visibility) {
   switch (Visibility) {
   case DW_VIS_local:
@@ -601,6 +614,8 @@
 return ArrayOrderString(Val);
   case DW_AT_APPLE_runtime_class:
 return LanguageString(Val);
+  case DW_AT_defaulted:
+return DefaultedMemberString(Val);
   }
 
   return StringRef();
Index: llvm/include/llvm/IR/DebugInfoMetadata.h
===
--- llvm/include/llvm/IR/DebugInfoMetadata.h
+++ llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -1758,6 +1758,14 @@
   bool isPure() const { return getSPFlags() & SPFlagPure; }
   bool isElemental() const { return getSPFlags() & SPFlagElemental; }
   bool isRecursive() const { return getSPFlags() & SPFlagRecursive; }
+  bool isDefaultedInClass() const {
+return getSPFlags() & SPFlagDefaultedInClass;
+  }
+  bool isDefaultedOutOfClass() const {
+return getSPFlags() & SPFlagDefaultedOutOfClass;
+  }
+  bool isNotDefaulted() const { return getSPFlags() & SPFlagNotDefaulted; }
+  bool isDeleted() const { return getSPFlags() & SPFlagDeleted; }
 
   /// Check if this is reference-qualified.
   ///
Index: llvm/include/llvm/IR/DebugInfoFlags.def
===
--- llvm/include/llvm/IR/DebugInfoFlags.def
+++ llvm/include/llvm/IR/DebugInfoFlags.def
@@ -88,11 +88,15 @@
 HANDLE_DISP_FLAG((1u << 6), Elemental)
 HANDLE_DISP_FLAG((1u << 7), Recursive)
 HANDLE_DISP_FLAG((1u << 8), MainSubprogram)
+HANDLE_DISP_FLAG((1u << 9), NotDefaulted)
+HANDLE_DISP_FLAG((1u << 10), DefaultedInClass)
+HANDLE_DISP_FLAG((1u << 11), DefaultedOutOfClass)
+HANDLE_DISP_FLAG((1u << 12), Deleted)
 
 #ifdef DISP_FLAG_LARGEST_NEEDED
 // Intended to be used with ADT/BitmaskEnum.h.
 // NOTE: Always must be equal to largest flag, check this when adding new flags.
-HANDLE_DISP_FLAG((1 << 8), Largest)
+HANDLE_DISP_FLAG((1 << 12), Largest)
 #undef DISP_FLAG_LARGEST_NEEDED
 #endif
 
Index: llvm/include/llvm/BinaryFormat/Dwarf.h
===
--- llvm/include/llvm/BinaryFormat/Dwarf.h
+++ llvm/include/llvm/BinaryFormat/Dwarf.h
@@ -411,6 +411,7 @@
 StringRef DecimalSignString(unsigned Sign);
 StringRef EndianityString(unsigned Endian);
 StringRef AccessibilityString(unsigned Access);
+StringRef DefaultedMemberString(unsigned DefaultedEncodings);
 StringRef VisibilityString(unsigned Visibility);
 StringRef VirtualityString(unsigned Virtuality);
 StringRef LanguageString(unsigned Language);
Index: clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
===
--- clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
+++ clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
@@ -4,8 +4,7 @@
 // RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple %s -o - \
 // RUN:   -O1 -disable-llvm-passes 

[PATCH] D68117: [DWARF-5] Support for C++11 defaulted, deleted member functions.

2019-09-28 Thread Sourabh Singh Tomar via Phabricator via cfe-commits
SouraVX marked 2 inline comments as done.
SouraVX added a comment.

In D68117#1686235 , @aprantl wrote:

> This needs a lot more test coverage: The frontend cases aren't all covered by 
> frontend checks and neither is the dwarf output.


Do you mean to add more test cases ?  Could you please elaborate on this?




Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:1608
 
+  if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
+// DWARF-5 support for, defaulted, deleted member functions

aprantl wrote:
> Please try to always upload patches with more context (git diff -U works 
> fine). I can't even tell which function this is in otherwise.
Thanks, for correcting  this. Seems to miss context part every time.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68117/new/

https://reviews.llvm.org/D68117



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68172: Don't install example analyzer plugins

2019-09-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

There's also D67877 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68172/new/

https://reviews.llvm.org/D68172



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68163: [analyzer][MallocChecker][NFC] Change the use of IdentifierInfo* to CallDescription

2019-09-28 Thread Kim Gräsman via Phabricator via cfe-commits
kimgr added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:1006
   const FunctionDecl *FD = C.getCalleeDecl(CE);
-  if (!FD)
+  if (!FD || FD->getKind() != Decl::Function)
 return;

NoQ wrote:
> The `FD->getKind() != Decl::Function` part is super mega redundant here.
Sorry for jumping in from nowhere. AFAIK, this is the only way to detect free 
vs member functions. It looks like this wants to discard member functions. Are 
you sure it's redundant? 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68163/new/

https://reviews.llvm.org/D68163



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68163: [analyzer][MallocChecker][NFC] Change the use of IdentifierInfo* to CallDescription

2019-09-28 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus marked 2 inline comments as done.
Szelethus added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:259
   /// calls.
   bool isCalled(const CallDescription &CD) const;
 

NoQ wrote:
> I don't fully understand how does overload resolution work in this case, 
> maybe rename the original function?
Well, `isCalled` may now have an arbitrary number of arguments. The single 
argument version is this function, and the //n//-argument ones call this //n// 
times: `isCalled(A, B, C)` -> `isCalled(A) || isCalled(B) || isCalled(B)`. I 
guess I could rename the other one to `isAnyCalled`, but I think its fine.



Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:1006
   const FunctionDecl *FD = C.getCalleeDecl(CE);
-  if (!FD)
+  if (!FD || FD->getKind() != Decl::Function)
 return;

kimgr wrote:
> NoQ wrote:
> > The `FD->getKind() != Decl::Function` part is super mega redundant here.
> Sorry for jumping in from nowhere. AFAIK, this is the only way to detect free 
> vs member functions. It looks like this wants to discard member functions. 
> Are you sure it's redundant? 
Please do! Though I have a suspicion that if this isn't redundant, such a check 
should be done in `CallDescription`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68163/new/

https://reviews.llvm.org/D68163



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68072: Reference qualifiers in member templates causing extra indentation.

2019-09-28 Thread Andreas Wass via Phabricator via cfe-commits
AndWass updated this revision to Diff 87.
AndWass added a comment.

Updated to fix test failures.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68072/new/

https://reviews.llvm.org/D68072

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14373,6 +14373,41 @@
   verifyFormat("auto lambda = [&a = a]() { a = 2; };", AlignStyle);
 }
 
+TEST_F(FormatTest, RefQualifiedTemplateMember) {
+  FormatStyle AlignStyle = getLLVMStyle();
+  AlignStyle.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Yes;
+
+  verifyFormat("struct f {\n"
+   "  template \n"
+   "  int &foo() & noexcept {}\n"
+   "};",
+   AlignStyle);
+
+  verifyFormat("struct f {\n"
+   "  template \n"
+   "  int &foo() && noexcept {}\n"
+   "};",
+   AlignStyle);
+
+  verifyFormat("struct f {\n"
+   "  template \n"
+   "  int &foo() const & noexcept {}\n"
+   "};",
+   AlignStyle);
+
+  verifyFormat("struct f {\n"
+   "  template \n"
+   "  int &foo() const & noexcept {}\n"
+   "};",
+   AlignStyle);
+
+  verifyFormat("struct f {\n"
+   "  template \n"
+   "  auto foo() && noexcept -> int & {}\n"
+   "};",
+   AlignStyle);
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -65,7 +65,7 @@
   AnnotatingParser(const FormatStyle &Style, AnnotatedLine &Line,
const AdditionalKeywords &Keywords)
   : Style(Style), Line(Line), CurrentToken(Line.First), AutoFound(false),
-Keywords(Keywords) {
+TrailingReturnFound(false), ParenthesisDepth(0), Keywords(Keywords) {
 Contexts.push_back(Context(tok::unknown, 1, /*IsExpression=*/false));
 resetTokenMetadata(CurrentToken);
   }
@@ -1367,6 +1367,12 @@
   }
 }
 
+if (Current.is(tok::l_paren)) {
+  ParenthesisDepth++;
+} else if (Current.is(tok::r_paren)) {
+  ParenthesisDepth--;
+}
+
 // Line.MightBeFunctionDecl can only be true after the parentheses of a
 // function declaration have been found. In this case, 'Current' is a
 // trailing token of this declaration and thus cannot be a name.
@@ -1389,7 +1395,11 @@
 } else if (Current.is(tok::arrow) && AutoFound && Line.MustBeDeclaration &&
Current.NestingLevel == 0) {
   Current.Type = TT_TrailingReturnArrow;
-} else if (Current.isOneOf(tok::star, tok::amp, tok::ampamp)) {
+  TrailingReturnFound = true;
+} else if (Current.is(tok::star) ||
+   (Current.isOneOf(tok::amp, tok::ampamp) &&
+(ParenthesisDepth != 0 || !Line.MightBeFunctionDecl ||
+ TrailingReturnFound))) {
   Current.Type = determineStarAmpUsage(Current,
Contexts.back().CanBeExpression &&
Contexts.back().IsExpression,
@@ -1412,6 +1422,8 @@
 Current.Type = TT_ConditionalExpr;
   }
 } else if (Current.isBinaryOperator() &&
+   !(Line.MightBeFunctionDecl && ParenthesisDepth == 0 &&
+ Current.isOneOf(tok::amp, tok::ampamp)) &&
(!Current.Previous || Current.Previous->isNot(tok::l_square)) &&
(!Current.is(tok::greater) &&
 Style.Language != FormatStyle::LK_TextProto)) {
@@ -1486,10 +1498,12 @@
   // colon after this, this is the only place which annotates the identifier
   // as a selector.)
   Current.Type = TT_SelectorName;
-} else if (Current.isOneOf(tok::identifier, tok::kw_const) &&
+} else if (Current.isOneOf(tok::identifier, tok::kw_const, tok::amp,
+   tok::ampamp) &&
Current.Previous &&
!Current.Previous->isOneOf(tok::equal, tok::at) &&
-   Line.MightBeFunctionDecl && Contexts.size() == 1) {
+   Line.MightBeFunctionDecl && !TrailingReturnFound &&
+   Contexts.size() == 1 && ParenthesisDepth == 0) {
   // Line.MightBeFunctionDecl can only be true after the parentheses of a
   // function declaration have been found.
   Current.Type = TT_TrailingAnnotation;
@@ -1767,6 +1781,8 @@
   AnnotatedLine &Line;
   FormatToken *CurrentToken;
   bool AutoFound;
+  bool TrailingReturnFound;
+  int ParenthesisDepth;
   const AdditionalKeywords &Keywords;
 
   // Set of "<" tokens that do not open a template parameter list. If parseAngle
@@ -2680,6

[PATCH] D67877: [analyzer] Conditionnaly include clang Analysis examples with cmake.

2019-09-28 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

I didn't know about this patch and published D68172 
: adding `BUILDTREE_ONLY` still builds the 
examples, but doesn't install them. It's also used by other test plugins like 
`llvm/lib/Transforms/Hello`.
 Thanks to @lebedev.ri for informing my about this patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67877/new/

https://reviews.llvm.org/D67877



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68165: [analyzer][MallocChecker][NFC] Split checkPostCall up, deploy CallDescriptionMap

2019-09-28 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus marked 2 inline comments as done.
Szelethus added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:378-379
+
+  using CheckFn = void (MallocChecker::*)(CheckerContext &C, const CallExpr 
*CE,
+  ProgramStateRef State) const;
+

NoQ wrote:
> Whenever i see a (`CE`, `State`) pair, it screams `CallEvent` to me. That 
> said, i'm worried that `State` in these callbacks isn't necessarily equal to 
> `C.getState()` (the latter, by the way, is always equal to the `CallEvent`'s 
> `.getState()` - that's a relief, right?), so if you'll ever be in the mood to 
> check that, that'd be great :)
It should be always equal to it. I'll change it.



Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:397-398
+  CallDescriptionMap NonFreeingMemFnMap{
+  {{"alloca", 1}, &MallocChecker::checkAlloca},
+  {{"_alloca", 1}, &MallocChecker::checkAlloca},
+  {{"malloc", 1}, &MallocChecker::checkMalloc},

NoQ wrote:
> I think `alloca` deserves `CDF_MaybeBuiltin`. This would also probably allow 
> you to remove the second line.
Actually, `BuiltinFunctionChecker` uses `evalCall` to create an `AllocaRegion` 
for `__builtin_alloca`. I spent an hour when writing this patch to track a 
crash down when I initially made this `CDF_MaybeBuiltin` :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68165/new/

https://reviews.llvm.org/D68165



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68172: Don't install example analyzer plugins

2019-09-28 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

The patch looks alright, I won't formally accept because if I knew how these 
worked, it wouldn't have caused so much pain to so many people :)

In D68172#1686793 , @aaronpuchert 
wrote:

> In D68172#1686772 , @NoQ wrote:
>
> > +@Szelethus because i'm a bit out-of-the-loop on plugins: i very vaguely 
> > remember that we decided to put them into tests(?)
>
>
> The plugins were in `test`, but D62445  
> changed that. Another solution would have been to move them into the 
> `unittests` directory. But other example plugins are also part of the 
> ordinary source tree, see for example `llvm/lib/Transforms/Hello`. In fact 
> this change is based on LLVMHello, which also has `BUILDTREE_ONLY`.


I honestly feel bad about these plugins. The first analyzer plugin laid in the 
`examples/` folder, but I was cautioned against adding more there as we're not 
really supporting them, but I think all the trouble of moving them wasn't worth 
it at all for such a negligible "gain".


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68172/new/

https://reviews.llvm.org/D68172



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67877: [analyzer] Conditionnaly include clang Analysis examples with cmake.

2019-09-28 Thread Jean-Bapiste Lepesme via Phabricator via cfe-commits
Jiboo added a comment.

@aaronpuchert thanks, that looks like a better fix than mine for PR43430, 
although I'm not sure D68172  obsoletes this 
patch.
@Szelethus could you confirm that thus examples shouldn't be built when 
CLANG_BUILD_EXAMPLES is OFF, and that this patch is still valid?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67877/new/

https://reviews.llvm.org/D67877



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r373147 - Driver tests: set `--sysroot=""` to support clang with `DEFAULT_SYSROOT`

2019-09-28 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Sat Sep 28 05:21:06 2019
New Revision: 373147

URL: http://llvm.org/viewvc/llvm-project?rev=373147&view=rev
Log:
Driver tests: set `--sysroot=""` to support clang with `DEFAULT_SYSROOT`

When testing clang that has been compiled with `-DDEFAULT_SYSROOT` set to some 
path,
some tests would fail. Override sysroot to be empty string for the tests to 
succeed
when clang is configured with `DEFAULT_SYSROOT`.

Differential Revision: https://reviews.llvm.org/D66834

Patch by Sergej Jaskiewicz .

Modified:
cfe/trunk/test/Driver/darwin-sdkroot.c
cfe/trunk/test/Driver/gcc-toolchain.cpp
cfe/trunk/test/Driver/mips-mti.cpp
cfe/trunk/test/Driver/msp430-toolchain.c
cfe/trunk/unittests/Driver/ToolChainTest.cpp

Modified: cfe/trunk/test/Driver/darwin-sdkroot.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-sdkroot.c?rev=373147&r1=373146&r2=373147&view=diff
==
--- cfe/trunk/test/Driver/darwin-sdkroot.c (original)
+++ cfe/trunk/test/Driver/darwin-sdkroot.c Sat Sep 28 05:21:06 2019
@@ -2,7 +2,7 @@
 //
 // RUN: rm -rf %t.tmpdir
 // RUN: mkdir -p %t.tmpdir
-// RUN: env SDKROOT=%t.tmpdir %clang -target x86_64-apple-darwin10 \
+// RUN: env SDKROOT=%t.tmpdir %clang -target x86_64-apple-darwin10 
--sysroot="" \
 // RUN:   -c %s -### 2> %t.log
 // RUN: FileCheck --check-prefix=CHECK-BASIC < %t.log %s
 //
@@ -13,7 +13,7 @@
 // Check that we don't use SDKROOT as the default if it is not a valid path.
 //
 // RUN: rm -rf %t.nonpath
-// RUN: env SDKROOT=%t.nonpath %clang -target x86_64-apple-darwin10 \
+// RUN: env SDKROOT=%t.nonpath %clang -target x86_64-apple-darwin10 
--sysroot="" \
 // RUN:   -c %s -### 2> %t.log
 // RUN: FileCheck --check-prefix=CHECK-NONPATH < %t.log %s
 //
@@ -23,7 +23,7 @@
 
 // Check that we don't use SDKROOT as the default if it is just "/"
 //
-// RUN: env SDKROOT=/ %clang -target x86_64-apple-darwin10 \
+// RUN: env SDKROOT=/ %clang -target x86_64-apple-darwin10 --sysroot="" \
 // RUN:   -c %s -### 2> %t.log
 // RUN: FileCheck --check-prefix=CHECK-NONROOT < %t.log %s
 //
@@ -43,7 +43,7 @@
 //
 // RUN: rm -rf %t/SDKs/iPhoneOS8.0.0.sdk
 // RUN: mkdir -p %t/SDKs/iPhoneOS8.0.0.sdk
-// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk %clang -target 
arm64-apple-darwin %s -### 2>&1 \
+// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk %clang -target 
arm64-apple-darwin --sysroot="" %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-IPHONE %s
 //
 // CHECK-IPHONE: clang
@@ -55,7 +55,7 @@
 //
 // RUN: rm -rf %t/SDKs/iPhoneSimulator8.0.sdk
 // RUN: mkdir -p %t/SDKs/iPhoneSimulator8.0.sdk
-// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator8.0.sdk %clang -target 
x86_64-apple-darwin %s -### 2>&1 \
+// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator8.0.sdk %clang -target 
x86_64-apple-darwin --sysroot="" %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-SIMULATOR %s
 //
 // CHECK-SIMULATOR: clang
@@ -66,7 +66,7 @@
 //
 // RUN: rm -rf %t/SDKs/MacOSX10.10.0.sdk
 // RUN: mkdir -p %t/SDKs/MacOSX10.10.0.sdk
-// RUN: env SDKROOT=%t/SDKs/MacOSX10.10.0.sdk %clang -target 
x86_64-apple-darwin %s -### 2>&1 \
+// RUN: env SDKROOT=%t/SDKs/MacOSX10.10.0.sdk %clang -target 
x86_64-apple-darwin --sysroot="" %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MACOSX %s
 //
 // CHECK-MACOSX: clang

Modified: cfe/trunk/test/Driver/gcc-toolchain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/gcc-toolchain.cpp?rev=373147&r1=373146&r2=373147&view=diff
==
--- cfe/trunk/test/Driver/gcc-toolchain.cpp (original)
+++ cfe/trunk/test/Driver/gcc-toolchain.cpp Sat Sep 28 05:21:06 2019
@@ -3,12 +3,14 @@
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t 2>&1 \
 // RUN: --target=i386-unknown-linux -stdlib=libstdc++ \
 // RUN: --gcc-toolchain=%S/Inputs/ubuntu_11.04_multiarch_tree/usr \
+// RUN: --sysroot="" \
 // RUN:   | FileCheck %s
 //
 // Additionally check that the legacy spelling of the flag works.
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t 2>&1 \
 // RUN: --target=i386-unknown-linux -stdlib=libstdc++ \
 // RUN: -gcc-toolchain %S/Inputs/ubuntu_11.04_multiarch_tree/usr \
+// RUN: --sysroot="" \
 // RUN:   | FileCheck %s
 //
 // Test for header search toolchain detection.

Modified: cfe/trunk/test/Driver/mips-mti.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-mti.cpp?rev=373147&r1=373146&r2=373147&view=diff
==
--- cfe/trunk/test/Driver/mips-mti.cpp (original)
+++ cfe/trunk/test/Driver/mips-mti.cpp Sat Sep 28 05:21:06 2019
@@ -4,6 +4,7 @@
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:--target=mips-mti-linux-gnu \
 // RUN:--gcc-toolchain=%S/Inputs/mips_mti_tree \
+// RUN:--sysroot="" \
 // RUN:-stdlib=libstdc++ \
 // RUN

[PATCH] D68072: Reference qualifiers in member templates causing extra indentation.

2019-09-28 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

As the number of clauses is vast, I think sometimes its worth just putting a 
one-line comment in to explain what construct you are matching, just to help 
future maintainers




Comment at: clang/lib/Format/TokenAnnotator.cpp:1375
+}
+
 // Line.MightBeFunctionDecl can only be true after the parentheses of a

could this be done using the MatchingParen?



Comment at: clang/lib/Format/TokenAnnotator.cpp:2704
+return Style.PointerAlignment != FormatStyle::PAS_Left;
   return true;
 }

 are you not testing the volatile case? could you add a comment here as to what 
you are actually matching like the lines above


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68072/new/

https://reviews.llvm.org/D68072



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66834: Driver tests: set `--sysroot=""` to support clang with `DEFAULT_SYSROOT`

2019-09-28 Thread Serge Pavlov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373147: Driver tests: set `--sysroot=""` to 
support clang with `DEFAULT_SYSROOT` (authored by sepavloff, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66834?vs=217991&id=89#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66834/new/

https://reviews.llvm.org/D66834

Files:
  cfe/trunk/test/Driver/darwin-sdkroot.c
  cfe/trunk/test/Driver/gcc-toolchain.cpp
  cfe/trunk/test/Driver/mips-mti.cpp
  cfe/trunk/test/Driver/msp430-toolchain.c
  cfe/trunk/unittests/Driver/ToolChainTest.cpp

Index: cfe/trunk/unittests/Driver/ToolChainTest.cpp
===
--- cfe/trunk/unittests/Driver/ToolChainTest.cpp
+++ cfe/trunk/unittests/Driver/ToolChainTest.cpp
@@ -60,7 +60,7 @@
 llvm::MemoryBuffer::getMemBuffer("\n"));
 
   std::unique_ptr C(TheDriver.BuildCompilation(
-  {"-fsyntax-only", "--gcc-toolchain=", "foo.cpp"}));
+  {"-fsyntax-only", "--gcc-toolchain=", "--sysroot=", "foo.cpp"}));
   EXPECT_TRUE(C);
 
   std::string S;
Index: cfe/trunk/test/Driver/darwin-sdkroot.c
===
--- cfe/trunk/test/Driver/darwin-sdkroot.c
+++ cfe/trunk/test/Driver/darwin-sdkroot.c
@@ -2,7 +2,7 @@
 //
 // RUN: rm -rf %t.tmpdir
 // RUN: mkdir -p %t.tmpdir
-// RUN: env SDKROOT=%t.tmpdir %clang -target x86_64-apple-darwin10 \
+// RUN: env SDKROOT=%t.tmpdir %clang -target x86_64-apple-darwin10 --sysroot="" \
 // RUN:   -c %s -### 2> %t.log
 // RUN: FileCheck --check-prefix=CHECK-BASIC < %t.log %s
 //
@@ -13,7 +13,7 @@
 // Check that we don't use SDKROOT as the default if it is not a valid path.
 //
 // RUN: rm -rf %t.nonpath
-// RUN: env SDKROOT=%t.nonpath %clang -target x86_64-apple-darwin10 \
+// RUN: env SDKROOT=%t.nonpath %clang -target x86_64-apple-darwin10 --sysroot="" \
 // RUN:   -c %s -### 2> %t.log
 // RUN: FileCheck --check-prefix=CHECK-NONPATH < %t.log %s
 //
@@ -23,7 +23,7 @@
 
 // Check that we don't use SDKROOT as the default if it is just "/"
 //
-// RUN: env SDKROOT=/ %clang -target x86_64-apple-darwin10 \
+// RUN: env SDKROOT=/ %clang -target x86_64-apple-darwin10 --sysroot="" \
 // RUN:   -c %s -### 2> %t.log
 // RUN: FileCheck --check-prefix=CHECK-NONROOT < %t.log %s
 //
@@ -43,7 +43,7 @@
 //
 // RUN: rm -rf %t/SDKs/iPhoneOS8.0.0.sdk
 // RUN: mkdir -p %t/SDKs/iPhoneOS8.0.0.sdk
-// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk %clang -target arm64-apple-darwin %s -### 2>&1 \
+// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk %clang -target arm64-apple-darwin --sysroot="" %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-IPHONE %s
 //
 // CHECK-IPHONE: clang
@@ -55,7 +55,7 @@
 //
 // RUN: rm -rf %t/SDKs/iPhoneSimulator8.0.sdk
 // RUN: mkdir -p %t/SDKs/iPhoneSimulator8.0.sdk
-// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator8.0.sdk %clang -target x86_64-apple-darwin %s -### 2>&1 \
+// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator8.0.sdk %clang -target x86_64-apple-darwin --sysroot="" %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-SIMULATOR %s
 //
 // CHECK-SIMULATOR: clang
@@ -66,7 +66,7 @@
 //
 // RUN: rm -rf %t/SDKs/MacOSX10.10.0.sdk
 // RUN: mkdir -p %t/SDKs/MacOSX10.10.0.sdk
-// RUN: env SDKROOT=%t/SDKs/MacOSX10.10.0.sdk %clang -target x86_64-apple-darwin %s -### 2>&1 \
+// RUN: env SDKROOT=%t/SDKs/MacOSX10.10.0.sdk %clang -target x86_64-apple-darwin --sysroot="" %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MACOSX %s
 //
 // CHECK-MACOSX: clang
Index: cfe/trunk/test/Driver/mips-mti.cpp
===
--- cfe/trunk/test/Driver/mips-mti.cpp
+++ cfe/trunk/test/Driver/mips-mti.cpp
@@ -4,6 +4,7 @@
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:--target=mips-mti-linux-gnu \
 // RUN:--gcc-toolchain=%S/Inputs/mips_mti_tree \
+// RUN:--sysroot="" \
 // RUN:-stdlib=libstdc++ \
 // RUN:-EB -mhard-float -mabi=32 \
 // RUN:   | FileCheck --check-prefix=EB-HARD-O32 %s
@@ -32,6 +33,7 @@
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:--target=mips-mti-linux-gnu \
 // RUN:--gcc-toolchain=%S/Inputs/mips_mti_tree \
+// RUN:--sysroot="" \
 // RUN:-stdlib=libstdc++ \
 // RUN:-EB -mhard-float -mabi=n32 \
 // RUN:   | FileCheck --check-prefix=EB-HARD-N32 %s
@@ -60,6 +62,7 @@
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:--target=mips64-mti-linux-gnu \
 // RUN:--gcc-toolchain=%S/Inputs/mips_mti_tree \
+// RUN:--sysroot="" \
 // RUN:-stdlib=libstdc++ \
 // RUN:-EB -mhard-float -mabi=64 \
 // RUN:   | FileCheck --check-prefix=EB-HARD-N64 %s
@@ -88,6 +91,7 @@
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 //

[PATCH] D68172: Don't install example analyzer plugins

2019-09-28 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D68172#1686960 , @Szelethus wrote:

> The patch looks alright, I won't formally accept because if I knew how these 
> worked, it wouldn't have caused so much pain to so many people :)


If it helps, this is from `add_llvm_library` in 
llvm/cmake/modules/AddLLVM.cmake:

  if (ARG_MODULE AND NOT TARGET ${name})
# Add empty "phony" target
add_custom_target(${name})
  elseif( EXCLUDE_FROM_ALL )
set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON)
  elseif(ARG_BUILDTREE_ONLY)
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS_BUILDTREE_ONLY ${name})
  else()
# ... installation code ... 
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
  endif()

The plugins are modules, but the targets exist, so we don't run into the first 
branch. With `EXCLUDE_FROM_ALL` we would make the target not being build by 
default, and with `ARG_BUILDTREE_ONLY` we make them build, but not install.

> I honestly feel bad about these plugins. The first analyzer plugin laid in 
> the `examples/` folder, but I was cautioned against adding more there as 
> we're not really supporting them, but I think all the trouble of moving them 
> wasn't worth it at all for such a negligible "gain".

Moving them out of `test` was probably necessary, but the current location 
should be fine.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68172/new/

https://reviews.llvm.org/D68172



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68172: Don't install example analyzer plugins

2019-09-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

I feel like i can stamp this.
There's similar-isn problem with lit-cpuid which is referenced in 
LLVMExports.cmake but is packaged in debian in lldb...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68172/new/

https://reviews.llvm.org/D68172



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66872: [clangd] SelectionTree should mark a node as fully-selected if the only claimed tokens were early-claimed.

2019-09-28 Thread Shaurya Gupta via Phabricator via cfe-commits
SureYeaah accepted this revision.
SureYeaah added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: usaxena95.

Sorry about the delay. LGTM. Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66872/new/

https://reviews.llvm.org/D66872



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67877: [analyzer] Conditionnaly include clang Analysis examples with cmake.

2019-09-28 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D67877#1686961 , @Jiboo wrote:

> @Szelethus could you confirm that thus examples shouldn't be built when 
> CLANG_BUILD_EXAMPLES is OFF, and that this patch is still valid?


The problem is that `CLANG_BUILD_EXAMPLES` is off by default. Maybe we want to 
build these plugins by default though to make sure there are no compiler 
errors. Since their compilation shouldn't take a lot of time, I think that is a 
reasonable position to assume.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67877/new/

https://reviews.llvm.org/D67877



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r373148 - Don't install example analyzer plugins

2019-09-28 Thread Aaron Puchert via cfe-commits
Author: aaronpuchert
Date: Sat Sep 28 06:28:50 2019
New Revision: 373148

URL: http://llvm.org/viewvc/llvm-project?rev=373148&view=rev
Log:
Don't install example analyzer plugins

Summary: Fixes PR43430.

Reviewers: hintonda, NoQ, Szelethus, lebedev.ri

Reviewed By: lebedev.ri

Differential Revision: https://reviews.llvm.org/D68172

Modified:
cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt
cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt

Modified: 
cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt?rev=373148&r1=373147&r2=373148&view=diff
==
--- cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt 
(original)
+++ cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt Sat 
Sep 28 06:28:50 2019
@@ -3,7 +3,7 @@ set(LLVM_LINK_COMPONENTS
   )
 
 set(LLVM_EXPORTED_SYMBOL_FILE 
${CMAKE_CURRENT_SOURCE_DIR}/CheckerDependencyHandlingAnalyzerPlugin.exports)
-add_llvm_library(CheckerDependencyHandlingAnalyzerPlugin MODULE 
CheckerDependencyHandling.cpp PLUGIN_TOOL clang)
+add_llvm_library(CheckerDependencyHandlingAnalyzerPlugin MODULE BUILDTREE_ONLY 
CheckerDependencyHandling.cpp PLUGIN_TOOL clang)
 
 clang_target_link_libraries(CheckerDependencyHandlingAnalyzerPlugin PRIVATE
   clangAnalysis

Modified: cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt?rev=373148&r1=373147&r2=373148&view=diff
==
--- cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt 
(original)
+++ cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt Sat Sep 
28 06:28:50 2019
@@ -3,7 +3,7 @@ set(LLVM_LINK_COMPONENTS
   )
 
 set(LLVM_EXPORTED_SYMBOL_FILE 
${CMAKE_CURRENT_SOURCE_DIR}/CheckerOptionHandlingAnalyzerPlugin.exports)
-add_llvm_library(CheckerOptionHandlingAnalyzerPlugin MODULE 
CheckerOptionHandling.cpp PLUGIN_TOOL clang)
+add_llvm_library(CheckerOptionHandlingAnalyzerPlugin MODULE BUILDTREE_ONLY 
CheckerOptionHandling.cpp PLUGIN_TOOL clang)
 
 clang_target_link_libraries(CheckerOptionHandlingAnalyzerPlugin PRIVATE
   clangAnalysis

Modified: cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt?rev=373148&r1=373147&r2=373148&view=diff
==
--- cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt (original)
+++ cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt Sat Sep 28 
06:28:50 2019
@@ -3,7 +3,7 @@ set(LLVM_LINK_COMPONENTS
   )
 
 set(LLVM_EXPORTED_SYMBOL_FILE 
${CMAKE_CURRENT_SOURCE_DIR}/SampleAnalyzerPlugin.exports)
-add_llvm_library(SampleAnalyzerPlugin MODULE MainCallChecker.cpp PLUGIN_TOOL 
clang)
+add_llvm_library(SampleAnalyzerPlugin MODULE BUILDTREE_ONLY 
MainCallChecker.cpp PLUGIN_TOOL clang)
 
 clang_target_link_libraries(SampleAnalyzerPlugin PRIVATE
   clangAnalysis


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68172: Don't install example analyzer plugins

2019-09-28 Thread Aaron Puchert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373148: Don't install example analyzer plugins 
(authored by aaronpuchert, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68172?vs=72&id=90#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68172/new/

https://reviews.llvm.org/D68172

Files:
  cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
  cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt
  cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt


Index: cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
===
--- cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
+++ cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
@@ -3,7 +3,7 @@
   )
 
 set(LLVM_EXPORTED_SYMBOL_FILE 
${CMAKE_CURRENT_SOURCE_DIR}/CheckerDependencyHandlingAnalyzerPlugin.exports)
-add_llvm_library(CheckerDependencyHandlingAnalyzerPlugin MODULE 
CheckerDependencyHandling.cpp PLUGIN_TOOL clang)
+add_llvm_library(CheckerDependencyHandlingAnalyzerPlugin MODULE BUILDTREE_ONLY 
CheckerDependencyHandling.cpp PLUGIN_TOOL clang)
 
 clang_target_link_libraries(CheckerDependencyHandlingAnalyzerPlugin PRIVATE
   clangAnalysis
Index: cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
===
--- cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
+++ cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
@@ -3,7 +3,7 @@
   )
 
 set(LLVM_EXPORTED_SYMBOL_FILE 
${CMAKE_CURRENT_SOURCE_DIR}/SampleAnalyzerPlugin.exports)
-add_llvm_library(SampleAnalyzerPlugin MODULE MainCallChecker.cpp PLUGIN_TOOL 
clang)
+add_llvm_library(SampleAnalyzerPlugin MODULE BUILDTREE_ONLY 
MainCallChecker.cpp PLUGIN_TOOL clang)
 
 clang_target_link_libraries(SampleAnalyzerPlugin PRIVATE
   clangAnalysis
Index: cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt
===
--- cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt
+++ cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt
@@ -3,7 +3,7 @@
   )
 
 set(LLVM_EXPORTED_SYMBOL_FILE 
${CMAKE_CURRENT_SOURCE_DIR}/CheckerOptionHandlingAnalyzerPlugin.exports)
-add_llvm_library(CheckerOptionHandlingAnalyzerPlugin MODULE 
CheckerOptionHandling.cpp PLUGIN_TOOL clang)
+add_llvm_library(CheckerOptionHandlingAnalyzerPlugin MODULE BUILDTREE_ONLY 
CheckerOptionHandling.cpp PLUGIN_TOOL clang)
 
 clang_target_link_libraries(CheckerOptionHandlingAnalyzerPlugin PRIVATE
   clangAnalysis


Index: cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
===
--- cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
+++ cfe/trunk/lib/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
@@ -3,7 +3,7 @@
   )
 
 set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/CheckerDependencyHandlingAnalyzerPlugin.exports)
-add_llvm_library(CheckerDependencyHandlingAnalyzerPlugin MODULE CheckerDependencyHandling.cpp PLUGIN_TOOL clang)
+add_llvm_library(CheckerDependencyHandlingAnalyzerPlugin MODULE BUILDTREE_ONLY CheckerDependencyHandling.cpp PLUGIN_TOOL clang)
 
 clang_target_link_libraries(CheckerDependencyHandlingAnalyzerPlugin PRIVATE
   clangAnalysis
Index: cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
===
--- cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
+++ cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
@@ -3,7 +3,7 @@
   )
 
 set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/SampleAnalyzerPlugin.exports)
-add_llvm_library(SampleAnalyzerPlugin MODULE MainCallChecker.cpp PLUGIN_TOOL clang)
+add_llvm_library(SampleAnalyzerPlugin MODULE BUILDTREE_ONLY MainCallChecker.cpp PLUGIN_TOOL clang)
 
 clang_target_link_libraries(SampleAnalyzerPlugin PRIVATE
   clangAnalysis
Index: cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt
===
--- cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt
+++ cfe/trunk/lib/Analysis/plugins/CheckerOptionHandling/CMakeLists.txt
@@ -3,7 +3,7 @@
   )
 
 set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/CheckerOptionHandlingAnalyzerPlugin.exports)
-add_llvm_library(CheckerOptionHandlingAnalyzerPlugin MODULE CheckerOptionHandling.cpp PLUGIN_TOOL clang)
+add_llvm_library(CheckerOptionHandlingAnalyzerPlugin MODULE BUILDTREE_ONLY CheckerOptionHandling.cpp PLUGIN_TOOL clang)
 
 clang_target_link_libraries(CheckerOptionHandlingAnalyzerPlugin PRIVATE
   clangAnalysis
__

r373150 - SemaExpr - silence static analyzer getAs<> null dereference warnings. NFCI.

2019-09-28 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Sat Sep 28 07:01:52 2019
New Revision: 373150

URL: http://llvm.org/viewvc/llvm-project?rev=373150&view=rev
Log:
SemaExpr - silence static analyzer getAs<> null dereference warnings. NFCI.

The static analyzer is warning about potential null dereferences, but in these 
cases we should be able to use castAs<> directly and if not assert will fire 
for us.

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=373150&r1=373149&r2=373150&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat Sep 28 07:01:52 2019
@@ -6714,8 +6714,8 @@ ExprResult Sema::BuildVectorLiteral(Sour
   assert(Ty->isVectorType() && "Expected vector type");
 
   SmallVector initExprs;
-  const VectorType *VTy = Ty->getAs();
-  unsigned numElems = Ty->getAs()->getNumElements();
+  const VectorType *VTy = Ty->castAs();
+  unsigned numElems = VTy->getNumElements();
 
   // '(...)' form of vector initialization in AltiVec: the number of
   // initializers must be one or must match the size of the vector.
@@ -6726,7 +6726,7 @@ ExprResult Sema::BuildVectorLiteral(Sour
 // vector. If a single value is specified in the initializer then it will
 // be replicated to all the components of the vector
 if (numExprs == 1) {
-  QualType ElemTy = Ty->getAs()->getElementType();
+  QualType ElemTy = VTy->getElementType();
   ExprResult Literal = DefaultLvalueConversion(exprs[0]);
   if (Literal.isInvalid())
 return ExprError();
@@ -6748,7 +6748,7 @@ ExprResult Sema::BuildVectorLiteral(Sour
 if (getLangOpts().OpenCL &&
 VTy->getVectorKind() == VectorType::GenericVector &&
 numExprs == 1) {
-QualType ElemTy = Ty->getAs()->getElementType();
+QualType ElemTy = VTy->getElementType();
 ExprResult Literal = DefaultLvalueConversion(exprs[0]);
 if (Literal.isInvalid())
   return ExprError();
@@ -7047,8 +7047,8 @@ checkConditionalObjectPointersCompatibil
   QualType RHSTy = RHS.get()->getType();
 
   // get the "pointed to" types
-  QualType lhptee = LHSTy->getAs()->getPointeeType();
-  QualType rhptee = RHSTy->getAs()->getPointeeType();
+  QualType lhptee = LHSTy->castAs()->getPointeeType();
+  QualType rhptee = RHSTy->castAs()->getPointeeType();
 
   // ignore qualifiers on void (C99 6.5.15p3, clause 6)
   if (lhptee->isVoidType() && rhptee->isIncompleteOrObjectType()) {
@@ -7533,8 +7533,8 @@ QualType Sema::FindCompositeObjCPointerT
   LHS = RHS = true;
   return QualType();
 }
-QualType lhptee = LHSTy->getAs()->getPointeeType();
-QualType rhptee = RHSTy->getAs()->getPointeeType();
+QualType lhptee = LHSTy->castAs()->getPointeeType();
+QualType rhptee = RHSTy->castAs()->getPointeeType();
 QualType destPointee
 = Context.getQualifiedType(lhptee, rhptee.getQualifiers());
 QualType destType = Context.getPointerType(destPointee);
@@ -7553,8 +7553,8 @@ QualType Sema::FindCompositeObjCPointerT
   LHS = RHS = true;
   return QualType();
 }
-QualType lhptee = LHSTy->getAs()->getPointeeType();
-QualType rhptee = RHSTy->getAs()->getPointeeType();
+QualType lhptee = LHSTy->castAs()->getPointeeType();
+QualType rhptee = RHSTy->castAs()->getPointeeType();
 QualType destPointee
 = Context.getQualifiedType(rhptee, lhptee.getQualifiers());
 QualType destType = Context.getPointerType(destPointee);
@@ -8059,8 +8059,8 @@ checkObjCPointerTypesForAssignment(Sema
   return Sema::IncompatiblePointer;
 return Sema::Compatible;
   }
-  QualType lhptee = LHSType->getAs()->getPointeeType();
-  QualType rhptee = RHSType->getAs()->getPointeeType();
+  QualType lhptee = LHSType->castAs()->getPointeeType();
+  QualType rhptee = RHSType->castAs()->getPointeeType();
 
   if (!lhptee.isAtLeastAsQualifiedAs(rhptee) &&
   // make an exception for id
@@ -9401,8 +9401,8 @@ static bool checkArithmeticBinOpPointerO
 
   // if both are pointers check if operation is valid wrt address spaces
   if (S.getLangOpts().OpenCL && isLHSPointer && isRHSPointer) {
-const PointerType *lhsPtr = LHSExpr->getType()->getAs();
-const PointerType *rhsPtr = RHSExpr->getType()->getAs();
+const PointerType *lhsPtr = LHSExpr->getType()->castAs();
+const PointerType *rhsPtr = RHSExpr->getType()->castAs();
 if (!lhsPtr->isAddressSpaceOverlapping(*rhsPtr)) {
   S.Diag(Loc,
  diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
@@ -10495,7 +10495,7 @@ static QualType checkArithmeticOrEnumera
   return QualType();
 }
 QualType IntType =
-LHSStrippedType->getAs()->getDecl()->getIntegerType();
+LHSStrippedType->castAs()->getDecl()->getIntegerType();
 assert(IntType->isArithmeticType());
 
 // We can't use `CK_Int

[PATCH] D68165: [analyzer][MallocChecker][NFC] Split checkPostCall up, deploy CallDescriptionMap

2019-09-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:397-398
+  CallDescriptionMap NonFreeingMemFnMap{
+  {{"alloca", 1}, &MallocChecker::checkAlloca},
+  {{"_alloca", 1}, &MallocChecker::checkAlloca},
+  {{"malloc", 1}, &MallocChecker::checkMalloc},

Szelethus wrote:
> NoQ wrote:
> > I think `alloca` deserves `CDF_MaybeBuiltin`. This would also probably 
> > allow you to remove the second line.
> Actually, `BuiltinFunctionChecker` uses `evalCall` to create an 
> `AllocaRegion` for `__builtin_alloca`. I spent an hour when writing this 
> patch to track a crash down when I initially made this `CDF_MaybeBuiltin` :)
Oh misery.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68165/new/

https://reviews.llvm.org/D68165



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68182: [Clangd] Ensure children are always RootStmt in ExtractFunction (Fixes #153)

2019-09-28 Thread Shaurya Gupta via Phabricator via cfe-commits
SureYeaah created this revision.
SureYeaah added reviewers: sammccall, kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov, kristof.beyls.
Herald added a project: clang.
SureYeaah edited the summary of this revision.

We weren't always checking if children are RootStmts in ExtractFunction.

For `void f([[int a]]);`, the ParmVarDecl appeared as a RootStmt since
we didn't perform the check and ended up being casted to a (null) Stmt.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68182

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -554,7 +554,8 @@
   EXPECT_THAT(apply(" [[int a = 5;]] a++; "), StartsWith("fail"));
   // Don't extract return
   EXPECT_THAT(apply(" if(true) [[return;]] "), StartsWith("fail"));
-  
+  // Shouldn't crash.
+  EXPECT_THAT(apply("void f([[int a]]);"), "unavailable");
 }
 
 TEST_F(ExtractFunctionTest, FileTest) {
Index: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -111,28 +111,30 @@
 const Node *getParentOfRootStmts(const Node *CommonAnc) {
   if (!CommonAnc)
 return nullptr;
+  const Node* Parent = CommonAnc;
   switch (CommonAnc->Selected) {
-  case SelectionTree::Selection::Unselected:
-// Ensure all Children are RootStmts.
-return llvm::all_of(CommonAnc->Children, isRootStmt) ? CommonAnc : nullptr;
-  case SelectionTree::Selection::Partial:
-// Treat Partially selected VarDecl as completely selected since
-// SelectionTree doesn't always select VarDecls correctly.
-// FIXME: Remove this after D66872 is upstream)
-if (!CommonAnc->ASTNode.get())
-  return nullptr;
-LLVM_FALLTHROUGH;
-  case SelectionTree::Selection::Complete:
-// If the Common Ancestor is completely selected, then it's a root 
statement
-// and its parent will be unselected.
-const Node *Parent = CommonAnc->Parent;
-// If parent is a DeclStmt, even though it's unselected, we consider it a
-// root statement and return its parent. This is done because the VarDecls
-// claim the entire selection range of the Declaration and DeclStmt is
-// always unselected.
-return Parent->ASTNode.get() ? Parent->Parent : Parent;
+case SelectionTree::Selection::Partial:
+  // Treat Partially selected VarDecl as completely selected since
+  // SelectionTree doesn't always select VarDecls correctly.
+  // FIXME: Remove this after D66872 is upstream)
+  if (!CommonAnc->ASTNode.get())
+return nullptr;
+  LLVM_FALLTHROUGH;
+case SelectionTree::Selection::Complete:
+  // If the Common Ancestor is completely selected, then it's a root 
statement
+  // and its parent will be unselected.
+  Parent = CommonAnc->Parent;
+  // If parent is a DeclStmt, even though it's unselected, we consider it a
+  // root statement and return its parent. This is done because the 
VarDecls
+  // claim the entire selection range of the Declaration and DeclStmt is
+  // always unselected.
+  if(Parent->ASTNode.get())
+Parent = Parent->Parent;
+  LLVM_FALLTHROUGH;
+case SelectionTree::Selection::Unselected:
+  // Ensure all Children are RootStmts.
+  return llvm::all_of(Parent->Children, isRootStmt) ? Parent : nullptr;
   }
-  llvm_unreachable("Unhandled SelectionTree::Selection enum");
 }
 
 // The ExtractionZone class forms a view of the code wrt Zone.


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -554,7 +554,8 @@
   EXPECT_THAT(apply(" [[int a = 5;]] a++; "), StartsWith("fail"));
   // Don't extract return
   EXPECT_THAT(apply(" if(true) [[return;]] "), StartsWith("fail"));
-  
+  // Shouldn't crash.
+  EXPECT_THAT(apply("void f([[int a]]);"), "unavailable");
 }
 
 TEST_F(ExtractFunctionTest, FileTest) {
Index: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -111,28 +111,30 @@
 const Node *getParentOfRootStmts(const Node *CommonAnc) {
   if (!CommonAnc)
 return nullptr;
+  const Node* Parent = CommonAnc;
   switch (CommonAnc->Selected) {
-  case SelectionTree::Selection::Unselected:
-// Ensure all Children

[PATCH] D68182: [Clangd] Ensure children are always RootStmt in ExtractFunction (Fixes #153)

2019-09-28 Thread Shaurya Gupta via Phabricator via cfe-commits
SureYeaah updated this revision to Diff 93.
SureYeaah added a comment.

Added llmv_unreachable


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68182/new/

https://reviews.llvm.org/D68182

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -554,7 +554,8 @@
   EXPECT_THAT(apply(" [[int a = 5;]] a++; "), StartsWith("fail"));
   // Don't extract return
   EXPECT_THAT(apply(" if(true) [[return;]] "), StartsWith("fail"));
-  
+  // Shouldn't crash.
+  EXPECT_THAT(apply("void f([[int a]]);"), "unavailable");
 }
 
 TEST_F(ExtractFunctionTest, FileTest) {
Index: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -111,26 +111,29 @@
 const Node *getParentOfRootStmts(const Node *CommonAnc) {
   if (!CommonAnc)
 return nullptr;
+  const Node* Parent = CommonAnc;
   switch (CommonAnc->Selected) {
-  case SelectionTree::Selection::Unselected:
-// Ensure all Children are RootStmts.
-return llvm::all_of(CommonAnc->Children, isRootStmt) ? CommonAnc : nullptr;
-  case SelectionTree::Selection::Partial:
-// Treat Partially selected VarDecl as completely selected since
-// SelectionTree doesn't always select VarDecls correctly.
-// FIXME: Remove this after D66872 is upstream)
-if (!CommonAnc->ASTNode.get())
-  return nullptr;
-LLVM_FALLTHROUGH;
-  case SelectionTree::Selection::Complete:
-// If the Common Ancestor is completely selected, then it's a root 
statement
-// and its parent will be unselected.
-const Node *Parent = CommonAnc->Parent;
-// If parent is a DeclStmt, even though it's unselected, we consider it a
-// root statement and return its parent. This is done because the VarDecls
-// claim the entire selection range of the Declaration and DeclStmt is
-// always unselected.
-return Parent->ASTNode.get() ? Parent->Parent : Parent;
+case SelectionTree::Selection::Partial:
+  // Treat Partially selected VarDecl as completely selected since
+  // SelectionTree doesn't always select VarDecls correctly.
+  // FIXME: Remove this after D66872 is upstream)
+  if (!CommonAnc->ASTNode.get())
+return nullptr;
+  LLVM_FALLTHROUGH;
+case SelectionTree::Selection::Complete:
+  // If the Common Ancestor is completely selected, then it's a root 
statement
+  // and its parent will be unselected.
+  Parent = CommonAnc->Parent;
+  // If parent is a DeclStmt, even though it's unselected, we consider it a
+  // root statement and return its parent. This is done because the 
VarDecls
+  // claim the entire selection range of the Declaration and DeclStmt is
+  // always unselected.
+  if(Parent->ASTNode.get())
+Parent = Parent->Parent;
+  LLVM_FALLTHROUGH;
+case SelectionTree::Selection::Unselected:
+  // Ensure all Children are RootStmts.
+  return llvm::all_of(Parent->Children, isRootStmt) ? Parent : nullptr;
   }
   llvm_unreachable("Unhandled SelectionTree::Selection enum");
 }


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -554,7 +554,8 @@
   EXPECT_THAT(apply(" [[int a = 5;]] a++; "), StartsWith("fail"));
   // Don't extract return
   EXPECT_THAT(apply(" if(true) [[return;]] "), StartsWith("fail"));
-  
+  // Shouldn't crash.
+  EXPECT_THAT(apply("void f([[int a]]);"), "unavailable");
 }
 
 TEST_F(ExtractFunctionTest, FileTest) {
Index: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -111,26 +111,29 @@
 const Node *getParentOfRootStmts(const Node *CommonAnc) {
   if (!CommonAnc)
 return nullptr;
+  const Node* Parent = CommonAnc;
   switch (CommonAnc->Selected) {
-  case SelectionTree::Selection::Unselected:
-// Ensure all Children are RootStmts.
-return llvm::all_of(CommonAnc->Children, isRootStmt) ? CommonAnc : nullptr;
-  case SelectionTree::Selection::Partial:
-// Treat Partially selected VarDecl as completely selected since
-// SelectionTree doesn't always select VarDecls correctly.
-// FIXME: Remove this after D66872 is upstream)
-if (!CommonAnc->ASTNode.get())
-  return nullptr;
-

[PATCH] D67877: [analyzer] Conditionnaly include clang Analysis examples with cmake.

2019-09-28 Thread Jean-Bapiste Lepesme via Phabricator via cfe-commits
Jiboo abandoned this revision.
Jiboo added a comment.

Superseded by D68172 .


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67877/new/

https://reviews.llvm.org/D67877



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68072: [clang-format] Reference qualifiers in member templates causing extra indentation.

2019-09-28 Thread Andreas Wass via Phabricator via cfe-commits
AndWass updated this revision to Diff 99.
AndWass added a comment.

Removed the manual paranthesis-tracking, using NestingLevel instead.
Moved tests to the already existing `UnderstandsFunctionRefQualification` test 
case.
Clarified what is being matched against in 
`TokenAnnotator::spaceRequiredBetween`


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68072/new/

https://reviews.llvm.org/D68072

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6901,6 +6901,73 @@
Spaces);
   verifyFormat("Deleted &operator=( const Deleted & ) &;", Spaces);
   verifyFormat("SomeType MemberFunction( const Deleted & ) &;", Spaces);
+
+  FormatStyle BreakTemplate = getLLVMStyle();
+  BreakTemplate.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Yes;
+
+  verifyFormat("struct f {\n"
+   "  template \n"
+   "  int &foo(const std::string &str) & noexcept {}\n"
+   "};",
+   BreakTemplate);
+
+  verifyFormat("struct f {\n"
+   "  template \n"
+   "  int &foo(const std::string &str) && noexcept {}\n"
+   "};",
+   BreakTemplate);
+
+  verifyFormat("struct f {\n"
+   "  template \n"
+   "  int &foo(const std::string &str) const & noexcept {}\n"
+   "};",
+   BreakTemplate);
+
+  verifyFormat("struct f {\n"
+   "  template \n"
+   "  int &foo(const std::string &str) const & noexcept {}\n"
+   "};",
+   BreakTemplate);
+
+  verifyFormat("struct f {\n"
+   "  template \n"
+   "  auto foo(const std::string &str) && noexcept -> int & {}\n"
+   "};",
+   BreakTemplate);
+
+  FormatStyle AlignLeftBreakTemplate = getLLVMStyle();
+  AlignLeftBreakTemplate.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Yes;
+  AlignLeftBreakTemplate.PointerAlignment = FormatStyle::PAS_Left;
+
+  verifyFormat("struct f {\n"
+   "  template \n"
+   "  int& foo(const std::string& str) & noexcept {}\n"
+   "};",
+   AlignLeftBreakTemplate);
+
+  verifyFormat("struct f {\n"
+   "  template \n"
+   "  int& foo(const std::string& str) && noexcept {}\n"
+   "};",
+   AlignLeftBreakTemplate);
+
+  verifyFormat("struct f {\n"
+   "  template \n"
+   "  int& foo(const std::string& str) const & noexcept {}\n"
+   "};",
+   AlignLeftBreakTemplate);
+
+  verifyFormat("struct f {\n"
+   "  template \n"
+   "  int& foo(const std::string& str) const & noexcept {}\n"
+   "};",
+   AlignLeftBreakTemplate);
+
+  verifyFormat("struct f {\n"
+   "  template \n"
+   "  auto foo(const std::string& str) && noexcept -> int& {}\n"
+   "};",
+   AlignLeftBreakTemplate);
 }
 
 TEST_F(FormatTest, UnderstandsNewAndDelete) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -65,7 +65,7 @@
   AnnotatingParser(const FormatStyle &Style, AnnotatedLine &Line,
const AdditionalKeywords &Keywords)
   : Style(Style), Line(Line), CurrentToken(Line.First), AutoFound(false),
-Keywords(Keywords) {
+TrailingReturnFound(false), Keywords(Keywords) {
 Contexts.push_back(Context(tok::unknown, 1, /*IsExpression=*/false));
 resetTokenMetadata(CurrentToken);
   }
@@ -1389,7 +1389,11 @@
 } else if (Current.is(tok::arrow) && AutoFound && Line.MustBeDeclaration &&
Current.NestingLevel == 0) {
   Current.Type = TT_TrailingReturnArrow;
-} else if (Current.isOneOf(tok::star, tok::amp, tok::ampamp)) {
+  TrailingReturnFound = true;
+} else if (Current.is(tok::star) ||
+   (Current.isOneOf(tok::amp, tok::ampamp) &&
+(Current.NestingLevel != 0 || !Line.MightBeFunctionDecl ||
+ TrailingReturnFound))) {
   Current.Type = determineStarAmpUsage(Current,
Contexts.back().CanBeExpression &&
Contexts.back().IsExpression,
@@ -1412,6 +1416,8 @@
 Current.Type = TT_ConditionalExpr;
   }
 } else if (Current.isBinaryOperator() &&
+   !(Line.MightBeFunctionDecl && Current.NestingLevel == 0 &&
+ Current.isOneOf(tok::amp, tok::ampamp)) &&
(!Current.Previous || Current.Previous->isNot(tok::l_square)) &&
(!Current.is(tok::greater) &&
 Style.Languag

[PATCH] D68072: [clang-format] Reference qualifiers in member templates causing extra indentation.

2019-09-28 Thread Andreas Wass via Phabricator via cfe-commits
AndWass marked 4 inline comments as done.
AndWass added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:1375
+}
+
 // Line.MightBeFunctionDecl can only be true after the parentheses of a

MyDeveloperDay wrote:
> could this be done using the MatchingParen?
Removed the old code to use `Current.NestingLevel` instead.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2704
+return Style.PointerAlignment != FormatStyle::PAS_Left;
   return true;
 }

MyDeveloperDay wrote:
>  are you not testing the volatile case? could you add a comment here as to 
> what you are actually matching like the lines above
const and volatile are tested in existing tests. I moved my tests to the same 
test case.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68072/new/

https://reviews.llvm.org/D68072



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68185: [Diagnostics] Warn when class implements a copy constructor/copy assignment operator, but missing the copy assignment operator/copy constructor

2019-09-28 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 created this revision.
xbolva00 added a reviewer: rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
xbolva00 updated this revision to Diff 222301.

Clang version of https://www.viva64.com/en/w/v690/
Also requested by Chromium developers:
https://bugs.chromium.org/p/chromium/issues/detail?id=979077&q=component%3ATools%3ELLVM&colspec=ID%20Pri%20M%20Stars%20ReleaseBlock%20Component%20Status%20Owner%20Summary%20OS%20Modified


https://reviews.llvm.org/D68185

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclCXX.cpp
  test/SemaCXX/warn-custom-copy.cpp


Index: test/SemaCXX/warn-custom-copy.cpp
===
--- test/SemaCXX/warn-custom-copy.cpp
+++ test/SemaCXX/warn-custom-copy.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wcustom-copy %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class Clz // expected-warning {{class implements custom copy assignment 
operator but missing custom copy constructor}}
+
+{
+  char *buf;
+
+public:
+  Clz() : buf(nullptr) {}
+  Clz &operator=(const Clz &r) {
+buf = r.buf;
+return *this;
+  }
+};
+
+class Clz2 // expected-warning {{class implements custom copy assignment 
operator but missing custom copy constructor}}
+
+{
+  char *buf;
+
+public:
+  Clz2() : buf(nullptr) {}
+  Clz2(const Clz2 &r) : buf(nullptr) {
+(void)buf;
+(void)r;
+  }
+};
+
+class Clz3 {
+  char *buf;
+
+public:
+  Clz3() : buf(nullptr) {}
+  Clz3(const Clz3 &r) : buf(nullptr) {
+(void)buf;
+(void)r;
+  }
+  Clz3 &operator=(const Clz3 &r) {
+buf = r.buf;
+return *this;
+  }
+};
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -6279,6 +6279,14 @@
 }
   }
 
+  // Warn if the class implements custom copy constructor but missing
+  // custom copy assignment operator and vice versa.
+  if (Record->hasUserDeclaredCopyAssignment() !=
+  Record->hasUserDeclaredCopyConstructor())
+Diag(Record->getLocation(), diag::warn_missing_custom_copy)
+<< Record->hasUserDeclaredCopyConstructor()
+<< !Record->hasUserDeclaredCopyConstructor();
+
   // Warn if the class has virtual methods but non-virtual public destructor.
   if (Record->isPolymorphic() && !Record->isDependentType()) {
 CXXDestructorDecl *dtor = Record->getDestructor();
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2245,6 +2245,11 @@
 def note_final_dtor_non_final_class_silence : Note<
   "mark %0 as '%select{final|sealed}1' to silence this warning">;
 
+def warn_missing_custom_copy : Warning<
+  "class implements custom %select{copy assignment operator|copy constructor}0 
"
+  "but missing custom %select{copy assignment operator|copy constructor}1">,
+  InGroup>;
+
 // C++11 attributes
 def err_repeat_attribute : Error<"%0 attribute cannot be repeated">;
 


Index: test/SemaCXX/warn-custom-copy.cpp
===
--- test/SemaCXX/warn-custom-copy.cpp
+++ test/SemaCXX/warn-custom-copy.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wcustom-copy %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class Clz // expected-warning {{class implements custom copy assignment operator but missing custom copy constructor}}
+
+{
+  char *buf;
+
+public:
+  Clz() : buf(nullptr) {}
+  Clz &operator=(const Clz &r) {
+buf = r.buf;
+return *this;
+  }
+};
+
+class Clz2 // expected-warning {{class implements custom copy assignment operator but missing custom copy constructor}}
+
+{
+  char *buf;
+
+public:
+  Clz2() : buf(nullptr) {}
+  Clz2(const Clz2 &r) : buf(nullptr) {
+(void)buf;
+(void)r;
+  }
+};
+
+class Clz3 {
+  char *buf;
+
+public:
+  Clz3() : buf(nullptr) {}
+  Clz3(const Clz3 &r) : buf(nullptr) {
+(void)buf;
+(void)r;
+  }
+  Clz3 &operator=(const Clz3 &r) {
+buf = r.buf;
+return *this;
+  }
+};
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -6279,6 +6279,14 @@
 }
   }
 
+  // Warn if the class implements custom copy constructor but missing
+  // custom copy assignment operator and vice versa.
+  if (Record->hasUserDeclaredCopyAssignment() !=
+  Record->hasUserDeclaredCopyConstructor())
+Diag(Record->getLocation(), diag::warn_missing_custom_copy)
+<< Record->hasUserDeclaredCopyConstructor()
+<< !Record->hasUserDeclaredCopyConstructor();
+
   // Warn if the class has virtual methods but non-virtual public destructor.
   if (Record->isPolymorphic() && !Record->isDependentType()) {
 CXXDestructorDecl *dtor = Record->getDestructor();
Index: include/clang/Basi

[PATCH] D68185: [Diagnostics] Warn when class implements a copy constructor/copy assignment operator, but missing the copy assignment operator/copy constructor

2019-09-28 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 222301.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68185/new/

https://reviews.llvm.org/D68185

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclCXX.cpp
  test/SemaCXX/warn-custom-copy.cpp


Index: test/SemaCXX/warn-custom-copy.cpp
===
--- test/SemaCXX/warn-custom-copy.cpp
+++ test/SemaCXX/warn-custom-copy.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wcustom-copy %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class Clz // expected-warning {{class implements custom copy assignment 
operator but missing custom copy constructor}}
+
+{
+  char *buf;
+
+public:
+  Clz() : buf(nullptr) {}
+  Clz &operator=(const Clz &r) {
+buf = r.buf;
+return *this;
+  }
+};
+
+class Clz2 // expected-warning {{class implements custom copy assignment 
operator but missing custom copy constructor}}
+
+{
+  char *buf;
+
+public:
+  Clz2() : buf(nullptr) {}
+  Clz2(const Clz2 &r) : buf(nullptr) {
+(void)buf;
+(void)r;
+  }
+};
+
+class Clz3 {
+  char *buf;
+
+public:
+  Clz3() : buf(nullptr) {}
+  Clz3(const Clz3 &r) : buf(nullptr) {
+(void)buf;
+(void)r;
+  }
+  Clz3 &operator=(const Clz3 &r) {
+buf = r.buf;
+return *this;
+  }
+};
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -6279,6 +6279,14 @@
 }
   }
 
+  // Warn if the class implements custom copy constructor but missing
+  // custom copy assignment operator and vice versa.
+  if (Record->hasUserDeclaredCopyAssignment() !=
+  Record->hasUserDeclaredCopyConstructor())
+Diag(Record->getLocation(), diag::warn_missing_custom_copy)
+<< Record->hasUserDeclaredCopyConstructor()
+<< !Record->hasUserDeclaredCopyConstructor();
+
   // Warn if the class has virtual methods but non-virtual public destructor.
   if (Record->isPolymorphic() && !Record->isDependentType()) {
 CXXDestructorDecl *dtor = Record->getDestructor();
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2245,6 +2245,11 @@
 def note_final_dtor_non_final_class_silence : Note<
   "mark %0 as '%select{final|sealed}1' to silence this warning">;
 
+def warn_missing_custom_copy : Warning<
+  "class implements custom %select{copy assignment operator|copy constructor}0 
"
+  "but missing custom %select{copy assignment operator|copy constructor}1">,
+  InGroup>;
+
 // C++11 attributes
 def err_repeat_attribute : Error<"%0 attribute cannot be repeated">;
 


Index: test/SemaCXX/warn-custom-copy.cpp
===
--- test/SemaCXX/warn-custom-copy.cpp
+++ test/SemaCXX/warn-custom-copy.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wcustom-copy %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class Clz // expected-warning {{class implements custom copy assignment operator but missing custom copy constructor}}
+
+{
+  char *buf;
+
+public:
+  Clz() : buf(nullptr) {}
+  Clz &operator=(const Clz &r) {
+buf = r.buf;
+return *this;
+  }
+};
+
+class Clz2 // expected-warning {{class implements custom copy assignment operator but missing custom copy constructor}}
+
+{
+  char *buf;
+
+public:
+  Clz2() : buf(nullptr) {}
+  Clz2(const Clz2 &r) : buf(nullptr) {
+(void)buf;
+(void)r;
+  }
+};
+
+class Clz3 {
+  char *buf;
+
+public:
+  Clz3() : buf(nullptr) {}
+  Clz3(const Clz3 &r) : buf(nullptr) {
+(void)buf;
+(void)r;
+  }
+  Clz3 &operator=(const Clz3 &r) {
+buf = r.buf;
+return *this;
+  }
+};
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -6279,6 +6279,14 @@
 }
   }
 
+  // Warn if the class implements custom copy constructor but missing
+  // custom copy assignment operator and vice versa.
+  if (Record->hasUserDeclaredCopyAssignment() !=
+  Record->hasUserDeclaredCopyConstructor())
+Diag(Record->getLocation(), diag::warn_missing_custom_copy)
+<< Record->hasUserDeclaredCopyConstructor()
+<< !Record->hasUserDeclaredCopyConstructor();
+
   // Warn if the class has virtual methods but non-virtual public destructor.
   if (Record->isPolymorphic() && !Record->isDependentType()) {
 CXXDestructorDecl *dtor = Record->getDestructor();
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2245,6 +2245,11 @@
 def note_final_dtor_non_final_class_silence : Note<
   "mark %0 as '%select{final|sealed}1' to silence this warning">;
 
+def warn_missing_c

[PATCH] D68185: [Diagnostics] Warn when class implements a copy constructor/copy assignment operator, but missing the copy assignment operator/copy constructor

2019-09-28 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

Please add test cases showing the intended behavior for

- when the copy constructor is explicitly defaulted but the copy assignment 
operator is {implicitly defaulted, implicitly deleted, user-provided}
- when the copy assignment operator is explicitly defaulted but the copy 
constructor is {implicitly defaulted, implicitly deleted, user-provided}
- when the {copy constructor, copy assignment operator} is user-provided but 
the other is implicitly deleted

An example of an implicitly deleted copy assignment operator would be

  struct A {
  int& x;
  A(const A& rhs) : x(rhs.x) {}
  };

Also, how does the presence of a user-provided destructor interact with this 
diagnostic? If I provide a destructor but implicitly default my copy 
operations, isn't that just as bad, Rule-of-Three-wise?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68185/new/

https://reviews.llvm.org/D68185



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68185: [Diagnostics] Warn when class implements a copy constructor/copy assignment operator, but missing the copy assignment operator/copy constructor

2019-09-28 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

>> if I provide a destructor but implicitly default my copy operations, isn't 
>> that just as bad, Rule-of-Three-wise?

Yeah, I am wondering about this too. whether we should check the whole 
Rule-of-Three. Suggestions from other reviewers?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68185/new/

https://reviews.llvm.org/D68185



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67321: Respect CLANG_LINK_CLANG_DYLIB=ON in libclang and c-index-test

2019-09-28 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 222302.
aaronpuchert marked 4 inline comments as done.
aaronpuchert added a comment.

Handle static libraries correctly.

Dependencies of executables are obviously always PRIVATE, but for library 
targets we have to turn PRIVATE or PUBLIC dependencies into INTERFACE 
dependencies. This is basically also what add_llvm_library's LINK_LIBS does.

I tested this by configuring a couple of build profiles and inspecting 
build.ninja.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67321/new/

https://reviews.llvm.org/D67321

Files:
  clang/cmake/modules/AddClang.cmake
  clang/tools/c-index-test/CMakeLists.txt
  clang/tools/libclang/CMakeLists.txt


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -34,7 +34,7 @@
   ../../include/clang-c/Index.h
   )
 
-set(LIBS
+set(CLANG_LIB_DEPS
   clangAST
   clangBasic
   clangDriver
@@ -44,11 +44,10 @@
   clangSema
   clangSerialization
   clangTooling
-  LLVMSupport
 )
 
 if (CLANG_ENABLE_ARCMT)
-  list(APPEND LIBS clangARCMigrate)
+  list(APPEND CLANG_LIB_DEPS clangARCMigrate)
 endif ()
 
 if (TARGET clangTidyPlugin)
@@ -113,6 +112,11 @@
   Support
   )
 
+clang_target_link_libraries(libclang
+  PRIVATE
+  ${CLANG_LIB_DEPS}
+  )
+
 if(ENABLE_SHARED)
   if(WIN32)
 set_target_properties(libclang
Index: clang/tools/c-index-test/CMakeLists.txt
===
--- clang/tools/c-index-test/CMakeLists.txt
+++ clang/tools/c-index-test/CMakeLists.txt
@@ -25,6 +25,9 @@
   target_link_libraries(c-index-test
 PRIVATE
 libclang
+  )
+  clang_target_link_libraries(c-index-test
+PRIVATE
 clangAST
 clangBasic
 clangCodeGen
Index: clang/cmake/modules/AddClang.cmake
===
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -173,11 +173,25 @@
   llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
 endmacro()
 
+# Link with a Clang component library, or clang-cpp if CLANG_LINK_CLANG_DYLIB
+# is set. If target is a static library, PUBLIC and PRIVATE dependencies are
+# treated as INTERFACE dependencies, so this can replace LINK_LIBS.
 function(clang_target_link_libraries target type)
+  get_target_property(TARGET_TYPE ${target} TYPE)
+  if(${TARGET_TYPE} EQUAL "STATIC_LIBRARY")
+set(type INTERFACE)
+  endif()
   if (CLANG_LINK_CLANG_DYLIB)
 target_link_libraries(${target} ${type} clang-cpp)
   else()
 target_link_libraries(${target} ${type} ${ARGN})
   endif()
 
+  if (TARGET "${target}_static")
+if (CLANG_LINK_CLANG_DYLIB)
+  target_link_libraries(${target} INTERFACE clang-cpp)
+else()
+  target_link_libraries(${target} INTERFACE ${ARGN})
+endif()
+  endif()
 endfunction()


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -34,7 +34,7 @@
   ../../include/clang-c/Index.h
   )
 
-set(LIBS
+set(CLANG_LIB_DEPS
   clangAST
   clangBasic
   clangDriver
@@ -44,11 +44,10 @@
   clangSema
   clangSerialization
   clangTooling
-  LLVMSupport
 )
 
 if (CLANG_ENABLE_ARCMT)
-  list(APPEND LIBS clangARCMigrate)
+  list(APPEND CLANG_LIB_DEPS clangARCMigrate)
 endif ()
 
 if (TARGET clangTidyPlugin)
@@ -113,6 +112,11 @@
   Support
   )
 
+clang_target_link_libraries(libclang
+  PRIVATE
+  ${CLANG_LIB_DEPS}
+  )
+
 if(ENABLE_SHARED)
   if(WIN32)
 set_target_properties(libclang
Index: clang/tools/c-index-test/CMakeLists.txt
===
--- clang/tools/c-index-test/CMakeLists.txt
+++ clang/tools/c-index-test/CMakeLists.txt
@@ -25,6 +25,9 @@
   target_link_libraries(c-index-test
 PRIVATE
 libclang
+  )
+  clang_target_link_libraries(c-index-test
+PRIVATE
 clangAST
 clangBasic
 clangCodeGen
Index: clang/cmake/modules/AddClang.cmake
===
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -173,11 +173,25 @@
   llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
 endmacro()
 
+# Link with a Clang component library, or clang-cpp if CLANG_LINK_CLANG_DYLIB
+# is set. If target is a static library, PUBLIC and PRIVATE dependencies are
+# treated as INTERFACE dependencies, so this can replace LINK_LIBS.
 function(clang_target_link_libraries target type)
+  get_target_property(TARGET_TYPE ${target} TYPE)
+  if(${TARGET_TYPE} EQUAL "STATIC_LIBRARY")
+set(type INTERFACE)
+  endif()
   if (CLANG_LINK_CLANG_DYLIB)
 target_link_libraries(${target} ${type} clang-cpp)
   else()
 target_link_libraries(${target} ${type} ${ARGN})
   endif()
 
+  if (TARGET "${target}_static

[PATCH] D67321: Respect CLANG_LINK_CLANG_DYLIB=ON in libclang and c-index-test

2019-09-28 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 222303.
aaronpuchert added a comment.

Fix typo.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67321/new/

https://reviews.llvm.org/D67321

Files:
  clang/cmake/modules/AddClang.cmake
  clang/tools/c-index-test/CMakeLists.txt
  clang/tools/libclang/CMakeLists.txt


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -34,7 +34,7 @@
   ../../include/clang-c/Index.h
   )
 
-set(LIBS
+set(CLANG_LIB_DEPS
   clangAST
   clangBasic
   clangDriver
@@ -44,11 +44,10 @@
   clangSema
   clangSerialization
   clangTooling
-  LLVMSupport
 )
 
 if (CLANG_ENABLE_ARCMT)
-  list(APPEND LIBS clangARCMigrate)
+  list(APPEND CLANG_LIB_DEPS clangARCMigrate)
 endif ()
 
 if (TARGET clangTidyPlugin)
@@ -113,6 +112,11 @@
   Support
   )
 
+clang_target_link_libraries(libclang
+  PRIVATE
+  ${CLANG_LIB_DEPS}
+  )
+
 if(ENABLE_SHARED)
   if(WIN32)
 set_target_properties(libclang
Index: clang/tools/c-index-test/CMakeLists.txt
===
--- clang/tools/c-index-test/CMakeLists.txt
+++ clang/tools/c-index-test/CMakeLists.txt
@@ -25,6 +25,9 @@
   target_link_libraries(c-index-test
 PRIVATE
 libclang
+  )
+  clang_target_link_libraries(c-index-test
+PRIVATE
 clangAST
 clangBasic
 clangCodeGen
Index: clang/cmake/modules/AddClang.cmake
===
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -173,11 +173,25 @@
   llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
 endmacro()
 
+# Link with a Clang component library, or clang-cpp if CLANG_LINK_CLANG_DYLIB
+# is set. If target is a static library, PUBLIC and PRIVATE dependencies are
+# treated as INTERFACE dependencies, so this can replace LINK_LIBS.
 function(clang_target_link_libraries target type)
+  get_target_property(TARGET_TYPE ${target} TYPE)
+  if(${TARGET_TYPE} EQUAL "STATIC_LIBRARY")
+set(type INTERFACE)
+  endif()
   if (CLANG_LINK_CLANG_DYLIB)
 target_link_libraries(${target} ${type} clang-cpp)
   else()
 target_link_libraries(${target} ${type} ${ARGN})
   endif()
 
+  if (TARGET "${target}_static")
+if (CLANG_LINK_CLANG_DYLIB)
+  target_link_libraries("${target}_static" INTERFACE clang-cpp)
+else()
+  target_link_libraries("${target}_static" INTERFACE ${ARGN})
+endif()
+  endif()
 endfunction()


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -34,7 +34,7 @@
   ../../include/clang-c/Index.h
   )
 
-set(LIBS
+set(CLANG_LIB_DEPS
   clangAST
   clangBasic
   clangDriver
@@ -44,11 +44,10 @@
   clangSema
   clangSerialization
   clangTooling
-  LLVMSupport
 )
 
 if (CLANG_ENABLE_ARCMT)
-  list(APPEND LIBS clangARCMigrate)
+  list(APPEND CLANG_LIB_DEPS clangARCMigrate)
 endif ()
 
 if (TARGET clangTidyPlugin)
@@ -113,6 +112,11 @@
   Support
   )
 
+clang_target_link_libraries(libclang
+  PRIVATE
+  ${CLANG_LIB_DEPS}
+  )
+
 if(ENABLE_SHARED)
   if(WIN32)
 set_target_properties(libclang
Index: clang/tools/c-index-test/CMakeLists.txt
===
--- clang/tools/c-index-test/CMakeLists.txt
+++ clang/tools/c-index-test/CMakeLists.txt
@@ -25,6 +25,9 @@
   target_link_libraries(c-index-test
 PRIVATE
 libclang
+  )
+  clang_target_link_libraries(c-index-test
+PRIVATE
 clangAST
 clangBasic
 clangCodeGen
Index: clang/cmake/modules/AddClang.cmake
===
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -173,11 +173,25 @@
   llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
 endmacro()
 
+# Link with a Clang component library, or clang-cpp if CLANG_LINK_CLANG_DYLIB
+# is set. If target is a static library, PUBLIC and PRIVATE dependencies are
+# treated as INTERFACE dependencies, so this can replace LINK_LIBS.
 function(clang_target_link_libraries target type)
+  get_target_property(TARGET_TYPE ${target} TYPE)
+  if(${TARGET_TYPE} EQUAL "STATIC_LIBRARY")
+set(type INTERFACE)
+  endif()
   if (CLANG_LINK_CLANG_DYLIB)
 target_link_libraries(${target} ${type} clang-cpp)
   else()
 target_link_libraries(${target} ${type} ${ARGN})
   endif()
 
+  if (TARGET "${target}_static")
+if (CLANG_LINK_CLANG_DYLIB)
+  target_link_libraries("${target}_static" INTERFACE clang-cpp)
+else()
+  target_link_libraries("${target}_static" INTERFACE ${ARGN})
+endif()
+  endif()
 endfunction()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/li

[PATCH] D68187: [libclang] Use strict prototypes in header

2019-09-28 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added reviewers: aaron.ballman, arphaman, ddunbar, jkorous.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.

When included in a C program, these function declarations are treated as
K&R declarations, which conveys no information about the number of
arguments of the function. A function with no arguments has to be
declared with parameter-type-list "void".


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68187

Files:
  clang/include/clang-c/FatalErrorHandler.h


Index: clang/include/clang-c/FatalErrorHandler.h
===
--- clang/include/clang-c/FatalErrorHandler.h
+++ clang/include/clang-c/FatalErrorHandler.h
@@ -18,14 +18,14 @@
  * Installs error handler that prints error message to stderr and calls 
abort().
  * Replaces currently installed error handler (if any).
  */
-void clang_install_aborting_llvm_fatal_error_handler();
+void clang_install_aborting_llvm_fatal_error_handler(void);
 
 /**
  * Removes currently installed error handler (if any).
  * If no error handler is intalled, the default strategy is to print error
  * message to stderr and call exit(1).
  */
-void clang_uninstall_llvm_fatal_error_handler();
+void clang_uninstall_llvm_fatal_error_handler(void);
 
 #ifdef __cplusplus
 }


Index: clang/include/clang-c/FatalErrorHandler.h
===
--- clang/include/clang-c/FatalErrorHandler.h
+++ clang/include/clang-c/FatalErrorHandler.h
@@ -18,14 +18,14 @@
  * Installs error handler that prints error message to stderr and calls abort().
  * Replaces currently installed error handler (if any).
  */
-void clang_install_aborting_llvm_fatal_error_handler();
+void clang_install_aborting_llvm_fatal_error_handler(void);
 
 /**
  * Removes currently installed error handler (if any).
  * If no error handler is intalled, the default strategy is to print error
  * message to stderr and call exit(1).
  */
-void clang_uninstall_llvm_fatal_error_handler();
+void clang_uninstall_llvm_fatal_error_handler(void);
 
 #ifdef __cplusplus
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68187: [libclang] Use strict prototypes in header

2019-09-28 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

Can be "reproduced" with `clang -fsyntax-only -Wstrict-prototypes 
clang/include/clang-c/*.h`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68187/new/

https://reviews.llvm.org/D68187



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r373159 - For P0784R7: compute whether a variable has constant destruction if it

2019-09-28 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sat Sep 28 22:08:46 2019
New Revision: 373159

URL: http://llvm.org/viewvc/llvm-project?rev=373159&view=rev
Log:
For P0784R7: compute whether a variable has constant destruction if it
has a constexpr destructor.

For constexpr variables, reject if the variable does not have constant
destruction. In all cases, do not emit runtime calls to the destructor
for variables with constant destruction.

Added:
cfe/trunk/test/CXX/expr/expr.const/p6-2a.cpp
cfe/trunk/test/CodeGenCXX/non-const-init-cxx2a.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/Interp/Interp.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp
cfe/trunk/test/CodeGenCXX/attr-no-destroy-d54344.cpp
cfe/trunk/test/CodeGenCXX/const-init-cxx2a.cpp
cfe/trunk/test/CodeGenCXX/no_destroy.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=373159&r1=373158&r2=373159&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Sat Sep 28 22:08:46 2019
@@ -808,12 +808,19 @@ struct EvaluatedStmt {
   /// valid if CheckedICE is true.
   bool IsICE : 1;
 
+  /// Whether this variable is known to have constant destruction. That is,
+  /// whether running the destructor on the initial value is a side-effect
+  /// (and doesn't inspect any state that might have changed during program
+  /// execution). This is currently only computed if the destructor is
+  /// non-trivial.
+  bool HasConstantDestruction : 1;
+
   Stmt *Value;
   APValue Evaluated;
 
-  EvaluatedStmt() : WasEvaluated(false), IsEvaluating(false), 
CheckedICE(false),
-CheckingICE(false), IsICE(false) {}
-
+  EvaluatedStmt()
+  : WasEvaluated(false), IsEvaluating(false), CheckedICE(false),
+CheckingICE(false), IsICE(false), HasConstantDestruction(false) {}
 };
 
 /// Represents a variable declaration or definition.
@@ -1267,6 +1274,14 @@ public:
   /// to untyped APValue if the value could not be evaluated.
   APValue *getEvaluatedValue() const;
 
+  /// Evaluate the destruction of this variable to determine if it constitutes
+  /// constant destruction.
+  ///
+  /// \pre isInitICE()
+  /// \return \c true if this variable has constant destruction, \c false if
+  /// not.
+  bool evaluateDestruction(SmallVectorImpl &Notes) const;
+
   /// Determines whether it is already known whether the
   /// initializer is an integral constant expression or not.
   bool isInitKnownICE() const;
@@ -1505,9 +1520,14 @@ public:
   // has no definition within this source file.
   bool isKnownToBeDefined() const;
 
-  /// Do we need to emit an exit-time destructor for this variable?
+  /// Is destruction of this variable entirely suppressed? If so, the variable
+  /// need not have a usable destructor at all.
   bool isNoDestroy(const ASTContext &) const;
 
+  /// Do we need to emit an exit-time destructor for this variable, and if so,
+  /// what kind?
+  QualType::DestructionKind needsDestruction(const ASTContext &Ctx) const;
+
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K >= firstVar && K <= lastVar; }

Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td?rev=373159&r1=373158&r2=373159&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td Sat Sep 28 22:08:46 2019
@@ -145,8 +145,10 @@ def note_constexpr_access_volatile_obj :
   "a constant expression">;
 def note_constexpr_volatile_here : Note<
   "volatile %select{temporary created|object declared|member declared}0 here">;
-def note_constexpr_ltor_mutable : Note<
-  "read of mutable member %0 is not allowed in a constant expression">;
+def note_constexpr_access_mutable : Note<
+  "%select{read of|read of|assignment to|increment of|decrement of|"
+  "member call on|dynamic_cast of|typeid applied to|destruction of}0 "
+  "mutable member %1 is not allowed in a con

r373160 - Fix checking for permitted results of constant expressions.

2019-09-28 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sat Sep 28 22:58:31 2019
New Revision: 373160

URL: http://llvm.org/viewvc/llvm-project?rev=373160&view=rev
Log:
Fix checking for permitted results of constant expressions.

In the presence of mutable state, we need to check whether temporaries
involved in a constant expression have permissible values at the end of
the overall evaluation, rather than at the end of the evaluation of the
initializer of the temporary.

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=373160&r1=373159&r2=373160&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Sat Sep 28 22:58:31 2019
@@ -1912,12 +1912,30 @@ static void NoteLValueLocation(EvalInfo
   // We have no information to show for a typeid(T) object.
 }
 
+enum class CheckEvaluationResultKind {
+  ConstantExpression,
+  FullyInitialized,
+};
+
+/// Materialized temporaries that we've already checked to determine if they're
+/// initializsed by a constant expression.
+using CheckedTemporaries =
+llvm::SmallPtrSet;
+
+static bool CheckEvaluationResult(CheckEvaluationResultKind CERK,
+  EvalInfo &Info, SourceLocation DiagLoc,
+  QualType Type, const APValue &Value,
+  Expr::ConstExprUsage Usage,
+  SourceLocation SubobjectLoc,
+  CheckedTemporaries &CheckedTemps);
+
 /// Check that this reference or pointer core constant expression is a valid
 /// value for an address or reference constant expression. Return true if we
 /// can fold this expression, whether or not it's a constant expression.
 static bool CheckLValueConstantExpression(EvalInfo &Info, SourceLocation Loc,
   QualType Type, const LValue &LVal,
-  Expr::ConstExprUsage Usage) {
+  Expr::ConstExprUsage Usage,
+  CheckedTemporaries &CheckedTemps) {
   bool IsReferenceType = Type->isReferenceType();
 
   APValue::LValueBase Base = LVal.getLValueBase();
@@ -1978,6 +1996,16 @@ static bool CheckLValueConstantExpressio
 // FIXME: Diagnostic!
 return false;
 }
+  } else if (const auto *MTE = dyn_cast_or_null(
+ Base.dyn_cast())) {
+if (CheckedTemps.insert(MTE).second) {
+  APValue *V = Info.Ctx.getMaterializedTemporaryValue(MTE, false);
+  assert(V && "evasluation result refers to uninitialised temporary");
+  if (!CheckEvaluationResult(CheckEvaluationResultKind::ConstantExpression,
+ Info, MTE->getExprLoc(), getType(Base), *V,
+ Usage, SourceLocation(), CheckedTemps))
+return false;
+}
   }
 
   // Allow address constant expressions to be past-the-end pointers. This is
@@ -2050,16 +2078,12 @@ static bool CheckLiteralType(EvalInfo &I
   return false;
 }
 
-enum class CheckEvaluationResultKind {
-  ConstantExpression,
-  FullyInitialized,
-};
-
-static bool
-CheckEvaluationResult(CheckEvaluationResultKind CERK, EvalInfo &Info,
-  SourceLocation DiagLoc, QualType Type,
-  const APValue &Value, Expr::ConstExprUsage Usage,
-  SourceLocation SubobjectLoc = SourceLocation()) {
+static bool CheckEvaluationResult(CheckEvaluationResultKind CERK,
+  EvalInfo &Info, SourceLocation DiagLoc,
+  QualType Type, const APValue &Value,
+  Expr::ConstExprUsage Usage,
+  SourceLocation SubobjectLoc,
+  CheckedTemporaries &CheckedTemps) {
   if (!Value.hasValue()) {
 Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized)
   << true << Type;
@@ -2081,18 +2105,20 @@ CheckEvaluationResult(CheckEvaluationRes
 for (unsigned I = 0, N = Value.getArrayInitializedElts(); I != N; ++I) {
   if (!CheckEvaluationResult(CERK, Info, DiagLoc, EltTy,
  Value.getArrayInitializedElt(I), Usage,
- SubobjectLoc))
+ SubobjectLoc, CheckedTemps))
 return false;
 }
 if (!Value.hasArrayFiller())
   return true;
 return CheckEvaluationResult(CERK, Info, DiagLoc, EltTy,
- Value.getArrayFiller(), Usage, SubobjectLoc);
+ Value.getArrayFiller(), Usage, SubobjectLoc,
+ CheckedTemps);
   }
   if (Value.isUnion() && Value.getUnionField()) {
 return CheckEv

r373161 - For now, disallow lifetime-extended temporaries with non-trivial (but

2019-09-28 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sat Sep 28 23:22:54 2019
New Revision: 373161

URL: http://llvm.org/viewvc/llvm-project?rev=373161&view=rev
Log:
For now, disallow lifetime-extended temporaries with non-trivial (but
constexpr) destructors from being used in the values of constexpr
variables.

The standard rules here are unclear at best, so rejecting the
problematic cases seems prudent. Prior to this change, we would fail to
run the destructors for these temporaries, even if they had
side-effects, which is certainly not the right behavior.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td?rev=373161&r1=373160&r2=373161&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td Sat Sep 28 23:22:54 2019
@@ -210,6 +210,9 @@ def note_constexpr_destroy_out_of_lifeti
   "destroying object '%0' whose lifetime has already ended">;
 def note_constexpr_unsupported_destruction : Note<
   "non-trivial destruction of type %0 in a constant expression is not 
supported">;
+def note_constexpr_unsupported_tempoarary_nontrivial_dtor : Note<
+  "non-trivial destruction of lifetime-extended temporary with type %0 "
+  "used in the result of a constant expression is not yet supported">;
 def note_constexpr_unsupported_unsized_array : Note<
   "array-to-pointer decay of array member without known bound is not 
supported">;
 def note_constexpr_unsized_array_indexed : Note<

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=373161&r1=373160&r2=373161&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Sat Sep 28 23:22:54 2019
@@ -1999,10 +1999,18 @@ static bool CheckLValueConstantExpressio
   } else if (const auto *MTE = dyn_cast_or_null(
  Base.dyn_cast())) {
 if (CheckedTemps.insert(MTE).second) {
+  QualType TempType = getType(Base);
+  if (TempType.isDestructedType()) {
+Info.FFDiag(MTE->getExprLoc(),
+
diag::note_constexpr_unsupported_tempoarary_nontrivial_dtor)
+<< TempType;
+return false;
+  }
+
   APValue *V = Info.Ctx.getMaterializedTemporaryValue(MTE, false);
   assert(V && "evasluation result refers to uninitialised temporary");
   if (!CheckEvaluationResult(CheckEvaluationResultKind::ConstantExpression,
- Info, MTE->getExprLoc(), getType(Base), *V,
+ Info, MTE->getExprLoc(), TempType, *V,
  Usage, SourceLocation(), CheckedTemps))
 return false;
 }

Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp?rev=373161&r1=373160&r2=373161&view=diff
==
--- cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp Sat Sep 28 23:22:54 
2019
@@ -1250,3 +1250,22 @@ namespace dtor_call {
 as.b.~A(); // expected-note {{destruction of member 'b' of union with 
active member 'a'}}
   }
 }
+
+namespace temp_dtor {
+  void f();
+  struct A {
+bool b;
+constexpr ~A() { if (b) f(); }
+  };
+
+  // We can't accept either of these unless we start actually registering the
+  // destructors of the A temporaries to run on shutdown. It's unclear what the
+  // intended standard behavior is so we reject this for now.
+  constexpr A &&a = A{false}; // expected-error {{constant}} expected-note 
{{non-trivial destruction of lifetime-extended temporary}}
+  void f() { a.b = true; }
+
+  constexpr A &&b = A{true}; // expected-error {{constant}} expected-note 
{{non-trivial destruction of lifetime-extended temporary}}
+
+  // FIXME: We could in prinicple accept this.
+  constexpr const A &c = A{false}; // expected-error {{constant}} 
expected-note {{non-trivial destruction of lifetime-extended temporary}}
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits