diff options
author | Tyler Nowicki <tnowicki@apple.com> | 2014-07-29 17:21:32 +0000 |
---|---|---|
committer | Tyler Nowicki <tnowicki@apple.com> | 2014-07-29 17:21:32 +0000 |
commit | 93c915721ece64f52c95121318724c5c251d7467 (patch) | |
tree | 0d7a2c6f3cb04499667852462414a8143b29661f /lib/Sema | |
parent | fa3d66d724a1d7db2c096e1fbbebf7b9b5fd7bb5 (diff) | |
download | clang-93c915721ece64f52c95121318724c5c251d7467.tar.gz |
Modify how the loop hint attribute is printed as a lead-up to supporting constant expression values.
Reviewed by Aaron Ballman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214185 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaStmtAttr.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/Sema/SemaStmtAttr.cpp b/lib/Sema/SemaStmtAttr.cpp index 86c487b4cd..595aa3656e 100644 --- a/lib/Sema/SemaStmtAttr.cpp +++ b/lib/Sema/SemaStmtAttr.cpp @@ -87,10 +87,11 @@ static Attr *handleLoopHintAttr(Sema &S, Stmt *St, const AttributeList &A, Spelling = LoopHintAttr::Pragma_clang_loop; } - int ValueInt; + int ValueInt = -1; if (Option == LoopHintAttr::Unroll && Spelling == LoopHintAttr::Pragma_unroll) { - ValueInt = 1; + if (ValueInfo) + ValueInt = (ValueInfo->isStr("disable") ? 0 : 1); } else if (Option == LoopHintAttr::Unroll && Spelling == LoopHintAttr::Pragma_nounroll) { ValueInt = 0; @@ -174,7 +175,6 @@ static void CheckForIncompatibleAttributes( }; auto &CategoryState = HintAttrs[Category]; - SourceLocation OptionLoc = LH->getRange().getBegin(); const LoopHintAttr *PrevAttr; if (Option == LoopHintAttr::Vectorize || Option == LoopHintAttr::Interleave || Option == LoopHintAttr::Unroll) { @@ -187,11 +187,13 @@ static void CheckForIncompatibleAttributes( CategoryState.NumericAttr = LH; } + PrintingPolicy Policy(S.Context.getLangOpts()); + SourceLocation OptionLoc = LH->getRange().getBegin(); if (PrevAttr) // Cannot specify same type of attribute twice. S.Diag(OptionLoc, diag::err_pragma_loop_compatibility) - << /*Duplicate=*/true << PrevAttr->getDiagnosticName() - << LH->getDiagnosticName(); + << /*Duplicate=*/true << PrevAttr->getDiagnosticName(Policy) + << LH->getDiagnosticName(Policy); if (CategoryState.EnableAttr && CategoryState.NumericAttr && (Category == Unroll || !CategoryState.EnableAttr->getValue())) { @@ -200,8 +202,8 @@ static void CheckForIncompatibleAttributes( // compatible with "enable" form of the unroll pragma, unroll(full). S.Diag(OptionLoc, diag::err_pragma_loop_compatibility) << /*Duplicate=*/false - << CategoryState.EnableAttr->getDiagnosticName() - << CategoryState.NumericAttr->getDiagnosticName(); + << CategoryState.EnableAttr->getDiagnosticName(Policy) + << CategoryState.NumericAttr->getDiagnosticName(Policy); } } } |