Re: [clang] c411c1b - Fix missing qualifier in template type diffing

2021-08-17 Thread Richard Trieu via cfe-commits
Thanks for the simplified test case.  I've pushed it at 02e73d4

On Mon, Aug 16, 2021 at 10:31 PM David Blaikie  wrote:

> Perhaps the test case could be stripped down a bit?
>
> template 
> class Array {};
>
> template 
> class S {};
>
> template 
> Array Make();
>
> void Call() {
> Array> v = Make>();
> }
>
> Seems to exhibit the same issue, by the looks of it.
>
> On Mon, Aug 16, 2021 at 6:38 PM via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>> Author: Weverything
>> Date: 2021-08-16T18:34:18-07:00
>> New Revision: c411c1bd7f7d3550d24333f80980c0be6481d34a
>>
>> URL:
>> https://github.com/llvm/llvm-project/commit/c411c1bd7f7d3550d24333f80980c0be6481d34a
>> DIFF:
>> https://github.com/llvm/llvm-project/commit/c411c1bd7f7d3550d24333f80980c0be6481d34a.diff
>>
>> LOG: Fix missing qualifier in template type diffing
>>
>> Handle SubstTemplateTypeParmType so qualifiers do not get dropped from
>> the diagnostic message.
>>
>> Added:
>>
>>
>> Modified:
>> clang/lib/AST/ASTDiagnostic.cpp
>> clang/test/Misc/diag-template-diffing.cpp
>>
>> Removed:
>>
>>
>>
>>
>> 
>> diff  --git a/clang/lib/AST/ASTDiagnostic.cpp
>> b/clang/lib/AST/ASTDiagnostic.cpp
>> index dc22481d0a84c..7e435e8b35b80 100644
>> --- a/clang/lib/AST/ASTDiagnostic.cpp
>> +++ b/clang/lib/AST/ASTDiagnostic.cpp
>> @@ -1088,6 +1088,9 @@ class TemplateDiff {
>>  Ty->getAs())
>>return TST;
>>
>> +if (const auto* SubstType = Ty->getAs())
>> +  Ty = SubstType->getReplacementType();
>> +
>>  const RecordType *RT = Ty->getAs();
>>
>>  if (!RT)
>>
>> diff  --git a/clang/test/Misc/diag-template-
>> diff ing.cpp b/clang/test/Misc/diag-template-
>> diff ing.cpp
>> index cc1cc9ca70679..6bf6e2de4277c 100644
>> --- a/clang/test/Misc/diag-template-
>> diff ing.cpp
>> +++ b/clang/test/Misc/diag-template-
>> diff ing.cpp
>> @@ -1488,6 +1488,43 @@ void run(A_reg reg, A_ptr ptr,
>> A_ref ref) {
>>  }
>>  }
>>
>> +namespace SubstTemplateTypeParmType {
>> +template 
>> +class Array {
>> +};
>> +
>> +template 
>> +class S{};
>> +
>> +template 
>> +Array Make(T ()[num]);
>> +
>> +void Run(int, Array>) {}
>> +
>> +Array> Make();
>> +void Call() {
>> +  const S s1[5];
>> +  S s2[5];
>> +
>> +  Run(0, Make(s1));   // Error
>> +  Run(0, Make(s2));   // Okay
>> +}
>> +
>> +// CHECK-ELIDE-NOTREE: no matching function for call to 'Run'
>> +// CHECK-ELIDE-NOTREE: no known conversion from 'Array>' to
>> 'Array>' for 2nd argument
>> +// CHECK-NOELIDE-NOTREE: no matching function for call to 'Run'
>> +// CHECK-NOELIDE-NOTREE: no known conversion from 'Array>'
>> to 'Array>' for 2nd argument
>> +// CHECK-ELIDE-TREE: no matching function for call to 'Run'
>> +// CHECK-ELIDE-TREE: no known conversion from argument type to parameter
>> type for 2nd argument
>> +// CHECK-ELIDE-TREE:   Array<
>> +// CHECK-ELIDE-TREE: [const != (no qualifiers)] S<...>>
>> +// CHECK-NOELIDE-TREE: no matching function for call to 'Run'
>> +// CHECK-NOELIDE-TREE: no known conversion from argument type to
>> parameter type for 2nd argument
>> +// CHECK-NOELIDE-TREE:   Array<
>> +// CHECK-NOELIDE-TREE: [const != (no qualifiers)] S<
>> +// CHECK-NOELIDE-TREE:   int>>
>> +}
>> +
>>  // CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated.
>>  // CHECK-NOELIDE-NOTREE: {{[0-9]*}} errors generated.
>>  // CHECK-ELIDE-TREE: {{[0-9]*}} errors generated.
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r375326 - Add -Wbitwise-conditional-parentheses to warn on mixing '|' and '&' with "?:"

2019-10-18 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Oct 18 18:47:49 2019
New Revision: 375326

URL: http://llvm.org/viewvc/llvm-project?rev=375326=rev
Log:
Add -Wbitwise-conditional-parentheses to warn on mixing '|' and '&' with "?:"

Extend -Wparentheses to cover mixing bitwise-and and bitwise-or with the
conditional operator. There's two main cases seen with this:

unsigned bits1 = 0xf0 | cond ? 0x4 : 0x1;
unsigned bits2 = cond1 ? 0xf0 : 0x10 | cond2 ? 0x5 : 0x2;

// Intended order of evaluation:
unsigned bits1 = 0xf0 | (cond ? 0x4 : 0x1);
unsigned bits2 = (cond1 ? 0xf0 : 0x10) | (cond2 ? 0x5 : 0x2);

// Actual order of evaluation:
unsigned bits1 = (0xf0 | cond) ? 0x4 : 0x1;
unsigned bits2 = cond1 ? 0xf0 : ((0x10 | cond2) ? 0x5 : 0x2);

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


Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/parentheses.c

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=375326=375325=375326=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Fri Oct 18 18:47:49 2019
@@ -61,6 +61,9 @@ Improvements to Clang's diagnostics
   operation and a constant.  The group also has the new warning which diagnoses
   when a bitwise-or with a non-negative value is converted to a bool, since
   that bool will always be true.
+- -Wbitwise-conditional-parentheses will warn on operator precedence issues
+  when mixing bitwise-and (&) and bitwise-or (|) operator with the
+  conditional operator (?:).
 
 Non-comprehensive list of changes in this release
 -

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=375326=375325=375326=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Oct 18 18:47:49 2019
@@ -296,6 +296,7 @@ def ExitTimeDestructors : DiagGroup<"exi
 def FlexibleArrayExtensions : DiagGroup<"flexible-array-extensions">;
 def FourByteMultiChar : DiagGroup<"four-char-constants">;
 def GlobalConstructors : DiagGroup<"global-constructors">;
+def BitwiseConditionalParentheses: 
DiagGroup<"bitwise-conditional-parentheses">;
 def BitwiseOpParentheses: DiagGroup<"bitwise-op-parentheses">;
 def LogicalOpParentheses: DiagGroup<"logical-op-parentheses">;
 def LogicalNotParentheses: DiagGroup<"logical-not-parentheses">;
@@ -737,6 +738,7 @@ def ParenthesesOnEquality : DiagGroup<"p
 def Parentheses : DiagGroup<"parentheses",
 [LogicalOpParentheses,
  LogicalNotParentheses,
+ BitwiseConditionalParentheses,
  BitwiseOpParentheses,
  ShiftOpParentheses,
  OverloadedShiftOpParentheses,

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=375326=375325=375326=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Oct 18 18:47:49 
2019
@@ -5745,6 +5745,9 @@ def note_precedence_silence : Note<
 def warn_precedence_conditional : Warning<
   "operator '?:' has lower precedence than '%0'; '%0' will be evaluated 
first">,
   InGroup;
+def warn_precedence_bitwise_conditional : Warning<
+  "operator '?:' has lower precedence than '%0'; '%0' will be evaluated 
first">,
+  InGroup;
 def note_precedence_conditional_first : Note<
   "place parentheses around the '?:' expression to evaluate it first">;
 

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=375326=375325=375326=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Oct 18 18:47:49 2019
@@ -7620,7 +7620,12 @@ static void SuggestParentheses(Sema 
 static bool IsArithmeticOp(BinaryOperatorKind Opc) {
   return BinaryOperator::isAdditiveOp(Opc) ||
  BinaryOperator::isMultiplicativeOp(Opc) ||
- BinaryOperator::isShiftOp(Opc);
+ BinaryOperator::isShiftOp(Opc) || Opc == BO_And || Opc == BO_Or;
+  // This only checks for bitwise-or and bitwise-and, but not bitwise-xor and
+  // not any of the logical operators.  Bitwise-xor is commonly used as a
+  // logical-xor because there is no logical-xor 

r375318 - New tautological warning for bitwise-or with non-zero constant always true.

2019-10-18 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Oct 18 17:57:23 2019
New Revision: 375318

URL: http://llvm.org/viewvc/llvm-project?rev=375318=rev
Log:
New tautological warning for bitwise-or with non-zero constant always true.

Taking a value and the bitwise-or it with a non-zero constant will always
result in a non-zero value. In a boolean context, this is always true.

if (x | 0x4) {}  // always true, intended '&'

This patch creates a new warning group -Wtautological-bitwise-compare for this
warning. It also moves in the existing tautological bitwise comparisons into
this group. A few other changes were needed to the CFGBuilder so that all bool
contexts would be checked. The warnings in -Wtautological-bitwise-compare will
be off by default due to using the CFG.

Fixes: https://bugs.llvm.org/show_bug.cgi?id=42666
Differential Revision: https://reviews.llvm.org/D66046


Added:
cfe/trunk/test/SemaCXX/warn-bitwise-compare.cpp
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/include/clang/Analysis/CFG.h
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/test/Sema/warn-bitwise-compare.c

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=375318=375317=375318=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Fri Oct 18 17:57:23 2019
@@ -56,6 +56,11 @@ Improvements to Clang's diagnostics
 - -Wtautological-compare for self comparisons and
   -Wtautological-overlap-compare will now look through member and array
   access to determine if two operand expressions are the same.
+- -Wtautological-bitwise-compare is a new warning group.  This group has the
+  current warning which diagnoses the tautological comparison of a bitwise
+  operation and a constant.  The group also has the new warning which diagnoses
+  when a bitwise-or with a non-negative value is converted to a bool, since
+  that bool will always be true.
 
 Non-comprehensive list of changes in this release
 -

Modified: cfe/trunk/include/clang/Analysis/CFG.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=375318=375317=375318=diff
==
--- cfe/trunk/include/clang/Analysis/CFG.h (original)
+++ cfe/trunk/include/clang/Analysis/CFG.h Fri Oct 18 17:57:23 2019
@@ -1213,6 +1213,7 @@ public:
   virtual void compareAlwaysTrue(const BinaryOperator *B, bool isAlwaysTrue) {}
   virtual void compareBitwiseEquality(const BinaryOperator *B,
   bool isAlwaysTrue) {}
+  virtual void compareBitwiseOr(const BinaryOperator *B) {}
 };
 
 /// Represents a source-level, intra-procedural CFG that represents the

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=375318=375317=375318=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Oct 18 17:57:23 2019
@@ -516,12 +516,14 @@ def TautologicalConstantCompare : DiagGr
 [TautologicalOutOfRangeCompare]>;
 def TautologicalPointerCompare : DiagGroup<"tautological-pointer-compare">;
 def TautologicalOverlapCompare : DiagGroup<"tautological-overlap-compare">;
+def TautologicalBitwiseCompare : DiagGroup<"tautological-bitwise-compare">;
 def TautologicalUndefinedCompare : DiagGroup<"tautological-undefined-compare">;
 def TautologicalObjCBoolCompare : DiagGroup<"tautological-objc-bool-compare">;
 def TautologicalCompare : DiagGroup<"tautological-compare",
 [TautologicalConstantCompare,
  TautologicalPointerCompare,
  TautologicalOverlapCompare,
+ TautologicalBitwiseCompare,
  TautologicalUndefinedCompare,
  TautologicalObjCBoolCompare]>;
 def HeaderHygiene : DiagGroup<"header-hygiene">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=375318=375317=375318=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Oct 18 17:57:23 
2019
@@ -8332,7 +8332,10 @@ def warn_comparison_always : Warning<
   InGroup;
 def warn_comparison_bitwise_always 

r373421 - Revert r368237 - Update fix-it hints for std::move warnings.

2019-10-01 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Oct  1 19:32:15 2019
New Revision: 373421

URL: http://llvm.org/viewvc/llvm-project?rev=373421=rev
Log:
Revert r368237 - Update fix-it hints for std::move warnings.

r368237 attempted to improve fix-its for move warnings, but introduced some
regressions to -Wpessimizing-move.  Revert that change and add the missing
test cases to the pessimizing move test to prevent future regressions.

Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/SemaCXX/warn-pessmizing-move.cpp
cfe/trunk/test/SemaCXX/warn-redundant-move.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=373421=373420=373421=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Oct  1 19:32:15 2019
@@ -7580,34 +7580,27 @@ static void CheckMoveOnConstruction(Sema
   if (!DestType->isRecordType())
 return;
 
-  const CXXConstructExpr *CCE =
-  dyn_cast(InitExpr->IgnoreParens());
-  if (!CCE || CCE->getNumArgs() != 1)
-return;
+  unsigned DiagID = 0;
+  if (IsReturnStmt) {
+const CXXConstructExpr *CCE =
+dyn_cast(InitExpr->IgnoreParens());
+if (!CCE || CCE->getNumArgs() != 1)
+  return;
 
-  if (!CCE->getConstructor()->isCopyOrMoveConstructor())
-return;
+if (!CCE->getConstructor()->isCopyOrMoveConstructor())
+  return;
 
-  InitExpr = CCE->getArg(0)->IgnoreImpCasts();
+InitExpr = CCE->getArg(0)->IgnoreImpCasts();
+  }
 
   // Find the std::move call and get the argument.
   const CallExpr *CE = dyn_cast(InitExpr->IgnoreParens());
   if (!CE || !CE->isCallToStdMove())
 return;
 
-  const Expr *Arg = CE->getArg(0);
-
-  unsigned DiagID = 0;
-
-  if (!IsReturnStmt && !isa(Arg))
-return;
+  const Expr *Arg = CE->getArg(0)->IgnoreImplicit();
 
-  if (isa(Arg)) {
-DiagID = diag::warn_pessimizing_move_on_initialization;
-const Expr *ArgStripped = Arg->IgnoreImplicit()->IgnoreParens();
-if (!ArgStripped->isRValue() || !ArgStripped->getType()->isRecordType())
-  return;
-  } else { // IsReturnStmt
+  if (IsReturnStmt) {
 const DeclRefExpr *DRE = dyn_cast(Arg->IgnoreParenImpCasts());
 if (!DRE || DRE->refersToEnclosingVariableOrCapture())
   return;
@@ -7634,18 +7627,24 @@ static void CheckMoveOnConstruction(Sema
   DiagID = diag::warn_redundant_move_on_return;
 else
   DiagID = diag::warn_pessimizing_move_on_return;
+  } else {
+DiagID = diag::warn_pessimizing_move_on_initialization;
+const Expr *ArgStripped = Arg->IgnoreImplicit()->IgnoreParens();
+if (!ArgStripped->isRValue() || !ArgStripped->getType()->isRecordType())
+  return;
   }
 
   S.Diag(CE->getBeginLoc(), DiagID);
 
   // Get all the locations for a fix-it.  Don't emit the fix-it if any location
   // is within a macro.
-  SourceLocation BeginLoc = CCE->getBeginLoc();
-  if (BeginLoc.isMacroID())
+  SourceLocation CallBegin = CE->getCallee()->getBeginLoc();
+  if (CallBegin.isMacroID())
 return;
   SourceLocation RParen = CE->getRParenLoc();
   if (RParen.isMacroID())
 return;
+  SourceLocation LParen;
   SourceLocation ArgLoc = Arg->getBeginLoc();
 
   // Special testing for the argument location.  Since the fix-it needs the
@@ -7656,16 +7655,14 @@ static void CheckMoveOnConstruction(Sema
 ArgLoc = 
S.getSourceManager().getImmediateExpansionRange(ArgLoc).getBegin();
   }
 
-  SourceLocation LParen = ArgLoc.getLocWithOffset(-1);
   if (LParen.isMacroID())
 return;
-  SourceLocation EndLoc = CCE->getEndLoc();
-  if (EndLoc.isMacroID())
-return;
+
+  LParen = ArgLoc.getLocWithOffset(-1);
 
   S.Diag(CE->getBeginLoc(), diag::note_remove_move)
-  << FixItHint::CreateRemoval(SourceRange(BeginLoc, LParen))
-  << FixItHint::CreateRemoval(SourceRange(RParen, EndLoc));
+  << FixItHint::CreateRemoval(SourceRange(CallBegin, LParen))
+  << FixItHint::CreateRemoval(SourceRange(RParen, RParen));
 }
 
 static void CheckForNullPointerDereference(Sema , const Expr *E) {

Modified: cfe/trunk/test/SemaCXX/warn-pessmizing-move.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-pessmizing-move.cpp?rev=373421=373420=373421=diff
==
--- cfe/trunk/test/SemaCXX/warn-pessmizing-move.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-pessmizing-move.cpp Tue Oct  1 19:32:15 2019
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -Wpessimizing-move -std=c++11 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wpessimizing-move -std=c++11 -verify %s 
-DUSER_DEFINED
 // RUN: %clang_cc1 -fsyntax-only -Wpessimizing-move -std=c++11 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 // definitions for std::move
@@ -12,7 +13,15 @@ template  typename remove_refer
 }
 }
 
-struct A {};
+struct A {
+#ifdef USER_DEFINED
+  A() {}
+  A(const A &) {}
+  A(A &&) {}
+  A 

r372454 - Fix bad APInt compare.

2019-09-20 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Sep 20 21:18:54 2019
New Revision: 372454

URL: http://llvm.org/viewvc/llvm-project?rev=372454=rev
Log:
Fix bad APInt compare.

APInt comparison require both to have the same bitwidth.  Since only the value
is needed, use the compare function APInt::isSameValue instead.

Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/test/SemaCXX/self-comparison.cpp

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=372454=372453=372454=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Fri Sep 20 21:18:54 2019
@@ -3983,7 +3983,8 @@ bool Expr::isSameComparisonOperand(const
 const auto Integer1 = dyn_cast(Idx1);
 const auto Integer2 = dyn_cast(Idx2);
 if (Integer1 && Integer2) {
-  if (Integer1->getValue() != Integer2->getValue())
+  if (!llvm::APInt::isSameValue(Integer1->getValue(),
+Integer2->getValue()))
 return false;
 } else {
   if (!isSameComparisonOperand(Idx1, Idx2))

Modified: cfe/trunk/test/SemaCXX/self-comparison.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/self-comparison.cpp?rev=372454=372453=372454=diff
==
--- cfe/trunk/test/SemaCXX/self-comparison.cpp (original)
+++ cfe/trunk/test/SemaCXX/self-comparison.cpp Fri Sep 20 21:18:54 2019
@@ -86,6 +86,7 @@ int struct_test(S s1, S s2, S *s3, T t)
   return s3->field == s3->field;  // expected-warning {{self-comparison always 
evaluates to true}}
   return s3->static_field == S::static_field;  // expected-warning 
{{self-comparison always evaluates to true}}
   return s1.array[0] == s1.array[0];  // expected-warning {{self-comparison 
always evaluates to true}}
+  return s1.array[0] == s1.array[0ull];  // expected-warning {{self-comparison 
always evaluates to true}}
   return s1.array[I1] == s1.array[I1];  // expected-warning {{self-comparison 
always evaluates to true}}
   return s1.array[s2.array[0]] == s1.array[s2.array[0]];  // expected-warning 
{{self-comparison always evaluates to true}}
   return s3->array[t.field] == s3->array[t.field];  // expected-warning 
{{self-comparison always evaluates to true}}


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


r372453 - Merge and improve code that detects same value in comparisons.

2019-09-20 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Sep 20 20:02:26 2019
New Revision: 372453

URL: http://llvm.org/viewvc/llvm-project?rev=372453=rev
Log:
Merge and improve code that detects same value in comparisons.

-Wtautological-overlap-compare and self-comparison from -Wtautological-compare
relay on detecting the same operand in different locations.  Previously, each
warning had it's own operand checker.  Now, both are merged together into
one function that each can call.  The function also now looks through member
access and array accesses.

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

Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Analysis/array-struct-region.cpp
cfe/trunk/test/Sema/warn-overlap.c
cfe/trunk/test/SemaCXX/compare-cxx2a.cpp
cfe/trunk/test/SemaCXX/self-comparison.cpp

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=372453=372452=372453=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Fri Sep 20 20:02:26 2019
@@ -53,6 +53,9 @@ Improvements to Clang's diagnostics
 
 - -Wtautological-overlap-compare will warn on negative numbers and non-int
   types.
+- -Wtautological-compare for self comparisons and
+  -Wtautological-overlap-compare will now look through member and array
+  access to determine if two operand expressions are the same.
 
 Non-comprehensive list of changes in this release
 -

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=372453=372452=372453=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Fri Sep 20 20:02:26 2019
@@ -906,6 +906,11 @@ public:
 return skipRValueSubobjectAdjustments(CommaLHSs, Adjustments);
   }
 
+  /// Checks that the two Expr's will refer to the same value as a comparison
+  /// operand.  The caller must ensure that the values referenced by the Expr's
+  /// are not modified between E1 and E2 or the result my be invalid.
+  static bool isSameComparisonOperand(const Expr* E1, const Expr* E2);
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() >= firstExprConstant &&
T->getStmtClass() <= lastExprConstant;

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=372453=372452=372453=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Fri Sep 20 20:02:26 2019
@@ -3921,6 +3921,111 @@ bool Expr::refersToGlobalRegisterVar() c
   return false;
 }
 
+bool Expr::isSameComparisonOperand(const Expr* E1, const Expr* E2) {
+  E1 = E1->IgnoreParens();
+  E2 = E2->IgnoreParens();
+
+  if (E1->getStmtClass() != E2->getStmtClass())
+return false;
+
+  switch (E1->getStmtClass()) {
+default:
+  return false;
+case CXXThisExprClass:
+  return true;
+case DeclRefExprClass: {
+  // DeclRefExpr without an ImplicitCastExpr can happen for integral
+  // template parameters.
+  const auto *DRE1 = cast(E1);
+  const auto *DRE2 = cast(E2);
+  return DRE1->isRValue() && DRE2->isRValue() &&
+ DRE1->getDecl() == DRE2->getDecl();
+}
+case ImplicitCastExprClass: {
+  // Peel off implicit casts.
+  while (true) {
+const auto *ICE1 = dyn_cast(E1);
+const auto *ICE2 = dyn_cast(E2);
+if (!ICE1 || !ICE2)
+  return false;
+if (ICE1->getCastKind() != ICE2->getCastKind())
+  return false;
+E1 = ICE1->getSubExpr()->IgnoreParens();
+E2 = ICE2->getSubExpr()->IgnoreParens();
+// The final cast must be one of these types.
+if (ICE1->getCastKind() == CK_LValueToRValue ||
+ICE1->getCastKind() == CK_ArrayToPointerDecay ||
+ICE1->getCastKind() == CK_FunctionToPointerDecay) {
+  break;
+}
+  }
+
+  const auto *DRE1 = dyn_cast(E1);
+  const auto *DRE2 = dyn_cast(E2);
+  if (DRE1 && DRE2)
+return declaresSameEntity(DRE1->getDecl(), DRE2->getDecl());
+
+  const auto *Ivar1 = dyn_cast(E1);
+  const auto *Ivar2 = dyn_cast(E2);
+  if (Ivar1 && Ivar2) {
+return Ivar1->isFreeIvar() && Ivar2->isFreeIvar() &&
+   declaresSameEntity(Ivar1->getDecl(), Ivar2->getDecl());
+  }
+
+  const auto *Array1 = dyn_cast(E1);
+  const auto *Array2 = dyn_cast(E2);
+  if (Array1 && Array2) {
+if (!isSameComparisonOperand(Array1->getBase(), Array2->getBase()))
+  return false;
+

r372448 - Improve -Wtautological-overlap-compare

2019-09-20 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Sep 20 19:37:10 2019
New Revision: 372448

URL: http://llvm.org/viewvc/llvm-project?rev=372448=rev
Log:
Improve -Wtautological-overlap-compare

Allow this warning to detect a larger number of constant values, including
negative numbers, and handle non-int types better.

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

Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/lib/Analysis/ReachableCode.cpp
cfe/trunk/test/Analysis/cfg.cpp
cfe/trunk/test/Sema/warn-overlap.c
cfe/trunk/test/Sema/warn-unreachable.c
cfe/trunk/test/SemaCXX/warn-unreachable.cpp

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=372448=372447=372448=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Fri Sep 20 19:37:10 2019
@@ -51,7 +51,8 @@ Major New Features
 Improvements to Clang's diagnostics
 ^^^
 
-- ...
+- -Wtautological-overlap-compare will warn on negative numbers and non-int
+  types.
 
 Non-comprehensive list of changes in this release
 -

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=372448=372447=372448=diff
==
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Fri Sep 20 19:37:10 2019
@@ -70,11 +70,35 @@ static SourceLocation GetEndLoc(Decl *D)
   return D->getLocation();
 }
 
+/// Returns true on constant values based around a single IntegerLiteral.
+/// Allow for use of parentheses, integer casts, and negative signs.
+static bool IsIntegerLiteralConstantExpr(const Expr *E) {
+  // Allow parentheses
+  E = E->IgnoreParens();
+
+  // Allow conversions to different integer kind.
+  if (const auto *CE = dyn_cast(E)) {
+if (CE->getCastKind() != CK_IntegralCast)
+  return false;
+E = CE->getSubExpr();
+  }
+
+  // Allow negative numbers.
+  if (const auto *UO = dyn_cast(E)) {
+if (UO->getOpcode() != UO_Minus)
+  return false;
+E = UO->getSubExpr();
+  }
+
+  return isa(E);
+}
+
 /// Helper for tryNormalizeBinaryOperator. Attempts to extract an 
IntegerLiteral
-/// or EnumConstantDecl from the given Expr. If it fails, returns nullptr.
+/// constant expression or EnumConstantDecl from the given Expr. If it fails,
+/// returns nullptr.
 static const Expr *tryTransformToIntOrEnumConstant(const Expr *E) {
   E = E->IgnoreParens();
-  if (isa(E))
+  if (IsIntegerLiteralConstantExpr(E))
 return E;
   if (auto *DR = dyn_cast(E->IgnoreParenImpCasts()))
 return isa(DR->getDecl()) ? DR : nullptr;
@@ -121,11 +145,11 @@ tryNormalizeBinaryOperator(const BinaryO
 static bool areExprTypesCompatible(const Expr *E1, const Expr *E2) {
   // User intent isn't clear if they're mixing int literals with enum
   // constants.
-  if (isa(E1) != isa(E2))
+  if (isa(E1) != isa(E2))
 return false;
 
   // Integer literal comparisons, regardless of literal type, are acceptable.
-  if (isa(E1))
+  if (!isa(E1))
 return true;
 
   // IntegerLiterals are handled above and only EnumConstantDecls are expected
@@ -1081,6 +1105,10 @@ private:
 // * Variable x is equal to the largest literal.
 // * Variable x is greater than largest literal.
 bool AlwaysTrue = true, AlwaysFalse = true;
+// Track value of both subexpressions.  If either side is always
+// true/false, another warning should have already been emitted.
+bool LHSAlwaysTrue = true, LHSAlwaysFalse = true;
+bool RHSAlwaysTrue = true, RHSAlwaysFalse = true;
 for (const llvm::APSInt  : Values) {
   TryResult Res1, Res2;
   Res1 = analyzeLogicOperatorCondition(BO1, Value, L1);
@@ -1096,10 +1124,16 @@ private:
 AlwaysTrue &= (Res1.isTrue() || Res2.isTrue());
 AlwaysFalse &= !(Res1.isTrue() || Res2.isTrue());
   }
+
+  LHSAlwaysTrue &= Res1.isTrue();
+  LHSAlwaysFalse &= Res1.isFalse();
+  RHSAlwaysTrue &= Res2.isTrue();
+  RHSAlwaysFalse &= Res2.isFalse();
 }
 
 if (AlwaysTrue || AlwaysFalse) {
-  if (BuildOpts.Observer)
+  if (!LHSAlwaysTrue && !LHSAlwaysFalse && !RHSAlwaysTrue &&
+  !RHSAlwaysFalse && BuildOpts.Observer)
 BuildOpts.Observer->compareAlwaysTrue(B, AlwaysTrue);
   return TryResult(AlwaysTrue);
 }

Modified: cfe/trunk/lib/Analysis/ReachableCode.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ReachableCode.cpp?rev=372448=372447=372448=diff
==
--- cfe/trunk/lib/Analysis/ReachableCode.cpp (original)
+++ cfe/trunk/lib/Analysis/ReachableCode.cpp Fri Sep 20 19:37:10 2019
@@ -247,7 +247,7 @@ static bool 

[clang-tools-extra] r369316 - Fix typo. "piont" => "point"

2019-08-19 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Mon Aug 19 17:28:21 2019
New Revision: 369316

URL: http://llvm.org/viewvc/llvm-project?rev=369316=rev
Log:
Fix typo.  "piont" => "point"

Found by Chris Morris (cwmorris).

Modified:
clang-tools-extra/trunk/clang-tidy/abseil/DurationConversionCastCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/abseil-duration-conversion-cast.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/abseil/DurationConversionCastCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationConversionCastCheck.cpp?rev=369316=369315=369316=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationConversionCastCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationConversionCastCheck.cpp 
Mon Aug 19 17:28:21 2019
@@ -70,7 +70,7 @@ void DurationConversionCastCheck::check(
 llvm::StringRef NewFuncName = getDurationInverseForScale(*Scale).first;
 
 diag(MatchedCast->getBeginLoc(), "duration should be converted directly to 
"
- "a floating-piont number rather than "
+ "a floating-point number rather than "
  "through a type cast")
 << FixItHint::CreateReplacement(
MatchedCast->getSourceRange(),

Modified: 
clang-tools-extra/trunk/test/clang-tidy/abseil-duration-conversion-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/abseil-duration-conversion-cast.cpp?rev=369316=369315=369316=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/abseil-duration-conversion-cast.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/abseil-duration-conversion-cast.cpp 
Mon Aug 19 17:28:21 2019
@@ -11,37 +11,37 @@ void f() {
   // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted 
directly to an integer rather than through a type cast 
[abseil-duration-conversion-cast]
   // CHECK-FIXES: absl::ToInt64Hours(d1);
   x = static_cast(absl::ToInt64Hours(d1));
-  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted 
directly to a floating-piont number rather than through a type cast 
[abseil-duration-conversion-cast]
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted 
directly to a floating-point number rather than through a type cast 
[abseil-duration-conversion-cast]
   // CHECK-FIXES: absl::ToDoubleHours(d1);
   i = static_cast(absl::ToDoubleMinutes(d1));
   // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted 
directly to an integer rather than through a type cast 
[abseil-duration-conversion-cast]
   // CHECK-FIXES: absl::ToInt64Minutes(d1);
   x = static_cast(absl::ToInt64Minutes(d1));
-  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted 
directly to a floating-piont number rather than through a type cast 
[abseil-duration-conversion-cast]
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted 
directly to a floating-point number rather than through a type cast 
[abseil-duration-conversion-cast]
   // CHECK-FIXES: absl::ToDoubleMinutes(d1);
   i = static_cast(absl::ToDoubleSeconds(d1));
   // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted 
directly to an integer rather than through a type cast 
[abseil-duration-conversion-cast]
   // CHECK-FIXES: absl::ToInt64Seconds(d1);
   x = static_cast(absl::ToInt64Seconds(d1));
-  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted 
directly to a floating-piont number rather than through a type cast 
[abseil-duration-conversion-cast]
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted 
directly to a floating-point number rather than through a type cast 
[abseil-duration-conversion-cast]
   // CHECK-FIXES: absl::ToDoubleSeconds(d1);
   i = static_cast(absl::ToDoubleMilliseconds(d1));
   // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted 
directly to an integer rather than through a type cast 
[abseil-duration-conversion-cast]
   // CHECK-FIXES: absl::ToInt64Milliseconds(d1);
   x = static_cast(absl::ToInt64Milliseconds(d1));
-  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted 
directly to a floating-piont number rather than through a type cast 
[abseil-duration-conversion-cast]
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted 
directly to a floating-point number rather than through a type cast 
[abseil-duration-conversion-cast]
   // CHECK-FIXES: absl::ToDoubleMilliseconds(d1);
   i = static_cast(absl::ToDoubleMicroseconds(d1));
   // CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted 
directly to an integer rather than through a type cast 
[abseil-duration-conversion-cast]
   // CHECK-FIXES: 

r368244 - Inline diagnostic text into .td file. NFC.

2019-08-07 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Aug  7 18:45:31 2019
New Revision: 368244

URL: http://llvm.org/viewvc/llvm-project?rev=368244=rev
Log:
Inline diagnostic text into .td file.  NFC.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=368244=368243=368244=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Aug  7 18:45:31 
2019
@@ -8150,7 +8150,8 @@ def warn_unsupported_lifetime_extension
 // should result in a warning, since these always evaluate to a constant.
 // Array comparisons have similar warnings
 def warn_comparison_always : Warning<
-  "%select{self-|array }0comparison always evaluates to %select{a 
constant|%2}1">,
+  "%select{self-|array }0comparison always evaluates to "
+  "%select{a constant|true|false|'std::strong_ordering::equal'}1">,
   InGroup;
 def warn_comparison_bitwise_always : Warning<
   "bitwise comparison always evaluates to %select{false|true}0">,

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=368244=368243=368244=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Aug  7 18:45:31 2019
@@ -10174,45 +10174,55 @@ static void diagnoseTautologicalComparis
   // result.
   ValueDecl *DL = getCompareDecl(LHSStripped);
   ValueDecl *DR = getCompareDecl(RHSStripped);
+
+  // Used for indexing into %select in warn_comparison_always
+  enum {
+AlwaysConstant,
+AlwaysTrue,
+AlwaysFalse,
+AlwaysEqual, // std::strong_ordering::equal from operator<=>
+  };
   if (DL && DR && declaresSameEntity(DL, DR)) {
-StringRef Result;
+unsigned Result;
 switch (Opc) {
 case BO_EQ: case BO_LE: case BO_GE:
-  Result = "true";
+  Result = AlwaysTrue;
   break;
 case BO_NE: case BO_LT: case BO_GT:
-  Result = "false";
+  Result = AlwaysFalse;
   break;
 case BO_Cmp:
-  Result = "'std::strong_ordering::equal'";
+  Result = AlwaysEqual;
   break;
 default:
+  Result = AlwaysConstant;
   break;
 }
 S.DiagRuntimeBehavior(Loc, nullptr,
   S.PDiag(diag::warn_comparison_always)
-  << 0 /*self-comparison*/ << !Result.empty()
+  << 0 /*self-comparison*/
   << Result);
   } else if (DL && DR &&
  DL->getType()->isArrayType() && DR->getType()->isArrayType() &&
  !DL->isWeak() && !DR->isWeak()) {
 // What is it always going to evaluate to?
-StringRef Result;
+unsigned Result;
 switch(Opc) {
 case BO_EQ: // e.g. array1 == array2
-  Result = "false";
+  Result = AlwaysFalse;
   break;
 case BO_NE: // e.g. array1 != array2
-  Result = "true";
+  Result = AlwaysTrue;
   break;
 default: // e.g. array1 <= array2
   // The best we can say is 'a constant'
+  Result = AlwaysConstant;
   break;
 }
 S.DiagRuntimeBehavior(Loc, nullptr,
   S.PDiag(diag::warn_comparison_always)
   << 1 /*array comparison*/
-  << !Result.empty() << Result);
+  << Result);
   }
 
   if (isa(LHSStripped))


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


r368237 - Update fix-it hints for std::move warnings.

2019-08-07 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Aug  7 17:12:51 2019
New Revision: 368237

URL: http://llvm.org/viewvc/llvm-project?rev=368237=rev
Log:
Update fix-it hints for std::move warnings.

Fix -Wpessimizing-move and -Wredundant-move when warning on initializer lists.
The new fix-it hints for removing the std::move call will now also suggest
removing the braces for the initializer list so that the resulting code will
still be compilable.

This fixes PR42832

Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/SemaCXX/warn-pessmizing-move.cpp
cfe/trunk/test/SemaCXX/warn-redundant-move.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=368237=368236=368237=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Wed Aug  7 17:12:51 2019
@@ -7305,27 +7305,34 @@ static void CheckMoveOnConstruction(Sema
   if (!DestType->isRecordType())
 return;
 
-  unsigned DiagID = 0;
-  if (IsReturnStmt) {
-const CXXConstructExpr *CCE =
-dyn_cast(InitExpr->IgnoreParens());
-if (!CCE || CCE->getNumArgs() != 1)
-  return;
+  const CXXConstructExpr *CCE =
+  dyn_cast(InitExpr->IgnoreParens());
+  if (!CCE || CCE->getNumArgs() != 1)
+return;
 
-if (!CCE->getConstructor()->isCopyOrMoveConstructor())
-  return;
+  if (!CCE->getConstructor()->isCopyOrMoveConstructor())
+return;
 
-InitExpr = CCE->getArg(0)->IgnoreImpCasts();
-  }
+  InitExpr = CCE->getArg(0)->IgnoreImpCasts();
 
   // Find the std::move call and get the argument.
   const CallExpr *CE = dyn_cast(InitExpr->IgnoreParens());
   if (!CE || !CE->isCallToStdMove())
 return;
 
-  const Expr *Arg = CE->getArg(0)->IgnoreImplicit();
+  const Expr *Arg = CE->getArg(0);
+
+  unsigned DiagID = 0;
+
+  if (!IsReturnStmt && !isa(Arg))
+return;
 
-  if (IsReturnStmt) {
+  if (isa(Arg)) {
+DiagID = diag::warn_pessimizing_move_on_initialization;
+const Expr *ArgStripped = Arg->IgnoreImplicit()->IgnoreParens();
+if (!ArgStripped->isRValue() || !ArgStripped->getType()->isRecordType())
+  return;
+  } else { // IsReturnStmt
 const DeclRefExpr *DRE = dyn_cast(Arg->IgnoreParenImpCasts());
 if (!DRE || DRE->refersToEnclosingVariableOrCapture())
   return;
@@ -7352,24 +7359,18 @@ static void CheckMoveOnConstruction(Sema
   DiagID = diag::warn_redundant_move_on_return;
 else
   DiagID = diag::warn_pessimizing_move_on_return;
-  } else {
-DiagID = diag::warn_pessimizing_move_on_initialization;
-const Expr *ArgStripped = Arg->IgnoreImplicit()->IgnoreParens();
-if (!ArgStripped->isRValue() || !ArgStripped->getType()->isRecordType())
-  return;
   }
 
   S.Diag(CE->getBeginLoc(), DiagID);
 
   // Get all the locations for a fix-it.  Don't emit the fix-it if any location
   // is within a macro.
-  SourceLocation CallBegin = CE->getCallee()->getBeginLoc();
-  if (CallBegin.isMacroID())
+  SourceLocation BeginLoc = CCE->getBeginLoc();
+  if (BeginLoc.isMacroID())
 return;
   SourceLocation RParen = CE->getRParenLoc();
   if (RParen.isMacroID())
 return;
-  SourceLocation LParen;
   SourceLocation ArgLoc = Arg->getBeginLoc();
 
   // Special testing for the argument location.  Since the fix-it needs the
@@ -7380,14 +7381,16 @@ static void CheckMoveOnConstruction(Sema
 ArgLoc = 
S.getSourceManager().getImmediateExpansionRange(ArgLoc).getBegin();
   }
 
+  SourceLocation LParen = ArgLoc.getLocWithOffset(-1);
   if (LParen.isMacroID())
 return;
-
-  LParen = ArgLoc.getLocWithOffset(-1);
+  SourceLocation EndLoc = CCE->getEndLoc();
+  if (EndLoc.isMacroID())
+return;
 
   S.Diag(CE->getBeginLoc(), diag::note_remove_move)
-  << FixItHint::CreateRemoval(SourceRange(CallBegin, LParen))
-  << FixItHint::CreateRemoval(SourceRange(RParen, RParen));
+  << FixItHint::CreateRemoval(SourceRange(BeginLoc, LParen))
+  << FixItHint::CreateRemoval(SourceRange(RParen, EndLoc));
 }
 
 static void CheckForNullPointerDereference(Sema , const Expr *E) {

Modified: cfe/trunk/test/SemaCXX/warn-pessmizing-move.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-pessmizing-move.cpp?rev=368237=368236=368237=diff
==
--- cfe/trunk/test/SemaCXX/warn-pessmizing-move.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-pessmizing-move.cpp Wed Aug  7 17:12:51 2019
@@ -122,13 +122,13 @@ A test7() {
   A a3 = (std::move(A()));
   // expected-warning@-1{{prevents copy elision}}
   // expected-note@-2{{remove std::move call}}
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:11-[[@LINE-3]]:21}:""
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:24-[[@LINE-4]]:25}:""
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:21}:""
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:24-[[@LINE-4]]:26}:""
   A a4 = (std::move((A(;
   // 

Re: LLVM Types

2019-08-06 Thread Richard Trieu via cfe-commits
To avoid confusion, there's both a LLVM Type and a Clang Type.  The LLVM
Type is used in the LLVM IR while the Clang Type represents types in a
language, like C++.

The Clang Doxygen pages have this hierarchy, although it's truncated
because Type is so large, but you can click through to get the missing
nodes.  It's available at:
https://clang.llvm.org/doxygen/classclang_1_1Type.html

There's also "clang/AST/TypeNode.def" which has the Type classes available
as macro calls.  You define the macros, include the file, then the
preprocessor will do all the work of filling in hierarchy.  You can see
this in action by how Type fills up an enum:

class alignas(8) Type : public ExtQualsTypeCommonBase {
public:
  enum TypeClass {
#define TYPE(Class, Base) Class,
#define LAST_TYPE(Class) TypeLast = Class,
#define ABSTRACT_TYPE(Class, Base)
#include "clang/AST/TypeNodes.def"
TagFirst = Record, TagLast = Enum
  };

On Tue, Aug 6, 2019 at 8:15 AM Monalisa Rout via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hello,
> Can I dump LLVM Type hierarchies somehow ??
>
> Types which are declared in this file ("clang/AST/Type.h
> "  )
>
> Regards,
> Mona
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r365727 - Increase the number of parser diagnostics.

2019-07-10 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Jul 10 19:54:15 2019
New Revision: 365727

URL: http://llvm.org/viewvc/llvm-project?rev=365727=rev
Log:
Increase the number of parser diagnostics.

The reserved range for parser diagnostics is getting close to being filled,
so increase the space for them.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticIDs.h

Modified: cfe/trunk/include/clang/Basic/DiagnosticIDs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticIDs.h?rev=365727=365726=365727=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticIDs.h (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h Wed Jul 10 19:54:15 2019
@@ -32,7 +32,7 @@ namespace clang {
   DIAG_SIZE_FRONTEND  =  150,
   DIAG_SIZE_SERIALIZATION =  120,
   DIAG_SIZE_LEX   =  400,
-  DIAG_SIZE_PARSE =  500,
+  DIAG_SIZE_PARSE =  600,
   DIAG_SIZE_AST   =  200,
   DIAG_SIZE_COMMENT   =  100,
   DIAG_SIZE_CROSSTU   =  100,


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


r364119 - [ODRHash] Skip some typedef types.

2019-06-21 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Jun 21 17:32:19 2019
New Revision: 364119

URL: http://llvm.org/viewvc/llvm-project?rev=364119=rev
Log:
[ODRHash] Skip some typedef types.

In some cases, a typedef only strips aways a keyword for a type, keeping the
same name as the root record type.  This causes some confusion when the type
is defined in one modules but only forward declared in another.  Skipping the
typedef and going straight to the record will avoid this issue.

typedef struct S {} S;
S* s;  // S is TypedefType here

struct S;
S* s;  // S is RecordType here

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=364119=364118=364119=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Jun 21 17:32:19 2019
@@ -696,7 +696,52 @@ public:
 ID.AddInteger(Quals.getAsOpaqueValue());
   }
 
+  // Return the RecordType if the typedef only strips away a keyword.
+  // Otherwise, return the original type.
+  static const Type *RemoveTypedef(const Type *T) {
+const auto *TypedefT = dyn_cast(T);
+if (!TypedefT) {
+  return T;
+}
+
+const TypedefNameDecl *D = TypedefT->getDecl();
+QualType UnderlyingType = D->getUnderlyingType();
+
+if (UnderlyingType.hasLocalQualifiers()) {
+  return T;
+}
+
+const auto *ElaboratedT = dyn_cast(UnderlyingType);
+if (!ElaboratedT) {
+  return T;
+}
+
+if (ElaboratedT->getQualifier() != nullptr) {
+  return T;
+}
+
+QualType NamedType = ElaboratedT->getNamedType();
+if (NamedType.hasLocalQualifiers()) {
+  return T;
+}
+
+const auto *RecordT = dyn_cast(NamedType);
+if (!RecordT) {
+  return T;
+}
+
+const IdentifierInfo *TypedefII = TypedefT->getDecl()->getIdentifier();
+const IdentifierInfo *RecordII = RecordT->getDecl()->getIdentifier();
+if (!TypedefII || !RecordII ||
+TypedefII->getName() != RecordII->getName()) {
+  return T;
+}
+
+return RecordT;
+  }
+
   void Visit(const Type *T) {
+T = RemoveTypedef(T);
 ID.AddInteger(T->getTypeClass());
 Inherited::Visit(T);
   }

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=364119=364118=364119=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri Jun 21 17:32:19 2019
@@ -4621,9 +4621,70 @@ struct S2 {
 #else
 S2 s2;
 #endif
-
 }
 
+namespace TypedefStruct {
+#if defined(FIRST)
+struct T1;
+class S1 {
+  T1* t;
+};
+#elif defined(SECOND)
+typedef struct T1 {} T1;
+class S1 {
+  T1* t;
+};
+#else
+S1 s1;
+#endif
+
+#if defined(FIRST)
+struct T2;
+class S2 {
+  const T2* t = nullptr;
+};
+#elif defined(SECOND)
+typedef struct T2 {} T2;
+class S2 {
+  const T2* t = nullptr;
+};
+#else
+S2 s2;
+#endif
+
+#if defined(FIRST)
+struct T3;
+class S3 {
+  T3* const t = nullptr;
+};
+#elif defined(SECOND)
+typedef struct T3 {} T3;
+class S3 {
+  T3* const t = nullptr;
+};
+#else
+S3 s3;
+#endif
+
+#if defined(FIRST)
+namespace NS4 {
+struct T4;
+} // namespace NS4
+class S4 {
+  NS4::T4* t = 0;
+};
+#elif defined(SECOND)
+namespace NS4 {
+typedef struct T4 {} T4;
+} // namespace NS4
+class S4 {
+  NS4::T4* t = 0;
+};
+#else
+S4 s4;
+#endif
+} // namespace TypedefStruct
+
 // Keep macros contained to one file.
 #ifdef FIRST
 #undef FIRST


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


r362187 - Redirect test output to /dev/null

2019-05-30 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Thu May 30 19:23:33 2019
New Revision: 362187

URL: http://llvm.org/viewvc/llvm-project?rev=362187=rev
Log:
Redirect test output to /dev/null

Modified:
cfe/trunk/test/Driver/armv8.1m.main.s

Modified: cfe/trunk/test/Driver/armv8.1m.main.s
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/armv8.1m.main.s?rev=362187=362186=362187=diff
==
--- cfe/trunk/test/Driver/armv8.1m.main.s (original)
+++ cfe/trunk/test/Driver/armv8.1m.main.s Thu May 30 19:23:33 2019
@@ -1,13 +1,13 @@
 # REQUIRES: arm-registered-target
-# RUN: not %clang -c -target arm-none-none-eabi -march=armv8-m.main %s 2>%t
+# RUN: not %clang -c -target arm-none-none-eabi -march=armv8-m.main -o 
/dev/null %s 2>%t
 # RUN:  FileCheck --check-prefix=ERROR-V8M < %t %s
-# RUN: not %clang -c -target arm-none-none-eabi -march=armv8.1-m.main %s 2>%t
+# RUN: not %clang -c -target arm-none-none-eabi -march=armv8.1-m.main -o 
/dev/null %s 2>%t
 # RUN:  FileCheck --check-prefix=ERROR-V81M < %t %s
-# RUN: not %clang -c -target arm-none-none-eabi -march=armv8.1-m.main+dsp %s 
2>%t
+# RUN: not %clang -c -target arm-none-none-eabi -march=armv8.1-m.main+dsp -o 
/dev/null %s 2>%t
 # RUN:  FileCheck --check-prefix=ERROR-V81M_DSP < %t %s
-# RUN: not %clang -c -target arm-none-none-eabi -march=armv8.1-m.main+mve %s 
2>%t
+# RUN: not %clang -c -target arm-none-none-eabi -march=armv8.1-m.main+mve -o 
/dev/null %s 2>%t
 # RUN:  FileCheck --check-prefix=ERROR-V81M_MVE < %t %s
-# RUN: not %clang -c -target arm-none-none-eabi -march=armv8.1-m.main+mve.fp 
%s 2>%t
+# RUN: not %clang -c -target arm-none-none-eabi -march=armv8.1-m.main+mve.fp 
-o /dev/null %s 2>%t
 # RUN:  FileCheck --check-prefix=ERROR-V81M_MVEFP < %t %s
 
 .syntax unified


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


Re: r359960 - Reduce amount of work ODR hashing does.

2019-05-07 Thread Richard Trieu via cfe-commits
*From: *David Blaikie 
*Date: *Mon, May 6, 2019 at 4:39 PM
*To: *Richard Trieu
*Cc: *cfe-commits

On Mon, May 6, 2019 at 4:24 PM Richard Trieu  wrote:
> >
> > There was no cycle for this crash.
>
> Oh, yeah, didn't mean to imply there were - but that a system designed
> to prevent cycles might also be used/help prevent redundant work like
> this.
>
> > What happened is that an exponential runtime is reduced to a linear
> runtime.  Without this revision, ODR hashing would have worked if the
> machine had enough memory and the user waited long enough.
> >
> > void foo(int a, int b) {}
> > When computing the ODR hash for function foo, it will visit the type int
> twice, once per parameter.  In general, re-visiting types shouldn't be a
> problem, and in most cases, should be pretty fast.
>
> It does mean some potentially problematic worst-case situations where
> non-trivial types are mentioned more than once (eg: if, instead of
> int, it was a complex struct type - it wouldn't cycle, but it would do
> all that work twice (or many more times if it appears in more places
> in the entity being hashed)
>

See below in the answer to DWARF.  ODRHash did have a system, it worked for
a while until it didn't, and was since removed.

>
> > class S {
> >   void bar(S* s);
> > };
> > There's actually two ways to visit the Decl behind S,
> ODR::AddCXXRecordDecl and ODR::AddDecl.  When computing the ODR hash of S,
> ODR::AddCXXRecordDecl is used for a deep dive into the AST of S.  When
> reaching S another way, (via FunctionDecl bar, parameter s, PointerType S*,
> RecordType S), then the CXXRecordDecl gets processed through ODR::AddDecl,
> which only processes enough information to identify S, but not any of its
> deeper details.  This allows self-reference without introducing cycles.
>
> Ah, OK - specifically to break the cycle.
>
> So the ODR hash of the function "void f(S*)" doesn't hash the
> implementation of S, (it uses AddDecl, not AddCXXRecordDecl)? But if
> it were "void f(S)" it would hash S? What about a member function that
> takes a parameter by value? ("struct S { void bar(S); }")
>

The three functions AddCXXRecordDecl, AddFunctionDecl, and AddEnumDecl are
the entry points from outside to use the ODRHash and nothing inside ODRHash
will call these functions.  That means hashing "class S {};"
AddCXXRecordDecl is called with S.  Every other example, "void f(S)", "void
bar(S);", etc will be called into AddDecl.  The next question is probably,
how do you know if two functions "void f(S)" in two files refer to same
class S?  The answer is, ODRHash doesn't know and doesn't care.  But when
Clang imports both "void f(S)" functions, it will also import both S
classes.  Since Clang checks, ODRHash doesn't need to.

>
> > I think it would be possible to add some checks in debug mode to catch
> cycles.  I'm not sure it can detect redundant work as the function foo
> example above shows that visiting the same types over multiple times is
> expected.
>
> Both for efficiency and to avoid these cycles, it might be worthwhile
> to consider a different way to resolve this issue
>
> The reason these ideas come to my mind is that DWARF has a type hash
> that works in a different way to avoid cycles and redundant work.
>
> http://dwarfstd.org/doc/DWARF5.pdf - 7.32, Type Signature Computation.
> It works by assigning every type a number when it's first encountered
> (even before its contents are hashed), and if it's ever encountered
> again, hash the number again rather than going back into hashing the
> implementation.
>
> Originally, ODR hashing did have a system similar to what DWARF had.
Relevant portions of 7.32 are 1, 4.a, and 4.b.  Basically, maintain a list
of Type's, when first visiting a Type, add it to the list and process it,
and if the Type is ever seen again, use the index number instead
reprocessing.  Worked well, and then the AST had a small change in it where
now we needed two different Type's to hash to the same thing.
https://reviews.llvm.org/rL335853 ripped this out.  It's possible to
replace it, but it needs to be better than what we currently have.


> This way no type is hashed more than once, avoiding cycles and redundant
> work.
>
> >
> >
> >
> > From: David Blaikie 
> > Date: Sat, May 4, 2019 at 9:06 AM
> > To: Richard Trieu
> > Cc: cfe-commits
> >
> >> Does the ODR hashing have some sort of cycle breaking infrastructure -
> >> so that if the same type is seen more than once (eg: classes have
> >> members that have pointers back to the outer class type, etc) they
> >> don't cause indefinite cycles? Should that infrastructure 

Re: r359960 - Reduce amount of work ODR hashing does.

2019-05-06 Thread Richard Trieu via cfe-commits
There was no cycle for this crash.  What happened is that an exponential
runtime is reduced to a linear runtime.  Without this revision, ODR hashing
would have worked if the machine had enough memory and the user waited long
enough.

void foo(int a, int b) {}
When computing the ODR hash for function foo, it will visit the type int
twice, once per parameter.  In general, re-visiting types shouldn't be a
problem, and in most cases, should be pretty fast.

class S {
  void bar(S* s);
};
There's actually two ways to visit the Decl behind S, ODR::AddCXXRecordDecl
and ODR::AddDecl.  When computing the ODR hash of S, ODR::AddCXXRecordDecl
is used for a deep dive into the AST of S.  When reaching S another way,
(via FunctionDecl bar, parameter s, PointerType S*, RecordType S), then the
CXXRecordDecl gets processed through ODR::AddDecl, which only processes
enough information to identify S, but not any of its deeper details.  This
allows self-reference without introducing cycles.

I think it would be possible to add some checks in debug mode to catch
cycles.  I'm not sure it can detect redundant work as the function foo
example above shows that visiting the same types over multiple times is
expected.



*From: *David Blaikie 
*Date: *Sat, May 4, 2019 at 9:06 AM
*To: *Richard Trieu
*Cc: *cfe-commits

Does the ODR hashing have some sort of cycle breaking infrastructure -
> so that if the same type is seen more than once (eg: classes have
> members that have pointers back to the outer class type, etc) they
> don't cause indefinite cycles? Should that infrastructure have caught
> these cases & avoided the redundant work?
>
> I'm curious to understand better how these things work/overlap/or don't.
>
> On Fri, May 3, 2019 at 9:20 PM Richard Trieu via cfe-commits
>  wrote:
> >
> > Author: rtrieu
> > Date: Fri May  3 21:22:33 2019
> > New Revision: 359960
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=359960=rev
> > Log:
> > Reduce amount of work ODR hashing does.
> >
> > When a FunctionProtoType is in the original type in a DecayedType, the
> decayed
> > type is a PointerType which points back the original FunctionProtoType.
> The
> > visitor for ODRHashing will attempt to process both Type's, doing double
> work.
> > By chaining together multiple DecayedType's and FunctionProtoType's,
> this would
> > result in 2^N Type's visited only N DecayedType's and N
> FunctionProtoType's
> > exsit.  Another bug where VisitDecayedType and VisitAdjustedType did
> > redundant work doubled the work at each level, giving 4^N Type's
> visited.  This
> > patch removed the double work and detects when a FunctionProtoType
> decays to
> > itself to only check the Type once.  This lowers the exponential runtime
> to
> > linear runtime.  Fixes https://bugs.llvm.org/show_bug.cgi?id=41625
> >
> > Modified:
> > cfe/trunk/lib/AST/ODRHash.cpp
> > cfe/trunk/test/Modules/odr_hash.cpp
> >
> > Modified: cfe/trunk/lib/AST/ODRHash.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=359960=359959=359960=diff
> >
> ==
> > --- cfe/trunk/lib/AST/ODRHash.cpp (original)
> > +++ cfe/trunk/lib/AST/ODRHash.cpp Fri May  3 21:22:33 2019
> > @@ -703,14 +703,36 @@ public:
> >void VisitType(const Type *T) {}
> >
> >void VisitAdjustedType(const AdjustedType *T) {
> > -AddQualType(T->getOriginalType());
> > -AddQualType(T->getAdjustedType());
> > +QualType Original = T->getOriginalType();
> > +QualType Adjusted = T->getAdjustedType();
> > +
> > +// The original type and pointee type can be the same, as in the
> case of
> > +// function pointers decaying to themselves.  Set a bool and only
> process
> > +// the type once, to prevent doubling the work.
> > +SplitQualType split = Adjusted.split();
> > +if (auto Pointer = dyn_cast(split.Ty)) {
> > +  if (Pointer->getPointeeType() == Original) {
> > +Hash.AddBoolean(true);
> > +ID.AddInteger(split.Quals.getAsOpaqueValue());
> > +AddQualType(Original);
> > +VisitType(T);
> > +return;
> > +  }
> > +}
> > +
> > +// The original type and pointee type are different, such as in the
> case
> > +// of a array decaying to an element pointer.  Set a bool to false
> and
> > +// process both types.
> > +Hash.AddBoolean(false);
> > +AddQualType(Original);
> > +AddQualType(Adjusted);
> > +
> >  VisitType(T);
> >}
> >
> >void Vi

r359960 - Reduce amount of work ODR hashing does.

2019-05-03 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri May  3 21:22:33 2019
New Revision: 359960

URL: http://llvm.org/viewvc/llvm-project?rev=359960=rev
Log:
Reduce amount of work ODR hashing does.

When a FunctionProtoType is in the original type in a DecayedType, the decayed
type is a PointerType which points back the original FunctionProtoType.  The
visitor for ODRHashing will attempt to process both Type's, doing double work.
By chaining together multiple DecayedType's and FunctionProtoType's, this would
result in 2^N Type's visited only N DecayedType's and N FunctionProtoType's
exsit.  Another bug where VisitDecayedType and VisitAdjustedType did
redundant work doubled the work at each level, giving 4^N Type's visited.  This
patch removed the double work and detects when a FunctionProtoType decays to
itself to only check the Type once.  This lowers the exponential runtime to
linear runtime.  Fixes https://bugs.llvm.org/show_bug.cgi?id=41625

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=359960=359959=359960=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri May  3 21:22:33 2019
@@ -703,14 +703,36 @@ public:
   void VisitType(const Type *T) {}
 
   void VisitAdjustedType(const AdjustedType *T) {
-AddQualType(T->getOriginalType());
-AddQualType(T->getAdjustedType());
+QualType Original = T->getOriginalType();
+QualType Adjusted = T->getAdjustedType();
+
+// The original type and pointee type can be the same, as in the case of
+// function pointers decaying to themselves.  Set a bool and only process
+// the type once, to prevent doubling the work.
+SplitQualType split = Adjusted.split();
+if (auto Pointer = dyn_cast(split.Ty)) {
+  if (Pointer->getPointeeType() == Original) {
+Hash.AddBoolean(true);
+ID.AddInteger(split.Quals.getAsOpaqueValue());
+AddQualType(Original);
+VisitType(T);
+return;
+  }
+}
+
+// The original type and pointee type are different, such as in the case
+// of a array decaying to an element pointer.  Set a bool to false and
+// process both types.
+Hash.AddBoolean(false);
+AddQualType(Original);
+AddQualType(Adjusted);
+
 VisitType(T);
   }
 
   void VisitDecayedType(const DecayedType *T) {
-AddQualType(T->getDecayedType());
-AddQualType(T->getPointeeType());
+// getDecayedType and getPointeeType are derived from getAdjustedType
+// and don't need to be separately processed.
 VisitAdjustedType(T);
   }
 

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=359960=359959=359960=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri May  3 21:22:33 2019
@@ -4587,6 +4587,43 @@ int num = bar();
 #endif
 }
 
+namespace FunctionProtoTypeDecay {
+#if defined(FIRST)
+struct S1 {
+  struct X {};
+  using Y = X(X());
+};
+#elif defined(SECOND)
+struct S1 {
+  struct X {};
+  using Y = X(X(X()));
+};
+#else
+S1 s1;
+// expected-error@first.h:* {{'FunctionProtoTypeDecay::S1::Y' from module 
'FirstModule' is not present in definition of 'FunctionProtoTypeDecay::S1' in 
module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'Y' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S2 {
+  struct X {};
+  using Y =
+  X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(
+  X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(
+  X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(
+  X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(
+  
+  
+  
+  ;
+};
+#elif defined(SECOND)
+#else
+S2 s2;
+#endif
+
+}
+
 // Keep macros contained to one file.
 #ifdef FIRST
 #undef FIRST


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


r359740 - Consume unexpected "template" keywords after "using"

2019-05-01 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed May  1 16:33:49 2019
New Revision: 359740

URL: http://llvm.org/viewvc/llvm-project?rev=359740=rev
Log:
Consume unexpected "template" keywords after "using"

The parser was dealing with unexpected "template" keywords after "using"
keywords too late and putting the parser into the wrong state, which could
lead to a crash down the line.  This change allows the parser to consume the
bad "template" keywords earlier, and continue parsing as if "template" was
never there to begin with for better error recovery.

Added:
cfe/trunk/test/Parser/using-template.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseDeclCXX.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=359740=359739=359740=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Wed May  1 16:33:49 
2019
@@ -683,6 +683,8 @@ def err_id_after_template_in_nested_name
   "expected template name after 'template' keyword in nested name specifier">;
 def err_unexpected_template_in_unqualified_id : Error<
   "'template' keyword not permitted here">;
+def err_unexpected_template_after_using : Error<
+  "'template' keyword not permitted after 'using' keyword">;
 def err_two_right_angle_brackets_need_space : Error<
   "a space is required between consecutive right angle brackets (use '> >')">;
 def err_right_angle_bracket_equal_needs_space : Error<

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=359740=359739=359740=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Wed May  1 16:33:49 2019
@@ -474,6 +474,13 @@ Parser::ParseUsingDirectiveOrDeclaration
 return nullptr;
   }
 
+  // Consume unexpected 'template' keywords.
+  while (Tok.is(tok::kw_template)) {
+SourceLocation TemplateLoc = ConsumeToken();
+Diag(TemplateLoc, diag::err_unexpected_template_after_using)
+<< FixItHint::CreateRemoval(TemplateLoc);
+  }
+
   // 'using namespace' means this is a using-directive.
   if (Tok.is(tok::kw_namespace)) {
 // Template parameters are always an error here.
@@ -2542,6 +2549,13 @@ Parser::ParseCXXClassMemberDeclaration(A
 // Eat 'using'.
 SourceLocation UsingLoc = ConsumeToken();
 
+// Consume unexpected 'template' keywords.
+while (Tok.is(tok::kw_template)) {
+  SourceLocation TemplateLoc = ConsumeToken();
+  Diag(TemplateLoc, diag::err_unexpected_template_after_using)
+  << FixItHint::CreateRemoval(TemplateLoc);
+}
+
 if (Tok.is(tok::kw_namespace)) {
   Diag(UsingLoc, diag::err_using_namespace_in_class);
   SkipUntil(tok::semi, StopBeforeMatch);

Added: cfe/trunk/test/Parser/using-template.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/using-template.cpp?rev=359740=auto
==
--- cfe/trunk/test/Parser/using-template.cpp (added)
+++ cfe/trunk/test/Parser/using-template.cpp Wed May  1 16:33:49 2019
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 %s -verify
+
+namespace N1 {
+template 
+struct Foo {
+  template 
+  struct Bar {
+static constexpr bool is_present = false;
+  };
+};
+
+template 
+struct Foo : public Foo {
+  using template Foo::Bar;
+  // expected-error@-1 {{'template' keyword not permitted after 'using' 
keyword}}
+};
+}
+
+namespace N2 {
+namespace foo {
+  using I = int;
+}
+using template namespace foo;
+// expected-error@-1 {{'template' keyword not permitted after 'using' keyword}}
+using template template namespace foo;
+// expected-error@-1 2{{'template' keyword not permitted after 'using' 
keyword}}
+I i;
+}
+
+namespace N3 {
+namespace foo {
+  using I = int;
+}
+using template foo::I;
+// expected-error@-1 {{'template' keyword not permitted after 'using' keyword}}
+I i;
+}
+
+namespace N4 {
+template 
+class A {};
+
+template 
+using B = A;
+B b;
+
+using template  C = A;
+// expected-error@-1 {{'template' keyword not permitted after 'using' keyword}}
+// expected-error@-2 {{expected unqualified-id}}
+C c;
+// expected-error@-1 {{no template named 'C'}}
+}


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


r356231 - Remove an assert in template pack deduction during nested instantiation.

2019-03-14 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Thu Mar 14 21:26:02 2019
New Revision: 356231

URL: http://llvm.org/viewvc/llvm-project?rev=356231=rev
Log:
Remove an assert in template pack deduction during nested instantiation.

Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaTemplate/pack-deduction.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=356231=356230=356231=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Thu Mar 14 21:26:02 2019
@@ -3804,25 +3804,25 @@ static bool addInstantiatedParametersToS
 Scope.MakeInstantiatedLocalArgPack(PatternParam);
 Optional NumArgumentsInExpansion
   = S.getNumArgumentsInExpansion(PatternParam->getType(), TemplateArgs);
-assert(NumArgumentsInExpansion &&
-   "should only be called when all template arguments are known");
-QualType PatternType =
-PatternParam->getType()->castAs()->getPattern();
-for (unsigned Arg = 0; Arg < *NumArgumentsInExpansion; ++Arg) {
-  ParmVarDecl *FunctionParam = Function->getParamDecl(FParamIdx);
-  FunctionParam->setDeclName(PatternParam->getDeclName());
-  if (!PatternDecl->getType()->isDependentType()) {
-Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(S, Arg);
-QualType T = S.SubstType(PatternType, TemplateArgs,
- FunctionParam->getLocation(),
- FunctionParam->getDeclName());
-if (T.isNull())
-  return true;
-FunctionParam->setType(T);
-  }
+if (NumArgumentsInExpansion) {
+  QualType PatternType =
+  PatternParam->getType()->castAs()->getPattern();
+  for (unsigned Arg = 0; Arg < *NumArgumentsInExpansion; ++Arg) {
+ParmVarDecl *FunctionParam = Function->getParamDecl(FParamIdx);
+FunctionParam->setDeclName(PatternParam->getDeclName());
+if (!PatternDecl->getType()->isDependentType()) {
+  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(S, Arg);
+  QualType T = S.SubstType(PatternType, TemplateArgs,
+   FunctionParam->getLocation(),
+   FunctionParam->getDeclName());
+  if (T.isNull())
+return true;
+  FunctionParam->setType(T);
+}
 
-  Scope.InstantiatedLocalPackArg(PatternParam, FunctionParam);
-  ++FParamIdx;
+Scope.InstantiatedLocalPackArg(PatternParam, FunctionParam);
+++FParamIdx;
+  }
 }
   }
 

Modified: cfe/trunk/test/SemaTemplate/pack-deduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/pack-deduction.cpp?rev=356231=356230=356231=diff
==
--- cfe/trunk/test/SemaTemplate/pack-deduction.cpp (original)
+++ cfe/trunk/test/SemaTemplate/pack-deduction.cpp Thu Mar 14 21:26:02 2019
@@ -166,3 +166,22 @@ namespace substitution_vs_function_deduc
 A().g(f); // expected-error {{no match}}
   }
 }
+
+namespace Nested_Explicit_Specialization {
+template 
+struct Outer {
+
+  template 
+  struct Inner;
+
+  template <>
+  struct Inner<0> {
+template 
+void Test(Args...) {}
+  };
+};
+
+void Run() {
+  Outer::Inner<0>().Test(1,1);
+}
+}


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


r350913 - Fix header issues.

2019-01-10 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Thu Jan 10 17:32:35 2019
New Revision: 350913

URL: http://llvm.org/viewvc/llvm-project?rev=350913=rev
Log:
Fix header issues.

Several headers would fail to compile if other headers were not previously
included.  The usual issue is that a class is forward declared, but the
full definition is needed.  The requirement for the definition is use of
isa/dyn_cast or calling functions of pointer-packed data types such as
DenseMap or PointerIntPair.  Add missing includes to these headers.

SVals.h required an out-of-line method definition in the .cpp file to avoid
circular inclusion of headers with BasicValueFactory.h

Modified:
cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h
cfe/trunk/include/clang/AST/BaseSubobject.h
cfe/trunk/include/clang/AST/Mangle.h
cfe/trunk/include/clang/AST/TemplateName.h
cfe/trunk/include/clang/Analysis/ConstructionContext.h
cfe/trunk/include/clang/Lex/PreprocessingRecord.h
cfe/trunk/include/clang/Sema/Scope.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
cfe/trunk/lib/CodeGen/CGOpenCLRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/VarBypassDetector.h
cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp

Modified: cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h?rev=350913=350912=350913=diff
==
--- cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h (original)
+++ cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h Thu Jan 10 17:32:35 
2019
@@ -15,6 +15,7 @@
 #ifndef LLVM_CLANG_AST_ASTSTRUCTURALEQUIVALENCE_H
 #define LLVM_CLANG_AST_ASTSTRUCTURALEQUIVALENCE_H
 
+#include "clang/AST/DeclBase.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/Optional.h"

Modified: cfe/trunk/include/clang/AST/BaseSubobject.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/BaseSubobject.h?rev=350913=350912=350913=diff
==
--- cfe/trunk/include/clang/AST/BaseSubobject.h (original)
+++ cfe/trunk/include/clang/AST/BaseSubobject.h Thu Jan 10 17:32:35 2019
@@ -15,6 +15,7 @@
 #define LLVM_CLANG_AST_BASESUBOBJECT_H
 
 #include "clang/AST/CharUnits.h"
+#include "clang/AST/DeclCXX.h"
 #include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/Support/type_traits.h"
 #include 

Modified: cfe/trunk/include/clang/AST/Mangle.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Mangle.h?rev=350913=350912=350913=diff
==
--- cfe/trunk/include/clang/AST/Mangle.h (original)
+++ cfe/trunk/include/clang/AST/Mangle.h Thu Jan 10 17:32:35 2019
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_AST_MANGLE_H
 #define LLVM_CLANG_AST_MANGLE_H
 
+#include "clang/AST/Decl.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/ABI.h"
 #include "llvm/ADT/DenseMap.h"

Modified: cfe/trunk/include/clang/AST/TemplateName.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TemplateName.h?rev=350913=350912=350913=diff
==
--- cfe/trunk/include/clang/AST/TemplateName.h (original)
+++ cfe/trunk/include/clang/AST/TemplateName.h Thu Jan 10 17:32:35 2019
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_AST_TEMPLATENAME_H
 #define LLVM_CLANG_AST_TEMPLATENAME_H
 
+#include "clang/AST/NestedNameSpecifier.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/PointerIntPair.h"

Modified: cfe/trunk/include/clang/Analysis/ConstructionContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/ConstructionContext.h?rev=350913=350912=350913=diff
==
--- cfe/trunk/include/clang/Analysis/ConstructionContext.h (original)
+++ cfe/trunk/include/clang/Analysis/ConstructionContext.h Thu Jan 10 17:32:35 
2019
@@ -19,6 +19,7 @@
 
 #include "clang/Analysis/Support/BumpVector.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/ExprObjC.h"
 
 namespace clang {
 

Modified: cfe/trunk/include/clang/Lex/PreprocessingRecord.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessingRecord.h?rev=350913=350912=350913=diff
==
--- cfe/trunk/include/clang/Lex/PreprocessingRecord.h (original)
+++ cfe/trunk/include/clang/Lex/PreprocessingRecord.h Thu Jan 10 17:32:35 2019
@@ -15,6 +15,7 @@
 #ifndef LLVM_CLANG_LEX_PREPROCESSINGRECORD_H
 #define LLVM_CLANG_LEX_PREPROCESSINGRECORD_H
 
+#include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 

[clang-tools-extra] r350797 - Remove unnecessary include.

2019-01-09 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Jan  9 20:53:10 2019
New Revision: 350797

URL: http://llvm.org/viewvc/llvm-project?rev=350797=rev
Log:
Remove unnecessary include.

QuerySession.h does not need anything from Query.h, so it does not need to
include it.

Modified:
clang-tools-extra/trunk/clang-query/QuerySession.h

Modified: clang-tools-extra/trunk/clang-query/QuerySession.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/QuerySession.h?rev=350797=350796=350797=diff
==
--- clang-tools-extra/trunk/clang-query/QuerySession.h (original)
+++ clang-tools-extra/trunk/clang-query/QuerySession.h Wed Jan  9 20:53:10 2019
@@ -10,7 +10,6 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_SESSION_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_SESSION_H
 
-#include "Query.h"
 #include "clang/ASTMatchers/Dynamic/VariantValue.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringMap.h"


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


r350792 - Refactor declarations of ASTContext allocate functions into its own header.

2019-01-09 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Jan  9 19:23:25 2019
New Revision: 350792

URL: http://llvm.org/viewvc/llvm-project?rev=350792=rev
Log:
Refactor declarations of ASTContext allocate functions into its own header.

Forward declarations of the allocate functions combine with the forward
declaration of the ASTContext class is enough information for some headers
without pulling in ASTContext.h in its entirety.  Pull the existing
declarations from AttrIterator.h into a new header.  Also place the default
alignment size into this header.  Previously, new had its default in
AttrIterator.h while new[] had its default in ASTContext.h.  Add new header
includes where it is needed.  Specifically to ASTVector.h to make it a
standalone header, unlike previously which it was standalone as long as
none of its functions were called.

Added:
cfe/trunk/include/clang/AST/ASTContextAllocate.h
  - copied, changed from r350683, cfe/trunk/include/clang/AST/AttrIterator.h
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/ASTVector.h
cfe/trunk/include/clang/AST/Attr.h
cfe/trunk/include/clang/AST/AttrIterator.h
cfe/trunk/include/clang/AST/Decl.h

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=350792=350791=350792=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed Jan  9 19:23:25 2019
@@ -15,6 +15,7 @@
 #ifndef LLVM_CLANG_AST_ASTCONTEXT_H
 #define LLVM_CLANG_AST_ASTCONTEXT_H
 
+#include "clang/AST/ASTContextAllocate.h"
 #include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/CanonicalType.h"
 #include "clang/AST/CommentCommandTraits.h"
@@ -2969,8 +2970,8 @@ inline Selector GetUnarySelector(StringR
 /// This placement form of operator new uses the ASTContext's allocator for
 /// obtaining memory.
 ///
-/// IMPORTANT: These are also declared in clang/AST/AttrIterator.h! Any changes
-/// here need to also be made there.
+/// IMPORTANT: These are also declared in clang/AST/ASTContextAllocate.h!
+/// Any changes here need to also be made there.
 ///
 /// We intentionally avoid using a nothrow specification here so that the calls
 /// to this operator will not perform a null check on the result -- the
@@ -2993,7 +2994,7 @@ inline Selector GetUnarySelector(StringR
 ///  allocator supports it).
 /// @return The allocated memory. Could be nullptr.
 inline void *operator new(size_t Bytes, const clang::ASTContext ,
-  size_t Alignment) {
+  size_t Alignment /* = 8 */) {
   return C.Allocate(Bytes, Alignment);
 }
 
@@ -3031,7 +3032,7 @@ inline void operator delete(void *Ptr, c
 ///  allocator supports it).
 /// @return The allocated memory. Could be nullptr.
 inline void *operator new[](size_t Bytes, const clang::ASTContext& C,
-size_t Alignment = 8) {
+size_t Alignment /* = 8 */) {
   return C.Allocate(Bytes, Alignment);
 }
 

Copied: cfe/trunk/include/clang/AST/ASTContextAllocate.h (from r350683, 
cfe/trunk/include/clang/AST/AttrIterator.h)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContextAllocate.h?p2=cfe/trunk/include/clang/AST/ASTContextAllocate.h=cfe/trunk/include/clang/AST/AttrIterator.h=350683=350792=350792=diff
==
--- cfe/trunk/include/clang/AST/AttrIterator.h (original)
+++ cfe/trunk/include/clang/AST/ASTContextAllocate.h Wed Jan  9 19:23:25 2019
@@ -1,4 +1,4 @@
-//===- AttrIterator.h - Classes for attribute iteration -*- C++ 
-*-===//
+//===- ASTContextAllocate.h - ASTContext allocate functions -*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -7,35 +7,27 @@
 //
 
//===--===//
 //
-//  This file defines the Attr vector and specific_attr_iterator interfaces.
+//  This file declares ASTContext allocation functions separate from the main
+//  code in ASTContext.h.
 //
 
//===--===//
 
-#ifndef LLVM_CLANG_AST_ATTRITERATOR_H
-#define LLVM_CLANG_AST_ATTRITERATOR_H
+#ifndef LLVM_CLANG_AST_ASTCONTEXTALLOCATE_H
+#define LLVM_CLANG_AST_ASTCONTEXTALLOCATE_H
 
-#include "clang/Basic/LLVM.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/Casting.h"
-#include 
 #include 
-#include 
 
 namespace clang {
 
 class ASTContext;
-class Attr;
 
 } // namespace clang
 
 // Defined in ASTContext.h
 void *operator new(size_t Bytes, const clang::ASTContext ,
size_t Alignment = 8);
-
-// FIXME: Being forced to not have a default argument here due to redeclaration
-//rules on default arguments sucks
 void *operator new[](size_t 

Re: r350143 - Add vtable anchor to classes.

2019-01-04 Thread Richard Trieu via cfe-commits
This was a cleanup before some other refactoring I wanted to do, but that
refactoring has been put on hold for a bit, so I committed this change to
improve the codebase a little and not have to redo it later.

On Mon, Dec 31, 2018 at 4:50 PM David Blaikie  wrote:

> While I realize it's in the coding standard - is there any particular
> other motivation for this? (Given you've been doing layering cleanup - I'm
> wondering fi this is an interesting workaround for some layering problems,
> for instance?)
>
> On Sat, Dec 29, 2018 at 1:05 PM Richard Trieu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rtrieu
>> Date: Fri Dec 28 18:02:30 2018
>> New Revision: 350143
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=350143=rev
>> Log:
>> Add vtable anchor to classes.
>>
>> Modified:
>> cfe/trunk/include/clang/AST/DeclCXX.h
>> cfe/trunk/include/clang/AST/DeclTemplate.h
>> cfe/trunk/include/clang/Lex/ModuleMap.h
>> cfe/trunk/lib/AST/DeclCXX.cpp
>> cfe/trunk/lib/AST/DeclTemplate.cpp
>> cfe/trunk/lib/Lex/ModuleMap.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=350143=350142=350143=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
>> +++ cfe/trunk/include/clang/AST/DeclCXX.h Fri Dec 28 18:02:30 2018
>> @@ -3918,6 +3918,7 @@ class MSPropertyDecl : public Declarator
>>: DeclaratorDecl(MSProperty, DC, L, N, T, TInfo, StartL),
>>  GetterId(Getter), SetterId(Setter) {}
>>
>> +  void anchor() override;
>>  public:
>>friend class ASTDeclReader;
>>
>>
>> Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=350143=350142=350143=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
>> +++ cfe/trunk/include/clang/AST/DeclTemplate.h Fri Dec 28 18:02:30 2018
>> @@ -751,6 +751,7 @@ class RedeclarableTemplateDecl : public
>>  return getMostRecentDecl();
>>}
>>
>> +  void anchor() override;
>>  protected:
>>template  struct SpecEntryTraits {
>>  using DeclType = EntryType;
>>
>> Modified: cfe/trunk/include/clang/Lex/ModuleMap.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=350143=350142=350143=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Lex/ModuleMap.h (original)
>> +++ cfe/trunk/include/clang/Lex/ModuleMap.h Fri Dec 28 18:02:30 2018
>> @@ -45,6 +45,8 @@ class SourceManager;
>>  /// A mechanism to observe the actions of the module map parser as it
>>  /// reads module map files.
>>  class ModuleMapCallbacks {
>> +  virtual void anchor();
>> +
>>  public:
>>virtual ~ModuleMapCallbacks() = default;
>>
>>
>> Modified: cfe/trunk/lib/AST/DeclCXX.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=350143=350142=350143=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/DeclCXX.cpp (original)
>> +++ cfe/trunk/lib/AST/DeclCXX.cpp Fri Dec 28 18:02:30 2018
>> @@ -2910,6 +2910,8 @@ void DecompositionDecl::printName(llvm::
>>os << ']';
>>  }
>>
>> +void MSPropertyDecl::anchor() {}
>> +
>>  MSPropertyDecl *MSPropertyDecl::Create(ASTContext , DeclContext *DC,
>> SourceLocation L, DeclarationName
>> N,
>> QualType T, TypeSourceInfo *TInfo,
>>
>> Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=350143=350142=350143=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
>> +++ cfe/trunk/lib/AST/DeclTemplate.cpp Fri Dec 28 18:02:30 2018
>> @@ -149,6 +149,8 @@ void *allocateDefaultArgStorageChain(con
>>  // RedeclarableTemplateDecl Implementation
>>
>>  
>> //===--===//
>>
>> +void RedeclarableTemplateDecl::anchor() {}
>> +
>>  Redeclara

r350143 - Add vtable anchor to classes.

2018-12-28 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Dec 28 18:02:30 2018
New Revision: 350143

URL: http://llvm.org/viewvc/llvm-project?rev=350143=rev
Log:
Add vtable anchor to classes.

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/DeclTemplate.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=350143=350142=350143=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Fri Dec 28 18:02:30 2018
@@ -3918,6 +3918,7 @@ class MSPropertyDecl : public Declarator
   : DeclaratorDecl(MSProperty, DC, L, N, T, TInfo, StartL),
 GetterId(Getter), SetterId(Setter) {}
 
+  void anchor() override;
 public:
   friend class ASTDeclReader;
 

Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=350143=350142=350143=diff
==
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Fri Dec 28 18:02:30 2018
@@ -751,6 +751,7 @@ class RedeclarableTemplateDecl : public
 return getMostRecentDecl();
   }
 
+  void anchor() override;
 protected:
   template  struct SpecEntryTraits {
 using DeclType = EntryType;

Modified: cfe/trunk/include/clang/Lex/ModuleMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=350143=350142=350143=diff
==
--- cfe/trunk/include/clang/Lex/ModuleMap.h (original)
+++ cfe/trunk/include/clang/Lex/ModuleMap.h Fri Dec 28 18:02:30 2018
@@ -45,6 +45,8 @@ class SourceManager;
 /// A mechanism to observe the actions of the module map parser as it
 /// reads module map files.
 class ModuleMapCallbacks {
+  virtual void anchor();
+
 public:
   virtual ~ModuleMapCallbacks() = default;
 

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=350143=350142=350143=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Fri Dec 28 18:02:30 2018
@@ -2910,6 +2910,8 @@ void DecompositionDecl::printName(llvm::
   os << ']';
 }
 
+void MSPropertyDecl::anchor() {}
+
 MSPropertyDecl *MSPropertyDecl::Create(ASTContext , DeclContext *DC,
SourceLocation L, DeclarationName N,
QualType T, TypeSourceInfo *TInfo,

Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=350143=350142=350143=diff
==
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Fri Dec 28 18:02:30 2018
@@ -149,6 +149,8 @@ void *allocateDefaultArgStorageChain(con
 // RedeclarableTemplateDecl Implementation
 
//===--===//
 
+void RedeclarableTemplateDecl::anchor() {}
+
 RedeclarableTemplateDecl::CommonBase *RedeclarableTemplateDecl::getCommonPtr() 
const {
   if (Common)
 return Common;

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=350143=350142=350143=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Fri Dec 28 18:02:30 2018
@@ -54,6 +54,8 @@
 
 using namespace clang;
 
+void ModuleMapCallbacks::anchor() {}
+
 void ModuleMap::resolveLinkAsDependencies(Module *Mod) {
   auto PendingLinkAs = PendingLinkAsModule.find(Mod->Name);
   if (PendingLinkAs != PendingLinkAsModule.end()) {


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


r349237 - Fix includes and dependencies for libclang

2018-12-14 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Dec 14 20:25:19 2018
New Revision: 349237

URL: http://llvm.org/viewvc/llvm-project?rev=349237=rev
Log:
Fix includes and dependencies for libclang

Remove unneeded includes
Add needed include
Remove dependency on Serialization

Modified:
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
cfe/trunk/tools/libclang/CIndexDiagnostic.cpp
cfe/trunk/tools/libclang/CMakeLists.txt
cfe/trunk/tools/libclang/CXStoredDiagnostic.cpp

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=349237=349236=349237=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Dec 14 20:25:19 2018
@@ -31,14 +31,12 @@
 #include "clang/Basic/Version.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
-#include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Index/CodegenNameGenerator.h"
 #include "clang/Index/CommentToXML.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/PreprocessingRecord.h"
 #include "clang/Lex/Preprocessor.h"
-#include "clang/Serialization/SerializationDiagnostic.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringSwitch.h"

Modified: cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp?rev=349237=349236=349237=diff
==
--- cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp Fri Dec 14 20:25:19 2018
@@ -26,7 +26,6 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
-#include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "clang/Sema/Sema.h"
 #include "llvm/ADT/SmallString.h"

Modified: cfe/trunk/tools/libclang/CIndexDiagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexDiagnostic.cpp?rev=349237=349236=349237=diff
==
--- cfe/trunk/tools/libclang/CIndexDiagnostic.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexDiagnostic.cpp Fri Dec 14 20:25:19 2018
@@ -19,7 +19,6 @@
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Frontend/DiagnosticRenderer.h"
-#include "clang/Frontend/FrontendDiagnostic.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/raw_ostream.h"
 

Modified: cfe/trunk/tools/libclang/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CMakeLists.txt?rev=349237=349236=349237=diff
==
--- cfe/trunk/tools/libclang/CMakeLists.txt (original)
+++ cfe/trunk/tools/libclang/CMakeLists.txt Fri Dec 14 20:25:19 2018
@@ -40,7 +40,6 @@ set(LIBS
   clangIndex
   clangLex
   clangSema
-  clangSerialization
   clangTooling
 )
 

Modified: cfe/trunk/tools/libclang/CXStoredDiagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXStoredDiagnostic.cpp?rev=349237=349236=349237=diff
==
--- cfe/trunk/tools/libclang/CXStoredDiagnostic.cpp (original)
+++ cfe/trunk/tools/libclang/CXStoredDiagnostic.cpp Fri Dec 14 20:25:19 2018
@@ -17,8 +17,8 @@
 #include "CXSourceLocation.h"
 #include "CXString.h"
 
+#include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Frontend/ASTUnit.h"
-#include "clang/Frontend/FrontendDiagnostic.h"
 #include "llvm/ADT/Twine.h"
 
 using namespace clang;


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


r349230 - Move static analyzer core diagnostics to common.

2018-12-14 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Dec 14 18:30:16 2018
New Revision: 349230

URL: http://llvm.org/viewvc/llvm-project?rev=349230=rev
Log:
Move static analyzer core diagnostics to common.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=349230=349229=349230=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Fri Dec 14 18:30:16 
2018
@@ -290,4 +290,10 @@ def err_openclcxx_not_supported : Error<
 // OpenMP
 def err_omp_more_one_clause : Error<
   "directive '#pragma omp %0' cannot contain more than one '%1' 
clause%select{| with '%3' name modifier| with 'source' dependence}2">;
+
+// Static Analyzer Core
+def err_unknown_analyzer_checker : Error<
+"no analyzer checkers are associated with '%0'">;
+def note_suggest_disabling_all_checkers : Note<
+"use -analyzer-disable-all-checks to disable all static analyzer 
checkers">;
 }

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=349230=349229=349230=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Fri Dec 14 
18:30:16 2018
@@ -160,11 +160,6 @@ def warn_unknown_warning_specifier : War
 "unknown %0 warning specifier: '%1'">,
 InGroup;
 
-def err_unknown_analyzer_checker : Error<
-"no analyzer checkers are associated with '%0'">;
-def note_suggest_disabling_all_checkers : Note<
-"use -analyzer-disable-all-checks to disable all static analyzer 
checkers">;
-
 def warn_incompatible_analyzer_plugin_api : Warning<
 "checker plugin '%0' is not compatible with this version of the analyzer">,
 InGroup >;

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp?rev=349230=349229=349230=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CheckerRegistry.cpp Fri Dec 14 18:30:16 
2018
@@ -10,7 +10,6 @@
 #include "clang/StaticAnalyzer/Core/CheckerRegistry.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
 #include "llvm/ADT/STLExtras.h"


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


r349125 - Fix up diagnostics.

2018-12-13 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Thu Dec 13 19:35:10 2018
New Revision: 349125

URL: http://llvm.org/viewvc/llvm-project?rev=349125=rev
Log:
Fix up diagnostics.

Move some diagnostics around between Diagnostic*Kinds.td files.  Diagnostics
used in multiple places were moved to DiagnosticCommonKinds.td.  Diagnostics
listed in the wrong place (ie, Sema diagnostics listed in
DiagnosticsParseKinds.td) were moved to the correct places.  One diagnostic
split into two so that the diagnostic string is in the .td file instead of in
code.  Cleaned up the diagnostic includes after all the changes.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Basic/DiagnosticCrossTUKinds.td
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
cfe/trunk/lib/Frontend/DependencyFile.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td?rev=349125=349124=349125=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td Thu Dec 13 19:35:10 2018
@@ -314,4 +314,34 @@ def err_odr_non_type_parameter_type_inco
   "non-type template parameter declared with incompatible types in different "
   "translation units (%0 vs. %1)">;
 def err_unsupported_ast_node: Error<"cannot import unsupported AST node %0">;
+
+def remark_sanitize_address_insert_extra_padding_accepted : Remark<
+"-fsanitize-address-field-padding applied to %0">, ShowInSystemHeader,
+InGroup;
+def remark_sanitize_address_insert_extra_padding_rejected : Remark<
+"-fsanitize-address-field-padding ignored for %0 because it "
+"%select{is not C++|is packed|is a union|is trivially copyable|"
+"has trivial destructor|is standard layout|is in a blacklisted file|"
+"is blacklisted}1">, ShowInSystemHeader,
+InGroup;
+
+def warn_npot_ms_struct : Warning<
+  "ms_struct may not produce Microsoft-compatible layouts with fundamental "
+  "data types with sizes that aren't a power of two">,
+  DefaultError, InGroup;
+
+// -Wpadded, -Wpacked
+def warn_padded_struct_field : Warning<
+  "padding %select{struct|interface|class}0 %1 with %2 "
+  "%select{byte|bit}3%s2 to align %4">,
+  InGroup, DefaultIgnore;
+def warn_padded_struct_anon_field : Warning<
+  "padding %select{struct|interface|class}0 %1 with %2 "
+  "%select{byte|bit}3%s2 to align anonymous bit-field">,
+  InGroup, DefaultIgnore;
+def warn_padded_struct_size : Warning<
+  "padding size of %0 with %1 %select{byte|bit}2%s1 to alignment boundary">,
+  InGroup, DefaultIgnore;
+def warn_unnecessary_packed : Warning<
+  "packed attribute is unnecessary for %0">, InGroup, DefaultIgnore;
 }

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=349125=349124=349125=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Thu Dec 13 19:35:10 
2018
@@ -131,6 +131,36 @@ def err_nullability_conflicting : Error<
 
 }
 
+// OpenCL Section 6.8.g
+def err_opencl_unknown_type_specifier : Error<
+  "OpenCL %select{C|C++}0 version %1 does not support the '%2' "
+  "%select{type qualifier|storage class specifier}3">;
+
+def warn_unknown_attribute_ignored : Warning<
+  "unknown attribute %0 ignored">, InGroup;
+def err_use_of_tag_name_without_tag : Error<
+  "must use '%1' tag to refer to type %0%select{| in this scope}2">;
+
+def duplicate_declspec : TextSubstitution<
+  "duplicate '%0' declaration specifier">;
+
+def ext_duplicate_declspec : Extension<"%sub{duplicate_declspec}0">,
+  InGroup;
+def ext_warn_duplicate_declspec : ExtWarn<"%sub{duplicate_declspec}0">,
+  InGroup;
+def warn_duplicate_declspec : Warning<"%sub{duplicate_declspec}0">,
+  InGroup;
+
+def err_friend_decl_spec : Error<"'%0' is invalid in friend declarations">;
+
+def err_invalid_member_in_interface : Error<
+  "%select{data member |non-public member function |static member function |"
+  "user-declared constructor|user-declared destructor|operator |"
+  "nested class }0%1 is not permitted within an interface type">;
+
+def err_attribute_uuid_malformed_guid : Error<
+  "uuid attribute contains a malformed GUID">;
+
 // Sema && 

r348907 - Move PCHContainerOperations from Frontend to Serialization

2018-12-11 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Dec 11 18:53:59 2018
New Revision: 348907

URL: http://llvm.org/viewvc/llvm-project?rev=348907=rev
Log:
Move PCHContainerOperations from Frontend to Serialization

Fix a layering violation.  Frontend depends on Serialization, so anything used
by both should be in Serialization.

Added:
cfe/trunk/include/clang/Frontend/PCHContainerOperations.h
cfe/trunk/include/clang/Serialization/PCHContainerOperations.h
  - copied, changed from r348906, 
cfe/trunk/include/clang/Frontend/PCHContainerOperations.h
cfe/trunk/lib/Serialization/PCHContainerOperations.cpp
  - copied, changed from r348906, 
cfe/trunk/lib/Frontend/PCHContainerOperations.cpp
Removed:
cfe/trunk/lib/Frontend/PCHContainerOperations.cpp
Modified:
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/include/clang/module.modulemap
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CMakeLists.txt
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/CMakeLists.txt
cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp
cfe/trunk/lib/Serialization/ModuleManager.cpp

Added: cfe/trunk/include/clang/Frontend/PCHContainerOperations.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHContainerOperations.h?rev=348907=auto
==
--- cfe/trunk/include/clang/Frontend/PCHContainerOperations.h (added)
+++ cfe/trunk/include/clang/Frontend/PCHContainerOperations.h Tue Dec 11 
18:53:59 2018
@@ -0,0 +1,15 @@
+//===--- Frontend/PCHContainerOperations.h - PCH Containers -*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_PCH_CONTAINER_OPERATIONS_H
+#define LLVM_CLANG_PCH_CONTAINER_OPERATIONS_H
+
+#include "clang/Serialization/PCHContainerOperations.h"
+
+#endif

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=348907=348906=348907=diff
==
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Tue Dec 11 18:53:59 2018
@@ -26,10 +26,10 @@
 #include "clang/AST/TypeLoc.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Sema/SemaConsumer.h"
 #include "clang/Serialization/ASTBitCodes.h"
 #include "clang/Serialization/ASTDeserializationListener.h"
+#include "clang/Serialization/PCHContainerOperations.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"

Copied: cfe/trunk/include/clang/Serialization/PCHContainerOperations.h (from 
r348906, cfe/trunk/include/clang/Frontend/PCHContainerOperations.h)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/PCHContainerOperations.h?p2=cfe/trunk/include/clang/Serialization/PCHContainerOperations.h=cfe/trunk/include/clang/Frontend/PCHContainerOperations.h=348906=348907=348907=diff
==
--- cfe/trunk/include/clang/Frontend/PCHContainerOperations.h (original)
+++ cfe/trunk/include/clang/Serialization/PCHContainerOperations.h Tue Dec 11 
18:53:59 2018
@@ -1,4 +1,4 @@
-//===--- Frontend/PCHContainerOperations.h - PCH Containers -*- C++ 
-*-===//
+//===--- Serialization/PCHContainerOperations.h - PCH Containers --*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -7,8 +7,8 @@
 //
 
//===--===//
 
-#ifndef LLVM_CLANG_PCH_CONTAINER_OPERATIONS_H
-#define LLVM_CLANG_PCH_CONTAINER_OPERATIONS_H
+#ifndef LLVM_CLANG_SERIALIZATION_PCHCONTAINEROPERATIONS_H
+#define LLVM_CLANG_SERIALIZATION_PCHCONTAINEROPERATIONS_H
 
 #include "clang/Basic/Module.h"
 #include "llvm/ADT/SmallVector.h"

Modified: cfe/trunk/include/clang/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/module.modulemap?rev=348907=348906=348907=diff
==
--- cfe/trunk/include/clang/module.modulemap (original)
+++ cfe/trunk/include/clang/module.modulemap Tue Dec 11 18:53:59 2018
@@ -103,9 +103,6 @@ module Clang_Frontend {
   textual header "Frontend/LangStandards.def"
 
   module * { export * }
-
-  // FIXME: This violates layers.
-  exclude header "Frontend/PCHContainerOperations.h"
 }
 
 module Clang_FrontendTool { requires cplusplus umbrella "FrontendTool" module 
* { export * } }

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 

r348827 - Move CodeGenOptions from Frontend to Basic

2018-12-10 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Mon Dec 10 19:18:39 2018
New Revision: 348827

URL: http://llvm.org/viewvc/llvm-project?rev=348827=rev
Log:
Move CodeGenOptions from Frontend to Basic

Basic uses CodeGenOptions and should not depend on Frontend.

Added:
cfe/trunk/include/clang/Basic/CodeGenOptions.def
  - copied unchanged from r348826, 
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/include/clang/Basic/CodeGenOptions.h
  - copied, changed from r348826, 
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/Basic/CodeGenOptions.cpp
  - copied, changed from r348826, cfe/trunk/lib/Frontend/CodeGenOptions.cpp
Removed:
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/Frontend/CodeGenOptions.cpp
Modified:
cfe/trunk/include/clang/Frontend/CompilerInvocation.h
cfe/trunk/include/clang/module.modulemap
cfe/trunk/lib/Basic/CMakeLists.txt
cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenPGO.h
cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
cfe/trunk/lib/CodeGen/CoverageMappingGen.h
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/Frontend/CMakeLists.txt
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Copied: cfe/trunk/include/clang/Basic/CodeGenOptions.h (from r348826, 
cfe/trunk/include/clang/Frontend/CodeGenOptions.h)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CodeGenOptions.h?p2=cfe/trunk/include/clang/Basic/CodeGenOptions.h=cfe/trunk/include/clang/Frontend/CodeGenOptions.h=348826=348827=348827=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Basic/CodeGenOptions.h Mon Dec 10 19:18:39 2018
@@ -11,8 +11,8 @@
 //
 
//===--===//
 
-#ifndef LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H
-#define LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H
+#ifndef LLVM_CLANG_BASIC_CODEGENOPTIONS_H
+#define LLVM_CLANG_BASIC_CODEGENOPTIONS_H
 
 #include "clang/Basic/DebugInfoOptions.h"
 #include "clang/Basic/Sanitizers.h"
@@ -33,12 +33,12 @@ class CodeGenOptionsBase {
 public:
 #define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits;
 #define ENUM_CODEGENOPT(Name, Type, Bits, Default)
-#include "clang/Frontend/CodeGenOptions.def"
+#include "clang/Basic/CodeGenOptions.def"
 
 protected:
 #define CODEGENOPT(Name, Bits, Default)
 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) unsigned Name : Bits;
-#include "clang/Frontend/CodeGenOptions.def"
+#include "clang/Basic/CodeGenOptions.def"
 };
 
 /// CodeGenOptions - Track various options which control how the code
@@ -288,7 +288,7 @@ public:
 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
   Type get##Name() const { return static_cast(Name); } \
   void set##Name(Type Value) { Name = static_cast(Value); }
-#include "clang/Frontend/CodeGenOptions.def"
+#include "clang/Basic/CodeGenOptions.def"
 
   CodeGenOptions();
 

Removed: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=348826=auto
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def (removed)
@@ -1,366 +0,0 @@
-//===--- CodeGenOptions.def - Code generation option database - C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-//
-// This file defines the code generation options. Users of this file
-// must define the CODEGENOPT macro to make use of this information.
-// Optionally, the user may also define ENUM_CODEGENOPT (for options
-// that have enumeration type and VALUE_CODEGENOPT is a code
-// generation option that describes a value rather 

r348685 - Move diagnostic enums into Basic.

2018-12-07 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Dec  7 21:05:03 2018
New Revision: 348685

URL: http://llvm.org/viewvc/llvm-project?rev=348685=rev
Log:
Move diagnostic enums into Basic.

Move enums from */*Diagnostic.h to Basic/Diagnostic*.h.  Basic/AllDiagnostics.h
needs all the enums and moving the sources to Basic prevents a Basic->*->Basic
dependency loop.  This also allows each Basic/Diagnostics*Kinds.td to have a
header at Basic/Diagnostic*.h (except for Common).  The old headers are kept in 
place since other packages are still using them.

Added:
cfe/trunk/include/clang/Basic/DiagnosticAST.h
  - copied, changed from r348541, 
cfe/trunk/include/clang/AST/ASTDiagnostic.h
cfe/trunk/include/clang/Basic/DiagnosticAnalysis.h
  - copied, changed from r348541, 
cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h
cfe/trunk/include/clang/Basic/DiagnosticComment.h
  - copied, changed from r348541, 
cfe/trunk/include/clang/AST/CommentDiagnostic.h
cfe/trunk/include/clang/Basic/DiagnosticCrossTU.h
  - copied, changed from r348541, 
cfe/trunk/include/clang/CrossTU/CrossTUDiagnostic.h
cfe/trunk/include/clang/Basic/DiagnosticDriver.h
  - copied, changed from r348541, 
cfe/trunk/include/clang/Driver/DriverDiagnostic.h
cfe/trunk/include/clang/Basic/DiagnosticFrontend.h
  - copied, changed from r348541, 
cfe/trunk/include/clang/Frontend/FrontendDiagnostic.h
cfe/trunk/include/clang/Basic/DiagnosticLex.h
  - copied, changed from r348541, 
cfe/trunk/include/clang/Lex/LexDiagnostic.h
cfe/trunk/include/clang/Basic/DiagnosticParse.h
  - copied, changed from r348541, 
cfe/trunk/include/clang/Parse/ParseDiagnostic.h
cfe/trunk/include/clang/Basic/DiagnosticRefactoring.h
  - copied, changed from r348541, 
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringDiagnostic.h
cfe/trunk/include/clang/Basic/DiagnosticSema.h
  - copied, changed from r348541, 
cfe/trunk/include/clang/Sema/SemaDiagnostic.h
cfe/trunk/include/clang/Basic/DiagnosticSerialization.h
  - copied, changed from r348541, 
cfe/trunk/include/clang/Serialization/SerializationDiagnostic.h
Modified:
cfe/trunk/include/clang/AST/ASTDiagnostic.h
cfe/trunk/include/clang/AST/CommentDiagnostic.h
cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h
cfe/trunk/include/clang/Basic/AllDiagnostics.h
cfe/trunk/include/clang/CrossTU/CrossTUDiagnostic.h
cfe/trunk/include/clang/Driver/DriverDiagnostic.h
cfe/trunk/include/clang/Frontend/FrontendDiagnostic.h
cfe/trunk/include/clang/Lex/LexDiagnostic.h
cfe/trunk/include/clang/Parse/ParseDiagnostic.h
cfe/trunk/include/clang/Sema/SemaDiagnostic.h
cfe/trunk/include/clang/Serialization/SerializationDiagnostic.h
cfe/trunk/include/clang/Tooling/Refactoring/RefactoringDiagnostic.h

Modified: cfe/trunk/include/clang/AST/ASTDiagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTDiagnostic.h?rev=348685=348684=348685=diff
==
--- cfe/trunk/include/clang/AST/ASTDiagnostic.h (original)
+++ cfe/trunk/include/clang/AST/ASTDiagnostic.h Fri Dec  7 21:05:03 2018
@@ -11,19 +11,9 @@
 #define LLVM_CLANG_AST_ASTDIAGNOSTIC_H
 
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticAST.h"
 
 namespace clang {
-  namespace diag {
-enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
- SFINAE,NOWERROR,SHOWINSYSHEADER,CATEGORY) ENUM,
-#define ASTSTART
-#include "clang/Basic/DiagnosticASTKinds.inc"
-#undef DIAG
-  NUM_BUILTIN_AST_DIAGNOSTICS
-};
-  }  // end namespace diag
-
   /// DiagnosticsEngine argument formatting function for diagnostics that
   /// involve AST nodes.
   ///

Modified: cfe/trunk/include/clang/AST/CommentDiagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentDiagnostic.h?rev=348685=348684=348685=diff
==
--- cfe/trunk/include/clang/AST/CommentDiagnostic.h (original)
+++ cfe/trunk/include/clang/AST/CommentDiagnostic.h Fri Dec  7 21:05:03 2018
@@ -10,20 +10,7 @@
 #ifndef LLVM_CLANG_AST_COMMENTDIAGNOSTIC_H
 #define LLVM_CLANG_AST_COMMENTDIAGNOSTIC_H
 
-#include "clang/Basic/Diagnostic.h"
-
-namespace clang {
-  namespace diag {
-enum {
-#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
- SFINAE,NOWERROR,SHOWINSYSHEADER,CATEGORY) ENUM,
-#define COMMENTSTART
-#include "clang/Basic/DiagnosticCommentKinds.inc"
-#undef DIAG
-  NUM_BUILTIN_COMMENT_DIAGNOSTICS
-};
-  }  // end namespace diag
-}  // end namespace clang
+#include "clang/Basic/DiagnosticComment.h"
 
 #endif
 

Modified: cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/AnalysisDiagnostic.h?rev=348685=348684=348685=diff
==
--- 

r348459 - Remove unnecessary include.

2018-12-05 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Dec  5 22:32:40 2018
New Revision: 348459

URL: http://llvm.org/viewvc/llvm-project?rev=348459=rev
Log:
Remove unnecessary include.

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

Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=348459=348458=348459=diff
==
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Wed Dec  5 
22:32:40 2018
@@ -21,7 +21,6 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/Preprocessor.h"
-#include "clang/Serialization/ASTWriter.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Bitcode/BitstreamReader.h"
 #include "llvm/DebugInfo/DWARF/DWARFContext.h"


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


r348458 - Remove CodeGen dependencies on Sema.

2018-12-05 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Dec  5 22:12:20 2018
New Revision: 348458

URL: http://llvm.org/viewvc/llvm-project?rev=348458=rev
Log:
Remove CodeGen dependencies on Sema.

Move diagnostics from Sema to Frontend (or Common) so that CodeGen no longer
needs to include the Sema diagnostic IDs.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/CodeGen/CGAtomic.cpp
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=348458=348457=348458=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Wed Dec  5 22:12:20 
2018
@@ -189,6 +189,12 @@ def err_seh___finally_block : Error<
 def note_invalid_subexpr_in_const_expr : Note<
   "subexpression not valid in a constant expression">;
 
+// Sema && Frontend
+let CategoryName = "Inline Assembly Issue" in {
+  def err_asm_invalid_type_in_input : Error<
+"invalid type %0 in asm input for constraint '%1'">;
+}
+
 // Targets
 
 def err_target_unknown_triple : Error<

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=348458=348457=348458=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Wed Dec  5 
22:12:20 2018
@@ -245,4 +245,49 @@ def warn_stdlibcxx_not_found : Warning<
   "include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the "
   "command line to use the libc++ standard library instead">,
   InGroup>;
+
+def err_builtin_needs_feature : Error<"%0 needs target feature %1">;
+def err_function_needs_feature : Error<
+  "always_inline function %1 requires target feature '%2', but would "
+  "be inlined into function %0 that is compiled without support for '%2'">;
+
+def err_alias_to_undefined : Error<
+  "%select{alias|ifunc}0 must point to a defined "
+  "%select{variable or |}1function">;
+def warn_alias_to_weak_alias : Warning<
+  "%select{alias|ifunc}2 will always resolve to %0 even if weak definition of "
+  "%1 is overridden">,
+  InGroup;
+def err_duplicate_mangled_name : Error<
+  "definition with same mangled name '%0' as another definition">;
+def err_cyclic_alias : Error<
+  "%select{alias|ifunc}0 definition is part of a cycle">;
+def err_ifunc_resolver_return : Error<
+  "ifunc resolver function must return a pointer">;
+
+def warn_atomic_op_misaligned : Warning<
+  "%select{large|misaligned}0 atomic operation may incur "
+  "significant performance penalty">, InGroup>;
+
+def warn_alias_with_section : Warning<
+  "%select{alias|ifunc}1 will not be in section '%0' but in the same section "
+  "as the %select{aliasee|resolver}2">,
+  InGroup;
+
+let CategoryName = "Instrumentation Issue" in {
+def warn_profile_data_out_of_date : Warning<
+  "profile data may be out of date: of %0 function%s0, %1 
%plural{1:has|:have}1"
+  " mismatched data that will be ignored">,
+  InGroup;
+def warn_profile_data_missing : Warning<
+  "profile data may be incomplete: of %0 function%s0, %1 %plural{1:has|:have}1"
+  " no data">,
+  InGroup,
+  DefaultIgnore;
+def warn_profile_data_unprofiled : Warning<
+  "no profile data available for file \"%0\"">,
+  InGroup;
+
+} // end of instrumentation issue category
+
 }

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=348458=348457=348458=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Dec  5 22:12:20 
2018
@@ -622,11 +622,6 @@ def err_invalid_cpu_supports : Error<"in
 def err_invalid_cpu_is : Error<"invalid cpu name for builtin">;
 def err_invalid_cpu_specific_dispatch_value : Error<
 "invalid option '%0' for %select{cpu_specific|cpu_dispatch}1">;
-def err_builtin_needs_feature : Error<"%0 needs target feature %1">;
-def err_function_needs_feature
-: Error<"always_inline function %1 requires target feature '%2', but would 
"
-"be inlined into function %0 that is compiled without support for "
-"'%2'">;
 def warn_builtin_unknown : Warning<"use of unknown builtin %0">,
   InGroup, DefaultError;
 def warn_cstruct_memaccess : Warning<
@@ -2880,20 +2875,6 @@ def err_attribute_weakref_without_alias
  

r348238 - Remove unnecessary include.

2018-12-03 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Mon Dec  3 20:53:18 2018
New Revision: 348238

URL: http://llvm.org/viewvc/llvm-project?rev=348238=rev
Log:
Remove unnecessary include.

Modified:
cfe/trunk/lib/CodeGen/CodeGenTypes.h

Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.h?rev=348238=348237=348238=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenTypes.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.h Mon Dec  3 20:53:18 2018
@@ -17,7 +17,6 @@
 #include "CGCall.h"
 #include "clang/Basic/ABI.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
-#include "clang/Sema/Sema.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/IR/Module.h"
 


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


r347728 - Move LoopHint.h from Sema to Parse

2018-11-27 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Nov 27 20:36:31 2018
New Revision: 347728

URL: http://llvm.org/viewvc/llvm-project?rev=347728=rev
Log:
Move LoopHint.h from Sema to Parse

struct LoopHint was only used within Parse and not in any of the Sema or
Codegen files.  In the non-Parse files where it was included, it either wasn't
used or LoopHintAttr was used, so its inclusion did nothing.

Added:
cfe/trunk/include/clang/Parse/LoopHint.h
  - copied, changed from r347727, cfe/trunk/include/clang/Sema/LoopHint.h
Removed:
cfe/trunk/include/clang/Sema/LoopHint.h
Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/CodeGen/CGLoopInfo.cpp
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Sema/SemaStmtAttr.cpp

Copied: cfe/trunk/include/clang/Parse/LoopHint.h (from r347727, 
cfe/trunk/include/clang/Sema/LoopHint.h)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/LoopHint.h?p2=cfe/trunk/include/clang/Parse/LoopHint.h=cfe/trunk/include/clang/Sema/LoopHint.h=347727=347728=347728=diff
==
--- cfe/trunk/include/clang/Sema/LoopHint.h (original)
+++ cfe/trunk/include/clang/Parse/LoopHint.h Tue Nov 27 20:36:31 2018
@@ -7,8 +7,8 @@
 //
 
//===--===//
 
-#ifndef LLVM_CLANG_SEMA_LOOPHINT_H
-#define LLVM_CLANG_SEMA_LOOPHINT_H
+#ifndef LLVM_CLANG_PARSE_LOOPHINT_H
+#define LLVM_CLANG_PARSE_LOOPHINT_H
 
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/SourceLocation.h"
@@ -42,4 +42,4 @@ struct LoopHint {
 
 } // end namespace clang
 
-#endif // LLVM_CLANG_SEMA_LOOPHINT_H
+#endif // LLVM_CLANG_PARSE_LOOPHINT_H

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=347728=347727=347728=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Tue Nov 27 20:36:31 2018
@@ -22,7 +22,6 @@
 #include "clang/Lex/CodeCompletionHandler.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/DeclSpec.h"
-#include "clang/Sema/LoopHint.h"
 #include "clang/Sema/Sema.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Compiler.h"
@@ -38,6 +37,7 @@ namespace clang {
   class CorrectionCandidateCallback;
   class DeclGroupRef;
   class DiagnosticBuilder;
+  struct LoopHint;
   class Parser;
   class ParsingDeclRAIIObject;
   class ParsingDeclSpec;

Removed: cfe/trunk/include/clang/Sema/LoopHint.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/LoopHint.h?rev=347727=auto
==
--- cfe/trunk/include/clang/Sema/LoopHint.h (original)
+++ cfe/trunk/include/clang/Sema/LoopHint.h (removed)
@@ -1,45 +0,0 @@
-//===--- LoopHint.h - Types for LoopHint *- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#ifndef LLVM_CLANG_SEMA_LOOPHINT_H
-#define LLVM_CLANG_SEMA_LOOPHINT_H
-
-#include "clang/Basic/IdentifierTable.h"
-#include "clang/Basic/SourceLocation.h"
-#include "clang/Sema/Ownership.h"
-#include "clang/Sema/ParsedAttr.h"
-
-namespace clang {
-
-/// Loop optimization hint for loop and unroll pragmas.
-struct LoopHint {
-  // Source range of the directive.
-  SourceRange Range;
-  // Identifier corresponding to the name of the pragma.  "loop" for
-  // "#pragma clang loop" directives and "unroll" for "#pragma unroll"
-  // hints.
-  IdentifierLoc *PragmaNameLoc;
-  // Name of the loop hint.  Examples: "unroll", "vectorize".  In the
-  // "#pragma unroll" and "#pragma nounroll" cases, this is identical to
-  // PragmaNameLoc.
-  IdentifierLoc *OptionLoc;
-  // Identifier for the hint state argument.  If null, then the state is
-  // default value such as for "#pragma unroll".
-  IdentifierLoc *StateLoc;
-  // Expression for the hint argument if it exists, null otherwise.
-  Expr *ValueExpr;
-
-  LoopHint()
-  : PragmaNameLoc(nullptr), OptionLoc(nullptr), StateLoc(nullptr),
-ValueExpr(nullptr) {}
-};
-
-} // end namespace clang
-
-#endif // LLVM_CLANG_SEMA_LOOPHINT_H

Modified: cfe/trunk/lib/CodeGen/CGLoopInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGLoopInfo.cpp?rev=347728=347727=347728=diff
==
--- cfe/trunk/lib/CodeGen/CGLoopInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGLoopInfo.cpp Tue Nov 27 20:36:31 2018
@@ -10,7 +10,6 @@
 #include "CGLoopInfo.h"
 #include "clang/AST/ASTContext.h"
 #include 

r347727 - [CodeGen] Fix included headers.

2018-11-27 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Nov 27 20:14:29 2018
New Revision: 347727

URL: http://llvm.org/viewvc/llvm-project?rev=347727=rev
Log:
[CodeGen] Fix included headers.

Remove the included Parse header because CodeGen should not depend on Parse.
Instead, include the Lex headers that it needs instead.

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

Modified: cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp?rev=347727=347726=347727=diff
==
--- cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp (original)
+++ cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp Tue Nov 27 20:14:29 2018
@@ -14,7 +14,8 @@
 #include "MacroPPCallbacks.h"
 #include "CGDebugInfo.h"
 #include "clang/CodeGen/ModuleBuilder.h"
-#include "clang/Parse/Parser.h"
+#include "clang/Lex/MacroInfo.h"
+#include "clang/Lex/Preprocessor.h"
 
 using namespace clang;
 


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


r347726 - [diagtool] Remove unneeded header includes.

2018-11-27 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Nov 27 19:59:35 2018
New Revision: 347726

URL: http://llvm.org/viewvc/llvm-project?rev=347726=rev
Log:
[diagtool] Remove unneeded header includes.

Modified:
cfe/trunk/tools/diagtool/ListWarnings.cpp
cfe/trunk/tools/diagtool/TreeView.cpp

Modified: cfe/trunk/tools/diagtool/ListWarnings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/diagtool/ListWarnings.cpp?rev=347726=347725=347726=diff
==
--- cfe/trunk/tools/diagtool/ListWarnings.cpp (original)
+++ cfe/trunk/tools/diagtool/ListWarnings.cpp Tue Nov 27 19:59:35 2018
@@ -14,7 +14,6 @@
 
 #include "DiagTool.h"
 #include "DiagnosticNames.h"
-#include "clang/AST/ASTDiagnostic.h"
 #include "clang/Basic/AllDiagnostics.h"
 #include "clang/Basic/Diagnostic.h"
 #include "llvm/ADT/StringMap.h"

Modified: cfe/trunk/tools/diagtool/TreeView.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/diagtool/TreeView.cpp?rev=347726=347725=347726=diff
==
--- cfe/trunk/tools/diagtool/TreeView.cpp (original)
+++ cfe/trunk/tools/diagtool/TreeView.cpp Tue Nov 27 19:59:35 2018
@@ -9,7 +9,6 @@
 
 #include "DiagTool.h"
 #include "DiagnosticNames.h"
-#include "clang/AST/ASTDiagnostic.h"
 #include "clang/Basic/AllDiagnostics.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"


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


Re: r345676 - [Win64] Handle passing i128 by value

2018-10-30 Thread Richard Trieu via cfe-commits
I have reverted this in r345691 because it caused test
CodeGen/mingw-long-double.c to start failing.

Command Output (stderr):
--
/usr/local/google/clang/install/llvm/tools/clang/test/CodeGen/mingw-long-double.c:36:11:
error: MSC64: expected string not found in input
// MSC64: define dso_local double @TestLD(double %x)
  ^
:12:1: note: scanning from here
; Function Attrs: noinline nounwind optnone
^
:35:1: note: possible intended match here
define dso_local void @TestLDC({ double, double }* noalias sret
%agg.result, { double, double }* %x) #2 {
^

--

I suspect your patch has changed the type of "double" to a different
floating point type, causing the failure.


On Tue, Oct 30, 2018 at 5:00 PM Reid Kleckner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rnk
> Date: Tue Oct 30 16:58:41 2018
> New Revision: 345676
>
> URL: http://llvm.org/viewvc/llvm-project?rev=345676=rev
> Log:
> [Win64] Handle passing i128 by value
>
> For arguments, pass it indirectly, since the ABI doc says pretty clearly
> that arguments larger than 8 bytes are passed indirectly. This makes
> va_list handling easier, anyway.
>
> When returning, GCC returns in XMM0, and we match them.
>
> Fixes PR39492.
>
> Added:
> cfe/trunk/test/CodeGen/win64-i128.c
> Modified:
> cfe/trunk/lib/CodeGen/TargetInfo.cpp
>
> Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=345676=345675=345676=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue Oct 30 16:58:41 2018
> @@ -3944,18 +3944,39 @@ ABIArgInfo WinX86_64ABIInfo::classify(Qu
>  return ABIArgInfo::getDirect(llvm::IntegerType::get(getVMContext(),
> Width));
>}
>
> -  // Bool type is always extended to the ABI, other builtin types are not
> -  // extended.
> -  const BuiltinType *BT = Ty->getAs();
> -  if (BT && BT->getKind() == BuiltinType::Bool)
> -return ABIArgInfo::getExtend(Ty);
> -
> -  // Mingw64 GCC uses the old 80 bit extended precision floating point
> unit. It
> -  // passes them indirectly through memory.
> -  if (IsMingw64 && BT && BT->getKind() == BuiltinType::LongDouble) {
> -const llvm::fltSemantics *LDF = ().getLongDoubleFormat();
> -if (LDF == ::APFloat::x87DoubleExtended())
> -  return ABIArgInfo::getIndirect(Align, /*ByVal=*/false);
> +  if (const BuiltinType *BT = Ty->getAs()) {
> +switch (BT->getKind()) {
> +case BuiltinType::Bool:
> +  // Bool type is always extended to the ABI, other builtin types are
> not
> +  // extended.
> +  return ABIArgInfo::getExtend(Ty);
> +
> +case BuiltinType::LongDouble:
> +  // Mingw64 GCC uses the old 80 bit extended precision floating point
> +  // unit. It passes them indirectly through memory.
> +  if (IsMingw64) {
> +const llvm::fltSemantics *LDF =
> ().getLongDoubleFormat();
> +if (LDF == ::APFloat::x87DoubleExtended())
> +  return ABIArgInfo::getIndirect(Align, /*ByVal=*/false);
> +break;
> +  }
> +
> +case BuiltinType::Int128:
> +case BuiltinType::UInt128:
> +  // If it's a parameter type, the normal ABI rule is that arguments
> larger
> +  // than 8 bytes are passed indirectly. GCC follows it. We follow it
> too,
> +  // even though it isn't particularly efficient.
> +  if (!IsReturnType)
> +return ABIArgInfo::getIndirect(Align, /*ByVal=*/false);
> +
> +  // Mingw64 GCC returns i128 in XMM0. Coerce to v2i64 to handle that.
> +  // Clang matches them for compatibility.
> +  return ABIArgInfo::getDirect(
> +  llvm::VectorType::get(llvm::Type::getInt64Ty(getVMContext()),
> 2));
> +
> +default:
> +  break;
> +}
>}
>
>return ABIArgInfo::getDirect();
>
> Added: cfe/trunk/test/CodeGen/win64-i128.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/win64-i128.c?rev=345676=auto
>
> ==
> --- cfe/trunk/test/CodeGen/win64-i128.c (added)
> +++ cfe/trunk/test/CodeGen/win64-i128.c Tue Oct 30 16:58:41 2018
> @@ -0,0 +1,16 @@
> +// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -o - %s \
> +// RUN:| FileCheck %s --check-prefix=GNU64
> +// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -o - %s \
> +// RUN:| FileCheck %s --check-prefix=MSC64
> +
> +typedef int int128_t __attribute__((mode(TI)));
> +
> +int128_t foo() { return 0; }
> +
> +// GNU64: define dso_local <2 x i64> @foo()
> +// MSC64: define dso_local <2 x i64> @foo()
> +
> +int128_t bar(int128_t a, int128_t b) { return a * b; }
> +
> +// GNU64: define dso_local <2 x i64> @bar(i128*, i128*)
> +// MSC64: define dso_local <2 x i64> @bar(i128*, i128*)
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> 

r345691 - Revert r345676 due to test failure.

2018-10-30 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Oct 30 19:10:51 2018
New Revision: 345691

URL: http://llvm.org/viewvc/llvm-project?rev=345691=rev
Log:
Revert r345676 due to test failure.

This was causing CodeGen/mingw-long-double.c to start failing.

Removed:
cfe/trunk/test/CodeGen/win64-i128.c
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=345691=345690=345691=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue Oct 30 19:10:51 2018
@@ -3943,40 +3943,18 @@ ABIArgInfo WinX86_64ABIInfo::classify(Qu
 // Otherwise, coerce it to a small integer.
 return ABIArgInfo::getDirect(llvm::IntegerType::get(getVMContext(), 
Width));
   }
-
-  if (const BuiltinType *BT = Ty->getAs()) {
-switch (BT->getKind()) {
-case BuiltinType::Bool:
-  // Bool type is always extended to the ABI, other builtin types are not
-  // extended.
-  return ABIArgInfo::getExtend(Ty);
-
-case BuiltinType::LongDouble:
-  // Mingw64 GCC uses the old 80 bit extended precision floating point
-  // unit. It passes them indirectly through memory.
-  if (IsMingw64) {
-const llvm::fltSemantics *LDF = ().getLongDoubleFormat();
-if (LDF == ::APFloat::x87DoubleExtended())
-  return ABIArgInfo::getIndirect(Align, /*ByVal=*/false);
-break;
-  }
-
-case BuiltinType::Int128:
-case BuiltinType::UInt128:
-  // If it's a parameter type, the normal ABI rule is that arguments larger
-  // than 8 bytes are passed indirectly. GCC follows it. We follow it too,
-  // even though it isn't particularly efficient.
-  if (!IsReturnType)
-return ABIArgInfo::getIndirect(Align, /*ByVal=*/false);
-
-  // Mingw64 GCC returns i128 in XMM0. Coerce to v2i64 to handle that.
-  // Clang matches them for compatibility.
-  return ABIArgInfo::getDirect(
-  llvm::VectorType::get(llvm::Type::getInt64Ty(getVMContext()), 2));
-
-default:
-  break;
-}
+  // Bool type is always extended to the ABI, other builtin types are not
+  // extended.
+  const BuiltinType *BT = Ty->getAs();
+  if (BT && BT->getKind() == BuiltinType::Bool)
+return ABIArgInfo::getExtend(Ty);
+
+  // Mingw64 GCC uses the old 80 bit extended precision floating point unit. It
+  // passes them indirectly through memory.
+  if (IsMingw64 && BT && BT->getKind() == BuiltinType::LongDouble) {
+const llvm::fltSemantics *LDF = ().getLongDoubleFormat();
+if (LDF == ::APFloat::x87DoubleExtended())
+  return ABIArgInfo::getIndirect(Align, /*ByVal=*/false);
   }
 
   return ABIArgInfo::getDirect();

Removed: cfe/trunk/test/CodeGen/win64-i128.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/win64-i128.c?rev=345690=auto
==
--- cfe/trunk/test/CodeGen/win64-i128.c (original)
+++ cfe/trunk/test/CodeGen/win64-i128.c (removed)
@@ -1,16 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -o - %s \
-// RUN:| FileCheck %s --check-prefix=GNU64
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -o - %s \
-// RUN:| FileCheck %s --check-prefix=MSC64
-
-typedef int int128_t __attribute__((mode(TI)));
-
-int128_t foo() { return 0; }
-
-// GNU64: define dso_local <2 x i64> @foo()
-// MSC64: define dso_local <2 x i64> @foo()
-
-int128_t bar(int128_t a, int128_t b) { return a * b; }
-
-// GNU64: define dso_local <2 x i64> @bar(i128*, i128*)
-// MSC64: define dso_local <2 x i64> @bar(i128*, i128*)


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


r345669 - Silence unused variable warnings. NFC

2018-10-30 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Oct 30 16:01:15 2018
New Revision: 345669

URL: http://llvm.org/viewvc/llvm-project?rev=345669=rev
Log:
Silence unused variable warnings.  NFC

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

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=345669=345668=345669=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue Oct 30 16:01:15 2018
@@ -965,6 +965,7 @@ EmitIntegerTruncationCheckHelper(Value *
  QualType DstType, CGBuilderTy ) {
   llvm::Type *SrcTy = Src->getType();
   llvm::Type *DstTy = Dst->getType();
+  (void)DstTy; // Only used in assert()
 
   // This should be truncation of integral types.
   assert(Src != Dst);
@@ -1058,6 +1059,8 @@ EmitIntegerSignChangeCheckHelper(Value *
 
   bool SrcSigned = SrcType->isSignedIntegerOrEnumerationType();
   bool DstSigned = DstType->isSignedIntegerOrEnumerationType();
+  (void)SrcSigned; // Only used in assert()
+  (void)DstSigned; // Only used in assert()
   unsigned SrcBits = SrcTy->getScalarSizeInBits();
   unsigned DstBits = DstTy->getScalarSizeInBits();
   (void)SrcBits; // Only used in assert()


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


r345228 - [Sema] Fix -Wcomma for C89

2018-10-24 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Oct 24 18:08:00 2018
New Revision: 345228

URL: http://llvm.org/viewvc/llvm-project?rev=345228=rev
Log:
[Sema] Fix -Wcomma for C89

There is a small difference in the scope flags for C89 versus the other C/C++
dialects.  This change ensures that the -Wcomma warning won't be duplicated or
issued in the wrong location.  Also, the test case is refactored into C and C++
parts, with the C++ parts guarded by a #ifdef to allow the test to run in both
modes.

https://bugs.llvm.org/show_bug.cgi?id=32370

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/SemaCXX/warn-comma-operator.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=345228=345227=345228=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Oct 24 18:08:00 2018
@@ -11309,8 +11309,11 @@ void Sema::DiagnoseCommaOperator(const E
   // The whitelisted locations are the initialization and increment portions
   // of a for loop.  The additional checks are on the condition of
   // if statements, do/while loops, and for loops.
+  // Differences in scope flags for C89 mode requires the extra logic.
   const unsigned ForIncrementFlags =
-  Scope::ControlScope | Scope::ContinueScope | Scope::BreakScope;
+  getLangOpts().C99 || getLangOpts().CPlusPlus
+  ? Scope::ControlScope | Scope::ContinueScope | Scope::BreakScope
+  : Scope::ContinueScope | Scope::BreakScope;
   const unsigned ForInitFlags = Scope::ControlScope | Scope::DeclScope;
   const unsigned ScopeFlags = getCurScope()->getFlags();
   if ((ScopeFlags & ForIncrementFlags) == ForIncrementFlags ||

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=345228=345227=345228=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Oct 24 18:08:00 2018
@@ -551,8 +551,9 @@ Sema::ActOnIfStmt(SourceLocation IfLoc,
 false);
 
   Expr *CondExpr = Cond.get().second;
-  if (!Diags.isIgnored(diag::warn_comma_operator,
-   CondExpr->getExprLoc()))
+  // Only call the CommaVisitor when not C89 due to differences in scope flags.
+  if ((getLangOpts().C99 || getLangOpts().CPlusPlus) &&
+  !Diags.isIgnored(diag::warn_comma_operator, CondExpr->getExprLoc()))
 CommaVisitor(*this).Visit(CondExpr);
 
   if (!elseStmt)
@@ -1328,6 +1329,11 @@ Sema::ActOnDoStmt(SourceLocation DoLoc,
 return StmtError();
   Cond = CondResult.get();
 
+  // Only call the CommaVisitor for C89 due to differences in scope flags.
+  if (Cond && !getLangOpts().C99 && !getLangOpts().CPlusPlus &&
+  !Diags.isIgnored(diag::warn_comma_operator, Cond->getExprLoc()))
+CommaVisitor(*this).Visit(Cond);
+
   DiagnoseUnusedExprResult(Body);
 
   return new (Context) DoStmt(Body, Cond, DoLoc, WhileLoc, CondRParen);

Modified: cfe/trunk/test/SemaCXX/warn-comma-operator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-comma-operator.cpp?rev=345228=345227=345228=diff
==
--- cfe/trunk/test/SemaCXX/warn-comma-operator.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-comma-operator.cpp Wed Oct 24 18:08:00 2018
@@ -1,8 +1,16 @@
 // RUN: %clang_cc1 -fsyntax-only -Wcomma -std=c++11 -verify %s
 // RUN: %clang_cc1 -fsyntax-only -Wcomma -std=c++11 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
+// RUN: %clang_cc1 -fsyntax-only -Wcomma -x c -std=c89 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wcomma -x c -std=c99 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wcomma -x c -std=c11 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wcomma -x c -std=c17 -verify %s
+
+// int returning function
+int return_four() { return 5; }
+
 // Test builtin operators
-void test1() {
+void test_builtin() {
   int x = 0, y = 0;
   for (; y < 10; x++, y++) {}
   for (; y < 10; ++x, y++) {}
@@ -23,6 +31,116 @@ void test1() {
   for (; y < 10; x ^= 5, ++y) {}
 }
 
+// Test nested comma operators
+void test_nested() {
+  int x1, x2, x3;
+  int y1, *y2 = 0, y3 = 5;
+
+#if __STDC_VERSION >= 199901L
+  for (int z1 = 5, z2 = 4, z3 = 3; x1 <4; ++x1) {}
+#endif
+}
+
+// Confusing "," for "=="
+void test_compare() {
+  if (return_four(), 5) {}
+  // expected-warning@-1{{comma operator}}
+  // expected-note@-2{{cast expression to void}}
+  // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:7-[[@LINE-3]]:7}:"static_cast("
+  // CHECK: fix-it:{{.*}}:{[[@LINE-4]]:20-[[@LINE-4]]:20}:")"
+
+  if (return_four() == 5) {}
+}
+
+// Confusing "," for "+"
+int test_plus() {
+  return return_four(), return_four();
+  // expected-warning@-1{{comma operator}}
+  // expected-note@-2{{cast expression to void}}
+  // 

r345111 - [Sema] Fix -Wcomma in dependent context

2018-10-23 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Oct 23 19:07:41 2018
New Revision: 345111

URL: http://llvm.org/viewvc/llvm-project?rev=345111=rev
Log:
[Sema] Fix -Wcomma in dependent context

When there is a dependent type inside a cast, the CastKind becomes CK_Dependent
instead of CK_ToVoid.  This fix will check that there is a dependent cast,
the original type is dependent, and the target type is void to ignore the cast.

https://bugs.llvm.org/show_bug.cgi?id=39375

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/warn-comma-operator.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=345111=345110=345111=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Oct 23 19:07:41 2018
@@ -11280,6 +11280,12 @@ static bool IgnoreCommaOperand(const Exp
 if (CE->getCastKind() == CK_ToVoid) {
   return true;
 }
+
+// static_cast on a dependent type will not show up as CK_ToVoid.
+if (CE->getCastKind() == CK_Dependent && E->getType()->isVoidType() &&
+CE->getSubExpr()->getType()->isDependentType()) {
+  return true;
+}
   }
 
   return false;

Modified: cfe/trunk/test/SemaCXX/warn-comma-operator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-comma-operator.cpp?rev=345111=345110=345111=diff
==
--- cfe/trunk/test/SemaCXX/warn-comma-operator.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-comma-operator.cpp Tue Oct 23 19:07:41 2018
@@ -276,3 +276,13 @@ void test14() {
   // CHECK: fix-it:{{.*}}:{[[@LINE-7]]:33-[[@LINE-7]]:33}:"static_cast("
   // CHECK: fix-it:{{.*}}:{[[@LINE-8]]:46-[[@LINE-8]]:46}:")"
 }
+
+// PR39375 - test cast to void to silence warnings
+template 
+void test15() {
+  (void)42, 0;
+  static_cast(42), 0;
+
+  (void)T{}, 0;
+  static_cast(T{}), 0;
+}


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


r344987 - [CodeGen] Attach InlineHint to more functions

2018-10-22 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Mon Oct 22 18:26:28 2018
New Revision: 344987

URL: http://llvm.org/viewvc/llvm-project?rev=344987=rev
Log:
[CodeGen] Attach InlineHint to more functions

For instantiated functions, search the template pattern to see if it marked
inline to determine if InlineHint attribute should be added to the function.


Added:
cfe/trunk/test/CodeGenCXX/inline-template-hint.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=344987=344986=344987=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Oct 22 18:26:28 2018
@@ -1299,9 +1299,19 @@ void CodeGenModule::SetLLVMFunctionAttri
 // Otherwise, propagate the inline hint attribute and potentially use its
 // absence to mark things as noinline.
 if (auto *FD = dyn_cast(D)) {
-  if (any_of(FD->redecls(), [&](const FunctionDecl *Redecl) {
-return Redecl->isInlineSpecified();
-  })) {
+  // Search function and template pattern redeclarations for inline.
+  auto CheckForInline = [](const FunctionDecl *FD) {
+auto CheckRedeclForInline = [](const FunctionDecl *Redecl) {
+  return Redecl->isInlineSpecified();
+};
+if (any_of(FD->redecls(), CheckRedeclForInline))
+  return true;
+const FunctionDecl *Pattern = FD->getTemplateInstantiationPattern();
+if (!Pattern)
+  return false;
+return any_of(Pattern->redecls(), CheckRedeclForInline);
+  };
+  if (CheckForInline(FD)) {
 B.addAttribute(llvm::Attribute::InlineHint);
   } else if (CodeGenOpts.getInlining() ==
  CodeGenOptions::OnlyHintInlining &&

Added: cfe/trunk/test/CodeGenCXX/inline-template-hint.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/inline-template-hint.cpp?rev=344987=auto
==
--- cfe/trunk/test/CodeGenCXX/inline-template-hint.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/inline-template-hint.cpp Mon Oct 22 18:26:28 2018
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-linux -O2 \
+// RUN:   -finline-functions -emit-llvm -disable-llvm-passes -o - \
+// RUN: | FileCheck -allow-deprecated-dag-overlap %s \
+// RUN:   --check-prefix=CHECK --check-prefix=SUITABLE
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-linux -O2 \
+// RUN:   -finline-hint-functions -emit-llvm -disable-llvm-passes -o - \
+// RUN: | FileCheck -allow-deprecated-dag-overlap %s \
+// RUN:   --check-prefix=CHECK --check-prefix=HINTED
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-linux -O2 \
+// RUN:   -fno-inline -emit-llvm -disable-llvm-passes -o - \
+// RUN: | FileCheck -allow-deprecated-dag-overlap %s \
+// RUN:   --check-prefix=CHECK --check-prefix=NOINLINE
+
+struct A {
+  inline void int_run(int);
+
+  template 
+  inline void template_run(T);
+};
+
+// CHECK: @_ZN1A7int_runEi({{.*}}) [[ATTR:#[0-9]+]]
+void A::int_run(int) {}
+// CHECK: @_ZN1A12template_runIiEEvT_({{.*}}) [[ATTR]]
+template 
+void A::template_run(T) {}
+
+void bar() {
+  A().int_run(1);
+  A().template_run(1);
+}
+
+// SUITABLE: attributes [[ATTR]] = { {{.*}}inlinehint{{.*}} }
+//   HINTED: attributes [[ATTR]] = { {{.*}}inlinehint{{.*}} }
+// NOINLINE: attributes [[ATTR]] = { {{.*}}noinline{{.*}} }


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


r344828 - Make -Wfor-loop-analysis work with C++17

2018-10-19 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Oct 19 19:15:58 2018
New Revision: 344828

URL: http://llvm.org/viewvc/llvm-project?rev=344828=rev
Log:
Make -Wfor-loop-analysis work with C++17

For now, disable the "variable in loop condition not modified" warning to not
be emitted when there is a structured binding variable in the loop condition.

https://bugs.llvm.org/show_bug.cgi?id=39285

Modified:
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/SemaCXX/warn-loop-analysis.cpp

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=344828=344827=344828=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Fri Oct 19 19:15:58 2018
@@ -1409,7 +1409,11 @@ namespace {
 
 void VisitDeclRefExpr(DeclRefExpr *E) {
   VarDecl *VD = dyn_cast(E->getDecl());
-  if (!VD) return;
+  if (!VD) {
+// Don't allow unhandled Decl types.
+Simple = false;
+return;
+  }
 
   Ranges.push_back(E->getSourceRange());
 

Modified: cfe/trunk/test/SemaCXX/warn-loop-analysis.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-loop-analysis.cpp?rev=344828=344827=344828=diff
==
--- cfe/trunk/test/SemaCXX/warn-loop-analysis.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-loop-analysis.cpp Fri Oct 19 19:15:58 2018
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wloop-analysis -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wloop-analysis -verify -std=c++17 %s
 
 struct S {
   bool stop() { return false; }
@@ -278,3 +278,24 @@ void test9() {
   // Don't warn when variable is defined by the loop condition.
   for (int i = 0; int x = f(i); ++i) {}
 }
+
+// Don't warn when decomposition variables are in the loop condition.
+// TODO: BindingDecl's which make a copy should warn.
+void test10() {
+  int arr[] = {1, 2, 3};
+  for (auto[i, j, k] = arr;;) { }
+  for (auto[i, j, k] = arr; i < j; ++i, ++j) { }
+
+  for (auto[i, j, k] = arr; i;) { }
+  for (auto[i, j, k] = arr; i < j;) { }
+  for (auto[i, j, k] = arr; i < j; ++arr[0]) { }
+
+  int a = 1, b = 2;
+  for (auto[i, j, k] = arr; a < b;) { }  // expected-warning{{variables 'a' 
and 'b' used in loop condition not modified in loop body}}
+  for (auto[i, j, k] = arr; a < b; ++a) { }
+
+  for (auto [i, j, k] = arr; i < a;) { }
+  for (auto[i, j, k] = arr; i < a; ++a) { }
+  for (auto[i, j, k] = arr; i < a; ++i) { }
+  for (auto[i, j, k] = arr; i < a; ++arr[0]) { }
+};


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


r342794 - Update smart pointer detection for thread safety analysis.

2018-09-21 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Sep 21 18:50:52 2018
New Revision: 342794

URL: http://llvm.org/viewvc/llvm-project?rev=342794=rev
Log:
Update smart pointer detection for thread safety analysis.

Objects are determined to be smart pointers if they have both a star and arrow
operator.  Some implementations of smart pointers have these overloaded
operators in a base class, while the check only searched the derived class.
This fix will also look for the operators in the base class.

Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=342794=342793=342794=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Sep 21 18:50:52 2018
@@ -425,17 +425,36 @@ static bool isIntOrBool(Expr *Exp) {
 // Check to see if the type is a smart pointer of some kind.  We assume
 // it's a smart pointer if it defines both operator-> and operator*.
 static bool threadSafetyCheckIsSmartPointer(Sema , const RecordType* RT) {
-  DeclContextLookupResult Res1 = RT->getDecl()->lookup(
-  S.Context.DeclarationNames.getCXXOperatorName(OO_Star));
-  if (Res1.empty())
-return false;
+  auto IsOverloadedOperatorPresent = [](const RecordDecl *Record,
+  OverloadedOperatorKind Op) {
+DeclContextLookupResult Result =
+Record->lookup(S.Context.DeclarationNames.getCXXOperatorName(Op));
+return !Result.empty();
+  };
+
+  const RecordDecl *Record = RT->getDecl();
+  bool foundStarOperator = IsOverloadedOperatorPresent(Record, OO_Star);
+  bool foundArrowOperator = IsOverloadedOperatorPresent(Record, OO_Arrow);
+  if (foundStarOperator && foundArrowOperator)
+return true;
 
-  DeclContextLookupResult Res2 = RT->getDecl()->lookup(
-  S.Context.DeclarationNames.getCXXOperatorName(OO_Arrow));
-  if (Res2.empty())
+  const CXXRecordDecl *CXXRecord = dyn_cast(Record);
+  if (!CXXRecord)
 return false;
 
-  return true;
+  for (auto BaseSpecifier : CXXRecord->bases()) {
+if (!foundStarOperator)
+  foundStarOperator = IsOverloadedOperatorPresent(
+  BaseSpecifier.getType()->getAsRecordDecl(), OO_Star);
+if (!foundArrowOperator)
+  foundArrowOperator = IsOverloadedOperatorPresent(
+  BaseSpecifier.getType()->getAsRecordDecl(), OO_Arrow);
+  }
+
+  if (foundStarOperator && foundArrowOperator)
+return true;
+
+  return false;
 }
 
 /// Check if passed in Decl is a pointer type.

Modified: cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp?rev=342794=342793=342794=diff
==
--- cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp Fri Sep 21 18:50:52 
2018
@@ -5481,3 +5481,98 @@ void f() {
   int  = i; // expected-warning {{reference 'i' is not yet bound to a value 
when used within its own initialization}}
 }
 }
+
+namespace Derived_Smart_Pointer {
+template 
+class SmartPtr_Derived : public SmartPtr {};
+
+class Foo {
+public:
+  SmartPtr_Derived mu_;
+  int a GUARDED_BY(mu_);
+  int b GUARDED_BY(mu_.get());
+  int c GUARDED_BY(*mu_);
+
+  void Lock()   EXCLUSIVE_LOCK_FUNCTION(mu_);
+  void Unlock() UNLOCK_FUNCTION(mu_);
+
+  void test0() {
+a = 1;  // expected-warning {{writing variable 'a' requires holding mutex 
'mu_' exclusively}}
+b = 1;  // expected-warning {{writing variable 'b' requires holding mutex 
'mu_' exclusively}}
+c = 1;  // expected-warning {{writing variable 'c' requires holding mutex 
'mu_' exclusively}}
+  }
+
+  void test1() {
+Lock();
+a = 1;
+b = 1;
+c = 1;
+Unlock();
+  }
+};
+
+class Bar {
+  SmartPtr_Derived foo;
+
+  void test0() {
+foo->a = 1;// expected-warning {{writing variable 'a' requires 
holding mutex 'foo->mu_' exclusively}}
+(*foo).b = 1;  // expected-warning {{writing variable 'b' requires 
holding mutex 'foo->mu_' exclusively}}
+foo.get()->c = 1;  // expected-warning {{writing variable 'c' requires 
holding mutex 'foo->mu_' exclusively}}
+  }
+
+  void test1() {
+foo->Lock();
+foo->a = 1;
+foo->Unlock();
+
+foo->mu_->Lock();
+foo->b = 1;
+foo->mu_->Unlock();
+
+MutexLock lock(foo->mu_.get());
+foo->c = 1;
+  }
+};
+
+class PointerGuard {
+  Mutex mu1;
+  Mutex mu2;
+  SmartPtr_Derived i GUARDED_BY(mu1) PT_GUARDED_BY(mu2);
+
+  void test0() {
+i.get();  // expected-warning {{reading variable 'i' requires holding 
mutex 'mu1'}}
+*i = 2;   // expected-warning {{reading variable 'i' requires holding 
mutex 'mu1'}} \
+  // expected-warning {{reading the value pointed 

r342774 - Make compare function in r342648 have strict weak ordering.

2018-09-21 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Sep 21 14:20:33 2018
New Revision: 342774

URL: http://llvm.org/viewvc/llvm-project?rev=342774=rev
Log:
Make compare function in r342648 have strict weak ordering.

Comparison functions used in sorting algorithms need to have strict weak
ordering.  Remove the assert and allow comparisons on all lists.

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

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=342774=342773=342774=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Sep 21 14:20:33 2018
@@ -7607,8 +7607,15 @@ public:
   SI->getAssociatedDeclaration())
 break;
 }
-assert(CI != CE && SI != SE &&
-   "Unexpected end of the map components.");
+
+// Lists contain the same elements.
+if (CI == CE && SI == SE)
+  return false;
+
+// List with less elements is less than list with more elements.
+if (CI == CE || SI == SE)
+  return CI == CE;
+
 const auto *FD1 = cast(CI->getAssociatedDeclaration());
 const auto *FD2 = cast(SI->getAssociatedDeclaration());
 if (FD1->getParent() == FD2->getParent())


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


r342199 - [ODRHash] Fix early exit that skipped code.

2018-09-13 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Thu Sep 13 18:15:28 2018
New Revision: 342199

URL: http://llvm.org/viewvc/llvm-project?rev=342199=rev
Log:
[ODRHash] Fix early exit that skipped code.

There is a bit of code at the end of AddDeclaration that should be run on
every exit of the function.  However, there was an early exit beforehand
that could be triggered, which causes a small amount of data to skip the
hashing, leading to false positive mismatch.  Use a separate function so
that this code is always run.

Modified:
cfe/trunk/include/clang/AST/ODRHash.h
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/class.h

Modified: cfe/trunk/include/clang/AST/ODRHash.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ODRHash.h?rev=342199=342198=342199=diff
==
--- cfe/trunk/include/clang/AST/ODRHash.h (original)
+++ cfe/trunk/include/clang/AST/ODRHash.h Thu Sep 13 18:15:28 2018
@@ -91,6 +91,9 @@ public:
   void AddBoolean(bool value);
 
   static bool isWhitelistedDecl(const Decl* D, const DeclContext *Parent);
+
+private:
+  void AddDeclarationNameImpl(DeclarationName Name);
 };
 
 }  // end namespace clang

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=342199=342198=342199=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Thu Sep 13 18:15:28 2018
@@ -34,8 +34,17 @@ void ODRHash::AddIdentifierInfo(const Id
 
 void ODRHash::AddDeclarationName(DeclarationName Name, bool TreatAsDecl) {
   if (TreatAsDecl)
+// Matches the NamedDecl check in AddDecl
 AddBoolean(true);
 
+  AddDeclarationNameImpl(Name);
+
+  if (TreatAsDecl)
+// Matches the ClassTemplateSpecializationDecl check in AddDecl
+AddBoolean(false);
+}
+
+void ODRHash::AddDeclarationNameImpl(DeclarationName Name) {
   // Index all DeclarationName and use index numbers to refer to them.
   auto Result = DeclNameMap.insert(std::make_pair(Name, DeclNameMap.size()));
   ID.AddInteger(Result.first->second);
@@ -91,9 +100,6 @@ void ODRHash::AddDeclarationName(Declara
 }
   }
   }
-
-  if (TreatAsDecl)
-AddBoolean(false);
 }
 
 void ODRHash::AddNestedNameSpecifier(const NestedNameSpecifier *NNS) {

Modified: cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/class.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/class.h?rev=342199=342198=342199=diff
==
--- cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/class.h (original)
+++ cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/class.h Thu Sep 13 
18:15:28 2018
@@ -6,6 +6,7 @@ class S {
   void run() {
 int x;
 A::Check(, 1);
+A::Check(, 1);
   }
 };
 #endif


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


r341498 - Remove unnecessary options from test RUN lines.

2018-09-05 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Sep  5 15:14:46 2018
New Revision: 341498

URL: http://llvm.org/viewvc/llvm-project?rev=341498=rev
Log:
Remove unnecessary options from test RUN lines.

These tests do not check the color printing, so color options should not
be used when running them.

Modified:
cfe/trunk/test/Modules/odr_hash-Friend.cpp
cfe/trunk/test/Modules/odr_hash-gnu.cpp

Modified: cfe/trunk/test/Modules/odr_hash-Friend.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash-Friend.cpp?rev=341498=341497=341498=diff
==
--- cfe/trunk/test/Modules/odr_hash-Friend.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash-Friend.cpp Wed Sep  5 15:14:46 2018
@@ -9,7 +9,7 @@
 // RUN:  -fmodules \
 // RUN:  -fimplicit-module-maps \
 // RUN:  -fmodules-cache-path=%t/modules.cache \
-// RUN:  -std=c++11 -x c++ %s -verify -DTEST1 -fcolor-diagnostics
+// RUN:  -std=c++11 -x c++ %s -verify -DTEST1
 
 // RUN: %clang_cc1 \
 // RUN:  -I %S/Inputs/odr_hash-Friend \
@@ -17,7 +17,7 @@
 // RUN:  -fmodules \
 // RUN:  -fimplicit-module-maps \
 // RUN:  -fmodules-cache-path=%t/modules.cache \
-// RUN:  -std=c++11 -x c++ %s -verify -DTEST2 -fcolor-diagnostics
+// RUN:  -std=c++11 -x c++ %s -verify -DTEST2
 
 // RUN: %clang_cc1 \
 // RUN:  -I %S/Inputs/odr_hash-Friend \
@@ -25,7 +25,7 @@
 // RUN:  -fmodules \
 // RUN:  -fimplicit-module-maps \
 // RUN:  -fmodules-cache-path=%t/modules.cache \
-// RUN:  -std=c++11 -x c++ %s -verify -DTEST3 -fcolor-diagnostics
+// RUN:  -std=c++11 -x c++ %s -verify -DTEST3
 
 // RUN: %clang_cc1 \
 // RUN:  -I %S/Inputs/odr_hash-Friend \
@@ -33,7 +33,7 @@
 // RUN:  -fmodules \
 // RUN:  -fimplicit-module-maps \
 // RUN:  -fmodules-cache-path=%t/modules.cache \
-// RUN:  -std=c++11 -x c++ %s -verify -DTEST3 -fcolor-diagnostics
+// RUN:  -std=c++11 -x c++ %s -verify -DTEST3
 
 // RUN: %clang_cc1 \
 // RUN:  -I %S/Inputs/odr_hash-Friend \
@@ -41,7 +41,7 @@
 // RUN:  -fmodules \
 // RUN:  -fimplicit-module-maps \
 // RUN:  -fmodules-cache-path=%t/modules.cache \
-// RUN:  -std=c++11 -x c++ %s -verify -DTEST3 -fcolor-diagnostics
+// RUN:  -std=c++11 -x c++ %s -verify -DTEST3
 
 #if defined(TEST1)
 #include "Box.h"

Modified: cfe/trunk/test/Modules/odr_hash-gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash-gnu.cpp?rev=341498=341497=341498=diff
==
--- cfe/trunk/test/Modules/odr_hash-gnu.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash-gnu.cpp Wed Sep  5 15:14:46 2018
@@ -25,7 +25,7 @@
 // RUN: echo "}">> %t/Inputs/module.map
 
 // Run test
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t/cache -x c++ -I%t/Inputs -verify %s -std=gnu++11 
-fcolor-diagnostics
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t/cache -x c++ -I%t/Inputs -verify %s -std=gnu++11
 
 #if !defined(FIRST) && !defined(SECOND)
 #include "first.h"


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


Re: r341421 - [ODRHash] Extend hash to support all Type's.

2018-09-05 Thread Richard Trieu via cfe-commits
Galina,

Thank you for letting me know.  The test case used an enum with default
type which has different behavior on Window systems.  I've added a triple
in r341496 which should fix the test.

Richard

On Wed, Sep 5, 2018 at 1:45 PM Galina Kistanova 
wrote:

> Hello Richard,
>
> This commit added broken test to one of our builders:
>
> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/12240
>
> . . .
> Failing Tests (3):
> Clang :: Modules/odr_hash.cpp
> LLVM :: CodeGen/AMDGPU/mubuf-legalize-operands.ll
> LLVM :: CodeGen/AMDGPU/mubuf-legalize-operands.mir
>
> Please have a look?
> The builder was already red and did not send notifications on this.
>
> Thanks
>
> Galina
>
> On Tue, Sep 4, 2018 at 3:54 PM Richard Trieu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rtrieu
>> Date: Tue Sep  4 15:53:19 2018
>> New Revision: 341421
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=341421=rev
>> Log:
>> [ODRHash] Extend hash to support all Type's.
>>
>> Added:
>> cfe/trunk/test/Modules/odr_hash-gnu.cpp
>> cfe/trunk/test/Modules/odr_hash-vector.cpp
>> cfe/trunk/test/Modules/odr_hash.cl
>> Modified:
>> cfe/trunk/include/clang/AST/ODRHash.h
>> cfe/trunk/lib/AST/ODRHash.cpp
>> cfe/trunk/lib/AST/StmtProfile.cpp
>> cfe/trunk/test/Modules/odr_hash-blocks.cpp
>> cfe/trunk/test/Modules/odr_hash.cpp
>> cfe/trunk/test/Modules/odr_hash.mm
>>
>> Modified: cfe/trunk/include/clang/AST/ODRHash.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ODRHash.h?rev=341421=341420=341421=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/ODRHash.h (original)
>> +++ cfe/trunk/include/clang/AST/ODRHash.h Tue Sep  4 15:53:19 2018
>> @@ -83,7 +83,7 @@ public:
>>void AddIdentifierInfo(const IdentifierInfo *II);
>>void AddNestedNameSpecifier(const NestedNameSpecifier *NNS);
>>void AddTemplateName(TemplateName Name);
>> -  void AddDeclarationName(DeclarationName Name);
>> +  void AddDeclarationName(DeclarationName Name, bool TreatAsDecl =
>> false);
>>void AddTemplateArgument(TemplateArgument TA);
>>void AddTemplateParameterList(const TemplateParameterList *TPL);
>>
>>
>> Modified: cfe/trunk/lib/AST/ODRHash.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=341421=341420=341421=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/ODRHash.cpp (original)
>> +++ cfe/trunk/lib/AST/ODRHash.cpp Tue Sep  4 15:53:19 2018
>> @@ -32,7 +32,10 @@ void ODRHash::AddIdentifierInfo(const Id
>>ID.AddString(II->getName());
>>  }
>>
>> -void ODRHash::AddDeclarationName(DeclarationName Name) {
>> +void ODRHash::AddDeclarationName(DeclarationName Name, bool TreatAsDecl)
>> {
>> +  if (TreatAsDecl)
>> +AddBoolean(true);
>> +
>>// Index all DeclarationName and use index numbers to refer to them.
>>auto Result = DeclNameMap.insert(std::make_pair(Name,
>> DeclNameMap.size()));
>>ID.AddInteger(Result.first->second);
>> @@ -88,6 +91,9 @@ void ODRHash::AddDeclarationName(Declara
>>  }
>>}
>>}
>> +
>> +  if (TreatAsDecl)
>> +AddBoolean(false);
>>  }
>>
>>  void ODRHash::AddNestedNameSpecifier(const NestedNameSpecifier *NNS) {
>> @@ -405,6 +411,7 @@ public:
>>
>>void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) {
>>  AddDecl(D->getTemplatedDecl());
>> +ID.AddInteger(D->getTemplatedDecl()->getODRHash());
>>  Inherited::VisitFunctionTemplateDecl(D);
>>}
>>
>> @@ -552,11 +559,27 @@ void ODRHash::AddFunctionDecl(const Func
>> !Function->isDefaulted() &&
>> !Function->isDeleted() &&
>> !Function->isLateTemplateParsed();
>>AddBoolean(HasBody);
>> -  if (HasBody) {
>> -auto *Body = Function->getBody();
>> -AddBoolean(Body);
>> -if (Body)
>> -  AddStmt(Body);
>> +  if (!HasBody) {
>> +return;
>> +  }
>> +
>> +  auto *Body = Function->getBody();
>> +  AddBoolean(Body);
>> +  if (Body)
>> +AddStmt(Body);
>> +
>> +  // Filter out sub-Decls which will not be processed in order to get an
>> +  // accurate count of Decl's.
>> +  llvm::

r341496 - Add triple to test case.

2018-09-05 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Sep  5 14:55:09 2018
New Revision: 341496

URL: http://llvm.org/viewvc/llvm-project?rev=341496=rev
Log:
Add triple to test case.

This test uses enums, which have different behavior when targeting different
systems.  Specifying a triple will give predictable behavior to this test.

Modified:
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=341496=341495=341496=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Wed Sep  5 14:55:09 2018
@@ -25,7 +25,9 @@
 // RUN: echo "}">> %t/Inputs/module.map
 
 // Run test
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t/cache -x c++ -I%t/Inputs -verify %s -std=c++1z 
-fcolor-diagnostics
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -x c++ -std=c++1z \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache \
+// RUN:   -I%t/Inputs -verify %s
 
 #if !defined(FIRST) && !defined(SECOND)
 #include "first.h"


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


r341421 - [ODRHash] Extend hash to support all Type's.

2018-09-04 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Sep  4 15:53:19 2018
New Revision: 341421

URL: http://llvm.org/viewvc/llvm-project?rev=341421=rev
Log:
[ODRHash] Extend hash to support all Type's.

Added:
cfe/trunk/test/Modules/odr_hash-gnu.cpp
cfe/trunk/test/Modules/odr_hash-vector.cpp
cfe/trunk/test/Modules/odr_hash.cl
Modified:
cfe/trunk/include/clang/AST/ODRHash.h
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/test/Modules/odr_hash-blocks.cpp
cfe/trunk/test/Modules/odr_hash.cpp
cfe/trunk/test/Modules/odr_hash.mm

Modified: cfe/trunk/include/clang/AST/ODRHash.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ODRHash.h?rev=341421=341420=341421=diff
==
--- cfe/trunk/include/clang/AST/ODRHash.h (original)
+++ cfe/trunk/include/clang/AST/ODRHash.h Tue Sep  4 15:53:19 2018
@@ -83,7 +83,7 @@ public:
   void AddIdentifierInfo(const IdentifierInfo *II);
   void AddNestedNameSpecifier(const NestedNameSpecifier *NNS);
   void AddTemplateName(TemplateName Name);
-  void AddDeclarationName(DeclarationName Name);
+  void AddDeclarationName(DeclarationName Name, bool TreatAsDecl = false);
   void AddTemplateArgument(TemplateArgument TA);
   void AddTemplateParameterList(const TemplateParameterList *TPL);
 

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=341421=341420=341421=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Tue Sep  4 15:53:19 2018
@@ -32,7 +32,10 @@ void ODRHash::AddIdentifierInfo(const Id
   ID.AddString(II->getName());
 }
 
-void ODRHash::AddDeclarationName(DeclarationName Name) {
+void ODRHash::AddDeclarationName(DeclarationName Name, bool TreatAsDecl) {
+  if (TreatAsDecl)
+AddBoolean(true);
+
   // Index all DeclarationName and use index numbers to refer to them.
   auto Result = DeclNameMap.insert(std::make_pair(Name, DeclNameMap.size()));
   ID.AddInteger(Result.first->second);
@@ -88,6 +91,9 @@ void ODRHash::AddDeclarationName(Declara
 }
   }
   }
+
+  if (TreatAsDecl)
+AddBoolean(false);
 }
 
 void ODRHash::AddNestedNameSpecifier(const NestedNameSpecifier *NNS) {
@@ -405,6 +411,7 @@ public:
 
   void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) {
 AddDecl(D->getTemplatedDecl());
+ID.AddInteger(D->getTemplatedDecl()->getODRHash());
 Inherited::VisitFunctionTemplateDecl(D);
   }
 
@@ -552,11 +559,27 @@ void ODRHash::AddFunctionDecl(const Func
!Function->isDefaulted() && !Function->isDeleted() &&
!Function->isLateTemplateParsed();
   AddBoolean(HasBody);
-  if (HasBody) {
-auto *Body = Function->getBody();
-AddBoolean(Body);
-if (Body)
-  AddStmt(Body);
+  if (!HasBody) {
+return;
+  }
+
+  auto *Body = Function->getBody();
+  AddBoolean(Body);
+  if (Body)
+AddStmt(Body);
+
+  // Filter out sub-Decls which will not be processed in order to get an
+  // accurate count of Decl's.
+  llvm::SmallVector Decls;
+  for (Decl *SubDecl : Function->decls()) {
+if (isWhitelistedDecl(SubDecl, Function)) {
+  Decls.push_back(SubDecl);
+}
+  }
+
+  ID.AddInteger(Decls.size());
+  for (auto SubDecl : Decls) {
+AddSubDecl(SubDecl);
   }
 }
 
@@ -592,13 +615,24 @@ void ODRHash::AddDecl(const Decl *D) {
   assert(D && "Expecting non-null pointer.");
   D = D->getCanonicalDecl();
 
-  if (const NamedDecl *ND = dyn_cast(D)) {
-AddDeclarationName(ND->getDeclName());
+  const NamedDecl *ND = dyn_cast(D);
+  AddBoolean(ND);
+  if (!ND) {
+ID.AddInteger(D->getKind());
 return;
   }
 
-  ID.AddInteger(D->getKind());
-  // TODO: Handle non-NamedDecl here.
+  AddDeclarationName(ND->getDeclName());
+
+  const auto *Specialization =
+dyn_cast(D);
+  AddBoolean(Specialization);
+  if (Specialization) {
+const TemplateArgumentList  = Specialization->getTemplateArgs();
+ID.AddInteger(List.size());
+for (const TemplateArgument  : List.asArray())
+  AddTemplateArgument(TA);
+  }
 }
 
 namespace {
@@ -700,11 +734,67 @@ public:
 VisitArrayType(T);
   }
 
+  void VisitAttributedType(const AttributedType *T) {
+ID.AddInteger(T->getAttrKind());
+AddQualType(T->getModifiedType());
+AddQualType(T->getEquivalentType());
+
+VisitType(T);
+  }
+
+  void VisitBlockPointerType(const BlockPointerType *T) {
+AddQualType(T->getPointeeType());
+VisitType(T);
+  }
+
   void VisitBuiltinType(const BuiltinType *T) {
 ID.AddInteger(T->getKind());
 VisitType(T);
   }
 
+  void VisitComplexType(const ComplexType *T) {
+AddQualType(T->getElementType());
+VisitType(T);
+  }
+
+  void VisitDecltypeType(const DecltypeType *T) {
+AddStmt(T->getUnderlyingExpr());
+AddQualType(T->getUnderlyingType());
+VisitType(T);
+  }
+
+ 

r341013 - Ensure canonical type is actually canonical.

2018-08-29 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Aug 29 18:57:52 2018
New Revision: 341013

URL: http://llvm.org/viewvc/llvm-project?rev=341013=rev
Log:
Ensure canonical type is actually canonical.

ASTContext::applyObjCProtocolQualifiers will return a canonical type when given
a canonical type and an array of canonical protocols.  If the protocols are not
canonical then the returned type is also not canonical.  Since a canonical type 
is needed, canonicalize the returned type before using it.  This later prevents
a type from having a non-canonical canonical type.

Added:
cfe/trunk/test/Modules/odr_hash.mm
Modified:
cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=341013=341012=341013=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Aug 29 18:57:52 2018
@@ -4550,8 +4550,8 @@ ASTContext::getObjCTypeParamType(const O
 if (!protocols.empty()) {
   // Apply the protocol qualifers.
   bool hasError;
-  Canonical = applyObjCProtocolQualifiers(Canonical, protocols, hasError,
-  true/*allowOnPointerType*/);
+  Canonical = getCanonicalType(applyObjCProtocolQualifiers(
+  Canonical, protocols, hasError, true /*allowOnPointerType*/));
   assert(!hasError && "Error when apply protocol qualifier to bound type");
 }
   }

Added: cfe/trunk/test/Modules/odr_hash.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.mm?rev=341013=auto
==
--- cfe/trunk/test/Modules/odr_hash.mm (added)
+++ cfe/trunk/test/Modules/odr_hash.mm Wed Aug 29 18:57:52 2018
@@ -0,0 +1,74 @@
+// Clear and create directories
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: mkdir %t/cache
+// RUN: mkdir %t/Inputs
+
+// Build first header file
+// RUN: echo "#define FIRST" >> %t/Inputs/first.h
+// RUN: cat %s   >> %t/Inputs/first.h
+
+// Build second header file
+// RUN: echo "#define SECOND" >> %t/Inputs/second.h
+// RUN: cat %s>> %t/Inputs/second.h
+
+// Test that each header can compile
+// RUN: %clang_cc1 -fsyntax-only -x objective-c++ %t/Inputs/first.h -fblocks 
-fobjc-arc
+// RUN: %clang_cc1 -fsyntax-only -x objective-c++ %t/Inputs/second.h -fblocks 
-fobjc-arc
+
+// Build module map file
+// RUN: echo "module FirstModule {" >> %t/Inputs/module.map
+// RUN: echo "header \"first.h\""   >> %t/Inputs/module.map
+// RUN: echo "}">> %t/Inputs/module.map
+// RUN: echo "module SecondModule {">> %t/Inputs/module.map
+// RUN: echo "header \"second.h\""  >> %t/Inputs/module.map
+// RUN: echo "}">> %t/Inputs/module.map
+
+// Run test
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t/cache -x objective-c++ -I%t/Inputs -verify %s -fblocks 
-fobjc-arc
+
+#if !defined(FIRST) && !defined(SECOND)
+#include "first.h"
+#include "second.h"
+#endif
+
+#if defined(FIRST) || defined(SECOND)
+@protocol P1
+@end
+
+@interface I1
+@end
+
+@interface Interface1  {
+@public
+  T x;
+}
+@end
+#endif
+
+#if defined(FIRST)
+struct S {
+  Interface1 *I;
+  decltype(I->x) x;
+  int y;
+};
+#elif defined(SECOND)
+struct S {
+  Interface1 *I;
+  decltype(I->x) x;
+  bool y;
+};
+#else
+S s;
+// expected-error@second.h:* {{'S::y' from module 'SecondModule' is not 
present in definition of 'S' in module 'FirstModule'}}
+// expected-note@first.h:* {{declaration of 'y' does not match}}
+#endif
+
+// Keep macros contained to one file.
+#ifdef FIRST
+#undef FIRST
+#endif
+
+#ifdef SECOND
+#undef SECOND
+#endif


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


r340357 - Add space to TemplateArgument dump

2018-08-21 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Aug 21 15:55:26 2018
New Revision: 340357

URL: http://llvm.org/viewvc/llvm-project?rev=340357=rev
Log:
Add space to TemplateArgument dump

Add a missing space when dumping a template argument which is a template
expansion.  Found during debugging so no test.

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=340357=340356=340357=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Aug 21 15:55:26 2018
@@ -997,7 +997,7 @@ void ASTDumper::dumpTemplateArgument(con
   A.getAsTemplate().dump(OS);
   break;
 case TemplateArgument::TemplateExpansion:
-  OS << " template expansion";
+  OS << " template expansion ";
   A.getAsTemplateOrTemplatePattern().dump(OS);
   break;
 case TemplateArgument::Expression:


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


r339409 - Fix size calculation from r339380

2018-08-09 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Thu Aug  9 18:30:10 2018
New Revision: 339409

URL: http://llvm.org/viewvc/llvm-project?rev=339409=rev
Log:
Fix size calculation from r339380

r339380 changed the trailing types of ParsedAttr to use llvm::TrailingObjects.
However, it did not copy over one of the size attributes, causing a too
small allocation for this object.  The error was detected with
AddressSanitizer use-after-poison

Modified:
cfe/trunk/include/clang/Sema/ParsedAttr.h

Modified: cfe/trunk/include/clang/Sema/ParsedAttr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ParsedAttr.h?rev=339409=339408=339409=diff
==
--- cfe/trunk/include/clang/Sema/ParsedAttr.h (original)
+++ cfe/trunk/include/clang/Sema/ParsedAttr.h Thu Aug  9 18:30:10 2018
@@ -581,7 +581,7 @@ public:
 TypeTagForDatatypeAllocSize =
 ParsedAttr::totalSizeToAlloc(0, 0, 1, 0, 0),
+ detail::PropertyData>(1, 0, 1, 0, 0),
 PropertyAllocSize =
 ParsedAttr::totalSizeToAllochttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r337978 - [ODRHash] Support hashing enums.

2018-07-25 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Jul 25 15:52:05 2018
New Revision: 337978

URL: http://llvm.org/viewvc/llvm-project?rev=337978=rev
Log:
[ODRHash] Support hashing enums.

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/ODRHash.h
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=337978=337977=337978=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Jul 25 15:52:05 2018
@@ -3335,6 +3335,10 @@ class EnumDecl : public TagDecl {
   /// information.
   MemberSpecializationInfo *SpecializationInfo = nullptr;
 
+  /// Store the ODRHash after first calculation.
+  unsigned HasODRHash : 1;
+  unsigned ODRHash;
+
   EnumDecl(ASTContext , DeclContext *DC, SourceLocation StartLoc,
SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl,
bool Scoped, bool ScopedUsingClassTag, bool Fixed)
@@ -3346,6 +3350,8 @@ class EnumDecl : public TagDecl {
 IsScoped = Scoped;
 IsScopedUsingClassTag = ScopedUsingClassTag;
 IsFixed = Fixed;
+HasODRHash = false;
+ODRHash = 0;
   }
 
   void anchor() override;
@@ -3496,6 +3502,8 @@ public:
 return IsFixed;
   }
 
+  unsigned getODRHash();
+
   /// Returns true if this can be considered a complete type.
   bool isComplete() const {
 // IntegerType is set for fixed type enums and non-fixed but implicitly

Modified: cfe/trunk/include/clang/AST/ODRHash.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ODRHash.h?rev=337978=337977=337978=diff
==
--- cfe/trunk/include/clang/AST/ODRHash.h (original)
+++ cfe/trunk/include/clang/AST/ODRHash.h Wed Jul 25 15:52:05 2018
@@ -58,6 +58,10 @@ public:
   // hash as if the function has no body.
   void AddFunctionDecl(const FunctionDecl *Function, bool SkipBody = false);
 
+  // Use this for ODR checking enums between modules.  This method compares
+  // more information than the AddDecl class.
+  void AddEnumDecl(const EnumDecl *Enum);
+
   // Process SubDecls of the main Decl.  This method calls the DeclVisitor
   // while AddDecl does not.
   void AddSubDecl(const Decl *D);
@@ -83,7 +87,7 @@ public:
   // Save booleans until the end to lower the size of data to process.
   void AddBoolean(bool value);
 
-  static bool isWhitelistedDecl(const Decl* D, const CXXRecordDecl *Record);
+  static bool isWhitelistedDecl(const Decl* D, const DeclContext *Parent);
 };
 
 }  // end namespace clang

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=337978=337977=337978=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Wed Jul 25 
15:52:05 2018
@@ -341,6 +341,33 @@ def note_module_odr_violation_function :
   "a different body"
   "}1">;
 
+def err_module_odr_violation_enum : Error<
+  "%q0 has different definitions in different modules; "
+  "%select{definition in module '%2'|defined here}1 "
+  "first difference is "
+  "%select{"
+  "enum that is %select{not scoped|scoped}4|"
+  "enum scoped with keyword %select{struct|class}4|"
+  "enum %select{without|with}4 specified type|"
+  "enum with specified type %4|"
+  "enum with %4 element%s4|"
+  "%ordinal4 element has name %5|"
+  "%ordinal4 element %5 %select{has|does not have}6 an initilizer|"
+  "%ordinal4 element %5 has an initializer|"
+  "}3">;
+
+def note_module_odr_violation_enum : Note<"but in '%0' found "
+  "%select{"
+  "enum that is %select{not scoped|scoped}2|"
+  "enum scoped with keyword %select{struct|class}2|"
+  "enum %select{without|with}2 specified type|"
+  "enum with specified type %2|"
+  "enum with %2 element%s2|"
+  "%ordinal2 element has name %3|"
+  "%ordinal2 element %3 %select{has|does not have}4 an initializer|"
+  "%ordinal2 element %3 has different initializer|"
+  "}1">;
+
 def err_module_odr_violation_mismatch_decl_unknown : Error<
   "%q0 %select{with definition in module '%2'|defined here}1 has different "
   "definitions in different modules; first difference is this "

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 

r336632 - [ODRHash] Merge the two function hashes into one.

2018-07-09 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Mon Jul  9 18:40:50 2018
New Revision: 336632

URL: http://llvm.org/viewvc/llvm-project?rev=336632=rev
Log:
[ODRHash] Merge the two function hashes into one.

Functions that are a sub-Decl of a record were hashed differently than other
functions.  This change keeps the AddFunctionDecl function and the hash of
records now calls this function.  In addition, AddFunctionDecl has an option
to perform a hash as if the body was absent, which is required for some
checks after loading modules.  Additional logic prevents multiple error
message from being printed.

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/ODRHash.h
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=336632=336631=336632=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Jul  9 18:40:50 2018
@@ -2504,6 +2504,10 @@ public:
   /// stored on first call, then the stored value returned on the other calls.
   unsigned getODRHash();
 
+  /// Returns cached ODRHash of the function.  This must have been previously
+  /// computed and stored.
+  unsigned getODRHash() const;
+
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) {

Modified: cfe/trunk/include/clang/AST/ODRHash.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ODRHash.h?rev=336632=336631=336632=diff
==
--- cfe/trunk/include/clang/AST/ODRHash.h (original)
+++ cfe/trunk/include/clang/AST/ODRHash.h Mon Jul  9 18:40:50 2018
@@ -54,8 +54,9 @@ public:
   void AddCXXRecordDecl(const CXXRecordDecl *Record);
 
   // Use this for ODR checking functions between modules.  This method compares
-  // more information than the AddDecl class.
-  void AddFunctionDecl(const FunctionDecl *Function);
+  // more information than the AddDecl class.  SkipBody will process the
+  // hash as if the function has no body.
+  void AddFunctionDecl(const FunctionDecl *Function, bool SkipBody = false);
 
   // Process SubDecls of the main Decl.  This method calls the DeclVisitor
   // while AddDecl does not.

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=336632=336631=336632=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Mon Jul  9 
18:40:50 2018
@@ -192,6 +192,8 @@ def err_module_odr_violation_mismatch_de
   "%select{method %5|constructor|destructor}4 "
 "is %select{not deleted|deleted}6|"
   "%select{method %5|constructor|destructor}4 "
+"is %select{not defaulted|defaulted}6|"
+  "%select{method %5|constructor|destructor}4 "
 "is %select{|pure }6%select{not virtual|virtual}7|"
   "%select{method %5|constructor|destructor}4 "
 "is %select{not static|static}6|"
@@ -217,6 +219,10 @@ def err_module_odr_violation_mismatch_de
 "with %6 template argument%s6|"
   "%select{method %5|constructor|destructor}4 "
 "with %6 for %ordinal7 template argument|"
+  "%select{method %5|constructor|destructor}4 "
+"with %select{no body|body}6|"
+  "%select{method %5|constructor|destructor}4 "
+"with body|"
   "%select{typedef|type alias}4 name %5|"
   "%select{typedef|type alias}4 %5 with underlying type %6|"
   "data member with name %4|"
@@ -257,6 +263,8 @@ def note_module_odr_violation_mismatch_d
   "%select{method %3|constructor|destructor}2 "
 "is %select{not deleted|deleted}4|"
   "%select{method %3|constructor|destructor}2 "
+"is %select{not defaulted|defaulted}4|"
+  "%select{method %3|constructor|destructor}2 "
 "is %select{|pure }4%select{not virtual|virtual}5|"
   "%select{method %3|constructor|destructor}2 "
 "is %select{not static|static}4|"
@@ -282,6 +290,10 @@ def note_module_odr_violation_mismatch_d
 "with %4 template argument%s4|"
   "%select{method %3|constructor|destructor}2 "
 "with %4 for %ordinal5 template argument|"
+  "%select{method %3|constructor|destructor}2 "
+"with %select{no body|body}4|"
+  "%select{method %3|constructor|destructor}2 "
+"with different body|"
   "%select{typedef|type alias}2 name %3|"
   "%select{typedef|type alias}2 %3 with different underlying type %4|"
   "data member with name %2|"

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 

r336610 - Rename function calls missed in r336605

2018-07-09 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Mon Jul  9 15:09:33 2018
New Revision: 336610

URL: http://llvm.org/viewvc/llvm-project?rev=336610=rev
Log:
Rename function calls missed in r336605

NextIsLatest -> isFirst

Modified:
cfe/trunk/include/clang/AST/Decl.h

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=336610=336609=336610=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Jul  9 15:09:33 2018
@@ -4260,7 +4260,7 @@ template
 void Redeclarable::setPreviousDecl(decl_type *PrevDecl) {
   // Note: This routine is implemented here because we need both NamedDecl
   // and Redeclarable to be defined.
-  assert(RedeclLink.NextIsLatest() &&
+  assert(RedeclLink.isFirst() &&
  "setPreviousDecl on a decl already in a redeclaration chain");
 
   if (PrevDecl) {
@@ -4268,7 +4268,7 @@ void Redeclarable::setPreviou
 // redeclaration, or we can build invalid chains. If the most recent
 // redeclaration is invalid, it won't be PrevDecl, but we want it anyway.
 First = PrevDecl->getFirstDecl();
-assert(First->RedeclLink.NextIsLatest() && "Expected first");
+assert(First->RedeclLink.isFirst() && "Expected first");
 decl_type *MostRecent = First->getNextRedeclaration();
 RedeclLink = PreviousDeclLink(cast(MostRecent));
 


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


r336475 - Check returned type is valid before using it.

2018-07-06 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Jul  6 17:17:25 2018
New Revision: 336475

URL: http://llvm.org/viewvc/llvm-project?rev=336475=rev
Log:
Check returned type is valid before using it.

Add a .isNull() check to returned QualType.  Fixes PR38077

Modified:
cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
cfe/trunk/test/SemaCXX/overloaded-name.cpp

Modified: cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp?rev=336475=336474=336475=diff
==
--- cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp Fri Jul  6 17:17:25 2018
@@ -846,6 +846,9 @@ bool Sema::ActOnCXXNestedNameSpecifierDe
   assert(DS.getTypeSpecType() == DeclSpec::TST_decltype);
 
   QualType T = BuildDecltypeType(DS.getRepAsExpr(), DS.getTypeSpecTypeLoc());
+  if (T.isNull())
+return true;
+
   if (!T->isDependentType() && !T->getAs()) {
 Diag(DS.getTypeSpecTypeLoc(), diag::err_expected_class_or_namespace) 
   << T << getLangOpts().CPlusPlus;

Modified: cfe/trunk/test/SemaCXX/overloaded-name.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overloaded-name.cpp?rev=336475=336474=336475=diff
==
--- cfe/trunk/test/SemaCXX/overloaded-name.cpp (original)
+++ cfe/trunk/test/SemaCXX/overloaded-name.cpp Fri Jul  6 17:17:25 2018
@@ -28,3 +28,11 @@ namespace rdar9623945 {
 }
   };
 }
+
+namespace PR38077 {
+  template  void bar() {} // expected-note {{possible target for 
call}}
+
+  int run() {
+decltype(bar)::does_not_exist; // expected-error {{reference to overloaded 
function could not be resolved; did you mean to call it?}}
+  }
+}


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


r334160 - Change return value of trivial visibility check.

2018-06-06 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Jun  6 20:20:30 2018
New Revision: 334160

URL: http://llvm.org/viewvc/llvm-project?rev=334160=rev
Log:
Change return value of trivial visibility check.

Previous, if no Decl's were checked, visibility was set to false.  Switch it
so that in cases of no Decl's, return true.  These are the Decl's after being
filtered.  Also remove an unreachable return statement since it is directly
after another return statement.

Added:
cfe/trunk/test/Modules/local-visibility.cpp
Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=334160=334159=334160=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Wed Jun  6 20:20:30 2018
@@ -1452,6 +1452,8 @@ template
 static bool hasVisibleDeclarationImpl(Sema , const NamedDecl *D,
   llvm::SmallVectorImpl *Modules,
   Filter F) {
+  bool HasFilteredRedecls = false;
+
   for (auto *Redecl : D->redecls()) {
 auto *R = cast(Redecl);
 if (!F(R))
@@ -1460,6 +1462,8 @@ static bool hasVisibleDeclarationImpl(Se
 if (S.isVisible(R))
   return true;
 
+HasFilteredRedecls = true;
+
 if (Modules) {
   Modules->push_back(R->getOwningModule());
   const auto  = S.Context.getModulesWithMergedDefinition(R);
@@ -1467,7 +1471,11 @@ static bool hasVisibleDeclarationImpl(Se
 }
   }
 
-  return false;
+  // Only return false if there is at least one redecl that is not filtered 
out.
+  if (HasFilteredRedecls)
+return false;
+
+  return true;
 }
 
 bool Sema::hasVisibleExplicitSpecialization(
@@ -1497,8 +1505,6 @@ bool Sema::hasVisibleMemberSpecializatio
 //class definition?
 return D->getLexicalDeclContext()->isFileContext();
   });
-
-  return false;
 }
 
 /// Determine whether a declaration is visible to name lookup.

Added: cfe/trunk/test/Modules/local-visibility.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/local-visibility.cpp?rev=334160=auto
==
--- cfe/trunk/test/Modules/local-visibility.cpp (added)
+++ cfe/trunk/test/Modules/local-visibility.cpp Wed Jun  6 20:20:30 2018
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -fmodules %s -verify
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+
+// expected-no-diagnostics
+template 
+struct S {
+  template 
+  struct Inner { };
+
+  template <>
+  struct Inner<0> { };
+};
+
+S::Inner<1> I1;
+S::Inner<0> I0;


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


r334151 - [ODRHash] Adjust info stored for FunctionTemplateDecl.

2018-06-06 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Jun  6 17:20:58 2018
New Revision: 334151

URL: http://llvm.org/viewvc/llvm-project?rev=334151=rev
Log:
[ODRHash] Adjust info stored for FunctionTemplateDecl.

Avoid storing information for definitions since those can be out-of-line and
vary between modules even when the declarations are the same.

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=334151=334150=334151=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Wed Jun  6 17:20:58 2018
@@ -427,7 +427,7 @@ public:
 
   void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) {
 Visit(D->getTemplatedDecl());
-ID.AddInteger(D->getTemplatedDecl()->getODRHash());
+AddDecl(D->getTemplatedDecl());
 Inherited::VisitFunctionTemplateDecl(D);
   }
 };

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=334151=334150=334151=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Wed Jun  6 17:20:58 2018
@@ -3617,6 +3617,20 @@ int I10 = F10();
 #endif
 // expected-error@second.h:* {{'FunctionDecl::F10' has different definitions 
in different modules; definition in module 'SecondModule' first difference is 
function body}}
 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
+
+#if defined(FIRST)
+struct S11 {
+  template  void foo();
+};
+#elif defined(SECOND)
+struct S11 {
+  template  void foo();
+};
+template  void S11::foo() {}
+#else
+S11 s11;
+#endif
+
 }  // namespace FunctionDecl
 
 namespace DeclTemplateArguments {


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


r333486 - [ODRHash] Support FunctionTemplateDecl in records.

2018-05-29 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue May 29 18:12:26 2018
New Revision: 333486

URL: http://llvm.org/viewvc/llvm-project?rev=333486=rev
Log:
[ODRHash] Support FunctionTemplateDecl in records.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=333486=333485=333486=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Tue May 29 
18:12:26 2018
@@ -168,11 +168,11 @@ def err_module_odr_violation_mismatch_de
   "%select{definition in module '%2'|defined here}1 found "
   "%select{end of class|public access specifier|private access specifier|"
   "protected access specifier|static assert|field|method|type alias|typedef|"
-  "data member|friend declaration}3">;
+  "data member|friend declaration|function template}3">;
 def note_module_odr_violation_mismatch_decl : Note<"but in '%0' found "
   "%select{end of class|public access specifier|private access specifier|"
   "protected access specifier|static assert|field|method|type alias|typedef|"
-  "data member|friend declaration}1">;
+  "data member|friend declaration|function template}1">;
 
 def err_module_odr_violation_mismatch_decl_diff : Error<
   "%q0 has different definitions in different modules; first difference is "
@@ -227,6 +227,18 @@ def err_module_odr_violation_mismatch_de
   "friend %select{class|function}4|"
   "friend %4|"
   "friend function %4|"
+  "function template %4 with %5 template parameter%s5|"
+  "function template %4 with %ordinal5 template parameter being a "
+"%select{type|non-type|template}6 template parameter|"
+  "function template %4 with %ordinal5 template parameter "
+"%select{with no name|named %7}6|"
+  "function template %4 with %ordinal5 template parameter with "
+"%select{no |}6default argument|"
+  "function template %4 with %ordinal5 template parameter with "
+"default argument %6|"
+  "function template %4 with %ordinal5 template parameter with one type|"
+  "function template %4 with %ordinal5 template parameter %select{not |}6"
+"being a template parameter pack|"
   "}3">;
 
 def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0' found "
@@ -280,6 +292,18 @@ def note_module_odr_violation_mismatch_d
   "friend %select{class|function}2|"
   "friend %2|"
   "friend function %2|"
+  "function template %2 with %3 template parameter%s3|"
+  "function template %2 with %ordinal3 template paramter being a "
+"%select{type|non-type|template}4 template parameter|"
+  "function template %2 with %ordinal3 template parameter "
+"%select{with no name|named %5}4|"
+  "function template %2 with %ordinal3 template parameter with "
+"%select{no |}4default argument|"
+  "function template %2 with %ordinal3 template parameter with "
+"default argument %4|"
+  "function template %2 with %ordinal3 template parameter with different type|"
+  "function template %2 with %ordinal3 template parameter %select{not |}4"
+"being a template parameter pack|"
   "}1">;
 
 def err_module_odr_violation_function : Error<

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=333486=333485=333486=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Tue May 29 18:12:26 2018
@@ -383,6 +383,7 @@ public:
 if (hasDefaultArgument) {
   AddTemplateArgument(D->getDefaultArgument());
 }
+Hash.AddBoolean(D->isParameterPack());
 
 Inherited::VisitTemplateTypeParmDecl(D);
   }
@@ -395,6 +396,7 @@ public:
 if (hasDefaultArgument) {
   AddStmt(D->getDefaultArgument());
 }
+Hash.AddBoolean(D->isParameterPack());
 
 Inherited::VisitNonTypeTemplateParmDecl(D);
   }
@@ -407,9 +409,27 @@ public:
 if (hasDefaultArgument) {
   AddTemplateArgument(D->getDefaultArgument().getArgument());
 }
+Hash.AddBoolean(D->isParameterPack());
 
 Inherited::VisitTemplateTemplateParmDecl(D);
   }
+
+  void VisitTemplateDecl(const TemplateDecl *D) {
+Hash.AddTemplateParameterList(D->getTemplateParameters());
+
+Inherited::VisitTemplateDecl(D);
+  }
+
+  void VisitRedeclarableTemplateDecl(const RedeclarableTemplateDecl *D) {
+Hash.AddBoolean(D->isMemberSpecialization());
+Inherited::VisitRedeclarableTemplateDecl(D);
+  }
+
+  void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) {
+Visit(D->getTemplatedDecl());
+ID.AddInteger(D->getTemplatedDecl()->getODRHash());
+

r333471 - Check pointer null-ness before dereferencing it.

2018-05-29 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue May 29 15:43:00 2018
New Revision: 333471

URL: http://llvm.org/viewvc/llvm-project?rev=333471=rev
Log:
Check pointer null-ness before dereferencing it.

-Warc-repeated-use-of-weak may trigger a segmentation fault when the Decl
being checked is outside of a function scope, leaving the current function
info pointer null.  This adds a check before using the function info.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaObjC/arc-repeated-weak.mm

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=333471=333470=333471=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue May 29 15:43:00 2018
@@ -10799,11 +10799,12 @@ void Sema::AddInitializerToDecl(Decl *Re
 // we do not warn to warn spuriously when 'x' and 'y' are on separate
 // paths through the function. This should be revisited if
 // -Wrepeated-use-of-weak is made flow-sensitive.
-if ((VDecl->getType().getObjCLifetime() == Qualifiers::OCL_Strong ||
- VDecl->getType().isNonWeakInMRRWithObjCWeak(Context)) &&
-!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
- Init->getLocStart()))
-  getCurFunction()->markSafeWeakUse(Init);
+if (FunctionScopeInfo *FSI = getCurFunction())
+  if ((VDecl->getType().getObjCLifetime() == Qualifiers::OCL_Strong ||
+   VDecl->getType().isNonWeakInMRRWithObjCWeak(Context)) &&
+  !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
+   Init->getLocStart()))
+FSI->markSafeWeakUse(Init);
   }
 
   // The initialization is usually a full-expression.

Modified: cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-repeated-weak.mm?rev=333471=333470=333471=diff
==
--- cfe/trunk/test/SemaObjC/arc-repeated-weak.mm (original)
+++ cfe/trunk/test/SemaObjC/arc-repeated-weak.mm Tue May 29 15:43:00 2018
@@ -479,3 +479,6 @@ void foo1() {
 // expected-error@-2{{cast of 'E' to 'INTFPtrTy' (aka 'INTF *') is disallowed 
with ARC}}
 #endif
 }
+
+@class NSString;
+static NSString* const kGlobal = @"";


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


r332310 - Enable control flow pruning of float overflow warnings.

2018-05-14 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Mon May 14 16:21:48 2018
New Revision: 332310

URL: http://llvm.org/viewvc/llvm-project?rev=332310=rev
Log:
Enable control flow pruning of float overflow warnings.

Like other conversion warnings, allow float overflow warnings to be disabled
in known dead paths of template instantiation.  This often occurs when a
template template type is a numeric type and the template will check the
range of the numeric type before performing the conversion.

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/warn-float-conversion.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=332310=332309=332310=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon May 14 16:21:48 2018
@@ -9673,7 +9673,8 @@ static void DiagnoseFloatingImpCast(Sema
 return DiagnoseImpCast(
 S, E, T, CContext,
 IsLiteral ? diag::warn_impcast_literal_float_to_integer_out_of_range
-  : diag::warn_impcast_float_to_integer_out_of_range);
+  : diag::warn_impcast_float_to_integer_out_of_range,
+PruneWarnings);
 
   unsigned DiagID = 0;
   if (IsLiteral) {

Modified: cfe/trunk/test/SemaCXX/warn-float-conversion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-float-conversion.cpp?rev=332310=332309=332310=diff
==
--- cfe/trunk/test/SemaCXX/warn-float-conversion.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-float-conversion.cpp Mon May 14 16:21:48 2018
@@ -89,4 +89,38 @@ void TestOverflow() {
 
   char e = 1.0 / 0.0;  // expected-warning{{implicit conversion of out of 
range value from 'double' to 'char' is undefined}}
 }
+
+
+template 
+class Check {
+ public:
+  static constexpr bool Safe();
+};
+
+template<>
+constexpr bool Check::Safe() { return false; }
+
+template<>
+constexpr bool Check::Safe() { return true; }
+
+template 
+T run1(T t) {
+  const float ret = 800;
+  return ret;  // expected-warning {{implicit conversion of out of range value 
from 'const float' to 'char' is undefined}}
+}
+
+template 
+T run2(T t) {
+  const float ret = 800;
+  if (Check::Safe())
+return ret;
+  else
+return t;
+}
+
+void test() {
+  float a = run1(a) + run2(a);
+  char b = run1(b) + run2(b);  // expected-note {{in instantiation of function 
template specialization 'run1' requested here}}
+}
+
 #endif  // OVERFLOW


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


r331706 - Move test input file into same directory as test. NFC

2018-05-07 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Mon May  7 17:29:21 2018
New Revision: 331706

URL: http://llvm.org/viewvc/llvm-project?rev=331706=rev
Log:
Move test input file into same directory as test.  NFC

Added:
cfe/trunk/test/Frontend/Inputs/resource_dir_with_cfi_blacklist/
cfe/trunk/test/Frontend/Inputs/resource_dir_with_cfi_blacklist/share/

cfe/trunk/test/Frontend/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
Removed:
cfe/trunk/test/Driver/Inputs/resource_dir_with_cfi_blacklist/
Modified:
cfe/trunk/test/Frontend/dependency-gen.c

Added: 
cfe/trunk/test/Frontend/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt?rev=331706=auto
==
(empty)

Modified: cfe/trunk/test/Frontend/dependency-gen.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/dependency-gen.c?rev=331706=331705=331706=diff
==
--- cfe/trunk/test/Frontend/dependency-gen.c (original)
+++ cfe/trunk/test/Frontend/dependency-gen.c Mon May  7 17:29:21 2018
@@ -21,7 +21,7 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck 
-check-prefix=CHECK-SIX %s
 // CHECK-SIX: {{ }}x.h
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only 
-resource-dir=%S/../Driver/Inputs/resource_dir_with_cfi_blacklist 
-fsanitize=cfi-vcall -flto -fvisibility=hidden 
-fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only 
-resource-dir=%S/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall 
-flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck 
-check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST


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


r330887 - Switch to Clang's isDigit function.

2018-04-25 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Apr 25 16:50:55 2018
New Revision: 330887

URL: http://llvm.org/viewvc/llvm-project?rev=330887=rev
Log:
Switch to Clang's isDigit function.

std::isdigit can be overloaded, causing the template deduction to fail.  Use
Clang's isDigit function which to avoid this.  Switch the other calls for
consistency.

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp?rev=330887=330886=330887=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp Wed Apr 25 16:50:55 2018
@@ -8,13 +8,13 @@
 
//===--===//
 
 #include "RISCV.h"
+#include "clang/Basic/CharInfo.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/TargetParser.h"
 #include "llvm/Support/raw_ostream.h"
-#include 
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
@@ -57,7 +57,7 @@ static bool getExtensionVersion(const Dr
   auto I = In.begin();
   auto E = In.end();
 
-  while (I != E && isdigit(*I))
+  while (I != E && isDigit(*I))
 Major.append(1, *I++);
 
   if (Major.empty())
@@ -66,7 +66,7 @@ static bool getExtensionVersion(const Dr
   if (I != E && *I == 'p') {
 ++I;
 
-while (I != E && isdigit(*I))
+while (I != E && isDigit(*I))
   Minor.append(1, *I++);
 
 // Expected 'p' to be followed by minor version number.
@@ -161,7 +161,7 @@ static void getExtensionFeatures(const D
 }
 
 std::string Major, Minor;
-auto Pos = Name.find_if(std::isdigit);
+auto Pos = Name.find_if(isDigit);
 if (Pos != StringRef::npos) {
   auto Next =  Name.substr(Pos);
   Name = Name.substr(0, Pos);


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


r330789 - [ODRHash] Hash template arguments of methods.

2018-04-24 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Apr 24 17:31:15 2018
New Revision: 330789

URL: http://llvm.org/viewvc/llvm-project?rev=330789=rev
Log:
[ODRHash] Hash template arguments of methods.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=330789=330788=330789=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Tue Apr 24 
17:31:15 2018
@@ -211,6 +211,12 @@ def err_module_odr_violation_mismatch_de
 "with %ordinal6 parameter with%select{out|}7 a default argument|"
   "%select{method %5|constructor|destructor}4 "
 "with %ordinal6 parameter with a default argument|"
+  "%select{method %5|constructor|destructor}4 "
+"with %select{no |}6template arguments|"
+  "%select{method %5|constructor|destructor}4 "
+"with %6 template argument%s6|"
+  "%select{method %5|constructor|destructor}4 "
+"with %6 for %ordinal7 template argument|"
   "%select{typedef|type alias}4 name %5|"
   "%select{typedef|type alias}4 %5 with underlying type %6|"
   "data member with name %4|"
@@ -258,6 +264,12 @@ def note_module_odr_violation_mismatch_d
 "with %ordinal4 parameter with%select{out|}5 a default argument|"
   "%select{method %3|constructor|destructor}2 "
 "with %ordinal4 parameter with a different default argument|"
+  "%select{method %3|constructor|destructor}2 "
+"with %select{no |}4template arguments|"
+  "%select{method %3|constructor|destructor}2 "
+"with %4 template argument%s4|"
+  "%select{method %3|constructor|destructor}2 "
+"with %4 for %ordinal5 template argument|"
   "%select{typedef|type alias}2 name %3|"
   "%select{typedef|type alias}2 %3 with different underlying type %4|"
   "data member with name %2|"

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=330789=330788=330789=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Tue Apr 24 17:31:15 2018
@@ -148,6 +148,8 @@ void ODRHash::AddTemplateArgument(Templa
   AddQualType(TA.getAsType());
   break;
 case TemplateArgument::Declaration:
+  AddDecl(TA.getAsDecl());
+  break;
 case TemplateArgument::NullPtr:
 case TemplateArgument::Integral:
   break;
@@ -330,6 +332,15 @@ public:
 
 AddQualType(D->getReturnType());
 
+const auto* SpecializationArgs = D->getTemplateSpecializationArgs();
+Hash.AddBoolean(SpecializationArgs);
+if (SpecializationArgs) {
+  ID.AddInteger(SpecializationArgs->size());
+  for (const TemplateArgument  : SpecializationArgs->asArray()) {
+Hash.AddTemplateArgument(TA);
+  }
+}
+
 Inherited::VisitFunctionDecl(D);
   }
 

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=330789=330788=330789=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Apr 24 17:31:15 2018
@@ -9450,6 +9450,12 @@ void ASTReader::diagnoseOdrViolations()
 return Hash.CalculateHash();
   };
 
+  auto ComputeTemplateArgumentODRHash = [](const TemplateArgument ) {
+Hash.clear();
+Hash.AddTemplateArgument(TA);
+return Hash.CalculateHash();
+  };
+
   // Issue any pending ODR-failure diagnostics.
   for (auto  : OdrMergeFailures) {
 // If we've already pointed out a specific problem with this class, don't
@@ -9948,6 +9954,9 @@ void ASTReader::diagnoseOdrViolations()
 MethodParameterName,
 MethodParameterSingleDefaultArgument,
 MethodParameterDifferentDefaultArgument,
+MethodNoTemplateArguments,
+MethodDifferentNumberTemplateArguments,
+MethodDifferentTemplateArgument,
 TypedefName,
 TypedefType,
 VarName,
@@ -10370,6 +10379,89 @@ void ASTReader::diagnoseOdrViolations()
   break;
 }
 
+const auto *FirstTemplateArgs =
+FirstMethod->getTemplateSpecializationArgs();
+const auto *SecondTemplateArgs =
+SecondMethod->getTemplateSpecializationArgs();
+
+if ((FirstTemplateArgs && !SecondTemplateArgs) ||
+(!FirstTemplateArgs && SecondTemplateArgs)) {
+  ODRDiagError(FirstMethod->getLocation(),
+   FirstMethod->getSourceRange(), 
MethodNoTemplateArguments)
+  << FirstMethodType << FirstName << 

r330074 - [ODRHash] Support pointer and reference types.

2018-04-13 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Apr 13 15:34:43 2018
New Revision: 330074

URL: http://llvm.org/viewvc/llvm-project?rev=330074=rev
Log:
[ODRHash] Support pointer and reference types.

Recommit r328404 which was reverted in rL328404.  r329869 fixed the issue that
caused the revert.

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=330074=330073=330074=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Apr 13 15:34:43 2018
@@ -642,6 +642,24 @@ public:
 VisitFunctionType(T);
   }
 
+  void VisitPointerType(const PointerType *T) {
+AddQualType(T->getPointeeType());
+VisitType(T);
+  }
+
+  void VisitReferenceType(const ReferenceType *T) {
+AddQualType(T->getPointeeTypeAsWritten());
+VisitType(T);
+  }
+
+  void VisitLValueReferenceType(const LValueReferenceType *T) {
+VisitReferenceType(T);
+  }
+
+  void VisitRValueReferenceType(const RValueReferenceType *T) {
+VisitReferenceType(T);
+  }
+
   void VisitTypedefType(const TypedefType *T) {
 AddDecl(T->getDecl());
 QualType UnderlyingType = T->getDecl()->getUnderlyingType();

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=330074=330073=330074=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri Apr 13 15:34:43 2018
@@ -2286,6 +2286,127 @@ Invalid1 i1;
 #undef DECLS
 }  // namespace BaseClass
 
+namespace PointersAndReferences {
+#if defined(FIRST) || defined(SECOND)
+template struct Wrapper{};
+#endif
+
+#if defined(FIRST)
+struct S1 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S1 {
+  Wrapper x;
+};
+#else
+S1 s1;
+// expected-error@first.h:* {{PointersAndReferences::S1::x' from module 
'FirstModule' is not present in definition of 'PointersAndReferences::S1' in 
module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S2 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S2 {
+  Wrapper x;
+};
+#else
+S2 s2;
+// expected-error@first.h:* {{PointersAndReferences::S2::x' from module 
'FirstModule' is not present in definition of 'PointersAndReferences::S2' in 
module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S3 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S3 {
+  Wrapper x;
+};
+#else
+S3 s3;
+// expected-error@first.h:* {{PointersAndReferences::S3::x' from module 
'FirstModule' is not present in definition of 'PointersAndReferences::S3' in 
module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S4 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S4 {
+  Wrapper x;
+};
+#else
+S4 s4;
+// expected-error@first.h:* {{PointersAndReferences::S4::x' from module 
'FirstModule' is not present in definition of 'PointersAndReferences::S4' in 
module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S5 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S5 {
+  Wrapper x;
+};
+#else
+S5 s5;
+// expected-error@second.h:* {{'PointersAndReferences::S5::x' from module 
'SecondModule' is not present in definition of 'PointersAndReferences::S5' in 
module 'FirstModule'}}
+// expected-note@first.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S6 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S6 {
+  Wrapper x;
+};
+#else
+S6 s6;
+// expected-error@first.h:* {{PointersAndReferences::S6::x' from module 
'FirstModule' is not present in definition of 'PointersAndReferences::S6' in 
module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#define DECLS\
+  Wrapper x1; \
+  Wrapper x2;   \
+  Wrapper x3; \
+  Wrapper x4; \
+  Wrapper x5;\
+  Wrapper x6;   \
+  Wrapper x7;  \
+  Wrapper x8;  \
+  Wrapper x9;
+
+#if defined(FIRST) || defined(SECOND)
+struct Valid1 {
+  DECLS
+};
+#else
+Valid1 v1;
+#endif
+
+#if defined(FIRST) || defined(SECOND)
+struct Invalid1 {
+  DECLS
+  ACCESS
+};
+#else
+Invalid1 i1;
+// expected-error@second.h:* {{'PointersAndReferences::Invalid1' has different 
definitions in different modules; first difference is definition in module 
'SecondModule' found private access specifier}}
+// expected-note@first.h:* {{but in 'FirstModule' found public access 
specifier}}
+#endif
+#undef DECLS
+}  // namespace PointersAndReferences
+
 
 // Collection of interesting cases below.
 



r329869 - [ODRHash] Skip more types hashing TypedefType

2018-04-11 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Apr 11 19:26:49 2018
New Revision: 329869

URL: http://llvm.org/viewvc/llvm-project?rev=329869=rev
Log:
[ODRHash] Skip more types hashing TypedefType

To get the underlying type for TypedefType's, also skip ElaboratedType's.

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=329869=329868=329869=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Wed Apr 11 19:26:49 2018
@@ -646,9 +646,19 @@ public:
 AddDecl(T->getDecl());
 QualType UnderlyingType = T->getDecl()->getUnderlyingType();
 VisitQualifiers(UnderlyingType.getQualifiers());
-while (const TypedefType *Underlying =
-   dyn_cast(UnderlyingType.getTypePtr())) {
-  UnderlyingType = Underlying->getDecl()->getUnderlyingType();
+while (true) {
+  if (const TypedefType *Underlying =
+  dyn_cast(UnderlyingType.getTypePtr())) {
+UnderlyingType = Underlying->getDecl()->getUnderlyingType();
+continue;
+  }
+  if (const ElaboratedType *Underlying =
+  dyn_cast(UnderlyingType.getTypePtr())) {
+UnderlyingType = Underlying->getNamedType();
+continue;
+  }
+
+  break;
 }
 AddType(UnderlyingType.getTypePtr());
 VisitType(T);

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=329869=329868=329869=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Wed Apr 11 19:26:49 2018
@@ -2744,6 +2744,38 @@ struct S3 {
 #else
 S3 s3;
 #endif
+
+#if defined(FIRST)
+using A4 = int;
+using B4 = A4;
+struct S4 {
+  B4 x;
+};
+#elif defined(SECOND)
+using A4 = int;
+using B4 = ::MultipleTypedefs::A4;
+struct S4 {
+  B4 x;
+};
+#else
+S4 s4;
+#endif
+
+#if defined(FIRST)
+using A5 = int;
+using B5 = MultipleTypedefs::A5;
+struct S5 {
+  B5 x;
+};
+#elif defined(SECOND)
+using A5 = int;
+using B5 = ::MultipleTypedefs::A5;
+struct S5 {
+  B5 x;
+};
+#else
+S5 s5;
+#endif
 }  // MultipleTypedefs
 
 namespace DefaultArguments {


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


r328763 - Refactor some code for a warning. NFC.

2018-03-28 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Mar 28 22:14:17 2018
New Revision: 328763

URL: http://llvm.org/viewvc/llvm-project?rev=328763=rev
Log:
Refactor some code for a warning.  NFC.

Use range-based for-loops instead of iterators to walk over vectors.
Switch the key of the DenseMap so a custom key handler is no longer needed.
Remove unncessary adds to the DenseMap.
Use unique_ptr instead of manual memory management.

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

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=328763=328762=328763=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Mar 28 22:14:17 2018
@@ -16028,39 +16028,10 @@ static bool ValidDuplicateEnum(EnumConst
   return false;
 }
 
-namespace {
-struct DupKey {
-  int64_t val;
-  bool isTombstoneOrEmptyKey;
-  DupKey(int64_t val, bool isTombstoneOrEmptyKey)
-: val(val), isTombstoneOrEmptyKey(isTombstoneOrEmptyKey) {}
-};
-
-static DupKey GetDupKey(const llvm::APSInt& Val) {
-  return DupKey(Val.isSigned() ? Val.getSExtValue() : Val.getZExtValue(),
-false);
-}
-
-struct DenseMapInfoDupKey {
-  static DupKey getEmptyKey() { return DupKey(0, true); }
-  static DupKey getTombstoneKey() { return DupKey(1, true); }
-  static unsigned getHashValue(const DupKey Key) {
-return (unsigned)(Key.val * 37);
-  }
-  static bool isEqual(const DupKey& LHS, const DupKey& RHS) {
-return LHS.isTombstoneOrEmptyKey == RHS.isTombstoneOrEmptyKey &&
-   LHS.val == RHS.val;
-  }
-};
-} // end anonymous namespace
-
 // Emits a warning when an element is implicitly set a value that
 // a previous element has already been set to.
 static void CheckForDuplicateEnumValues(Sema , ArrayRef Elements,
-EnumDecl *Enum,
-QualType EnumType) {
-  if (S.Diags.isIgnored(diag::warn_duplicate_enum_values, Enum->getLocation()))
-return;
+EnumDecl *Enum, QualType EnumType) {
   // Avoid anonymous enums
   if (!Enum->getIdentifier())
 return;
@@ -16069,20 +16040,28 @@ static void CheckForDuplicateEnumValues(
   if (Enum->getNumPositiveBits() > 63 || Enum->getNumNegativeBits() > 64)
 return;
 
+  if (S.Diags.isIgnored(diag::warn_duplicate_enum_values, Enum->getLocation()))
+return;
+
   typedef SmallVector ECDVector;
-  typedef SmallVector DuplicatesVector;
+  typedef SmallVector DuplicatesVector;
 
   typedef llvm::PointerUnion DeclOrVector;
-  typedef llvm::DenseMap
-  ValueToVectorMap;
+  typedef llvm::DenseMap ValueToVectorMap;
+
+  // Use int64_t as a key to avoid needing special handling for DenseMap keys.
+  auto EnumConstantToKey = [](const EnumConstantDecl *D) {
+llvm::APSInt Val = D->getInitVal();
+return Val.isSigned() ? Val.getSExtValue() : Val.getZExtValue();
+  };
 
   DuplicatesVector DupVector;
   ValueToVectorMap EnumMap;
 
   // Populate the EnumMap with all values represented by enum constants without
-  // an initialier.
-  for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
-EnumConstantDecl *ECD = cast_or_null(Elements[i]);
+  // an initializer.
+  for (auto *Element : Elements) {
+EnumConstantDecl *ECD = cast_or_null(Element);
 
 // Null EnumConstantDecl means a previous diagnostic has been emitted for
 // this constant.  Skip this enum since it may be ill-formed.
@@ -16090,45 +16069,45 @@ static void CheckForDuplicateEnumValues(
   return;
 }
 
+// Constants with initalizers are handled in the next loop.
 if (ECD->getInitExpr())
   continue;
 
-DupKey Key = GetDupKey(ECD->getInitVal());
-DeclOrVector  = EnumMap[Key];
-
-// First time encountering this value.
-if (Entry.isNull())
-  Entry = ECD;
+// Duplicate values are handled in the next loop.
+EnumMap.insert({EnumConstantToKey(ECD), ECD});
   }
 
+  if (EnumMap.size() == 0)
+return;
+
   // Create vectors for any values that has duplicates.
-  for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
-EnumConstantDecl *ECD = cast(Elements[i]);
+  for (auto *Element : Elements) {
+// The last loop returned if any constant was null.
+EnumConstantDecl *ECD = cast(Element);
 if (!ValidDuplicateEnum(ECD, Enum))
   continue;
 
-DupKey Key = GetDupKey(ECD->getInitVal());
-
-DeclOrVector& Entry = EnumMap[Key];
-if (Entry.isNull())
+auto Iter = EnumMap.find(EnumConstantToKey(ECD));
+if (Iter == EnumMap.end())
   continue;
 
+DeclOrVector& Entry = Iter->second;
 if (EnumConstantDecl *D = Entry.dyn_cast()) {
   // Ensure constants are different.
   if (D == ECD)
 continue;
 
   // Create new 

r328688 - Fix some handling of AST nodes with diagnostics.

2018-03-27 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Mar 27 21:16:13 2018
New Revision: 328688

URL: http://llvm.org/viewvc/llvm-project?rev=328688=rev
Log:
Fix some handling of AST nodes with diagnostics.

The diagnostic system for Clang can already handle many AST nodes.  Instead
of converting them to strings first, just hand the AST node directly to
the diagnostic system and let it handle the output.  Minor changes in some
diagnostic output.


Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/lib/Sema/SemaCUDA.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/Preprocessor/has_include.c
cfe/trunk/test/Sema/warn-duplicate-enum.c
cfe/trunk/test/SemaCUDA/function-overload.cu
cfe/trunk/test/SemaCUDA/kernel-call.cu
cfe/trunk/test/SemaCXX/ms-interface.cpp
cfe/trunk/test/SemaCXX/typo-correction.cpp
cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
cfe/trunk/test/SemaObjC/comptypes-legal.m
cfe/trunk/test/SemaObjC/protocol-expr-neg-1.m
cfe/trunk/test/SemaTemplate/warn-thread-safety-analysis.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=328688=328687=328688=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Tue Mar 27 21:16:13 
2018
@@ -575,7 +575,7 @@ def err_cxx11_attribute_forbids_argument
 def err_attribute_requires_arguments : Error<
   "parentheses must be omitted if %0 attribute's argument list is empty">;
 def err_cxx11_attribute_forbids_ellipsis : Error<
-  "attribute '%0' cannot be used as an attribute pack">;
+  "attribute %0 cannot be used as an attribute pack">;
 def err_cxx11_attribute_repeated : Error<
   "attribute %0 cannot appear multiple times in an attribute specifier">;
 def warn_cxx14_compat_using_attribute_ns : Warning<

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=328688=328687=328688=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Mar 27 21:16:13 
2018
@@ -1329,7 +1329,7 @@ def err_invalid_member_in_interface : Er
   "nested class }0%1 is not permitted within an interface type">;
 def err_invalid_base_in_interface : Error<
   "interface type cannot inherit from "
-  "%select{'struct|non-public 'interface|'class}0 %1'">;
+  "%select{struct|non-public interface|class}0 %1">;
 
 def err_abstract_type_in_decl : Error<
   "%select{return|parameter|variable|field|instance variable|"
@@ -1629,7 +1629,7 @@ def err_missing_default_ctor : Error<
   "%select{base class|member}2 %3 %select{which|which|of %1}0 "
   "does not have a default constructor">;
 def note_due_to_dllexported_class : Note<
-  "due to '%0' being dllexported%select{|; try compiling in C++11 mode}1">;
+  "due to %0 being dllexported%select{|; try compiling in C++11 mode}1">;
 
 def err_illegal_union_or_anon_struct_member : Error<
   "%select{anonymous struct|union}0 member %1 has a non-trivial "
@@ -2986,11 +2986,11 @@ def warn_lock_exclusive_and_shared : War
 def note_lock_exclusive_and_shared : Note<
   "the other acquisition of %0 '%1' is here">;
 def warn_variable_requires_any_lock : Warning<
-  "%select{reading|writing}1 variable '%0' requires holding "
+  "%select{reading|writing}1 variable %0 requires holding "
   "%select{any mutex|any mutex exclusively}1">,
   InGroup, DefaultIgnore;
 def warn_var_deref_requires_any_lock : Warning<
-  "%select{reading|writing}1 the value pointed to by '%0' requires holding "
+  "%select{reading|writing}1 the value pointed to by %0 requires holding "
   "%select{any mutex|any mutex exclusively}1">,
   InGroup, DefaultIgnore;
 def warn_fun_excludes_mutex : Warning<
@@ -3014,25 +3014,25 @@ def warn_acquire_requires_negative_cap :
 
 // Thread safety warnings on pass by reference
 def warn_guarded_pass_by_reference : Warning<
-  "passing variable '%1' by reference requires holding %0 "
+  "passing variable %1 by reference requires holding %0 "
   "%select{'%2'|'%2' exclusively}3">,
   InGroup, DefaultIgnore;
 def warn_pt_guarded_pass_by_reference : Warning<
-  "passing the value that '%1' points to by reference requires holding %0 "
+  "passing the value that %1 points to by reference requires holding %0 "
   "%select{'%2'|'%2' 

r328404 - [ODRHash] Support pointer and reference types.

2018-03-23 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Mar 23 17:52:44 2018
New Revision: 328404

URL: http://llvm.org/viewvc/llvm-project?rev=328404=rev
Log:
[ODRHash] Support pointer and reference types.

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=328404=328403=328404=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Mar 23 17:52:44 2018
@@ -642,6 +642,24 @@ public:
 VisitFunctionType(T);
   }
 
+  void VisitPointerType(const PointerType *T) {
+AddQualType(T->getPointeeType());
+VisitType(T);
+  }
+
+  void VisitReferenceType(const ReferenceType *T) {
+AddQualType(T->getPointeeTypeAsWritten());
+VisitType(T);
+  }
+
+  void VisitLValueReferenceType(const LValueReferenceType *T) {
+VisitReferenceType(T);
+  }
+
+  void VisitRValueReferenceType(const RValueReferenceType *T) {
+VisitReferenceType(T);
+  }
+
   void VisitTypedefType(const TypedefType *T) {
 AddDecl(T->getDecl());
 QualType UnderlyingType = T->getDecl()->getUnderlyingType();

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=328404=328403=328404=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri Mar 23 17:52:44 2018
@@ -2287,6 +2287,128 @@ Invalid1 i1;
 }  // namespace BaseClass
 
 
+namespace PointersAndReferences {
+#if defined(FIRST) || defined(SECOND)
+template struct Wrapper{};
+#endif
+
+#if defined(FIRST)
+struct S1 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S1 {
+  Wrapper x;
+};
+#else
+S1 s1;
+// expected-error@first.h:* {{PointersAndReferences::S1::x' from module 
'FirstModule' is not present in definition of 'PointersAndReferences::S1' in 
module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S2 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S2 {
+  Wrapper x;
+};
+#else
+S2 s2;
+// expected-error@first.h:* {{PointersAndReferences::S2::x' from module 
'FirstModule' is not present in definition of 'PointersAndReferences::S2' in 
module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S3 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S3 {
+  Wrapper x;
+};
+#else
+S3 s3;
+// expected-error@first.h:* {{PointersAndReferences::S3::x' from module 
'FirstModule' is not present in definition of 'PointersAndReferences::S3' in 
module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S4 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S4 {
+  Wrapper x;
+};
+#else
+S4 s4;
+// expected-error@first.h:* {{PointersAndReferences::S4::x' from module 
'FirstModule' is not present in definition of 'PointersAndReferences::S4' in 
module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S5 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S5 {
+  Wrapper x;
+};
+#else
+S5 s5;
+// expected-error@second.h:* {{'PointersAndReferences::S5::x' from module 
'SecondModule' is not present in definition of 'PointersAndReferences::S5' in 
module 'FirstModule'}}
+// expected-note@first.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S6 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S6 {
+  Wrapper x;
+};
+#else
+S6 s6;
+// expected-error@first.h:* {{PointersAndReferences::S6::x' from module 
'FirstModule' is not present in definition of 'PointersAndReferences::S6' in 
module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#define DECLS\
+  Wrapper x1; \
+  Wrapper x2;   \
+  Wrapper x3; \
+  Wrapper x4; \
+  Wrapper x5;\
+  Wrapper x6;   \
+  Wrapper x7;  \
+  Wrapper x8;  \
+  Wrapper x9;
+
+#if defined(FIRST) || defined(SECOND)
+struct Valid1 {
+  DECLS
+};
+#else
+Valid1 v1;
+#endif
+
+#if defined(FIRST) || defined(SECOND)
+struct Invalid1 {
+  DECLS
+  ACCESS
+};
+#else
+Invalid1 i1;
+// expected-error@second.h:* {{'PointersAndReferences::Invalid1' has different 
definitions in different modules; first difference is definition in module 
'SecondModule' found private access specifier}}
+// expected-note@first.h:* {{but in 'FirstModule' found public access 
specifier}}
+#endif
+#undef DECLS
+}  // namespace PointersAndReferences
+
+
 // Collection of interesting cases below.
 
 // Naive parsing of AST can lead to cycles in processing.  Ensure


___
cfe-commits mailing list

r327598 - Refactoring code around move/copy initialization. NFC.

2018-03-14 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Mar 14 20:00:55 2018
New Revision: 327598

URL: http://llvm.org/viewvc/llvm-project?rev=327598=rev
Log:
Refactoring code around move/copy initialization.  NFC.

Use an enum parameter instead of a bool for more control on how the copy elision
functions work.  Extract the move initialization code from the move or copy
initialization block.

Patch by: Arthur O'Dwyer

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

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=327598=327597=327598=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Mar 14 20:00:55 2018
@@ -3795,10 +3795,18 @@ public:
   RecordDecl *CreateCapturedStmtRecordDecl(CapturedDecl *,
SourceLocation Loc,
unsigned NumParams);
+
+  enum CopyElisionSemanticsKind {
+CES_Strict = 0,
+CES_AllowParameters = 1,
+CES_AllowDifferentTypes = 2,
+CES_Default = (CES_AllowParameters | CES_AllowDifferentTypes),
+  };
+
   VarDecl *getCopyElisionCandidate(QualType ReturnType, Expr *E,
-   bool AllowParamOrMoveConstructible);
+   CopyElisionSemanticsKind CESK);
   bool isCopyElisionCandidate(QualType ReturnType, const VarDecl *VD,
-  bool AllowParamOrMoveConstructible);
+  CopyElisionSemanticsKind CESK);
 
   StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
  Scope *CurScope);

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=327598=327597=327598=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Mar 14 20:00:55 2018
@@ -728,7 +728,7 @@ ExprResult Sema::BuildCXXThrow(SourceLoc
 //   exception object
 const VarDecl *NRVOVariable = nullptr;
 if (IsThrownVarInScope)
-  NRVOVariable = getCopyElisionCandidate(QualType(), Ex, false);
+  NRVOVariable = getCopyElisionCandidate(QualType(), Ex, CES_Strict);
 
 InitializedEntity Entity = InitializedEntity::InitializeException(
 OpLoc, ExceptionObjectTy,

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=327598=327597=327598=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Mar 14 20:00:55 2018
@@ -2862,7 +2862,7 @@ Sema::ActOnBreakStmt(SourceLocation Brea
 /// \param E The expression being returned from the function or block, or
 /// being thrown.
 ///
-/// \param AllowParamOrMoveConstructible Whether we allow function parameters 
or
+/// \param CESK Whether we allow function parameters or
 /// id-expressions that could be moved out of the function to be considered 
NRVO
 /// candidates. C++ prohibits these for NRVO itself, but we re-use this logic 
to
 /// determine whether we should try to move as part of a return or throw (which
@@ -2871,7 +2871,7 @@ Sema::ActOnBreakStmt(SourceLocation Brea
 /// \returns The NRVO candidate variable, if the return statement may use the
 /// NRVO, or NULL if there is no such candidate.
 VarDecl *Sema::getCopyElisionCandidate(QualType ReturnType, Expr *E,
-   bool AllowParamOrMoveConstructible) {
+   CopyElisionSemanticsKind CESK) {
   if (!getLangOpts().CPlusPlus)
 return nullptr;
 
@@ -2884,13 +2884,13 @@ VarDecl *Sema::getCopyElisionCandidate(Q
   if (!VD)
 return nullptr;
 
-  if (isCopyElisionCandidate(ReturnType, VD, AllowParamOrMoveConstructible))
+  if (isCopyElisionCandidate(ReturnType, VD, CESK))
 return VD;
   return nullptr;
 }
 
 bool Sema::isCopyElisionCandidate(QualType ReturnType, const VarDecl *VD,
-  bool AllowParamOrMoveConstructible) {
+  CopyElisionSemanticsKind CESK) {
   QualType VDType = VD->getType();
   // - in a return statement in a function with ...
   // ... a class return type ...
@@ -2899,14 +2899,14 @@ bool Sema::isCopyElisionCandidate(QualTy
   return false;
 // ... the same cv-unqualified type as the function return type ...
 // When considering moving this expression out, allow dissimilar types.
-if (!AllowParamOrMoveConstructible && !VDType->isDependentType() &&
+if (!(CESK & 

r327593 - [CFG] Allow CallExpr's to be looked up in CFG's

2018-03-14 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Mar 14 17:09:26 2018
New Revision: 327593

URL: http://llvm.org/viewvc/llvm-project?rev=327593=rev
Log:
[CFG] Allow CallExpr's to be looked up in CFG's

r327343 changed the handling for CallExpr in a CFG, which prevented lookups for
CallExpr while other Stmt kinds still worked.  This change carries over the
necessary bits from Stmt function to CallExpr function.

Added:
cfe/trunk/test/SemaCXX/constant-conversion.cpp
Modified:
cfe/trunk/lib/Analysis/CFG.cpp

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=327593=327592=327593=diff
==
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Wed Mar 14 17:09:26 2018
@@ -750,6 +750,9 @@ private:
   }
 
   void appendCall(CFGBlock *B, CallExpr *CE) {
+if (alwaysAdd(CE) && cachedEntry)
+  cachedEntry->second = B;
+
 if (BuildOpts.AddRichCXXConstructors) {
   if (CFGCXXRecordTypedCall::isCXXRecordTypedCall(CE, *Context)) {
 if (const ConstructionContextLayer *Layer =

Added: cfe/trunk/test/SemaCXX/constant-conversion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-conversion.cpp?rev=327593=auto
==
--- cfe/trunk/test/SemaCXX/constant-conversion.cpp (added)
+++ cfe/trunk/test/SemaCXX/constant-conversion.cpp Wed Mar 14 17:09:26 2018
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin %s
+
+// This file tests -Wconstant-conversion, a subcategory of -Wconversion
+// which is on by default.
+
+constexpr int nines() { return 9; }
+
+void too_big_for_char(int param) {
+  char warn1 = false ? 0 : 9;
+  // expected-warning@-1 {{implicit conversion from 'int' to 'char' changes 
value from 9 to -97}}
+  char warn2 = false ? 0 : nines();
+  // expected-warning@-1 {{implicit conversion from 'int' to 'char' changes 
value from 9 to -97}}
+
+  char warn3 = param > 0 ? 0 : 9;
+  // expected-warning@-1 {{implicit conversion from 'int' to 'char' changes 
value from 9 to -97}}
+  char warn4 = param > 0 ? 0 : nines();
+  // expected-warning@-1 {{implicit conversion from 'int' to 'char' changes 
value from 9 to -97}}
+
+  char ok1 = true ? 0 : 9;
+  char ok2 = true ? 0 : nines();
+
+  char ok3 = true ? 0 : 9 + 1;
+  char ok4 = true ? 0 : nines() + 1;
+}


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


Re: r324308 - Fix crash on invalid.

2018-02-22 Thread Richard Trieu via cfe-commits
Thanks, Hans!

On Thu, Feb 22, 2018 at 3:27 AM, Hans Wennborg <h...@chromium.org> wrote:

> Seems safe. Merged in r325766.
>
> On Thu, Feb 22, 2018 at 1:15 AM, Richard Trieu <rtr...@google.com> wrote:
> > Hi Hans,
> >
> > If there's still time for rc3, I'd like to get this crash fix in.  This
> adds
> > a null check to prevent a crash on invalid.
> >
> > Richard
> >
> > On Mon, Feb 5, 2018 at 6:58 PM, Richard Trieu via cfe-commits
> > <cfe-commits@lists.llvm.org> wrote:
> >>
> >> Author: rtrieu
> >> Date: Mon Feb  5 18:58:21 2018
> >> New Revision: 324308
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=324308=rev
> >> Log:
> >> Fix crash on invalid.
> >>
> >> Don't call a method when the pointer is null.
> >>
> >> Modified:
> >> cfe/trunk/lib/Sema/SemaExpr.cpp
> >> cfe/trunk/test/SemaCXX/lambda-expressions.cpp
> >>
> >> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaExpr.cpp?rev=324308=324307=324308=diff
> >>
> >> 
> ==
> >> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> >> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Feb  5 18:58:21 2018
> >> @@ -14958,7 +14958,8 @@ static void DoMarkVarDeclReferenced(Sema
> >>  if (RefersToEnclosingScope) {
> >>LambdaScopeInfo *const LSI =
> >>SemaRef.getCurLambda(/*IgnoreNonLambdaCapturingScope=
> */true);
> >> -  if (LSI && !LSI->CallOperator->Encloses(Var->getDeclContext()))
> {
> >> +  if (LSI && (!LSI->CallOperator ||
> >> +  !LSI->CallOperator->Encloses(Var->getDeclContext(
> {
> >>  // If a variable could potentially be odr-used, defer marking
> it
> >> so
> >>  // until we finish analyzing the full expression for any
> >>  // lvalue-to-rvalue
> >>
> >> Modified: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> SemaCXX/lambda-expressions.cpp?rev=324308=324307=324308=diff
> >>
> >> 
> ==
> >> --- cfe/trunk/test/SemaCXX/lambda-expressions.cpp (original)
> >> +++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp Mon Feb  5 18:58:21
> 2018
> >> @@ -608,3 +608,18 @@ namespace ConversionOperatorDoesNotHaveD
> >>// This used to crash in return type deduction for the conversion
> >> opreator.
> >>struct A { int n; void f() { +[](decltype(n)) {}; } };
> >>  }
> >> +
> >> +namespace TypoCorrection {
> >> +template  struct X {};
> >> +// expected-note@-1 {{template parameter is declared here}}
> >> +
> >> +template 
> >> +void Run(const int& points) {
> >> +// expected-note@-1 {{'points' declared here}}
> >> +  auto outer_lambda = []() {
> >> +auto inner_lambda = [](const X&) {};
> >> +// expected-error@-1 {{use of undeclared identifier 'Points'; did
> you
> >> mean 'points'?}}
> >> +// expected-error@-2 {{template argument for template type
> parameter
> >> must be a type}}
> >> +  };
> >> +}
> >> +}
> >>
> >>
> >> ___
> >> cfe-commits mailing list
> >> cfe-commits@lists.llvm.org
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >
> >
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r325742 - [ODRHash] Fix hashing for friend functions.

2018-02-21 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Feb 21 21:50:29 2018
New Revision: 325742

URL: http://llvm.org/viewvc/llvm-project?rev=325742=rev
Log:
[ODRHash] Fix hashing for friend functions.

When hashing a templated function, use the hash of the function it was
instantiated from.

Added:
cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Bad.h
cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Good.h
Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/Inputs/odr_hash-Friend/module.modulemap
cfe/trunk/test/Modules/odr_hash-Friend.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=325742=325741=325742=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Feb 21 21:50:29 2018
@@ -3625,6 +3625,12 @@ unsigned FunctionDecl::getODRHash() {
 }
   }
 
+  if (auto *FT = getInstantiatedFromMemberFunction()) {
+HasODRHash = true;
+ODRHash = FT->getODRHash();
+return ODRHash;
+  }
+
   class ODRHash Hash;
   Hash.AddFunctionDecl(this);
   HasODRHash = true;

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=325742=325741=325742=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Wed Feb 21 21:50:29 2018
@@ -484,9 +484,6 @@ void ODRHash::AddFunctionDecl(const Func
   if (!Function->hasBody()) return;
   if (!Function->getBody()) return;
 
-  // TODO: Fix hashing friend functions.
-  if (Function->getFriendObjectKind()) return;
-
   // Skip functions that are specializations or in specialization context.
   const DeclContext *DC = Function;
   while (DC) {

Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Bad.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Bad.h?rev=325742=auto
==
--- cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Bad.h (added)
+++ cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Bad.h Wed Feb 21 21:50:29 2018
@@ -0,0 +1,17 @@
+template 
+struct iterator {
+  void Compare(const iterator ) { return; }
+  friend void Check(iterator) { return; }
+};
+
+template  struct Box {
+  iterator I;
+
+  void test() {
+Check(I);
+I.Compare(I);
+  }
+};
+
+// Force instantiation of Box
+Box<> B;

Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Good.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Good.h?rev=325742=auto
==
--- cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Good.h (added)
+++ cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Good.h Wed Feb 21 21:50:29 
2018
@@ -0,0 +1,17 @@
+template 
+struct iterator {
+  void Compare(const iterator ) { }
+  friend void Check(iterator) {}
+};
+
+template  struct Box {
+  iterator I;
+
+  void test() {
+Check(I);
+I.Compare(I);
+  }
+};
+
+// Force instantiation of Box
+Box<> B;

Modified: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-Friend/module.modulemap?rev=325742=325741=325742=diff
==
--- cfe/trunk/test/Modules/Inputs/odr_hash-Friend/module.modulemap (original)
+++ cfe/trunk/test/Modules/Inputs/odr_hash-Friend/module.modulemap Wed Feb 21 
21:50:29 2018
@@ -13,3 +13,11 @@ module Module2 {
 module Module3 {
   header "M3.h"
 }
+
+module Good {
+  header "Good.h"
+}
+
+module Bad {
+  header "Bad.h"
+}

Modified: cfe/trunk/test/Modules/odr_hash-Friend.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash-Friend.cpp?rev=325742=325741=325742=diff
==
--- cfe/trunk/test/Modules/odr_hash-Friend.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash-Friend.cpp Wed Feb 21 21:50:29 2018
@@ -1,21 +1,89 @@
 // RUN: rm -rf %t
 
-// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/modules.cache \
+// PR35939: MicrosoftMangle.cpp triggers an assertion failure on this test.
+// UNSUPPORTED: system-windows
+
+// RUN: %clang_cc1 \
 // RUN:  -I %S/Inputs/odr_hash-Friend \
 // RUN:  -emit-obj -o /dev/null \
 // RUN:  -fmodules \
 // RUN:  -fimplicit-module-maps \
 // RUN:  -fmodules-cache-path=%t/modules.cache \
-// RUN:  -std=c++11 -x c++ %s -verify
+// RUN:  -std=c++11 -x c++ %s -verify -DTEST1 -fcolor-diagnostics
 
-// PR35939: MicrosoftMangle.cpp triggers an assertion failure on this test.
-// UNSUPPORTED: system-windows
+// RUN: %clang_cc1 \
+// RUN:  -I %S/Inputs/odr_hash-Friend \
+// RUN:  -emit-obj -o /dev/null \
+// RUN:  -fmodules \
+// RUN:  -fimplicit-module-maps \
+// 

r325741 - [ODRHash] Handle some template weirdness.

2018-02-21 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Feb 21 21:32:25 2018
New Revision: 325741

URL: http://llvm.org/viewvc/llvm-project?rev=325741=rev
Log:
[ODRHash] Handle some template weirdness.

Build the index off of DeclarationName instead of Decl pointers.  When finding
an UnresolvedLookupExprClass, hash it as if it were a DeclRefExpr.  This will
allow methods to be hashed.

Modified:
cfe/trunk/include/clang/AST/ODRHash.h
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/AST/StmtProfile.cpp

Modified: cfe/trunk/include/clang/AST/ODRHash.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ODRHash.h?rev=325741=325740=325741=diff
==
--- cfe/trunk/include/clang/AST/ODRHash.h (original)
+++ cfe/trunk/include/clang/AST/ODRHash.h Wed Feb 21 21:32:25 2018
@@ -37,8 +37,9 @@ class TemplateParameterList;
 // Typically, only one Add* call is needed.  clear can be called to reuse the
 // object.
 class ODRHash {
-  // Use DenseMaps to convert between Decl and Type pointers and an index 
value.
-  llvm::DenseMap DeclMap;
+  // Use DenseMaps to convert from DeclarationName and Type pointers
+  // to an index value.
+  llvm::DenseMap DeclNameMap;
   llvm::DenseMap TypeMap;
 
   // Save space by processing bools at the end.

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=325741=325740=325741=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Wed Feb 21 21:32:25 2018
@@ -33,6 +33,15 @@ void ODRHash::AddIdentifierInfo(const Id
 }
 
 void ODRHash::AddDeclarationName(DeclarationName Name) {
+  // Index all DeclarationName and use index numbers to refer to them.
+  auto Result = DeclNameMap.insert(std::make_pair(Name, DeclNameMap.size()));
+  ID.AddInteger(Result.first->second);
+  if (!Result.second) {
+// If found in map, the the DeclarationName has previously been processed.
+return;
+  }
+
+  // First time processing each DeclarationName, also process its details.
   AddBoolean(Name.isEmpty());
   if (Name.isEmpty())
 return;
@@ -168,7 +177,7 @@ void ODRHash::AddTemplateParameterList(c
 }
 
 void ODRHash::clear() {
-  DeclMap.clear();
+  DeclNameMap.clear();
   TypeMap.clear();
   Bools.clear();
   ID.clear();
@@ -418,7 +427,6 @@ bool ODRHash::isWhitelistedDecl(const De
 
 void ODRHash::AddSubDecl(const Decl *D) {
   assert(D && "Expecting non-null pointer.");
-  AddDecl(D);
 
   ODRDeclVisitor(ID, *this).Visit(D);
 }
@@ -476,9 +484,7 @@ void ODRHash::AddFunctionDecl(const Func
   if (!Function->hasBody()) return;
   if (!Function->getBody()) return;
 
-  // TODO: Fix hashing for class methods.
-  if (isa(Function)) return;
-  // And friend functions.
+  // TODO: Fix hashing friend functions.
   if (Function->getFriendObjectKind()) return;
 
   // Skip functions that are specializations or in specialization context.
@@ -504,19 +510,14 @@ void ODRHash::AddFunctionDecl(const Func
 void ODRHash::AddDecl(const Decl *D) {
   assert(D && "Expecting non-null pointer.");
   D = D->getCanonicalDecl();
-  auto Result = DeclMap.insert(std::make_pair(D, DeclMap.size()));
-  ID.AddInteger(Result.first->second);
-  // On first encounter of a Decl pointer, process it.  Every time afterwards,
-  // only the index value is needed.
-  if (!Result.second) {
-return;
-  }
-
-  ID.AddInteger(D->getKind());
 
   if (const NamedDecl *ND = dyn_cast(D)) {
 AddDeclarationName(ND->getDeclName());
+return;
   }
+
+  ID.AddInteger(D->getKind());
+  // TODO: Handle non-NamedDecl here.
 }
 
 namespace {

Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=325741=325740=325741=diff
==
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Wed Feb 21 21:32:25 2018
@@ -38,6 +38,8 @@ namespace {
 
 void VisitStmt(const Stmt *S);
 
+virtual void HandleStmtClass(Stmt::StmtClass SC) = 0;
+
 #define STMT(Node, Base) void Visit##Node(const Node *S);
 #include "clang/AST/StmtNodes.inc"
 
@@ -50,7 +52,7 @@ namespace {
 virtual void VisitType(QualType T) = 0;
 
 /// \brief Visit a name that occurs within an expression or statement.
-virtual void VisitName(DeclarationName Name) = 0;
+virtual void VisitName(DeclarationName Name, bool TreatAsDecl = false) = 0;
 
 /// \brief Visit identifiers that are not in Decl's or Type's.
 virtual void VisitIdentifierInfo(IdentifierInfo *II) = 0;
@@ -80,6 +82,10 @@ namespace {
  const ASTContext , bool Canonical)
 : StmtProfiler(ID, Canonical), Context(Context) {}
   private:
+void HandleStmtClass(Stmt::StmtClass SC) override {
+  ID.AddInteger(SC);
+}
+
 void 

Re: r324308 - Fix crash on invalid.

2018-02-21 Thread Richard Trieu via cfe-commits
Hi Hans,

If there's still time for rc3, I'd like to get this crash fix in.  This
adds a null check to prevent a crash on invalid.

Richard

On Mon, Feb 5, 2018 at 6:58 PM, Richard Trieu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rtrieu
> Date: Mon Feb  5 18:58:21 2018
> New Revision: 324308
>
> URL: http://llvm.org/viewvc/llvm-project?rev=324308=rev
> Log:
> Fix crash on invalid.
>
> Don't call a method when the pointer is null.
>
> Modified:
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/test/SemaCXX/lambda-expressions.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaE
> xpr.cpp?rev=324308=324307=324308=diff
> 
> ==
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Feb  5 18:58:21 2018
> @@ -14958,7 +14958,8 @@ static void DoMarkVarDeclReferenced(Sema
>  if (RefersToEnclosingScope) {
>LambdaScopeInfo *const LSI =
>SemaRef.getCurLambda(/*IgnoreNonLambdaCapturingScope=*/true);
> -  if (LSI && !LSI->CallOperator->Encloses(Var->getDeclContext())) {
> +  if (LSI && (!LSI->CallOperator ||
> +  !LSI->CallOperator->Encloses(Var->getDeclContext( {
>  // If a variable could potentially be odr-used, defer marking it
> so
>  // until we finish analyzing the full expression for any
>  // lvalue-to-rvalue
>
> Modified: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/
> lambda-expressions.cpp?rev=324308=324307=324308=diff
> 
> ==
> --- cfe/trunk/test/SemaCXX/lambda-expressions.cpp (original)
> +++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp Mon Feb  5 18:58:21 2018
> @@ -608,3 +608,18 @@ namespace ConversionOperatorDoesNotHaveD
>// This used to crash in return type deduction for the conversion
> opreator.
>struct A { int n; void f() { +[](decltype(n)) {}; } };
>  }
> +
> +namespace TypoCorrection {
> +template  struct X {};
> +// expected-note@-1 {{template parameter is declared here}}
> +
> +template 
> +void Run(const int& points) {
> +// expected-note@-1 {{'points' declared here}}
> +  auto outer_lambda = []() {
> +auto inner_lambda = [](const X&) {};
> +// expected-error@-1 {{use of undeclared identifier 'Points'; did
> you mean 'points'?}}
> +// expected-error@-2 {{template argument for template type parameter
> must be a type}}
> +  };
> +}
> +}
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r325040 - Update StmtProfile.cpp to handle zero template arguments.

2018-02-13 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Feb 13 11:53:40 2018
New Revision: 325040

URL: http://llvm.org/viewvc/llvm-project?rev=325040=rev
Log:
Update StmtProfile.cpp to handle zero template arguments.

Treat having no templates arguments differently than having zero template
arguments when profiling.

Modified:
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=325040=325039=325040=diff
==
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Tue Feb 13 11:53:40 2018
@@ -966,8 +966,11 @@ void StmtProfiler::VisitDeclRefExpr(cons
   if (!Canonical)
 VisitNestedNameSpecifier(S->getQualifier());
   VisitDecl(S->getDecl());
-  if (!Canonical)
-VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
+  if (!Canonical) {
+ID.AddBoolean(S->hasExplicitTemplateArgs());
+if (S->hasExplicitTemplateArgs())
+  VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
+  }
 }
 
 void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) {

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=325040=325039=325040=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Tue Feb 13 11:53:40 2018
@@ -2924,6 +2924,21 @@ int I10 = F10();
 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
 }  // namespace FunctionDecl
 
+namespace DeclTemplateArguments {
+#if defined(FIRST)
+int foo() { return 1; }
+int bar() { return foo(); }
+#elif defined(SECOND)
+template 
+int foo() { return 2; }
+int bar() { return foo<>(); }
+#else
+int num = bar();
+// expected-error@second.h:* {{'DeclTemplateArguments::bar' has different 
definitions in different modules; definition in module 'SecondModule' first 
difference is function body}}
+// expected-note@first.h:* {{but in 'FirstModule' found a different body}}
+#endif
+}
+
 // Keep macros contained to one file.
 #ifdef FIRST
 #undef FIRST


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


r324308 - Fix crash on invalid.

2018-02-05 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Mon Feb  5 18:58:21 2018
New Revision: 324308

URL: http://llvm.org/viewvc/llvm-project?rev=324308=rev
Log:
Fix crash on invalid.

Don't call a method when the pointer is null.

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/lambda-expressions.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=324308=324307=324308=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Feb  5 18:58:21 2018
@@ -14958,7 +14958,8 @@ static void DoMarkVarDeclReferenced(Sema
 if (RefersToEnclosingScope) {
   LambdaScopeInfo *const LSI =
   SemaRef.getCurLambda(/*IgnoreNonLambdaCapturingScope=*/true);
-  if (LSI && !LSI->CallOperator->Encloses(Var->getDeclContext())) {
+  if (LSI && (!LSI->CallOperator ||
+  !LSI->CallOperator->Encloses(Var->getDeclContext( {
 // If a variable could potentially be odr-used, defer marking it so
 // until we finish analyzing the full expression for any
 // lvalue-to-rvalue

Modified: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/lambda-expressions.cpp?rev=324308=324307=324308=diff
==
--- cfe/trunk/test/SemaCXX/lambda-expressions.cpp (original)
+++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp Mon Feb  5 18:58:21 2018
@@ -608,3 +608,18 @@ namespace ConversionOperatorDoesNotHaveD
   // This used to crash in return type deduction for the conversion opreator.
   struct A { int n; void f() { +[](decltype(n)) {}; } };
 }
+
+namespace TypoCorrection {
+template  struct X {};
+// expected-note@-1 {{template parameter is declared here}}
+
+template 
+void Run(const int& points) {
+// expected-note@-1 {{'points' declared here}}
+  auto outer_lambda = []() {
+auto inner_lambda = [](const X&) {};
+// expected-error@-1 {{use of undeclared identifier 'Points'; did you mean 
'points'?}}
+// expected-error@-2 {{template argument for template type parameter must 
be a type}}
+  };
+}
+}


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


Re: [libcxx] r323380 - [libc++] Fix PR20855 -- libc++ incorrectly diagnoses illegal reference binding in std::tuple.

2018-01-24 Thread Richard Trieu via cfe-commits
Thanks, Eric.

On Wed, Jan 24, 2018 at 3:11 PM, Eric Fiselier  wrote:

> Sorry for the breakage. Fixed in r323389.
>
> On Wed, Jan 24, 2018 at 4:08 PM, Eric Fiselier  wrote:
>
>> Looking.
>>
>> On Wed, Jan 24, 2018 at 3:52 PM, Richard Trieu  wrote:
>>
>>> Hi Eric,
>>>
>>> I am getting a build failure after this revision:
>>>
>>> llvm/projects/libcxx/include/tuple:175:27: error: no return statement
>>> in constexpr function
>>> static constexpr bool __can_bind_reference() {
>>>   ^
>>> 1 error generated.
>>>
>>> It looks like if the #if in __can_bind_reference is false, the function
>>> will be empty.  Can you take a look?
>>>
>>> Richard
>>>
>>> On Wed, Jan 24, 2018 at 2:14 PM, Eric Fiselier via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: ericwf
 Date: Wed Jan 24 14:14:01 2018
 New Revision: 323380

 URL: http://llvm.org/viewvc/llvm-project?rev=323380=rev
 Log:
 [libc++] Fix PR20855 -- libc++ incorrectly diagnoses illegal reference
 binding in std::tuple.

 Summary:
 See https://bugs.llvm.org/show_bug.cgi?id=20855

 Libc++ goes out of it's way to diagnose `std::tuple` constructions
 which are UB due to lifetime bugs caused by reference creation. For 
 example:

 ```
 // The 'const std::string&' is created *inside* the tuple constructor,
 and its lifetime is over before the end of the constructor call.
 std::tuple t(std::make_tuple(42, "abc"));
 ```

 However, we are over-aggressive and we incorrectly diagnose cases such
 as:

 ```
 void foo(std::tuple const&);
 foo(std::make_tuple(42, 42));
 ```

 This patch fixes the incorrectly diagnosed cases, as well as converting
 the diagnostic to use the newly added Clang trait
 `__reference_binds_to_temporary`. The new trait allows us to diagnose
 cases we previously couldn't such as:

 ```
 std::tuple t(42, "abc");
 ```

 Reviewers: rsmith, mclow.lists

 Reviewed By: rsmith

 Subscribers: cfe-commits

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

 Added:
 libcxx/trunk/test/libcxx/utilities/tuple/tuple.tuple/tuple.c
 nstr/PR20855_tuple_ref_binding_diagnostics.fail.cpp
 libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnst
 r/PR20855_tuple_ref_binding_diagnostics.pass.cpp
 Removed:
 libcxx/trunk/test/libcxx/utilities/tuple/tuple.tuple/diagnos
 e_reference_binding.fail.cpp
 libcxx/trunk/test/libcxx/utilities/tuple/tuple.tuple/diagnos
 e_reference_binding.pass.cpp
 Modified:
 libcxx/trunk/include/tuple

 Modified: libcxx/trunk/include/tuple
 URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tup
 le?rev=323380=323379=323380=diff
 
 ==
 --- libcxx/trunk/include/tuple (original)
 +++ libcxx/trunk/include/tuple Wed Jan 24 14:14:01 2018
 @@ -173,16 +173,9 @@ class __tuple_leaf

  template 
  static constexpr bool __can_bind_reference() {
 -using _RawTp = typename remove_reference<_Tp>::type;
 -using _RawHp = typename remove_reference<_Hp>::type;
 -using _CheckLValueArg = integral_constant::value
 -||  is_same<_RawTp, reference_wrapper<_RawHp>>::value
 -||  is_same<_RawTp, reference_wrapper>>> remove_const<_RawHp>::type>>::value
 ->;
 -return  !is_reference<_Hp>::value
 -|| (is_lvalue_reference<_Hp>::value &&
 _CheckLValueArg::value)
 -|| (is_rvalue_reference<_Hp>::value &&
 !is_lvalue_reference<_Tp>::value);
 +#if __has_keyword(__reference_binds_to_temporary)
 +  return !__reference_binds_to_temporary(_Hp, _Tp);
 +#endif
  }

  __tuple_leaf& operator=(const __tuple_leaf&);
 @@ -224,15 +217,15 @@ public:
  _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  explicit __tuple_leaf(_Tp&& __t) 
 _NOEXCEPT_((is_nothrow_constructible<_Hp,
 _Tp>::value))
  : __value_(_VSTD::forward<_Tp>(__t))
 -{static_assert(__can_bind_reference<_Tp>(),
 -   "Attempted to construct a reference element in a tuple with an
 rvalue");}
 +{static_assert(__can_bind_reference<_Tp&&>(),
 +   "Attempted construction of reference element binds to a
 temporary whose lifetime has ended");}

  template 
  _LIBCPP_INLINE_VISIBILITY
  explicit __tuple_leaf(integral_constant, const
 _Alloc&, _Tp&& __t)
  : __value_(_VSTD::forward<_Tp>(__t))
 -

Re: [libcxx] r323380 - [libc++] Fix PR20855 -- libc++ incorrectly diagnoses illegal reference binding in std::tuple.

2018-01-24 Thread Richard Trieu via cfe-commits
Hi Eric,

I am getting a build failure after this revision:

llvm/projects/libcxx/include/tuple:175:27: error: no return statement in
constexpr function
static constexpr bool __can_bind_reference() {
  ^
1 error generated.

It looks like if the #if in __can_bind_reference is false, the function
will be empty.  Can you take a look?

Richard

On Wed, Jan 24, 2018 at 2:14 PM, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Wed Jan 24 14:14:01 2018
> New Revision: 323380
>
> URL: http://llvm.org/viewvc/llvm-project?rev=323380=rev
> Log:
> [libc++] Fix PR20855 -- libc++ incorrectly diagnoses illegal reference
> binding in std::tuple.
>
> Summary:
> See https://bugs.llvm.org/show_bug.cgi?id=20855
>
> Libc++ goes out of it's way to diagnose `std::tuple` constructions which
> are UB due to lifetime bugs caused by reference creation. For example:
>
> ```
> // The 'const std::string&' is created *inside* the tuple constructor, and
> its lifetime is over before the end of the constructor call.
> std::tuple t(std::make_tuple(42, "abc"));
> ```
>
> However, we are over-aggressive and we incorrectly diagnose cases such as:
>
> ```
> void foo(std::tuple const&);
> foo(std::make_tuple(42, 42));
> ```
>
> This patch fixes the incorrectly diagnosed cases, as well as converting
> the diagnostic to use the newly added Clang trait
> `__reference_binds_to_temporary`. The new trait allows us to diagnose
> cases we previously couldn't such as:
>
> ```
> std::tuple t(42, "abc");
> ```
>
> Reviewers: rsmith, mclow.lists
>
> Reviewed By: rsmith
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D41977
>
> Added:
> libcxx/trunk/test/libcxx/utilities/tuple/tuple.tuple/tuple.
> cnstr/PR20855_tuple_ref_binding_diagnostics.fail.cpp
> libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.
> cnstr/PR20855_tuple_ref_binding_diagnostics.pass.cpp
> Removed:
> libcxx/trunk/test/libcxx/utilities/tuple/tuple.tuple/diagnos
> e_reference_binding.fail.cpp
> libcxx/trunk/test/libcxx/utilities/tuple/tuple.tuple/diagnos
> e_reference_binding.pass.cpp
> Modified:
> libcxx/trunk/include/tuple
>
> Modified: libcxx/trunk/include/tuple
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tup
> le?rev=323380=323379=323380=diff
> 
> ==
> --- libcxx/trunk/include/tuple (original)
> +++ libcxx/trunk/include/tuple Wed Jan 24 14:14:01 2018
> @@ -173,16 +173,9 @@ class __tuple_leaf
>
>  template 
>  static constexpr bool __can_bind_reference() {
> -using _RawTp = typename remove_reference<_Tp>::type;
> -using _RawHp = typename remove_reference<_Hp>::type;
> -using _CheckLValueArg = integral_constant -is_lvalue_reference<_Tp>::value
> -||  is_same<_RawTp, reference_wrapper<_RawHp>>::value
> -||  is_same<_RawTp, reference_wrapper remove_const<_RawHp>::type>>::value
> ->;
> -return  !is_reference<_Hp>::value
> -|| (is_lvalue_reference<_Hp>::value &&
> _CheckLValueArg::value)
> -|| (is_rvalue_reference<_Hp>::value &&
> !is_lvalue_reference<_Tp>::value);
> +#if __has_keyword(__reference_binds_to_temporary)
> +  return !__reference_binds_to_temporary(_Hp, _Tp);
> +#endif
>  }
>
>  __tuple_leaf& operator=(const __tuple_leaf&);
> @@ -224,15 +217,15 @@ public:
>  _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
>  explicit __tuple_leaf(_Tp&& __t) 
> _NOEXCEPT_((is_nothrow_constructible<_Hp,
> _Tp>::value))
>  : __value_(_VSTD::forward<_Tp>(__t))
> -{static_assert(__can_bind_reference<_Tp>(),
> -   "Attempted to construct a reference element in a tuple with an
> rvalue");}
> +{static_assert(__can_bind_reference<_Tp&&>(),
> +   "Attempted construction of reference element binds to a temporary
> whose lifetime has ended");}
>
>  template 
>  _LIBCPP_INLINE_VISIBILITY
>  explicit __tuple_leaf(integral_constant, const _Alloc&,
> _Tp&& __t)
>  : __value_(_VSTD::forward<_Tp>(__t))
> -{static_assert(__can_bind_reference<_Tp>(),
> -   "Attempted to construct a reference element in a tuple with an
> rvalue");}
> +{static_assert(__can_bind_reference<_Tp&&>(),
> +   "Attempted construction of reference element binds to a temporary
> whose lifetime has ended");}
>
>  template 
>  _LIBCPP_INLINE_VISIBILITY
>
> Removed: libcxx/trunk/test/libcxx/utilities/tuple/tuple.tuple/diagnos
> e_reference_binding.fail.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx
> /utilities/tuple/tuple.tuple/diagnose_reference_binding.
> fail.cpp?rev=323379=auto
> 
> ==
> --- 
> 

r323267 - Fix test Driver/solaris-ld.c

2018-01-23 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Jan 23 13:58:56 2018
New Revision: 323267

URL: http://llvm.org/viewvc/llvm-project?rev=323267=rev
Log:
Fix test Driver/solaris-ld.c

Allow test to accept calls to ld without full path.

Modified:
cfe/trunk/test/Driver/solaris-ld.c

Modified: cfe/trunk/test/Driver/solaris-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/solaris-ld.c?rev=323267=323266=323267=diff
==
--- cfe/trunk/test/Driver/solaris-ld.c (original)
+++ cfe/trunk/test/Driver/solaris-ld.c Tue Jan 23 13:58:56 2018
@@ -10,7 +10,7 @@
 // CHECK-LD-SPARC32-NOT: warning:
 // CHECK-LD-SPARC32: {{.*/clang}}" "-cc1" "-triple" "sparc-sun-solaris2.11"
 // CHECK-LD-SPARC32-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// CHECK-LD-SPARC32: {{.*/ld}}"
+// CHECK-LD-SPARC32: "{{(.*/)?ld}}"
 // CHECK-LD-SPARC32-SAME: "--dynamic-linker" "[[SYSROOT]]/usr/lib/ld.so.1"
 // CHECK-LD-SPARC32-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crt1.o"
 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/lib/crti.o"
@@ -34,7 +34,7 @@
 // CHECK-LD-SPARC64-NOT: warning:
 // CHECK-LD-SPARC64: {{.*/clang}}" "-cc1" "-triple" "sparcv9-sun-solaris2.11"
 // CHECK-LD-SPARC64-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// CHECK-LD-SPARC64: {{.*/ld}}"
+// CHECK-LD-SPARC64: "{{(.*/)?ld}}"
 // CHECK-LD-SPARC64-SAME: "--dynamic-linker" 
"[[SYSROOT]]/usr/lib/sparcv9/ld.so.1"
 // CHECK-LD-SPARC64-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9/crt1.o"
 // CHECK-LD-SPARC64-SAME: "[[SYSROOT]]/usr/lib/sparcv9/crti.o"
@@ -58,7 +58,7 @@
 // CHECK-LD-X32-NOT: warning:
 // CHECK-LD-X32: {{.*/clang}}" "-cc1" "-triple" "i386-pc-solaris2.11"
 // CHECK-LD-X32-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// CHECK-LD-X32: {{.*/ld}}"
+// CHECK-LD-X32: "{{(.*/)?ld}}"
 // CHECK-LD-X32-SAME: "--dynamic-linker" "[[SYSROOT]]/usr/lib/ld.so.1"
 // CHECK-LD-X32-SAME: "[[SYSROOT]]/usr/lib/crt1.o"
 // CHECK-LD-X32-SAME: "[[SYSROOT]]/usr/lib/crti.o"
@@ -82,7 +82,7 @@
 // CHECK-LD-X64-NOT: warning:
 // CHECK-LD-X64: {{.*/clang}}" "-cc1" "-triple" "x86_64-pc-solaris2.11"
 // CHECK-LD-X64-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
-// CHECK-LD-X64: {{.*/ld}}"
+// CHECK-LD-X64: "{{(.*/)?ld}}"
 // CHECK-LD-X64-SAME: "--dynamic-linker" "[[SYSROOT]]/usr/lib/amd64/ld.so.1"
 // CHECK-LD-X64-SAME: "[[SYSROOT]]/usr/lib/amd64/crt1.o"
 // CHECK-LD-X64-SAME: "[[SYSROOT]]/usr/lib/amd64/crti.o"
@@ -103,7 +103,7 @@
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-SPARC32-SHARED %s
-// CHECK-SPARC32-SHARED: {{.*/ld}}"
+// CHECK-SPARC32-SHARED: "{{(.*/)?ld}}"
 // CHECK-SPARC32-SHARED-SAME: "-lgcc_s"
 // CHECK-SPARC32-SHARED-SAME: "-lc"
 // CHECK-SPARC32-SHARED-NOT: "-lgcc"


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


Re: r322984 - Allow BlockDecl in CXXRecord scope to have no access specifier.

2018-01-19 Thread Richard Trieu via cfe-commits
Hans,

I recommend merging this revision into the release.  It fixes an assertion
error when mixing modules and blocks.

Richard


On Fri, Jan 19, 2018 at 12:46 PM, Richard Trieu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rtrieu
> Date: Fri Jan 19 12:46:19 2018
> New Revision: 322984
>
> URL: http://llvm.org/viewvc/llvm-project?rev=322984=rev
> Log:
> Allow BlockDecl in CXXRecord scope to have no access specifier.
>
> Using a BlockDecl in a default member initializer causes it to be attached
> to
> CXXMethodDecl without its access specifier being set.  This prevents a
> crash
> where getAccess is called on this BlockDecl, since that method expects any
> Decl in CXXRecord scope to have an access specifier.
>
> Added:
> cfe/trunk/test/Modules/odr_hash-blocks.cpp
> Modified:
> cfe/trunk/lib/AST/DeclBase.cpp
>
> Modified: cfe/trunk/lib/AST/DeclBase.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBa
> se.cpp?rev=322984=322983=322984=diff
> 
> ==
> --- cfe/trunk/lib/AST/DeclBase.cpp (original)
> +++ cfe/trunk/lib/AST/DeclBase.cpp Fri Jan 19 12:46:19 2018
> @@ -891,12 +891,14 @@ bool Decl::AccessDeclContextSanity() con
>// 4. the context is not a record
>// 5. it's invalid
>// 6. it's a C++0x static_assert.
> +  // 7. it's a block literal declaration
>if (isa(this) ||
>isa(this) ||
>isa(this) ||
>!isa(getDeclContext()) ||
>isInvalidDecl() ||
>isa(this) ||
> +  isa(this) ||
>// FIXME: a ParmVarDecl can have ClassTemplateSpecialization
>// as DeclContext (?).
>isa(this) ||
>
> Added: cfe/trunk/test/Modules/odr_hash-blocks.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/
> odr_hash-blocks.cpp?rev=322984=auto
> 
> ==
> --- cfe/trunk/test/Modules/odr_hash-blocks.cpp (added)
> +++ cfe/trunk/test/Modules/odr_hash-blocks.cpp Fri Jan 19 12:46:19 2018
> @@ -0,0 +1,119 @@
> +// Clear and create directories
> +// RUN: rm -rf %t
> +// RUN: mkdir %t
> +// RUN: mkdir %t/cache
> +// RUN: mkdir %t/Inputs
> +
> +// Build first header file
> +// RUN: echo "#define FIRST" >> %t/Inputs/first.h
> +// RUN: cat %s   >> %t/Inputs/first.h
> +
> +// Build second header file
> +// RUN: echo "#define SECOND" >> %t/Inputs/second.h
> +// RUN: cat %s>> %t/Inputs/second.h
> +
> +// Test that each header can compile
> +// RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++11 -fblocks
> %t/Inputs/first.h
> +// RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++11 -fblocks
> %t/Inputs/second.h
> +
> +// Build module map file
> +// RUN: echo "module FirstModule {" >> %t/Inputs/module.map
> +// RUN: echo "header \"first.h\""   >> %t/Inputs/module.map
> +// RUN: echo "}">> %t/Inputs/module.map
> +// RUN: echo "module SecondModule {">> %t/Inputs/module.map
> +// RUN: echo "header \"second.h\""  >> %t/Inputs/module.map
> +// RUN: echo "}">> %t/Inputs/module.map
> +
> +// Run test
> +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
> +// RUN:-fmodules-cache-path=%t/cache -x c++ -I%t/Inputs \
> +// RUN:-verify %s -std=c++11 -fblocks
> +
> +#if !defined(FIRST) && !defined(SECOND)
> +#include "first.h"
> +#include "second.h"
> +#endif
> +
> +// Used for testing
> +#if defined(FIRST)
> +#define ACCESS public:
> +#elif defined(SECOND)
> +#define ACCESS private:
> +#endif
> +
> +// TODO: S1, S2, and S3 should generate errors.
> +namespace Blocks {
> +#if defined(FIRST)
> +struct S1 {
> +  void (^block)(int x) = ^(int x) { };
> +};
> +#elif defined(SECOND)
> +struct S1 {
> +  void (^block)(int x) = ^(int y) { };
> +};
> +#else
> +S1 s1;
> +#endif
> +
> +#if defined(FIRST)
> +struct S2 {
> +  int (^block)(int x) = ^(int x) { return x + 1; };
> +};
> +#elif defined(SECOND)
> +struct S2 {
> +  int (^block)(int x) = ^(int x) { return x; };
> +};
> +#else
> +S2 s2;
> +#endif
> +
> +#if defined(FIRST)
> +struct S3 {
> +  void run(int (^block)(int x));
> +};
> +#elif defined(SECOND)
> +struct S3 {
> +  void run(int (^block)(int x, int y));
> +};
> +#else
> +S3 s3;
> +#endif
> +
> +#define DECLS   \
> +  int (^block)(int 

Re: r322813 - Fix Scope::dump()

2018-01-19 Thread Richard Trieu via cfe-commits
Hans,

I recommend merging this revision into the release.  It fixes an infinite
loop in Scope::dump()

Richard

On Wed, Jan 17, 2018 at 8:28 PM, Richard Trieu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rtrieu
> Date: Wed Jan 17 20:28:56 2018
> New Revision: 322813
>
> URL: http://llvm.org/viewvc/llvm-project?rev=322813=rev
> Log:
> Fix Scope::dump()
>
> The dump function for Scope only has 20 out of the 24 flags.  Since it
> looped
> until no flags were left, having an unknown flag lead to an infinite loop.
> That loop has been changed to a single pass for each flag, plus an assert
> to
> alert if new flags are added.
>
> Modified:
> cfe/trunk/lib/Sema/Scope.cpp
>
> Modified: cfe/trunk/lib/Sema/Scope.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Scope
> .cpp?rev=322813=322812=322813=diff
> 
> ==
> --- cfe/trunk/lib/Sema/Scope.cpp (original)
> +++ cfe/trunk/lib/Sema/Scope.cpp Wed Jan 17 20:28:56 2018
> @@ -143,72 +143,43 @@ void Scope::dumpImpl(raw_ostream ) co
>if (HasFlags)
>  OS << "Flags: ";
>
> -  while (Flags) {
> -if (Flags & FnScope) {
> -  OS << "FnScope";
> -  Flags &= ~FnScope;
> -} else if (Flags & BreakScope) {
> -  OS << "BreakScope";
> -  Flags &= ~BreakScope;
> -} else if (Flags & ContinueScope) {
> -  OS << "ContinueScope";
> -  Flags &= ~ContinueScope;
> -} else if (Flags & DeclScope) {
> -  OS << "DeclScope";
> -  Flags &= ~DeclScope;
> -} else if (Flags & ControlScope) {
> -  OS << "ControlScope";
> -  Flags &= ~ControlScope;
> -} else if (Flags & ClassScope) {
> -  OS << "ClassScope";
> -  Flags &= ~ClassScope;
> -} else if (Flags & BlockScope) {
> -  OS << "BlockScope";
> -  Flags &= ~BlockScope;
> -} else if (Flags & TemplateParamScope) {
> -  OS << "TemplateParamScope";
> -  Flags &= ~TemplateParamScope;
> -} else if (Flags & FunctionPrototypeScope) {
> -  OS << "FunctionPrototypeScope";
> -  Flags &= ~FunctionPrototypeScope;
> -} else if (Flags & FunctionDeclarationScope) {
> -  OS << "FunctionDeclarationScope";
> -  Flags &= ~FunctionDeclarationScope;
> -} else if (Flags & AtCatchScope) {
> -  OS << "AtCatchScope";
> -  Flags &= ~AtCatchScope;
> -} else if (Flags & ObjCMethodScope) {
> -  OS << "ObjCMethodScope";
> -  Flags &= ~ObjCMethodScope;
> -} else if (Flags & SwitchScope) {
> -  OS << "SwitchScope";
> -  Flags &= ~SwitchScope;
> -} else if (Flags & TryScope) {
> -  OS << "TryScope";
> -  Flags &= ~TryScope;
> -} else if (Flags & FnTryCatchScope) {
> -  OS << "FnTryCatchScope";
> -  Flags &= ~FnTryCatchScope;
> -} else if (Flags & SEHTryScope) {
> -  OS << "SEHTryScope";
> -  Flags &= ~SEHTryScope;
> -} else if (Flags & SEHExceptScope) {
> -  OS << "SEHExceptScope";
> -  Flags &= ~SEHExceptScope;
> -} else if (Flags & OpenMPDirectiveScope) {
> -  OS << "OpenMPDirectiveScope";
> -  Flags &= ~OpenMPDirectiveScope;
> -} else if (Flags & OpenMPLoopDirectiveScope) {
> -  OS << "OpenMPLoopDirectiveScope";
> -  Flags &= ~OpenMPLoopDirectiveScope;
> -} else if (Flags & OpenMPSimdDirectiveScope) {
> -  OS << "OpenMPSimdDirectiveScope";
> -  Flags &= ~OpenMPSimdDirectiveScope;
> -}
> +  std::pair<unsigned, const char *> FlagInfo[] = {
> +  {FnScope, "FnScope"},
> +  {BreakScope, "BreakScope"},
> +  {ContinueScope, "ContinueScope"},
> +  {DeclScope, "DeclScope"},
> +  {ControlScope, "ControlScope"},
> +  {ClassScope, "ClassScope"},
> +  {BlockScope, "BlockScope"},
> +  {TemplateParamScope, "TemplateParamScope"},
> +  {FunctionPrototypeScope, "FunctionPrototypeScope"},
> +  {FunctionDeclarationScope, "FunctionDeclarationScope"},
> +  {AtCatchScope, "AtCatchScope"},
> +  {ObjCMethodScope, "ObjCMethodScope"},
> +  {SwitchScope, "SwitchScop

r322984 - Allow BlockDecl in CXXRecord scope to have no access specifier.

2018-01-19 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Jan 19 12:46:19 2018
New Revision: 322984

URL: http://llvm.org/viewvc/llvm-project?rev=322984=rev
Log:
Allow BlockDecl in CXXRecord scope to have no access specifier.

Using a BlockDecl in a default member initializer causes it to be attached to
CXXMethodDecl without its access specifier being set.  This prevents a crash
where getAccess is called on this BlockDecl, since that method expects any
Decl in CXXRecord scope to have an access specifier.

Added:
cfe/trunk/test/Modules/odr_hash-blocks.cpp
Modified:
cfe/trunk/lib/AST/DeclBase.cpp

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=322984=322983=322984=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Fri Jan 19 12:46:19 2018
@@ -891,12 +891,14 @@ bool Decl::AccessDeclContextSanity() con
   // 4. the context is not a record
   // 5. it's invalid
   // 6. it's a C++0x static_assert.
+  // 7. it's a block literal declaration
   if (isa(this) ||
   isa(this) ||
   isa(this) ||
   !isa(getDeclContext()) ||
   isInvalidDecl() ||
   isa(this) ||
+  isa(this) ||
   // FIXME: a ParmVarDecl can have ClassTemplateSpecialization
   // as DeclContext (?).
   isa(this) ||

Added: cfe/trunk/test/Modules/odr_hash-blocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash-blocks.cpp?rev=322984=auto
==
--- cfe/trunk/test/Modules/odr_hash-blocks.cpp (added)
+++ cfe/trunk/test/Modules/odr_hash-blocks.cpp Fri Jan 19 12:46:19 2018
@@ -0,0 +1,119 @@
+// Clear and create directories
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: mkdir %t/cache
+// RUN: mkdir %t/Inputs
+
+// Build first header file
+// RUN: echo "#define FIRST" >> %t/Inputs/first.h
+// RUN: cat %s   >> %t/Inputs/first.h
+
+// Build second header file
+// RUN: echo "#define SECOND" >> %t/Inputs/second.h
+// RUN: cat %s>> %t/Inputs/second.h
+
+// Test that each header can compile
+// RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++11 -fblocks %t/Inputs/first.h
+// RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++11 -fblocks %t/Inputs/second.h
+
+// Build module map file
+// RUN: echo "module FirstModule {" >> %t/Inputs/module.map
+// RUN: echo "header \"first.h\""   >> %t/Inputs/module.map
+// RUN: echo "}">> %t/Inputs/module.map
+// RUN: echo "module SecondModule {">> %t/Inputs/module.map
+// RUN: echo "header \"second.h\""  >> %t/Inputs/module.map
+// RUN: echo "}">> %t/Inputs/module.map
+
+// Run test
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN:-fmodules-cache-path=%t/cache -x c++ -I%t/Inputs \
+// RUN:-verify %s -std=c++11 -fblocks
+
+#if !defined(FIRST) && !defined(SECOND)
+#include "first.h"
+#include "second.h"
+#endif
+
+// Used for testing
+#if defined(FIRST)
+#define ACCESS public:
+#elif defined(SECOND)
+#define ACCESS private:
+#endif
+
+// TODO: S1, S2, and S3 should generate errors.
+namespace Blocks {
+#if defined(FIRST)
+struct S1 {
+  void (^block)(int x) = ^(int x) { };
+};
+#elif defined(SECOND)
+struct S1 {
+  void (^block)(int x) = ^(int y) { };
+};
+#else
+S1 s1;
+#endif
+
+#if defined(FIRST)
+struct S2 {
+  int (^block)(int x) = ^(int x) { return x + 1; };
+};
+#elif defined(SECOND)
+struct S2 {
+  int (^block)(int x) = ^(int x) { return x; };
+};
+#else
+S2 s2;
+#endif
+
+#if defined(FIRST)
+struct S3 {
+  void run(int (^block)(int x));
+};
+#elif defined(SECOND)
+struct S3 {
+  void run(int (^block)(int x, int y));
+};
+#else
+S3 s3;
+#endif
+
+#define DECLS   \
+  int (^block)(int x) = ^(int x) { return x + x; }; \
+  void run(int (^block)(int x, int y));
+
+#if defined(FIRST) || defined(SECOND)
+struct Valid1 {
+  DECLS
+};
+#else
+Valid1 v1;
+#endif
+
+#if defined(FIRST) || defined(SECOND)
+struct Invalid1 {
+  DECLS
+  ACCESS
+};
+#else
+Invalid1 i1;
+// expected-error@second.h:* {{'Blocks::Invalid1' has different definitions in 
different modules; first difference is definition in module 'SecondModule' 
found private access specifier}}
+// expected-note@first.h:* {{but in 'FirstModule' found public access 
specifier}}
+#endif
+
+#undef DECLS
+}
+
+// Keep macros contained to one file.
+#ifdef FIRST
+#undef FIRST
+#endif
+
+#ifdef SECOND
+#undef SECOND
+#endif
+
+#ifdef ACCESS
+#undef ACCESS
+#endif


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


r322813 - Fix Scope::dump()

2018-01-17 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Jan 17 20:28:56 2018
New Revision: 322813

URL: http://llvm.org/viewvc/llvm-project?rev=322813=rev
Log:
Fix Scope::dump()

The dump function for Scope only has 20 out of the 24 flags.  Since it looped
until no flags were left, having an unknown flag lead to an infinite loop.
That loop has been changed to a single pass for each flag, plus an assert to
alert if new flags are added.

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

Modified: cfe/trunk/lib/Sema/Scope.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Scope.cpp?rev=322813=322812=322813=diff
==
--- cfe/trunk/lib/Sema/Scope.cpp (original)
+++ cfe/trunk/lib/Sema/Scope.cpp Wed Jan 17 20:28:56 2018
@@ -143,72 +143,43 @@ void Scope::dumpImpl(raw_ostream ) co
   if (HasFlags)
 OS << "Flags: ";
 
-  while (Flags) {
-if (Flags & FnScope) {
-  OS << "FnScope";
-  Flags &= ~FnScope;
-} else if (Flags & BreakScope) {
-  OS << "BreakScope";
-  Flags &= ~BreakScope;
-} else if (Flags & ContinueScope) {
-  OS << "ContinueScope";
-  Flags &= ~ContinueScope;
-} else if (Flags & DeclScope) {
-  OS << "DeclScope";
-  Flags &= ~DeclScope;
-} else if (Flags & ControlScope) {
-  OS << "ControlScope";
-  Flags &= ~ControlScope;
-} else if (Flags & ClassScope) {
-  OS << "ClassScope";
-  Flags &= ~ClassScope;
-} else if (Flags & BlockScope) {
-  OS << "BlockScope";
-  Flags &= ~BlockScope;
-} else if (Flags & TemplateParamScope) {
-  OS << "TemplateParamScope";
-  Flags &= ~TemplateParamScope;
-} else if (Flags & FunctionPrototypeScope) {
-  OS << "FunctionPrototypeScope";
-  Flags &= ~FunctionPrototypeScope;
-} else if (Flags & FunctionDeclarationScope) {
-  OS << "FunctionDeclarationScope";
-  Flags &= ~FunctionDeclarationScope;
-} else if (Flags & AtCatchScope) {
-  OS << "AtCatchScope";
-  Flags &= ~AtCatchScope;
-} else if (Flags & ObjCMethodScope) {
-  OS << "ObjCMethodScope";
-  Flags &= ~ObjCMethodScope;
-} else if (Flags & SwitchScope) {
-  OS << "SwitchScope";
-  Flags &= ~SwitchScope;
-} else if (Flags & TryScope) {
-  OS << "TryScope";
-  Flags &= ~TryScope;
-} else if (Flags & FnTryCatchScope) {
-  OS << "FnTryCatchScope";
-  Flags &= ~FnTryCatchScope;
-} else if (Flags & SEHTryScope) {
-  OS << "SEHTryScope";
-  Flags &= ~SEHTryScope;
-} else if (Flags & SEHExceptScope) {
-  OS << "SEHExceptScope";
-  Flags &= ~SEHExceptScope;
-} else if (Flags & OpenMPDirectiveScope) {
-  OS << "OpenMPDirectiveScope";
-  Flags &= ~OpenMPDirectiveScope;
-} else if (Flags & OpenMPLoopDirectiveScope) {
-  OS << "OpenMPLoopDirectiveScope";
-  Flags &= ~OpenMPLoopDirectiveScope;
-} else if (Flags & OpenMPSimdDirectiveScope) {
-  OS << "OpenMPSimdDirectiveScope";
-  Flags &= ~OpenMPSimdDirectiveScope;
-}
+  std::pair FlagInfo[] = {
+  {FnScope, "FnScope"},
+  {BreakScope, "BreakScope"},
+  {ContinueScope, "ContinueScope"},
+  {DeclScope, "DeclScope"},
+  {ControlScope, "ControlScope"},
+  {ClassScope, "ClassScope"},
+  {BlockScope, "BlockScope"},
+  {TemplateParamScope, "TemplateParamScope"},
+  {FunctionPrototypeScope, "FunctionPrototypeScope"},
+  {FunctionDeclarationScope, "FunctionDeclarationScope"},
+  {AtCatchScope, "AtCatchScope"},
+  {ObjCMethodScope, "ObjCMethodScope"},
+  {SwitchScope, "SwitchScope"},
+  {TryScope, "TryScope"},
+  {FnTryCatchScope, "FnTryCatchScope"},
+  {OpenMPDirectiveScope, "OpenMPDirectiveScope"},
+  {OpenMPLoopDirectiveScope, "OpenMPLoopDirectiveScope"},
+  {OpenMPSimdDirectiveScope, "OpenMPSimdDirectiveScope"},
+  {EnumScope, "EnumScope"},
+  {SEHTryScope, "SEHTryScope"},
+  {SEHExceptScope, "SEHExceptScope"},
+  {SEHFilterScope, "SEHFilterScope"},
+  {CompoundStmtScope, "CompoundStmtScope"},
+  {ClassInheritanceScope, "ClassInheritanceScope"}};
 
-if (Flags)
-  OS << " | ";
+  for (auto Info : FlagInfo) {
+if (Flags & Info.first) {
+  OS << Info.second;
+  Flags &= ~Info.first;
+  if (Flags)
+OS << " | ";
+}
   }
+
+  assert(Flags == 0 && "Unknown scope flags");
+
   if (HasFlags)
 OS << '\n';
 


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


Re: r322350 - [ODRHash] Don't hash friend functions.

2018-01-16 Thread Richard Trieu via cfe-commits
I feel it's best to merge this change into the release branch instead of
reverting the previous change.  I've filed a bug to request this revision,
and a few others that fix the test case, to be merged.
https://bugs.llvm.org/show_bug.cgi?id=35981

On Tue, Jan 16, 2018 at 2:44 PM, NAKAMURA Takumi <geek4ci...@gmail.com>
wrote:

> If r322350 is temporary fix, I suggest r321395 may be reverted in
> release_60. Richard, how do you think?
>
> On Wed, Jan 17, 2018 at 4:27 AM Richard Trieu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> There was a different, possibly related, issue with templated methods
>> that I just disabled checking for methods all together in r321396 until
>> I can investigate further.
>>
>>
>> On Mon, Jan 15, 2018 at 10:45 AM, David Blaikie <dblai...@gmail.com>
>> wrote:
>>
>>> I'm surprised this problem is unique to friend functions with
>>> definitions inline and the friend declaration site - doesn't a similar
>>> issue occur with member functions of templates that are not instantiated in
>>> some (similar) contexts?
>>>
>>> Is there a common solution that could be used for both cases?
>>>
>>>
>>> On Thu, Jan 11, 2018 at 8:43 PM Richard Trieu via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
>>>> Author: rtrieu
>>>> Date: Thu Jan 11 20:42:27 2018
>>>> New Revision: 322350
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=322350=rev
>>>> Log:
>>>> [ODRHash] Don't hash friend functions.
>>>>
>>>> In certain combinations of templated classes and friend functions, the
>>>> body
>>>> of friend functions does not get propagated along with function
>>>> signature.
>>>> Exclude friend functions for hashing to avoid this case.
>>>>
>>>> Added:
>>>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/
>>>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h
>>>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M1.h
>>>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M2.h
>>>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M3.h
>>>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/module.modulemap
>>>> cfe/trunk/test/Modules/odr_hash-Friend.cpp
>>>> Modified:
>>>> cfe/trunk/lib/AST/ODRHash.cpp
>>>>
>>>> Modified: cfe/trunk/lib/AST/ODRHash.cpp
>>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
>>>> ODRHash.cpp?rev=322350=322349=322350=diff
>>>> 
>>>> ==
>>>> --- cfe/trunk/lib/AST/ODRHash.cpp (original)
>>>> +++ cfe/trunk/lib/AST/ODRHash.cpp Thu Jan 11 20:42:27 2018
>>>> @@ -478,6 +478,8 @@ void ODRHash::AddFunctionDecl(const Func
>>>>
>>>>// TODO: Fix hashing for class methods.
>>>>if (isa(Function)) return;
>>>> +  // And friend functions.
>>>> +  if (Function->getFriendObjectKind()) return;
>>>>
>>>>// Skip functions that are specializations or in specialization
>>>> context.
>>>>const DeclContext *DC = Function;
>>>>
>>>> Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h
>>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
>>>> Modules/Inputs/odr_hash-Friend/Box.h?rev=322350=auto
>>>> 
>>>> ==
>>>> --- cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h (added)
>>>> +++ cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h Thu Jan 11
>>>> 20:42:27 2018
>>>> @@ -0,0 +1,14 @@
>>>> +template 
>>>> +struct iterator {
>>>> +  void Compare(const iterator ) { }
>>>> +  friend void Check(iterator) {}
>>>> +};
>>>> +
>>>> +template  struct Box {
>>>> +  iterator I;
>>>> +
>>>> +  void test() {
>>>> +Check(I);
>>>> +I.Compare(I);
>>>> +  }
>>>> +};
>>>>
>>>> Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M1.h
>>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
>>>> Modules/Inputs/odr_hash-Friend/M1.h?rev=322350=auto
>>>> 

Re: r322405 - Disable test for Windows to fix Windows buildbots.

2018-01-16 Thread Richard Trieu via cfe-commits
Tracking bug is PR35939
r322593 adds comment to test case
This test triggers an assertion in MicrosoftMangle.cpp

On Mon, Jan 15, 2018 at 10:38 AM, David Blaikie <dblai...@gmail.com> wrote:

> might be worth having an explanation (probably in both the commit message
> and in a comment in the source) about why this test isn't supported on
> windows?
>
> On Fri, Jan 12, 2018 at 1:50 PM Richard Trieu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rtrieu
>> Date: Fri Jan 12 13:49:20 2018
>> New Revision: 322405
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=322405=rev
>> Log:
>> Disable test for Windows to fix Windows buildbots.
>>
>> Modified:
>> cfe/trunk/test/Modules/odr_hash-Friend.cpp
>>
>> Modified: cfe/trunk/test/Modules/odr_hash-Friend.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
>> Modules/odr_hash-Friend.cpp?rev=322405=322404=322405=diff
>> 
>> ==
>> --- cfe/trunk/test/Modules/odr_hash-Friend.cpp (original)
>> +++ cfe/trunk/test/Modules/odr_hash-Friend.cpp Fri Jan 12 13:49:20 2018
>> @@ -8,6 +8,8 @@
>>  // RUN:  -fmodules-cache-path=%t/modules.cache \
>>  // RUN:  -std=c++11 -x c++ %s -verify
>>
>> +// UNSUPPORTED: windows
>> +
>>  // expected-no-diagnostics
>>
>>  #include "Box.h"
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r322593 - Add context to why test was disabled on Windows

2018-01-16 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Jan 16 11:53:06 2018
New Revision: 322593

URL: http://llvm.org/viewvc/llvm-project?rev=322593=rev
Log:
Add context to why test was disabled on Windows

test/Modules/odr_hash-Friend.cpp triggers an assertion in MicrosoftMangle.cpp
This has been reported in PR35939


Modified:
cfe/trunk/test/Modules/odr_hash-Friend.cpp

Modified: cfe/trunk/test/Modules/odr_hash-Friend.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash-Friend.cpp?rev=322593=322592=322593=diff
==
--- cfe/trunk/test/Modules/odr_hash-Friend.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash-Friend.cpp Tue Jan 16 11:53:06 2018
@@ -8,6 +8,7 @@
 // RUN:  -fmodules-cache-path=%t/modules.cache \
 // RUN:  -std=c++11 -x c++ %s -verify
 
+// PR35939: MicrosoftMangle.cpp triggers an assertion failure on this test.
 // UNSUPPORTED: system-windows
 
 // expected-no-diagnostics


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


Re: r322350 - [ODRHash] Don't hash friend functions.

2018-01-16 Thread Richard Trieu via cfe-commits
There was a different, possibly related, issue with templated methods that
I just disabled checking for methods all together in r321396 until I can
investigate further.

On Mon, Jan 15, 2018 at 10:45 AM, David Blaikie <dblai...@gmail.com> wrote:

> I'm surprised this problem is unique to friend functions with definitions
> inline and the friend declaration site - doesn't a similar issue occur with
> member functions of templates that are not instantiated in some (similar)
> contexts?
>
> Is there a common solution that could be used for both cases?
>
>
> On Thu, Jan 11, 2018 at 8:43 PM Richard Trieu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rtrieu
>> Date: Thu Jan 11 20:42:27 2018
>> New Revision: 322350
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=322350=rev
>> Log:
>> [ODRHash] Don't hash friend functions.
>>
>> In certain combinations of templated classes and friend functions, the
>> body
>> of friend functions does not get propagated along with function signature.
>> Exclude friend functions for hashing to avoid this case.
>>
>> Added:
>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/
>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h
>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M1.h
>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M2.h
>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M3.h
>> cfe/trunk/test/Modules/Inputs/odr_hash-Friend/module.modulemap
>> cfe/trunk/test/Modules/odr_hash-Friend.cpp
>> Modified:
>> cfe/trunk/lib/AST/ODRHash.cpp
>>
>> Modified: cfe/trunk/lib/AST/ODRHash.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
>> ODRHash.cpp?rev=322350=322349=322350=diff
>> 
>> ==
>> --- cfe/trunk/lib/AST/ODRHash.cpp (original)
>> +++ cfe/trunk/lib/AST/ODRHash.cpp Thu Jan 11 20:42:27 2018
>> @@ -478,6 +478,8 @@ void ODRHash::AddFunctionDecl(const Func
>>
>>// TODO: Fix hashing for class methods.
>>if (isa(Function)) return;
>> +  // And friend functions.
>> +  if (Function->getFriendObjectKind()) return;
>>
>>// Skip functions that are specializations or in specialization
>> context.
>>const DeclContext *DC = Function;
>>
>> Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
>> Modules/Inputs/odr_hash-Friend/Box.h?rev=322350=auto
>> 
>> ==
>> --- cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h (added)
>> +++ cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h Thu Jan 11
>> 20:42:27 2018
>> @@ -0,0 +1,14 @@
>> +template 
>> +struct iterator {
>> +  void Compare(const iterator ) { }
>> +  friend void Check(iterator) {}
>> +};
>> +
>> +template  struct Box {
>> +  iterator I;
>> +
>> +  void test() {
>> +Check(I);
>> +I.Compare(I);
>> +  }
>> +};
>>
>> Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M1.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
>> Modules/Inputs/odr_hash-Friend/M1.h?rev=322350=auto
>> 
>> ==
>> --- cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M1.h (added)
>> +++ cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M1.h Thu Jan 11
>> 20:42:27 2018
>> @@ -0,0 +1,6 @@
>> +#include "Box.h"
>> +
>> +void Peek() {
>> +  Box<> Gift;
>> +  Gift.test();
>> +}
>>
>> Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M2.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
>> Modules/Inputs/odr_hash-Friend/M2.h?rev=322350=auto
>> 
>> ==
>> --- cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M2.h (added)
>> +++ cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M2.h Thu Jan 11
>> 20:42:27 2018
>> @@ -0,0 +1,5 @@
>> +#include "Box.h"
>> +void x() {
>> +  Box<> Unused;
>> +  //Unused.test();
>> +}
>>
>> Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M3.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
>> Modules/Inputs/odr_hash-Friend/M3.h?rev=322350=auto
>> 
>> ==
>> --- cfe/trunk/test/Modules/Inputs/odr_hash-Fri

r322420 - Try to suppress Windows testing again.

2018-01-12 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Jan 12 15:13:33 2018
New Revision: 322420

URL: http://llvm.org/viewvc/llvm-project?rev=322420=rev
Log:
Try to suppress Windows testing again.

Modified:
cfe/trunk/test/Modules/odr_hash-Friend.cpp

Modified: cfe/trunk/test/Modules/odr_hash-Friend.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash-Friend.cpp?rev=322420=322419=322420=diff
==
--- cfe/trunk/test/Modules/odr_hash-Friend.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash-Friend.cpp Fri Jan 12 15:13:33 2018
@@ -8,7 +8,7 @@
 // RUN:  -fmodules-cache-path=%t/modules.cache \
 // RUN:  -std=c++11 -x c++ %s -verify
 
-// UNSUPPORTED: windows
+// UNSUPPORTED: system-windows
 
 // expected-no-diagnostics
 


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


r322405 - Disable test for Windows to fix Windows buildbots.

2018-01-12 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Jan 12 13:49:20 2018
New Revision: 322405

URL: http://llvm.org/viewvc/llvm-project?rev=322405=rev
Log:
Disable test for Windows to fix Windows buildbots.

Modified:
cfe/trunk/test/Modules/odr_hash-Friend.cpp

Modified: cfe/trunk/test/Modules/odr_hash-Friend.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash-Friend.cpp?rev=322405=322404=322405=diff
==
--- cfe/trunk/test/Modules/odr_hash-Friend.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash-Friend.cpp Fri Jan 12 13:49:20 2018
@@ -8,6 +8,8 @@
 // RUN:  -fmodules-cache-path=%t/modules.cache \
 // RUN:  -std=c++11 -x c++ %s -verify
 
+// UNSUPPORTED: windows
+
 // expected-no-diagnostics
 
 #include "Box.h"


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


Re: r321395 - [ODRHash] Support ODR violation detection in functions.

2018-01-11 Thread Richard Trieu via cfe-commits
Hi Vedant and Eric,

Please retry after r322350.  I suspect an interaction between templates and
friend functions is causing this issue.  This revision disables hashing for
friend functions for now.

Richard

On Thu, Jan 11, 2018 at 3:34 PM, Eric Fiselier <e...@efcs.ca> wrote:

> I'm hitting the same issue as well.
>
> Please let me know if there is anything I can do to get this fixed quickly.
>
> /Eric
>
> On Wed, Jan 3, 2018 at 5:20 PM, Richard Trieu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Vedant,
>>
>> I'm looking into it.
>>
>>
>> On Wed, Jan 3, 2018 at 11:12 AM, Vedant Kumar <v...@apple.com> wrote:
>>
>>> Oops, the build log was too big to attach. Resending with just the bot
>>> link, then:
>>> http://lab.llvm.org:8080/green/view/Experimental/job/clang-s
>>> tage2-coverage-R/2193/consoleText
>>>
>>> vedant
>>>
>>> On Jan 3, 2018, at 11:09 AM, Vedant Kumar <v...@apple.com> wrote:
>>>
>>> Hi Richard,
>>>
>>> This commit is causing an unexpected build failure in the stage2
>>> modules-enabled coverage bot. I've attached the build log. Here's the error:
>>>
>>> [3685/3899] 
>>> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/host-compiler/bin/clang++
>>>-DGTEST_HAS_RTTI=0 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
>>> -D__STDC_LIMIT_MACROS -Itools/lld/COFF 
>>> -I/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/COFF
>>>  
>>> -I/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/include
>>>  -Itools/lld/include -I/usr/include/libxml2 -Iinclude 
>>> -I/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include 
>>> -fPIC -fvisibility-inlines-hidden -Werror=date-time 
>>> -Werror=unguarded-availability-new -std=c++11 -fmodules 
>>> -fmodules-cache-path=/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/clang-build/module.cache
>>>  -fcxx-modules -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
>>> -Wmissing-field-initializers -pedantic -Wno-long-long 
>>> -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor 
>>> -Wstring-conversion -fcolor-diagnostics 
>>> -fprofile-instr-generate='/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/clang-build/profiles/%6m.profraw'
>>>  -fcoverage-mapping -O3 -DNDEBUG-fno-exceptions -fno-rtti -MMD -MT 
>>> tools/lld/COFF/CMakeFiles/lldCOFF.dir/PDB.cpp.o -MF 
>>> tools/lld/COFF/CMakeFiles/lldCOFF.dir/PDB.cpp.o.d -o 
>>> tools/lld/COFF/CMakeFiles/lldCOFF.dir/PDB.cpp.o -c 
>>> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/COFF/PDB.cpp
>>> FAILED: tools/lld/COFF/CMakeFiles/lldCOFF.dir/PDB.cpp.o
>>> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/host-compiler/bin/clang++
>>>-DGTEST_HAS_RTTI=0 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
>>> -D__STDC_LIMIT_MACROS -Itools/lld/COFF 
>>> -I/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/COFF
>>>  
>>> -I/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/include
>>>  -Itools/lld/include -I/usr/include/libxml2 -Iinclude 
>>> -I/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include 
>>> -fPIC -fvisibility-inlines-hidden -Werror=date-time 
>>> -Werror=unguarded-availability-new -std=c++11 -fmodules 
>>> -fmodules-cache-path=/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/clang-build/module.cache
>>>  -fcxx-modules -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
>>> -Wmissing-field-initializers -pedantic -Wno-long-long 
>>> -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor 
>>> -Wstring-conversion -fcolor-diagnostics 
>>> -fprofile-instr-generate='/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/clang-build/profiles/%6m.profraw'
>>>  -fcoverage-mapping -O3 -DNDEBUG-fno-exceptions -fno-rtti -MMD -MT 
>>> tools/lld/COFF/CMakeFiles/lldCOFF.dir/PDB.cpp.o -MF 
>>> tools/lld/COFF/CMakeFiles/lldCOFF.dir/PDB.cpp.o.d -o 
>>> tools/lld/COFF/CMakeFiles/lldCOFF.dir/PDB.cpp.o -c 
>>> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/COFF/PDB.cpp
>>> In module 'std' imported from 
>>> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/COFF/Config.h:16:
>>> /Users/bui

r322350 - [ODRHash] Don't hash friend functions.

2018-01-11 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Thu Jan 11 20:42:27 2018
New Revision: 322350

URL: http://llvm.org/viewvc/llvm-project?rev=322350=rev
Log:
[ODRHash] Don't hash friend functions.

In certain combinations of templated classes and friend functions, the body
of friend functions does not get propagated along with function signature.
Exclude friend functions for hashing to avoid this case.

Added:
cfe/trunk/test/Modules/Inputs/odr_hash-Friend/
cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h
cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M1.h
cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M2.h
cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M3.h
cfe/trunk/test/Modules/Inputs/odr_hash-Friend/module.modulemap
cfe/trunk/test/Modules/odr_hash-Friend.cpp
Modified:
cfe/trunk/lib/AST/ODRHash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=322350=322349=322350=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Thu Jan 11 20:42:27 2018
@@ -478,6 +478,8 @@ void ODRHash::AddFunctionDecl(const Func
 
   // TODO: Fix hashing for class methods.
   if (isa(Function)) return;
+  // And friend functions.
+  if (Function->getFriendObjectKind()) return;
 
   // Skip functions that are specializations or in specialization context.
   const DeclContext *DC = Function;

Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h?rev=322350=auto
==
--- cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h (added)
+++ cfe/trunk/test/Modules/Inputs/odr_hash-Friend/Box.h Thu Jan 11 20:42:27 2018
@@ -0,0 +1,14 @@
+template 
+struct iterator {
+  void Compare(const iterator ) { }
+  friend void Check(iterator) {}
+};
+
+template  struct Box {
+  iterator I;
+
+  void test() {
+Check(I);
+I.Compare(I);
+  }
+};

Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M1.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M1.h?rev=322350=auto
==
--- cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M1.h (added)
+++ cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M1.h Thu Jan 11 20:42:27 2018
@@ -0,0 +1,6 @@
+#include "Box.h"
+
+void Peek() {
+  Box<> Gift;
+  Gift.test();
+}

Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M2.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M2.h?rev=322350=auto
==
--- cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M2.h (added)
+++ cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M2.h Thu Jan 11 20:42:27 2018
@@ -0,0 +1,5 @@
+#include "Box.h"
+void x() {
+  Box<> Unused;
+  //Unused.test();
+}

Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M3.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M3.h?rev=322350=auto
==
--- cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M3.h (added)
+++ cfe/trunk/test/Modules/Inputs/odr_hash-Friend/M3.h Thu Jan 11 20:42:27 2018
@@ -0,0 +1,7 @@
+#include "Box.h"
+#include "M2.h"
+
+void Party() {
+  Box<> Present;
+  Present.test();
+}

Added: cfe/trunk/test/Modules/Inputs/odr_hash-Friend/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-Friend/module.modulemap?rev=322350=auto
==
--- cfe/trunk/test/Modules/Inputs/odr_hash-Friend/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/odr_hash-Friend/module.modulemap Thu Jan 11 
20:42:27 2018
@@ -0,0 +1,15 @@
+module Box {
+  header "Box.h"
+}
+
+module Module1 {
+  header "M1.h"
+}
+
+module Module2 {
+  header "M2.h"
+}
+
+module Module3 {
+  header "M3.h"
+}

Added: cfe/trunk/test/Modules/odr_hash-Friend.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash-Friend.cpp?rev=322350=auto
==
--- cfe/trunk/test/Modules/odr_hash-Friend.cpp (added)
+++ cfe/trunk/test/Modules/odr_hash-Friend.cpp Thu Jan 11 20:42:27 2018
@@ -0,0 +1,19 @@
+// RUN: rm -rf %t
+
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/modules.cache \
+// RUN:  -I %S/Inputs/odr_hash-Friend \
+// RUN:  -emit-obj -o /dev/null \
+// RUN:  -fmodules \
+// RUN:  -fimplicit-module-maps \
+// RUN:  -fmodules-cache-path=%t/modules.cache \
+// RUN:  -std=c++11 -x c++ %s -verify
+
+// expected-no-diagnostics
+
+#include "Box.h"
+#include "M1.h"
+#include "M3.h"
+
+void Run() {
+  Box<> Present;
+}



r321924 - Test case for r321396

2018-01-05 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Jan  5 19:20:59 2018
New Revision: 321924

URL: http://llvm.org/viewvc/llvm-project?rev=321924=rev
Log:
Test case for r321396

Any hashing for methods should be able to compile this test case without
emitting an error.  Since the class and method come from the same header from
each module, there should be no messages about ODR violations.

Added:
cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/
cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Module2/
cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Module2/include.h
cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Module2/not-include.h
cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub1/
cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub1/X.h
cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub1/Y.h
cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub1/Z.h
cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub2/
cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub2/A.h
cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub2/B.h
cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/class.h
cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/function.h
cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/module.modulemap
cfe/trunk/test/Modules/odr_hash-Unresolved.cpp

Added: cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Module2/include.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Module2/include.h?rev=321924=auto
==
--- cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Module2/include.h (added)
+++ cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Module2/include.h Fri Jan 
 5 19:20:59 2018
@@ -0,0 +1,3 @@
+// include.h
+#include "Sub1/Z.h"
+

Added: cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Module2/not-include.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Module2/not-include.h?rev=321924=auto
==
--- cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Module2/not-include.h 
(added)
+++ cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Module2/not-include.h Fri 
Jan  5 19:20:59 2018
@@ -0,0 +1,5 @@
+// not-include.h
+
+#include "function.h"
+#include "class.h"
+

Added: cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub1/X.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub1/X.h?rev=321924=auto
==
--- cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub1/X.h (added)
+++ cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub1/X.h Fri Jan  5 
19:20:59 2018
@@ -0,0 +1,3 @@
+// X.h
+#include "Sub1/Z.h"
+

Added: cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub1/Y.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub1/Y.h?rev=321924=auto
==
--- cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub1/Y.h (added)
+++ cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub1/Y.h Fri Jan  5 
19:20:59 2018
@@ -0,0 +1,4 @@
+// Y.h
+#include "Sub1/Z.h"
+#include "class.h"
+

Added: cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub1/Z.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub1/Z.h?rev=321924=auto
==
--- cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub1/Z.h (added)
+++ cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub1/Z.h Fri Jan  5 
19:20:59 2018
@@ -0,0 +1,4 @@
+// Z.h
+#include "Sub2/A.h"
+#include "Sub2/B.h"
+

Added: cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub2/A.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub2/A.h?rev=321924=auto
==
--- cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub2/A.h (added)
+++ cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub2/A.h Fri Jan  5 
19:20:59 2018
@@ -0,0 +1,3 @@
+// A.h
+#include "function.h"
+

Added: cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub2/B.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub2/B.h?rev=321924=auto
==
--- cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub2/B.h (added)
+++ cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/Sub2/B.h Fri Jan  5 
19:20:59 2018
@@ -0,0 +1,3 @@
+// B.h
+#include "function.h"
+

Added: cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/class.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/odr_hash-Unresolved/class.h?rev=321924=auto

Re: r321395 - [ODRHash] Support ODR violation detection in functions.

2018-01-03 Thread Richard Trieu via cfe-commits
~~
> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/host-compiler/include/c++/v1/list:394:11:
>  note: but in 'std.list' found a different body
>  bool operator!=(const __list_iterator& __x, const __list_iterator& __y)
>  ~^~
> 2 errors generated.
>
> I'm not sure how to act on this, because it looks like the error is saying
> that a definition in 'std.list' is incompatible with itself.
>
> I've temporarily disabled building with modules enabled on the bot. Could
> you take a look?
>
> thanks,
> vedant
>
> http://lab.llvm.org:8080/green/view/Experimental/job/
> clang-stage2-coverage-R/2193
>
> 
>
>
>
> On Dec 22, 2017, at 4:41 PM, Richard Trieu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: rtrieu
> Date: Fri Dec 22 16:41:01 2017
> New Revision: 321395
>
> URL: http://llvm.org/viewvc/llvm-project?rev=321395=rev
> Log:
> [ODRHash] Support ODR violation detection in functions.
>
> Extend the hashing to functions, which allows detection of function
> definition
> mismatches across modules.  This is a re-commit of r320230.
>
> Modified:
>cfe/trunk/include/clang/AST/Decl.h
>cfe/trunk/include/clang/AST/ODRHash.h
>cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
>cfe/trunk/include/clang/Serialization/ASTReader.h
>cfe/trunk/lib/AST/Decl.cpp
>cfe/trunk/lib/AST/ODRHash.cpp
>cfe/trunk/lib/Serialization/ASTReader.cpp
>cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
>cfe/trunk/test/Modules/odr_hash.cpp
>
> Modified: cfe/trunk/include/clang/AST/Decl.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/Decl.h?rev=321395=321394=321395=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/Decl.h (original)
> +++ cfe/trunk/include/clang/AST/Decl.h Fri Dec 22 16:41:01 2017
> @@ -1759,6 +1759,11 @@ protected:
>   unsigned IsCopyDeductionCandidate : 1;
>
> private:
> +
> +  /// Store the ODRHash after first calculation.
> +  unsigned HasODRHash : 1;
> +  unsigned ODRHash;
> +
>   /// \brief End part of this FunctionDecl's source range.
>   ///
>   /// We could compute the full range in getSourceRange(). However, when
> we're
> @@ -1841,8 +1846,9 @@ protected:
> IsExplicitlyDefaulted(false), HasImplicitReturnZero(false),
> IsLateTemplateParsed(false), IsConstexpr(isConstexprSpecified),
> InstantiationIsPending(false), UsesSEHTry(false),
> HasSkippedBody(false),
> -WillHaveBody(false), IsCopyDeductionCandidate(false),
> -EndRangeLoc(NameInfo.getEndLoc()), DNLoc(NameInfo.getInfo()) {}
> +WillHaveBody(false), IsCopyDeductionCandidate(false),
> HasODRHash(false),
> +ODRHash(0), EndRangeLoc(NameInfo.getEndLoc()),
> +DNLoc(NameInfo.getInfo()) {}
>
>   using redeclarable_base = Redeclarable;
>
> @@ -2439,6 +2445,10 @@ public:
>   /// returns 0.
>   unsigned getMemoryFunctionKind() const;
>
> +  /// \brief Returns ODRHash of the function.  This value is calculated
> and
> +  /// stored on first call, then the stored value returned on the other
> calls.
> +  unsigned getODRHash();
> +
>   // Implement isa/cast/dyncast/etc.
>   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
>   static bool classofKind(Kind K) {
>
> Modified: cfe/trunk/include/clang/AST/ODRHash.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/ODRHash.h?rev=321395=321394=321395=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/ODRHash.h (original)
> +++ cfe/trunk/include/clang/AST/ODRHash.h Fri Dec 22 16:41:01 2017
> @@ -53,6 +53,10 @@ public:
>   // more information than the AddDecl class.
>   void AddCXXRecordDecl(const CXXRecordDecl *Record);
>
> +  // Use this for ODR checking functions between modules.  This method
> compares
> +  // more information than the AddDecl class.
> +  void AddFunctionDecl(const FunctionDecl *Function);
> +
>   // Process SubDecls of the main Decl.  This method calls the DeclVisitor
>   // while AddDecl does not.
>   void AddSubDecl(const Decl *D);
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticSerializationKinds.td?rev=321395=321394=321395=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/Diagnost

r321396 - [ODRHash] Disable hashing on methods.

2017-12-22 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Dec 22 17:35:32 2017
New Revision: 321396

URL: http://llvm.org/viewvc/llvm-project?rev=321396=rev
Log:
[ODRHash] Disable hashing on methods.

Turn off hashing for class methods, but leave it on for other functions.  This
should get the buildbot to green for the time being.

Modified:
cfe/trunk/lib/AST/ODRHash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=321396=321395=321396=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Dec 22 17:35:32 2017
@@ -476,6 +476,9 @@ void ODRHash::AddFunctionDecl(const Func
   if (!Function->hasBody()) return;
   if (!Function->getBody()) return;
 
+  // TODO: Fix hashing for class methods.
+  if (isa(Function)) return;
+
   // Skip functions that are specializations or in specialization context.
   const DeclContext *DC = Function;
   while (DC) {


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


r321395 - [ODRHash] Support ODR violation detection in functions.

2017-12-22 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Dec 22 16:41:01 2017
New Revision: 321395

URL: http://llvm.org/viewvc/llvm-project?rev=321395=rev
Log:
[ODRHash] Support ODR violation detection in functions.

Extend the hashing to functions, which allows detection of function definition
mismatches across modules.  This is a re-commit of r320230.

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/ODRHash.h
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=321395=321394=321395=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Dec 22 16:41:01 2017
@@ -1759,6 +1759,11 @@ protected:
   unsigned IsCopyDeductionCandidate : 1;
 
 private:
+
+  /// Store the ODRHash after first calculation.
+  unsigned HasODRHash : 1;
+  unsigned ODRHash;
+
   /// \brief End part of this FunctionDecl's source range.
   ///
   /// We could compute the full range in getSourceRange(). However, when we're
@@ -1841,8 +1846,9 @@ protected:
 IsExplicitlyDefaulted(false), HasImplicitReturnZero(false),
 IsLateTemplateParsed(false), IsConstexpr(isConstexprSpecified),
 InstantiationIsPending(false), UsesSEHTry(false), 
HasSkippedBody(false),
-WillHaveBody(false), IsCopyDeductionCandidate(false),
-EndRangeLoc(NameInfo.getEndLoc()), DNLoc(NameInfo.getInfo()) {}
+WillHaveBody(false), IsCopyDeductionCandidate(false), 
HasODRHash(false),
+ODRHash(0), EndRangeLoc(NameInfo.getEndLoc()),
+DNLoc(NameInfo.getInfo()) {}
 
   using redeclarable_base = Redeclarable;
 
@@ -2439,6 +2445,10 @@ public:
   /// returns 0.
   unsigned getMemoryFunctionKind() const;
 
+  /// \brief Returns ODRHash of the function.  This value is calculated and
+  /// stored on first call, then the stored value returned on the other calls.
+  unsigned getODRHash();
+
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) {

Modified: cfe/trunk/include/clang/AST/ODRHash.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ODRHash.h?rev=321395=321394=321395=diff
==
--- cfe/trunk/include/clang/AST/ODRHash.h (original)
+++ cfe/trunk/include/clang/AST/ODRHash.h Fri Dec 22 16:41:01 2017
@@ -53,6 +53,10 @@ public:
   // more information than the AddDecl class.
   void AddCXXRecordDecl(const CXXRecordDecl *Record);
 
+  // Use this for ODR checking functions between modules.  This method compares
+  // more information than the AddDecl class.
+  void AddFunctionDecl(const FunctionDecl *Function);
+
   // Process SubDecls of the main Decl.  This method calls the DeclVisitor
   // while AddDecl does not.
   void AddSubDecl(const Decl *D);

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=321395=321394=321395=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Fri Dec 22 
16:41:01 2017
@@ -270,6 +270,29 @@ def note_module_odr_violation_mismatch_d
   "friend function %2|"
   "}1">;
 
+def err_module_odr_violation_function : Error<
+  "%q0 has different definitions in different modules; "
+  "%select{definition in module '%2'|defined here}1 "
+  "first difference is "
+  "%select{"
+  "return type is %4|"
+  "%ordinal4 parameter with name %5|"
+  "%ordinal4 parameter with type %5%select{| decayed from %7}6|"
+  "%ordinal4 parameter with%select{out|}5 a default argument|"
+  "%ordinal4 parameter with a default argument|"
+  "function body"
+  "}3">;
+
+def note_module_odr_violation_function : Note<"but in '%0' found "
+  "%select{"
+  "different return type %2|"
+  "%ordinal2 parameter with name %3|"
+  "%ordinal2 parameter with type %3%select{| decayed from %5}4|"
+  "%ordinal2 parameter with%select{out|}3 a default argument|"
+  "%ordinal2 parameter with a different default argument|"
+  "a different body"
+  "}1">;
+
 def err_module_odr_violation_mismatch_decl_unknown : Error<
   "%q0 %select{with definition in module '%2'|defined here}1 has different "
   "definitions in different modules; first difference is this "

Modified: 

r321319 - [ODRHash] Canonicalize Decl's before processing.

2017-12-21 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Thu Dec 21 14:38:29 2017
New Revision: 321319

URL: http://llvm.org/viewvc/llvm-project?rev=321319=rev
Log:
[ODRHash] Canonicalize Decl's before processing.

Canonicalizing the Decl before processing it as part of the hash should reduce
issues with non-canonical types showing up as mismatches.

Modified:
cfe/trunk/lib/AST/ODRHash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=321319=321318=321319=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Thu Dec 21 14:38:29 2017
@@ -468,6 +468,7 @@ void ODRHash::AddCXXRecordDecl(const CXX
 
 void ODRHash::AddDecl(const Decl *D) {
   assert(D && "Expecting non-null pointer.");
+  D = D->getCanonicalDecl();
   auto Result = DeclMap.insert(std::make_pair(D, DeclMap.size()));
   ID.AddInteger(Result.first->second);
   // On first encounter of a Decl pointer, process it.  Every time afterwards,


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


r320239 - Revert r320230 to fix buildbots.

2017-12-08 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Dec  8 19:02:21 2017
New Revision: 320239

URL: http://llvm.org/viewvc/llvm-project?rev=320239=rev
Log:
Revert r320230 to fix buildbots.

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/ODRHash.h
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=320239=320238=320239=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Dec  8 19:02:21 2017
@@ -1760,11 +1760,6 @@ protected:
   unsigned IsCopyDeductionCandidate : 1;
 
 private:
-
-  /// Store the ODRHash after first calculation.
-  unsigned HasODRHash : 1;
-  unsigned ODRHash;
-
   /// \brief End part of this FunctionDecl's source range.
   ///
   /// We could compute the full range in getSourceRange(). However, when we're
@@ -1847,9 +1842,8 @@ protected:
 IsExplicitlyDefaulted(false), HasImplicitReturnZero(false),
 IsLateTemplateParsed(false), IsConstexpr(isConstexprSpecified),
 InstantiationIsPending(false), UsesSEHTry(false), 
HasSkippedBody(false),
-WillHaveBody(false), IsCopyDeductionCandidate(false), 
HasODRHash(false),
-ODRHash(0), EndRangeLoc(NameInfo.getEndLoc()),
-DNLoc(NameInfo.getInfo()) {}
+WillHaveBody(false), IsCopyDeductionCandidate(false),
+EndRangeLoc(NameInfo.getEndLoc()), DNLoc(NameInfo.getInfo()) {}
 
   using redeclarable_base = Redeclarable;
 
@@ -2449,10 +2443,6 @@ public:
   /// returns 0.
   unsigned getMemoryFunctionKind() const;
 
-  /// \brief Returns ODRHash of the function.  This value is calculated and
-  /// stored on first call, then the stored value returned on the other calls.
-  unsigned getODRHash();
-
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) {

Modified: cfe/trunk/include/clang/AST/ODRHash.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ODRHash.h?rev=320239=320238=320239=diff
==
--- cfe/trunk/include/clang/AST/ODRHash.h (original)
+++ cfe/trunk/include/clang/AST/ODRHash.h Fri Dec  8 19:02:21 2017
@@ -53,10 +53,6 @@ public:
   // more information than the AddDecl class.
   void AddCXXRecordDecl(const CXXRecordDecl *Record);
 
-  // Use this for ODR checking functions between modules.  This method compares
-  // more information than the AddDecl class.
-  void AddFunctionDecl(const FunctionDecl *Function);
-
   // Process SubDecls of the main Decl.  This method calls the DeclVisitor
   // while AddDecl does not.
   void AddSubDecl(const Decl *D);

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=320239=320238=320239=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Fri Dec  8 
19:02:21 2017
@@ -270,29 +270,6 @@ def note_module_odr_violation_mismatch_d
   "friend function %2|"
   "}1">;
 
-def err_module_odr_violation_function : Error<
-  "%q0 has different definitions in different modules; "
-  "%select{definition in module '%2'|defined here}1 "
-  "first difference is "
-  "%select{"
-  "return type is %4|"
-  "%ordinal4 parameter with name %5|"
-  "%ordinal4 parameter with type %5%select{| decayed from %7}6|"
-  "%ordinal4 parameter with%select{out|}5 a default argument|"
-  "%ordinal4 parameter with a default argument|"
-  "function body"
-  "}3">;
-
-def note_module_odr_violation_function : Note<"but in '%0' found "
-  "%select{"
-  "different return type %2|"
-  "%ordinal2 parameter with name %3|"
-  "%ordinal2 parameter with type %3%select{| decayed from %5}4|"
-  "%ordinal2 parameter with%select{out|}3 a default argument|"
-  "%ordinal2 parameter with a different default argument|"
-  "a different body"
-  "}1">;
-
 def err_module_odr_violation_mismatch_decl_unknown : Error<
   "%q0 %select{with definition in module '%2'|defined here}1 has different "
   "definitions in different modules; first difference is this "

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=320239=320238=320239=diff

r320230 - [ODRHash] Support ODR violation detection in functions.

2017-12-08 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Dec  8 17:29:40 2017
New Revision: 320230

URL: http://llvm.org/viewvc/llvm-project?rev=320230=rev
Log:
[ODRHash] Support ODR violation detection in functions.

Extend the hashing to functions, which allows detection of function definition
mismatches across modules.

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/ODRHash.h
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=320230=320229=320230=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Dec  8 17:29:40 2017
@@ -1760,6 +1760,11 @@ protected:
   unsigned IsCopyDeductionCandidate : 1;
 
 private:
+
+  /// Store the ODRHash after first calculation.
+  unsigned HasODRHash : 1;
+  unsigned ODRHash;
+
   /// \brief End part of this FunctionDecl's source range.
   ///
   /// We could compute the full range in getSourceRange(). However, when we're
@@ -1842,8 +1847,9 @@ protected:
 IsExplicitlyDefaulted(false), HasImplicitReturnZero(false),
 IsLateTemplateParsed(false), IsConstexpr(isConstexprSpecified),
 InstantiationIsPending(false), UsesSEHTry(false), 
HasSkippedBody(false),
-WillHaveBody(false), IsCopyDeductionCandidate(false),
-EndRangeLoc(NameInfo.getEndLoc()), DNLoc(NameInfo.getInfo()) {}
+WillHaveBody(false), IsCopyDeductionCandidate(false), 
HasODRHash(false),
+ODRHash(0), EndRangeLoc(NameInfo.getEndLoc()),
+DNLoc(NameInfo.getInfo()) {}
 
   using redeclarable_base = Redeclarable;
 
@@ -2443,6 +2449,10 @@ public:
   /// returns 0.
   unsigned getMemoryFunctionKind() const;
 
+  /// \brief Returns ODRHash of the function.  This value is calculated and
+  /// stored on first call, then the stored value returned on the other calls.
+  unsigned getODRHash();
+
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) {

Modified: cfe/trunk/include/clang/AST/ODRHash.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ODRHash.h?rev=320230=320229=320230=diff
==
--- cfe/trunk/include/clang/AST/ODRHash.h (original)
+++ cfe/trunk/include/clang/AST/ODRHash.h Fri Dec  8 17:29:40 2017
@@ -53,6 +53,10 @@ public:
   // more information than the AddDecl class.
   void AddCXXRecordDecl(const CXXRecordDecl *Record);
 
+  // Use this for ODR checking functions between modules.  This method compares
+  // more information than the AddDecl class.
+  void AddFunctionDecl(const FunctionDecl *Function);
+
   // Process SubDecls of the main Decl.  This method calls the DeclVisitor
   // while AddDecl does not.
   void AddSubDecl(const Decl *D);

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=320230=320229=320230=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Fri Dec  8 
17:29:40 2017
@@ -270,6 +270,29 @@ def note_module_odr_violation_mismatch_d
   "friend function %2|"
   "}1">;
 
+def err_module_odr_violation_function : Error<
+  "%q0 has different definitions in different modules; "
+  "%select{definition in module '%2'|defined here}1 "
+  "first difference is "
+  "%select{"
+  "return type is %4|"
+  "%ordinal4 parameter with name %5|"
+  "%ordinal4 parameter with type %5%select{| decayed from %7}6|"
+  "%ordinal4 parameter with%select{out|}5 a default argument|"
+  "%ordinal4 parameter with a default argument|"
+  "function body"
+  "}3">;
+
+def note_module_odr_violation_function : Note<"but in '%0' found "
+  "%select{"
+  "different return type %2|"
+  "%ordinal2 parameter with name %3|"
+  "%ordinal2 parameter with type %3%select{| decayed from %5}4|"
+  "%ordinal2 parameter with%select{out|}3 a default argument|"
+  "%ordinal2 parameter with a different default argument|"
+  "a different body"
+  "}1">;
+
 def err_module_odr_violation_mismatch_decl_unknown : Error<
   "%q0 %select{with definition in module '%2'|defined here}1 has different "
   "definitions in different modules; first difference is this "

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 

  1   2   3   >