Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rettichschnidi/f6a8c3747281652cc998937ab4234244 to your computer and use it in GitHub Desktop.
Save rettichschnidi/f6a8c3747281652cc998937ab4234244 to your computer and use it in GitHub Desktop.
0001-HACK-First-attempt-to-mitigate-the-IAR-killing-forma.patch
From a77aaf4c69149d08b5e42f8419a39a8bc63bcdd5 Mon Sep 17 00:00:00 2001
From: Reto Schneider <[email protected]>
Date: Mon, 20 Jun 2016 01:47:10 +0200
Subject: [PATCH] - HACK: First attempt to mitigate the IAR killing formatting
---
lib/Format/FormatToken.h | 14 ++++++++++++++
lib/Format/TokenAnnotator.cpp | 20 ++++++++++++++++++--
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/lib/Format/FormatToken.h b/lib/Format/FormatToken.h
index d80bd0a..2343d32 100644
--- a/lib/Format/FormatToken.h
+++ b/lib/Format/FormatToken.h
@@ -559,6 +559,13 @@ struct AdditionalKeywords {
kw___except = &IdentTable.get("__except");
kw_mark = &IdentTable.get("mark");
+ kw_diag_suppress = &IdentTable.get("diag_suppress");
+ kw_diag_default = &IdentTable.get("diag_default");
+ kw_language = &IdentTable.get("language");
+ kw_location = &IdentTable.get("location");
+ kw_optimize = &IdentTable.get("optimize");
+ kw_segment = &IdentTable.get("segment");
+ kw_vector = &IdentTable.get("vector");
kw_extend = &IdentTable.get("extend");
kw_option = &IdentTable.get("option");
@@ -610,6 +617,13 @@ struct AdditionalKeywords {
// Pragma keywords.
IdentifierInfo *kw_mark;
+ IdentifierInfo *kw_diag_suppress;
+ IdentifierInfo *kw_diag_default;
+ IdentifierInfo *kw_language;
+ IdentifierInfo *kw_location;
+ IdentifierInfo *kw_optimize;
+ IdentifierInfo *kw_segment;
+ IdentifierInfo *kw_vector;
// Proto keywords.
IdentifierInfo *kw_extend;
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index ceecb3d..8889785 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -673,8 +673,11 @@ private:
void parsePragma() {
next(); // Consume "pragma".
- if (CurrentToken &&
- CurrentToken->isOneOf(Keywords.kw_mark, Keywords.kw_option)) {
+
+ if(!CurrentToken)
+ return;
+
+ if (CurrentToken->isOneOf(Keywords.kw_mark, Keywords.kw_option)) {
bool IsMark = CurrentToken->is(Keywords.kw_mark);
next(); // Consume "mark".
next(); // Consume first token (so we fix leading whitespace).
@@ -683,6 +686,19 @@ private:
CurrentToken->Type = TT_ImplicitStringLiteral;
next();
}
+ } else if (CurrentToken->isOneOf(Keywords.kw_diag_default,
+ Keywords.kw_diag_suppress,
+ Keywords.kw_language,
+ Keywords.kw_location,
+ Keywords.kw_optimize,
+ Keywords.kw_segment,
+ Keywords.kw_vector)) {
+ next(); // Consume "="
+ assert(CurrentToken);
+ CurrentToken->Finalized = true;
+ next(); // Consume e.g. "Pm066"
+ assert(CurrentToken);
+ CurrentToken->Finalized = true;
}
}
--
2.8.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment