[clang] [CIR][Dialect] Add SourceLangAttr (PR #152511)

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 7 10:25:32 PDT 2025


================
@@ -50,6 +50,43 @@ class CIR_UnitAttr<string name, string attrMnemonic, list<Trait> traits = []>
   let isOptional = 1;
 }
 
+//===----------------------------------------------------------------------===//
+// SourceLanguageAttr
+//===----------------------------------------------------------------------===//
+
+def CIR_SourceLanguage : CIR_I32EnumAttr<"SourceLanguage", "source language", [
+  I32EnumAttrCase<"C", 1, "c">,
+  I32EnumAttrCase<"CXX", 2, "cxx">
+]> {
+  // The enum attr class is defined in `CIR_SourceLanguageAttr` below,
+  // so that it can define extra class methods.
+  let genSpecializedAttr = 0;
+}
+
+def CIR_SourceLanguageAttr : CIR_EnumAttr<CIR_SourceLanguage, "lang"> {
----------------
bcardosolopes wrote:

Should we verify this attribute only happens at the module level?

https://github.com/llvm/llvm-project/pull/152511


More information about the cfe-commits mailing list